diff options
author | DeLesley Hutchins <delesley@google.com> | 2012-03-02 22:02:58 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2012-03-02 22:02:58 +0000 |
commit | 2a35be803c405221f5f23c7bdedb91f09efdd3ac (patch) | |
tree | 15eae122e56fa8c2faacbb658c1448a262815e11 | |
parent | 1cb2d742eb6635aeab6132ee5f0b5781d39487d7 (diff) |
Thread safety analysis: handle CFG blocks which call functions marked as noreturn.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151944 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/ThreadSafety.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/warn-thread-safety-analysis.cpp | 17 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/Analysis/ThreadSafety.cpp b/lib/Analysis/ThreadSafety.cpp index 1370d5dbac..40ad79b25c 100644 --- a/lib/Analysis/ThreadSafety.cpp +++ b/lib/Analysis/ThreadSafety.cpp @@ -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 diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp index a7c1c00268..78a276c4da 100644 --- a/test/SemaCXX/warn-thread-safety-analysis.cpp +++ b/test/SemaCXX/warn-thread-safety-analysis.cpp @@ -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; + } +} + +}; |