[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)
Marco Elver via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 29 08:52:46 PDT 2025
================
@@ -388,7 +395,7 @@ class SExprBuilder {
til::LiteralPtr *createVariable(const VarDecl *VD);
// Create placeholder for this: we don't know the VarDecl on construction yet.
- std::pair<til::LiteralPtr *, StringRef>
+ std::pair<til::LiteralPtr *, CapabilityExpr>
----------------
melver wrote:
I think this code is just more complex than it needs to be. I do not understand the need for createThisPlaceholder():
- Placeholder.second is only used if there's a ScopedLockableAttr;
- Placeholder.first is equivalent to a createVariable(nullptr);
Therefore, we can just defer the second step (getting the string+bool out) for when we determine it's a ScopedLockableAttr, and use createVariable(nullptr) instead of createThisPlaceholder(). The main problem was that the function that extracts the string (and now also the reentrant bool) wasn't available here.
So it'll just be much clearer if we have a constructor that does that for us, and just use that rather than through this complex indirection of "prefetching" the string+bool.
Also saves a few cycles if we simplify it. Let me try that.
https://github.com/llvm/llvm-project/pull/137133
More information about the cfe-commits
mailing list