From 81d07fc2c19c941b2104076a18bcb118e08674b8 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 12 Apr 2018 17:53:21 +0000 Subject: Fix the try_acquire_capability attribute to behave like the other try-lock functions. Fixes PR32954. llvm-svn: 329930 --- clang/lib/Analysis/ThreadSafety.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'clang/lib/Analysis/ThreadSafety.cpp') 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(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(Attr); getMutexIDs(ExclusiveLocksToAdd, A, Exp, FunDecl, @@ -2249,10 +2257,13 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) { A, nullptr, D); CapDiagKind = ClassifyDiagnostic(A); } else if (isa(Attr)) { - // Don't try to check trylock functions for now + // Don't try to check trylock functions for now. return; } else if (isa(Attr)) { - // Don't try to check trylock functions for now + // Don't try to check trylock functions for now. + return; + } else if (isa(Attr)) { + // Don't try to check trylock functions for now. return; } } -- cgit v1.2.3