From 76f0a6e9bc9ee5aae029f959f64fae290727cca4 Mon Sep 17 00:00:00 2001 From: DeLesley Hutchins Date: Mon, 2 Jul 2012 21:59:24 +0000 Subject: [PATCH] Thread Safety Analysis: turn off checking within trylock functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159601 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ThreadSafety.cpp | 6 +++++ test/SemaCXX/warn-thread-safety-analysis.cpp | 27 ++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/lib/Analysis/ThreadSafety.cpp b/lib/Analysis/ThreadSafety.cpp index fd4551b975..7406f324ae 100644 --- a/lib/Analysis/ThreadSafety.cpp +++ b/lib/Analysis/ThreadSafety.cpp @@ -1654,6 +1654,12 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) { } else if (isa(Attr)) { // Don't try to check lock functions for now return; + } else if (isa(Attr)) { + // Don't try to check trylock functions for now + return; + } else if (isa(Attr)) { + // Don't try to check trylock functions for now + return; } } } diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp index 1c47035c2b..cda2514238 100644 --- a/test/SemaCXX/warn-thread-safety-analysis.cpp +++ b/test/SemaCXX/warn-thread-safety-analysis.cpp @@ -2403,6 +2403,33 @@ void Foo::test3() { } // 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 -- 2.40.0