[cfe-commits] r159601 - in /cfe/trunk: lib/Analysis/ThreadSafety.cpp test/SemaCXX/warn-thread-safety-analysis.cpp
DeLesley Hutchins
delesley at google.com
Mon Jul 2 14:59:24 PDT 2012
Author: delesley
Date: Mon Jul 2 16:59:24 2012
New Revision: 159601
URL: http://llvm.org/viewvc/llvm-project?rev=159601&view=rev
Log:
Thread Safety Analysis: turn off checking within trylock functions.
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=159601&r1=159600&r2=159601&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ThreadSafety.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafety.cpp Mon Jul 2 16:59:24 2012
@@ -1654,6 +1654,12 @@
} else if (isa<SharedLockFunctionAttr>(Attr)) {
// Don't try to check lock functions for now
return;
+ } else if (isa<ExclusiveTrylockFunctionAttr>(Attr)) {
+ // Don't try to check trylock functions for now
+ return;
+ } else if (isa<SharedTrylockFunctionAttr>(Attr)) {
+ // Don't try to check trylock functions for now
+ return;
}
}
}
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=159601&r1=159600&r2=159601&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-thread-safety-analysis.cpp Mon Jul 2 16:59:24 2012
@@ -2403,6 +2403,33 @@
} // end namespace ReleasableScopedLock
+namespace TrylockFunctionTest {
+
+class Foo {
+public:
+ Mutex mu1_;
+ Mutex mu2_;
+ bool c;
+
+ bool lockBoth() EXCLUSIVE_TRYLOCK_FUNCTION(true, mu1_, mu2_);
+};
+
+bool Foo::lockBoth() {
+ if (!mu1_.TryLock())
+ return false;
+
+ mu2_.Lock();
+ if (!c) {
+ mu1_.Unlock();
+ mu2_.Unlock();
+ return false;
+ }
+
+ return true;
+}
+
+
+} // end namespace TrylockFunctionTest
More information about the cfe-commits
mailing list