forked from OSchip/llvm-project
Thread Safety Analysis: turn off checking within trylock functions.
llvm-svn: 159601
This commit is contained in:
parent
f019075271
commit
c4a6e51596
|
@ -1654,6 +1654,12 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
|
|||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue