[clang] Thread Safety Analysis: Support reentrant capabilities (PR #137133)
Marco Elver via cfe-commits
cfe-commits at lists.llvm.org
Fri May 9 10:45:42 PDT 2025
================
@@ -271,26 +272,34 @@ class CFGWalker {
// translateAttrExpr needs it, but that should be moved too.
class CapabilityExpr {
private:
- /// The capability expression and whether it's negated.
- llvm::PointerIntPair<const til::SExpr *, 1, bool> CapExpr;
+ static constexpr unsigned FlagNegative = 1u << 0;
+ static constexpr unsigned FlagReentrant = 1u << 1;
+
+ /// The capability expression and flags.
+ llvm::PointerIntPair<const til::SExpr *, 2, unsigned> CapExpr;
/// The kind of capability as specified by @ref CapabilityAttr::getName.
StringRef CapKind;
public:
- CapabilityExpr() : CapExpr(nullptr, false) {}
- CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg)
- : CapExpr(E, Neg), CapKind(Kind) {}
+ CapabilityExpr() : CapExpr(nullptr, 0) {}
+ CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg, bool Reentrant)
+ : CapExpr(E, (Neg ? FlagNegative : 0) | (Reentrant ? FlagReentrant : 0)),
+ CapKind(Kind) {}
+ CapabilityExpr(const til::SExpr *E, QualType QT, bool Neg);
----------------
melver wrote:
It's a bit of a maze, but I felt this is a decent trade-off. Less/simpler code traded off against (minimal) loss of abstraction.
https://github.com/llvm/llvm-project/pull/137133
More information about the cfe-commits
mailing list