Properly add shared locks to the initial list of locks being tracked, instead of assuming unlock functions always use exclusive locks.

Patch by Aaron Puchert.

llvm-svn: 338912
This commit is contained in:
Aaron Ballman 2018-08-03 19:37:45 +00:00
parent 397985db51
commit eaa18e60eb
2 changed files with 10 additions and 2 deletions

View File

@ -2242,8 +2242,8 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
// We must ignore such methods.
if (A->args_size() == 0)
return;
// FIXME -- deal with exclusive vs. shared unlock functions?
getMutexIDs(ExclusiveLocksToAdd, A, nullptr, D);
getMutexIDs(A->isShared() ? SharedLocksToAdd : ExclusiveLocksToAdd, A,
nullptr, D);
getMutexIDs(LocksReleased, A, nullptr, D);
CapDiagKind = ClassifyDiagnostic(A);
} else if (const auto *A = dyn_cast<AcquireCapabilityAttr>(Attr)) {

View File

@ -4078,6 +4078,14 @@ public:
mu_.Unlock();
}
void unlockExclusive() EXCLUSIVE_UNLOCK_FUNCTION(mu_) {
mu_.Unlock();
}
void unlockShared() SHARED_UNLOCK_FUNCTION(mu_) {
mu_.ReaderUnlock();
}
// Check failure to lock.
void lockBad() EXCLUSIVE_LOCK_FUNCTION(mu_) { // expected-note {{mutex acquired here}}
mu2_.Lock();