|
22 | 22 | #define LLVM_CLANG_ANALYSIS_ANALYSES_THREADSAFETYCOMMON_H
|
23 | 23 |
|
24 | 24 | #include "clang/AST/Decl.h"
|
| 25 | +#include "clang/AST/Type.h" |
25 | 26 | #include "clang/Analysis/Analyses/PostOrderCFGView.h"
|
26 | 27 | #include "clang/Analysis/Analyses/ThreadSafetyTIL.h"
|
27 | 28 | #include "clang/Analysis/Analyses/ThreadSafetyTraverse.h"
|
@@ -272,27 +273,34 @@ class CFGWalker {
|
272 | 273 | class CapabilityExpr {
|
273 | 274 | private:
|
274 | 275 | static constexpr unsigned FlagNegative = 1u << 0;
|
| 276 | + static constexpr unsigned FlagReentrant = 1u << 1; |
275 | 277 |
|
276 | 278 | /// The capability expression and flags.
|
277 |
| - llvm::PointerIntPair<const til::SExpr *, 1, unsigned> CapExpr; |
| 279 | + llvm::PointerIntPair<const til::SExpr *, 2, unsigned> CapExpr; |
278 | 280 |
|
279 | 281 | /// The kind of capability as specified by @ref CapabilityAttr::getName.
|
280 | 282 | StringRef CapKind;
|
281 | 283 |
|
282 | 284 | public:
|
283 | 285 | CapabilityExpr() : CapExpr(nullptr, 0) {}
|
284 |
| - CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg) |
285 |
| - : CapExpr(E, Neg ? FlagNegative : 0), CapKind(Kind) {} |
| 286 | + CapabilityExpr(const til::SExpr *E, StringRef Kind, bool Neg, bool Reentrant) |
| 287 | + : CapExpr(E, (Neg ? FlagNegative : 0) | (Reentrant ? FlagReentrant : 0)), |
| 288 | + CapKind(Kind) {} |
| 289 | + // Infers `Kind` and `Reentrant` from `QT`. |
| 290 | + CapabilityExpr(const til::SExpr *E, QualType QT, bool Neg); |
286 | 291 |
|
287 | 292 | // Don't allow implicitly-constructed StringRefs since we'll capture them.
|
288 |
| - template <typename T> CapabilityExpr(const til::SExpr *, T, bool) = delete; |
| 293 | + template <typename T> |
| 294 | + CapabilityExpr(const til::SExpr *, T, bool, bool) = delete; |
289 | 295 |
|
290 | 296 | const til::SExpr *sexpr() const { return CapExpr.getPointer(); }
|
291 | 297 | StringRef getKind() const { return CapKind; }
|
292 | 298 | bool negative() const { return CapExpr.getInt() & FlagNegative; }
|
| 299 | + bool reentrant() const { return CapExpr.getInt() & FlagReentrant; } |
293 | 300 |
|
294 | 301 | CapabilityExpr operator!() const {
|
295 |
| - return CapabilityExpr(CapExpr.getPointer(), CapKind, !negative()); |
| 302 | + return CapabilityExpr(CapExpr.getPointer(), CapKind, !negative(), |
| 303 | + reentrant()); |
296 | 304 | }
|
297 | 305 |
|
298 | 306 | bool equals(const CapabilityExpr &other) const {
|
@@ -389,10 +397,6 @@ class SExprBuilder {
|
389 | 397 | // Translate a variable reference.
|
390 | 398 | til::LiteralPtr *createVariable(const VarDecl *VD);
|
391 | 399 |
|
392 |
| - // Create placeholder for this: we don't know the VarDecl on construction yet. |
393 |
| - std::pair<til::LiteralPtr *, StringRef> |
394 |
| - createThisPlaceholder(const Expr *Exp); |
395 |
| - |
396 | 400 | // Translate a clang statement or expression to a TIL expression.
|
397 | 401 | // Also performs substitution of variables; Ctx provides the context.
|
398 | 402 | // Dispatches on the type of S.
|
|
0 commit comments