================
@@ -1745,42 +1814,26 @@ void ThreadSafetyAnalyzer::getEdgeLockset(FactSet
&Result,
const CFGBlock *CurrBlock) {
Result = ExitSet;
- bool Negate = false;
- auto [Exp, FunDecl, Cleanup] = getTerminatorTrylockCall(PredBlock, Negate);
- if (!Exp)
+ TrylockEdge Edge = resolveTrylockEdge(PredBlock, CurrBlock);
+ if (!Edge.TrylockCall)
return;
- CapExprSet ExclusiveLocksToAdd;
- CapExprSet SharedLocksToAdd;
-
- // If the condition is a call to a Trylock function, then grab the attributes
- for (const auto *Attr : FunDecl->specific_attrs<TryAcquireCapabilityAttr>())
- getMutexIDs(Attr->isShared() ? SharedLocksToAdd : ExclusiveLocksToAdd,
Attr,
- Exp, FunDecl, PredBlock, CurrBlock, Attr->getSuccessValue(),
- Negate);
-
- // Add and remove locks.
- SourceLocation Loc = Exp->getExprLoc();
- for (const auto &ExclusiveLockToAdd : ExclusiveLocksToAdd)
- addLock(Result, FactMan.createFact<LockableFactEntry>(ExclusiveLockToAdd,
- LK_Exclusive, Loc));
- for (const auto &SharedLockToAdd : SharedLocksToAdd)
- addLock(Result, FactMan.createFact<LockableFactEntry>(SharedLockToAdd,
- LK_Shared, Loc));
+ // Add the capabilities this edge proves were acquired.
+ SourceLocation Loc = Edge.TrylockCall->getExprLoc();
+ for (const TrylockEdgeCap &EC : Edge.Caps)
+ if (EC.Resolution == CapResolution::Success)
+ addLock(Result,
+ FactMan.createFact<LockableFactEntry>(EC.Cap, EC.Kind, Loc));
}
/// If the terminator of \p Block branches on the result of a try-lock call
/// (possibly stored in a local variable), add the capabilities acquired by
/// that call to \p Caps.
void ThreadSafetyAnalyzer::getTerminatorTrylockCaps(const CFGBlock *Block,
CapExprSet &Caps) {
- bool Negate = false;
- auto [Exp, FunDecl, Cleanup] = getTerminatorTrylockCall(Block, Negate);
- if (!Exp)
- return;
-
- for (const auto *Attr : FunDecl->specific_attrs<TryAcquireCapabilityAttr>())
- getMutexIDs(Caps, Attr, Exp, FunDecl);
+ const TrylockBranch &B = decodeTrylockBranch(Block);
+ for (const TrylockEdgeCap &TC : B.OnTrue)
----------------
vtjnash wrote:
That is likely correct, but also likely pre-existing issue. I have a very long
list of bugs to fix in the way this code is handling conditional caps
(particularly the negative cases), so this commit is just intended to be NFC to
start working through those
https://github.com/llvm/llvm-project/pull/220634
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits