|
30 | 30 | #include "clang/Analysis/CFG.h"
|
31 | 31 | #include "clang/Basic/LLVM.h"
|
32 | 32 | #include "llvm/ADT/DenseMap.h"
|
| 33 | +#include "llvm/ADT/PointerIntPair.h" |
33 | 34 | #include "llvm/ADT/SmallVector.h"
|
34 | 35 | #include "llvm/Support/Casting.h"
|
35 | 36 | #include <sstream>
|
@@ -269,56 +270,55 @@ class CFGWalker {
|
269 | 270 | // translateAttrExpr needs it, but that should be moved too.
|
270 | 271 | class CapabilityExpr {
|
271 | 272 | private:
|
272 |
| - /// The capability expression. |
273 |
| - const til::SExpr* CapExpr; |
274 |
| - |
275 |
| - /// True if this is a negative capability. |
276 |
| - bool Negated; |
| 273 | + /// The capability expression and whether it's negated. |
| 274 | + llvm::PointerIntPair<const til::SExpr *, 1, bool> CapExpr; |
277 | 275 |
|
278 | 276 | public:
|
279 |
| - CapabilityExpr(const til::SExpr *E, bool Neg) : CapExpr(E), Negated(Neg) {} |
| 277 | + CapabilityExpr(const til::SExpr *E, bool Neg) : CapExpr(E, Neg) {} |
280 | 278 |
|
281 |
| - const til::SExpr* sexpr() const { return CapExpr; } |
282 |
| - bool negative() const { return Negated; } |
| 279 | + const til::SExpr *sexpr() const { return CapExpr.getPointer(); } |
| 280 | + bool negative() const { return CapExpr.getInt(); } |
283 | 281 |
|
284 | 282 | CapabilityExpr operator!() const {
|
285 |
| - return CapabilityExpr(CapExpr, !Negated); |
| 283 | + return CapabilityExpr(CapExpr.getPointer(), !CapExpr.getInt()); |
286 | 284 | }
|
287 | 285 |
|
288 | 286 | bool equals(const CapabilityExpr &other) const {
|
289 |
| - return (Negated == other.Negated) && sx::equals(CapExpr, other.CapExpr); |
| 287 | + return (negative() == other.negative()) && |
| 288 | + sx::equals(sexpr(), other.sexpr()); |
290 | 289 | }
|
291 | 290 |
|
292 | 291 | bool matches(const CapabilityExpr &other) const {
|
293 |
| - return (Negated == other.Negated) && sx::matches(CapExpr, other.CapExpr); |
| 292 | + return (negative() == other.negative()) && |
| 293 | + sx::matches(sexpr(), other.sexpr()); |
294 | 294 | }
|
295 | 295 |
|
296 | 296 | bool matchesUniv(const CapabilityExpr &CapE) const {
|
297 | 297 | return isUniversal() || matches(CapE);
|
298 | 298 | }
|
299 | 299 |
|
300 | 300 | bool partiallyMatches(const CapabilityExpr &other) const {
|
301 |
| - return (Negated == other.Negated) && |
302 |
| - sx::partiallyMatches(CapExpr, other.CapExpr); |
| 301 | + return (negative() == other.negative()) && |
| 302 | + sx::partiallyMatches(sexpr(), other.sexpr()); |
303 | 303 | }
|
304 | 304 |
|
305 | 305 | const ValueDecl* valueDecl() const {
|
306 |
| - if (Negated || CapExpr == nullptr) |
| 306 | + if (negative() || sexpr() == nullptr) |
307 | 307 | return nullptr;
|
308 |
| - if (const auto *P = dyn_cast<til::Project>(CapExpr)) |
| 308 | + if (const auto *P = dyn_cast<til::Project>(sexpr())) |
309 | 309 | return P->clangDecl();
|
310 |
| - if (const auto *P = dyn_cast<til::LiteralPtr>(CapExpr)) |
| 310 | + if (const auto *P = dyn_cast<til::LiteralPtr>(sexpr())) |
311 | 311 | return P->clangDecl();
|
312 | 312 | return nullptr;
|
313 | 313 | }
|
314 | 314 |
|
315 | 315 | std::string toString() const {
|
316 |
| - if (Negated) |
317 |
| - return "!" + sx::toString(CapExpr); |
318 |
| - return sx::toString(CapExpr); |
| 316 | + if (negative()) |
| 317 | + return "!" + sx::toString(sexpr()); |
| 318 | + return sx::toString(sexpr()); |
319 | 319 | }
|
320 | 320 |
|
321 |
| - bool shouldIgnore() const { return CapExpr == nullptr; } |
| 321 | + bool shouldIgnore() const { return sexpr() == nullptr; } |
322 | 322 |
|
323 | 323 | bool isInvalid() const { return sexpr() && isa<til::Undefined>(sexpr()); }
|
324 | 324 |
|
|
0 commit comments