r203720 - Thread Safety Analysis: new test case for lambdas
DeLesley Hutchins
delesley at google.com
Wed Mar 12 14:33:48 PDT 2014
Author: delesley
Date: Wed Mar 12 16:33:47 2014
New Revision: 203720
URL: http://llvm.org/viewvc/llvm-project?rev=203720&view=rev
Log:
Thread Safety Analysis: new test case for lambdas
Modified:
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
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=203720&r1=203719&r2=203720&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Wed Mar 12 16:33:47 2014
@@ -4335,7 +4335,8 @@ class A {
} // end namespace NonMemberCalleeICETest
-namespace {
+
+namespace pt_guard_attribute_type {
int i PT_GUARDED_BY(sls_mu); // expected-warning {{'pt_guarded_by' only applies to pointer types; type here is 'int'}}
int j PT_GUARDED_VAR; // expected-warning {{'pt_guarded_var' only applies to pointer types; type here is 'int'}}
@@ -4346,4 +4347,34 @@ namespace {
typedef int PT_GUARDED_BY(sls_mu) bad1; // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}}
typedef int PT_GUARDED_VAR bad2; // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}}
}
-}
+} // end namespace pt_guard_attribute_type
+
+
+namespace ThreadAttributesOnLambdas {
+
+class Foo {
+ Mutex mu_;
+
+ void LockedFunction() EXCLUSIVE_LOCKS_REQUIRED(mu_);
+
+ void test() {
+ auto func1 = [this]() EXCLUSIVE_LOCKS_REQUIRED(mu_) {
+ LockedFunction();
+ };
+
+ auto func2 = [this]() NO_THREAD_SAFETY_ANALYSIS {
+ LockedFunction();
+ };
+
+ auto func3 = [this]() EXCLUSIVE_LOCK_FUNCTION(mu_) {
+ mu_.Lock();
+ };
+
+ func1(); // expected-warning {{calling function 'operator()' requires exclusive lock on 'mu_'}}
+ func2();
+ func3();
+ mu_.Unlock();
+ }
+};
+
+} // end namespace ThreadAttributesOnLambdas
More information about the cfe-commits
mailing list