[cfe-commits] r151944 - in /cfe/trunk: lib/Analysis/ThreadSafety.cpp test/SemaCXX/warn-thread-safety-analysis.cpp
DeLesley Hutchins
delesley at google.com
Fri Mar 2 14:02:58 PST 2012
Author: delesley
Date: Fri Mar 2 16:02:58 2012
New Revision: 151944
URL: http://llvm.org/viewvc/llvm-project?rev=151944&view=rev
Log:
Thread safety analysis: handle CFG blocks which call functions marked as noreturn.
Modified:
cfe/trunk/lib/Analysis/ThreadSafety.cpp
cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp
Modified: cfe/trunk/lib/Analysis/ThreadSafety.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafety.cpp?rev=151944&r1=151943&r2=151944&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Fri Mar 2 16:02:58 2012
@@ -1526,6 +1526,10 @@
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
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=151944&r1=151943&r2=151944&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Fri Mar 2 16:02:58 2012
@@ -2114,3 +2114,20 @@
} // end namespace InvalidNonStatic
+
+namespace NoReturnTest {
+
+bool condition();
+void fatal() __attribute__((noreturn));
+
+Mutex mu_;
+
+void test1() {
+ MutexLock lock(&mu_);
+ if (condition()) {
+ fatal();
+ return;
+ }
+}
+
+};
More information about the cfe-commits
mailing list