]> granicus.if.org Git - clang/commitdiff
Thread safety analysis: handle CFG blocks which call functions marked as noreturn.
authorDeLesley Hutchins <delesley@google.com>
Fri, 2 Mar 2012 22:02:58 +0000 (22:02 +0000)
committerDeLesley Hutchins <delesley@google.com>
Fri, 2 Mar 2012 22:02:58 +0000 (22:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151944 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ThreadSafety.cpp
test/SemaCXX/warn-thread-safety-analysis.cpp

index 1370d5dbacd95190c9f35094938eaafd5c01fd94..40ad79b25c8cc166f9364355920d556cacb860c0 100644 (file)
@@ -1526,6 +1526,10 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
       if (*PI == 0 || !VisitedBlocks.alreadySet(*PI))
         continue;
 
+      // Ignore edges from blocks that can't return.
+      if ((*PI)->hasNoReturnElement())
+        continue;
+
       // If the previous block ended in a 'continue' or 'break' statement, then
       // a difference in locksets is probably due to a bug in that block, rather
       // than in some other predecessor. In that case, keep the other
index a7c1c00268548165d67d9732b4d072d204ed4b53..78a276c4da2f90681f86c8e3b0b1dca9fc6a3a80 100644 (file)
@@ -2114,3 +2114,20 @@ class Foo {
 
 }  // end namespace InvalidNonStatic
 
+
+namespace NoReturnTest {
+
+bool condition();
+void fatal() __attribute__((noreturn));
+
+Mutex mu_;
+
+void test1() {
+  MutexLock lock(&mu_);
+  if (condition()) {
+    fatal();
+    return;
+  }
+}
+
+};