diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp index 1370d5dbacd9..40ad79b25c8c 100644 --- a/clang/lib/Analysis/ThreadSafety.cpp +++ b/clang/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/clang/test/SemaCXX/warn-thread-safety-analysis.cpp b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp index a7c1c0026854..78a276c4da2f 100644 --- a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp +++ b/clang/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; + } +} + +};