Author: Marco Elver Date: 2025-05-26T16:59:51+02:00 New Revision: 365dcf48b8aa726fb6a9ace4b37eb1f1cf121941
URL: https://github.com/llvm/llvm-project/commit/365dcf48b8aa726fb6a9ace4b37eb1f1cf121941 DIFF: https://github.com/llvm/llvm-project/commit/365dcf48b8aa726fb6a9ace4b37eb1f1cf121941.diff LOG: Thread Safety Analysis: Convert CapabilityExpr::CapExpr to hold flags Rather than holding a single bool, switch it to contain flags, which is both more descriptive and simplifies adding more flags in subsequent changes. NFC. Pull Request: https://github.com/llvm/llvm-project/pull/137133 Added: Modified: clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h Removed: ################################################################################ diff --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h index e99c5b2466334..6e46a2d721463 100644 --- a/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h +++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyCommon.h @@ -271,26 +271,28 @@ 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; + + /// The capability expression and flags. + llvm::PointerIntPair<const til::SExpr *, 1, unsigned> CapExpr; /// The kind of capability as specified by @ref CapabilityAttr::getName. StringRef CapKind; public: - CapabilityExpr() : CapExpr(nullptr, false) {} + CapabilityExpr() : CapExpr(nullptr, 0) {} CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg) - : CapExpr(E, Neg), CapKind(Kind) {} + : CapExpr(E, Neg ? FlagNegative : 0), CapKind(Kind) {} // Don't allow implicitly-constructed StringRefs since we'll capture them. template <typename T> CapabilityExpr(const til::SExpr *, T, bool) = delete; const til::SExpr *sexpr() const { return CapExpr.getPointer(); } StringRef getKind() const { return CapKind; } - bool negative() const { return CapExpr.getInt(); } + bool negative() const { return CapExpr.getInt() & FlagNegative; } CapabilityExpr operator!() const { - return CapabilityExpr(CapExpr.getPointer(), CapKind, !CapExpr.getInt()); + return CapabilityExpr(CapExpr.getPointer(), CapKind, !negative()); } bool equals(const CapabilityExpr &other) const { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits