[cfe-commits] r147331 - in /cfe/trunk: lib/Analysis/ThreadSafety.cpp test/SemaCXX/warn-thread-safety-analysis.cpp
DeLesley Hutchins
delesley at google.com
Wed Dec 28 16:56:49 PST 2011
Author: delesley
Date: Wed Dec 28 18:56:48 2011
New Revision: 147331
URL: http://llvm.org/viewvc/llvm-project?rev=147331&view=rev
Log:
Support for thread safety attributes on functions
Modified:
cfe/trunk/lib/Analysis/ThreadSafety.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=147331&r1=147330&r2=147331&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Wed Dec 28 18:56:48 2011
@@ -147,6 +147,9 @@
Parent = CE->getImplicitObjectArgument();
NumArgs = CE->getNumArgs();
FunArgs = CE->getArgs();
+ } else if (CallExpr *CE = dyn_cast<CallExpr>(DeclExp)) {
+ NumArgs = CE->getNumArgs();
+ FunArgs = CE->getArgs();
} else if (CXXConstructExpr *CE = dyn_cast<CXXConstructExpr>(DeclExp)) {
Parent = 0; // FIXME -- get the parent from DeclStmt
NumArgs = CE->getNumArgs();
@@ -350,7 +353,7 @@
void VisitUnaryOperator(UnaryOperator *UO);
void VisitBinaryOperator(BinaryOperator *BO);
void VisitCastExpr(CastExpr *CE);
- void VisitCXXMemberCallExpr(CXXMemberCallExpr *Exp);
+ void VisitCallExpr(CallExpr *Exp);
void VisitCXXConstructExpr(CXXConstructExpr *Exp);
void VisitDeclStmt(DeclStmt *S);
};
@@ -647,7 +650,7 @@
}
-void BuildLockset::VisitCXXMemberCallExpr(CXXMemberCallExpr *Exp) {
+void BuildLockset::VisitCallExpr(CallExpr *Exp) {
NamedDecl *D = dyn_cast_or_null<NamedDecl>(Exp->getCalleeDecl());
if(!D || !D->hasAttrs())
return;
Modified: cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp?rev=147331&r1=147330&r2=147331&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Wed Dec 28 18:56:48 2011
@@ -1605,3 +1605,25 @@
} // end namespace test_scoped_lockable
+namespace FunctionAttrTest {
+
+class Foo {
+public:
+ Mutex mu_;
+ int a GUARDED_BY(mu_);
+};
+
+Foo fooObj;
+
+void foo() EXCLUSIVE_LOCKS_REQUIRED(fooObj.mu_);
+
+void bar() {
+ foo(); // expected-warning {{calling function 'foo' requires exclusive lock on 'mu_'}}
+ fooObj.mu_.Lock();
+ foo();
+ fooObj.mu_.Unlock();
+}
+
+}; // end namespace FunctionAttrTest
+
+
More information about the cfe-commits
mailing list