summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2018-04-12 17:53:21 +0000
committerAaron Ballman <aaron@aaronballman.com>2018-04-12 17:53:21 +0000
commit81d07fc2c19c941b2104076a18bcb118e08674b8 (patch)
treeb11195c6167895eecb7c33103a90b9ab64636be8 /clang/lib/Analysis
parent4c5fa6be279c5a095e238548e8434be2ca36bb72 (diff)
downloadbcm5719-llvm-81d07fc2c19c941b2104076a18bcb118e08674b8.tar.gz
bcm5719-llvm-81d07fc2c19c941b2104076a18bcb118e08674b8.zip
Fix the try_acquire_capability attribute to behave like the other try-lock functions. Fixes PR32954.
llvm-svn: 329930
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/ThreadSafety.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp
index 685d1aee918..0456df20ac7 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1450,6 +1450,14 @@ void ThreadSafetyAnalyzer::getEdgeLockset(FactSet& Result,
// If the condition is a call to a Trylock function, then grab the attributes
for (const auto *Attr : FunDecl->attrs()) {
switch (Attr->getKind()) {
+ case attr::TryAcquireCapability: {
+ auto *A = cast<TryAcquireCapabilityAttr>(Attr);
+ getMutexIDs(A->isShared() ? SharedLocksToAdd : ExclusiveLocksToAdd, A,
+ Exp, FunDecl, PredBlock, CurrBlock, A->getSuccessValue(),
+ Negate);
+ CapDiagKind = ClassifyDiagnostic(A);
+ break;
+ };
case attr::ExclusiveTrylockFunction: {
const auto *A = cast<ExclusiveTrylockFunctionAttr>(Attr);
getMutexIDs(ExclusiveLocksToAdd, A, Exp, FunDecl,
@@ -2249,10 +2257,13 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
A, nullptr, D);
CapDiagKind = ClassifyDiagnostic(A);
} else if (isa<ExclusiveTrylockFunctionAttr>(Attr)) {
- // Don't try to check trylock functions for now
+ // Don't try to check trylock functions for now.
return;
} else if (isa<SharedTrylockFunctionAttr>(Attr)) {
- // Don't try to check trylock functions for now
+ // Don't try to check trylock functions for now.
+ return;
+ } else if (isa<TryAcquireCapabilityAttr>(Attr)) {
+ // Don't try to check trylock functions for now.
return;
}
}
OpenPOWER on IntegriCloud