[cfe-commits] r139310 - in /cfe/trunk: lib/Sema/AnalysisBasedWarnings.cpp test/SemaCXX/warn-thread-safety-analysis.cpp

Caitlin Sadowski supertri at google.com
Thu Sep 8 11:35:21 PDT 2011


Author: supertri
Date: Thu Sep  8 13:35:21 2011
New Revision: 139310

URL: http://llvm.org/viewvc/llvm-project?rev=139310&view=rev
Log:
Thread Safety: adding basic no thread safety analysis option

Modified:
    cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
    cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp

Modified: cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp?rev=139310&r1=139309&r2=139310&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp (original)
+++ cfe/trunk/lib/Sema/AnalysisBasedWarnings.cpp Thu Sep  8 13:35:21 2011
@@ -1305,6 +1305,8 @@
 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;
 

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=139310&r1=139309&r2=139310&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Thu Sep  8 13:35:21 2011
@@ -314,6 +314,10 @@
     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 @@
   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'}}





More information about the cfe-commits mailing list