[llvm-branch-commits] [clang] Thread Safety Analysis: Track try-acquired capabilities as a ternary try-held state (PR #220635)
Aaron Puchert via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Nov 15 16:53:01 PST 2026
https://github.com/aaronpuchert commented:
Just took a cursory look, but based on the complexity of the approach I like this a bit better than the alternative PR. The logic is still a bit complex, probably to some extent due to legacy reasons.
What I'm envisioning is that a fact contains everything we know about a particular capability expression, and that it basically encodes them as some state S. Then the overall state is simply a map (not multi-map) `CapabilityExpr` → S. In the earliest versions of the analysis, we simply had S = `bool`. Reentrancy and try-acquire complicate the picture though, as do scoped capabilities, which seem to have a different set of states (hence two subclasses of `FactEntry`).
Since try-acquire allows rebranching, I think it adds a list of (`CallExpr*`, T) pairs to our state: for every try-acquire call, we track what we know about the return value of that call in our branch: so T = {true, false, unknown}. I'm not sure if we should increment the reentrancy counter when we have "true", since you could also pick this up separately. Maybe we should add them on top in `getReentrancyDepth`.
As I wrote on the other change: maybe a pen-and-paper model before implementing this would be a good idea. It might be required that we improve modeling of negative capabilities (which are currently just regular capabilities with a negated expression). Other than that, this feels like the right direction to take.
https://github.com/llvm/llvm-project/pull/220635
More information about the llvm-branch-commits
mailing list