17
17
#include " clang/AST/Expr.h"
18
18
#include " clang/AST/Type.h"
19
19
#include " clang/Analysis/AnalysisDeclContext.h"
20
+ #include " clang/Analysis/CFG.h"
20
21
#include " clang/Basic/LLVM.h"
21
22
#include " clang/StaticAnalyzer/Core/PathSensitive/APSIntPtr.h"
22
23
#include " clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
@@ -80,29 +81,27 @@ class SymbolRegionValue : public SymbolData {
80
81
// / A symbol representing the result of an expression in the case when we do
81
82
// / not know anything about what the expression is.
82
83
class SymbolConjured : public SymbolData {
83
- const Stmt *S ;
84
+ const CFGBlock::ConstCFGElementRef ElemRef ;
84
85
QualType T;
85
86
unsigned Count;
86
87
const LocationContext *LCtx;
87
88
const void *SymbolTag;
88
89
89
90
friend class SymExprAllocator ;
90
- SymbolConjured (SymbolID sym, const Stmt *s, const LocationContext *lctx,
91
- QualType t, unsigned count, const void *symbolTag)
92
- : SymbolData(SymbolConjuredKind, sym), S(s), T(t), Count(count),
93
- LCtx (lctx), SymbolTag(symbolTag) {
94
- // FIXME: 's' might be a nullptr if we're conducting invalidation
95
- // that was caused by a destructor call on a temporary object,
96
- // which has no statement associated with it.
97
- // Due to this, we might be creating the same invalidation symbol for
98
- // two different invalidation passes (for two different temporaries).
91
+ SymbolConjured (SymbolID sym, CFGBlock::ConstCFGElementRef elemRef,
92
+ const LocationContext *lctx, QualType t, unsigned count,
93
+ const void *symbolTag)
94
+ : SymbolData(SymbolConjuredKind, sym), ElemRef(elemRef), T(t),
95
+ Count (count), LCtx(lctx), SymbolTag(symbolTag) {
99
96
assert (lctx);
100
97
assert (isValidTypeForSymbol (t));
101
98
}
102
99
103
100
public:
104
- // / It might return null.
105
- const Stmt *getStmt () const { return S; }
101
+ const CFGBlock::ConstCFGElementRef getCFGElementRef () const {
102
+ return ElemRef;
103
+ }
104
+
106
105
unsigned getCount () const { return Count; }
107
106
// / It might return null.
108
107
const void *getTag () const { return SymbolTag; }
@@ -113,19 +112,20 @@ class SymbolConjured : public SymbolData {
113
112
114
113
void dumpToStream (raw_ostream &os) const override ;
115
114
116
- static void Profile (llvm::FoldingSetNodeID &profile, const Stmt *S,
115
+ static void Profile (llvm::FoldingSetNodeID &profile,
116
+ const CFGBlock::ConstCFGElementRef ElemRef,
117
117
const LocationContext *LCtx, QualType T, unsigned Count,
118
118
const void *SymbolTag) {
119
119
profile.AddInteger ((unsigned )SymbolConjuredKind);
120
- profile.AddPointer (S );
120
+ profile.Add (ElemRef );
121
121
profile.AddPointer (LCtx);
122
122
profile.Add (T);
123
123
profile.AddInteger (Count);
124
124
profile.AddPointer (SymbolTag);
125
125
}
126
126
127
127
void Profile (llvm::FoldingSetNodeID& profile) override {
128
- Profile (profile, S , LCtx, T, Count, SymbolTag);
128
+ Profile (profile, ElemRef , LCtx, T, Count, SymbolTag);
129
129
}
130
130
131
131
// Implement isa<T> support.
@@ -533,18 +533,12 @@ class SymbolManager {
533
533
template <typename SymExprT, typename ... Args>
534
534
const SymExprT *acquire (Args &&...args);
535
535
536
- const SymbolConjured *conjureSymbol (const Stmt *E,
537
- const LocationContext *LCtx, QualType T,
538
- unsigned VisitCount,
539
- const void *SymbolTag = nullptr ) {
540
- return acquire<SymbolConjured>(E, LCtx, T, VisitCount, SymbolTag);
541
- }
536
+ const SymbolConjured *
537
+ conjureSymbol (const CFGBlock::ConstCFGElementRef ElemRef,
538
+ const LocationContext *LCtx, QualType T, unsigned VisitCount,
539
+ const void *SymbolTag = nullptr ) {
542
540
543
- const SymbolConjured* conjureSymbol (const Expr *E,
544
- const LocationContext *LCtx,
545
- unsigned VisitCount,
546
- const void *SymbolTag = nullptr ) {
547
- return conjureSymbol (E, LCtx, E->getType (), VisitCount, SymbolTag);
541
+ return acquire<SymbolConjured>(ElemRef, LCtx, T, VisitCount, SymbolTag);
548
542
}
549
543
550
544
QualType getType (const SymExpr *SE) const {
0 commit comments