forked from OSchip/llvm-project
Thread Safety Analysis: fix before/after checks so that they work on global
variables as well member variables. llvm-svn: 248803
This commit is contained in:
parent
c1bc38ed4f
commit
dc0541f12f
|
@ -291,6 +291,8 @@ public:
|
|||
return nullptr;
|
||||
if (auto *P = dyn_cast<til::Project>(CapExpr))
|
||||
return P->clangDecl();
|
||||
if (auto *P = dyn_cast<til::LiteralPtr>(CapExpr))
|
||||
return P->clangDecl();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ til::SExpr *SExprBuilder::translateDeclRefExpr(const DeclRefExpr *DRE,
|
|||
VD = FD->getParamDecl(I);
|
||||
}
|
||||
|
||||
// For non-local variables, treat it as a referenced to a named object.
|
||||
// For non-local variables, treat it as a reference to a named object.
|
||||
return new (Arena) til::LiteralPtr(VD);
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,8 @@ int main() {
|
|||
mutex_shared_lock(&mu2);
|
||||
Foo_fun1(1);
|
||||
|
||||
mutex_shared_lock(&mu1); // expected-warning{{acquiring mutex 'mu1' that is already held}}
|
||||
mutex_shared_lock(&mu1); // expected-warning{{acquiring mutex 'mu1' that is already held}} \
|
||||
expected-warning{{mutex 'mu1' must be acquired before 'mu2'}}
|
||||
mutex_unlock(&mu1);
|
||||
mutex_unlock(&mu2);
|
||||
mutex_shared_lock(&mu1);
|
||||
|
|
|
@ -5145,4 +5145,17 @@ void test() {
|
|||
} // end namespace TestReferenceNoThreadSafetyAnalysis
|
||||
|
||||
|
||||
namespace GlobalAcquiredBeforeAfterTest {
|
||||
|
||||
Mutex mu1;
|
||||
Mutex mu2 ACQUIRED_AFTER(mu1);
|
||||
|
||||
void test3() {
|
||||
mu2.Lock();
|
||||
mu1.Lock(); // expected-warning {{mutex 'mu1' must be acquired before 'mu2'}}
|
||||
mu1.Unlock();
|
||||
mu2.Unlock();
|
||||
}
|
||||
|
||||
} // end namespace GlobalAcquiredBeforeAfterTest
|
||||
|
||||
|
|
Loading…
Reference in New Issue