]> granicus.if.org Git - clang/commitdiff
Thread Safety: adding basic no thread safety analysis option
authorCaitlin Sadowski <supertri@google.com>
Thu, 8 Sep 2011 18:35:21 +0000 (18:35 +0000)
committerCaitlin Sadowski <supertri@google.com>
Thu, 8 Sep 2011 18:35:21 +0000 (18:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139310 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/AnalysisBasedWarnings.cpp
test/SemaCXX/warn-thread-safety-analysis.cpp

index 41b9f3b1a8f90c6d4ddb59d15966338bef439ba2..642638bf06fee794267b6e83bca31e85cde71b3f 100644 (file)
@@ -1305,6 +1305,8 @@ static void warnBackEdgeUnequalLocksets(Sema &S, const Lockset LoopReentrySet,
 static void checkThreadSafety(Sema &S, AnalysisContext &AC) {
   CFG *CFGraph = AC.getCFG();
   if (!CFGraph) return;
+  const Decl *D = AC.getDecl();
+  if (D && D->getAttr<NoThreadSafetyAnalysisAttr>()) return;
 
   Lockset::Factory LocksetFactory;
 
index a38d005db5d334ad59ad202acac2e5e83119901f..a834ee34c770d3fe120303b5ee2ad455df51de94 100644 (file)
@@ -314,6 +314,10 @@ class GBFoo {
     gb_field = 0; // \
       // expected-warning {{writing variable 'gb_field' requires lock 'sls_mu' to be held exclusively}}
   }
+
+  void testNoAnal() __attribute__((no_thread_safety_analysis)) {
+    gb_field = 0;
+  }
 };
 
 GBFoo GlobalGBFoo __attribute__((guarded_by(sls_mu)));
@@ -570,6 +574,12 @@ void es_fun_7() {
   sls_mu.Unlock();
 }
 
+void es_fun_8() __attribute__((no_thread_safety_analysis));
+
+void es_fun_8() {
+  Bar.aa_elr_fun_s();
+}
+
 void es_bad_0() {
   Bar.aa_elr_fun(); // \
     // expected-warning {{calling function 'aa_elr_fun' requires exclusive lock 'aa_mu'}}