@@ -80,29 +80,62 @@ class SymbolRegionValue : public SymbolData {
80
80
// / A symbol representing the result of an expression in the case when we do
81
81
// / not know anything about what the expression is.
82
82
class SymbolConjured : public SymbolData {
83
- const Stmt *S ;
83
+ ConstCFGElementRef Elem ;
84
84
QualType T;
85
85
unsigned Count;
86
86
const LocationContext *LCtx;
87
87
const void *SymbolTag;
88
88
89
89
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),
90
+ SymbolConjured (SymbolID sym, ConstCFGElementRef elem,
91
+ const LocationContext *lctx, QualType t, unsigned count,
92
+ const void *symbolTag)
93
+ : SymbolData(SymbolConjuredKind, sym), Elem(elem), T(t), Count(count),
93
94
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).
99
95
assert (lctx);
100
96
assert (isValidTypeForSymbol (t));
101
97
}
102
98
103
99
public:
104
- // / It might return null.
105
- const Stmt *getStmt () const { return S; }
100
+ ConstCFGElementRef getCFGElementRef () const { return Elem; }
101
+
102
+ // It might return null.
103
+ const Stmt *getStmt () const {
104
+ switch (Elem->getKind ()) {
105
+ case CFGElement::Initializer:
106
+ return Elem->castAs <CFGInitializer>().getInitializer ()->getInit ();
107
+ case CFGElement::ScopeBegin:
108
+ return Elem->castAs <CFGScopeBegin>().getTriggerStmt ();
109
+ case CFGElement::ScopeEnd:
110
+ return Elem->castAs <CFGScopeEnd>().getTriggerStmt ();
111
+ case CFGElement::NewAllocator:
112
+ return Elem->castAs <CFGNewAllocator>().getAllocatorExpr ();
113
+ case CFGElement::LifetimeEnds:
114
+ return Elem->castAs <CFGLifetimeEnds>().getTriggerStmt ();
115
+ case CFGElement::LoopExit:
116
+ return Elem->castAs <CFGLoopExit>().getLoopStmt ();
117
+ case CFGElement::Statement:
118
+ return Elem->castAs <CFGStmt>().getStmt ();
119
+ case CFGElement::Constructor:
120
+ return Elem->castAs <CFGConstructor>().getStmt ();
121
+ case CFGElement::CXXRecordTypedCall:
122
+ return Elem->castAs <CFGCXXRecordTypedCall>().getStmt ();
123
+ case CFGElement::AutomaticObjectDtor:
124
+ return Elem->castAs <CFGAutomaticObjDtor>().getTriggerStmt ();
125
+ case CFGElement::DeleteDtor:
126
+ return Elem->castAs <CFGDeleteDtor>().getDeleteExpr ();
127
+ case CFGElement::BaseDtor:
128
+ return nullptr ;
129
+ case CFGElement::MemberDtor:
130
+ return nullptr ;
131
+ case CFGElement::TemporaryDtor:
132
+ return Elem->castAs <CFGTemporaryDtor>().getBindTemporaryExpr ();
133
+ case CFGElement::CleanupFunction:
134
+ return nullptr ;
135
+ }
136
+ return nullptr ;
137
+ }
138
+
106
139
unsigned getCount () const { return Count; }
107
140
// / It might return null.
108
141
const void *getTag () const { return SymbolTag; }
@@ -113,19 +146,19 @@ class SymbolConjured : public SymbolData {
113
146
114
147
void dumpToStream (raw_ostream &os) const override ;
115
148
116
- static void Profile (llvm::FoldingSetNodeID &profile, const Stmt *S ,
149
+ static void Profile (llvm::FoldingSetNodeID &profile, ConstCFGElementRef Elem ,
117
150
const LocationContext *LCtx, QualType T, unsigned Count,
118
151
const void *SymbolTag) {
119
152
profile.AddInteger ((unsigned )SymbolConjuredKind);
120
- profile.AddPointer (S );
153
+ profile.Add (Elem );
121
154
profile.AddPointer (LCtx);
122
155
profile.Add (T);
123
156
profile.AddInteger (Count);
124
157
profile.AddPointer (SymbolTag);
125
158
}
126
159
127
160
void Profile (llvm::FoldingSetNodeID& profile) override {
128
- Profile (profile, S , LCtx, T, Count, SymbolTag);
161
+ Profile (profile, Elem , LCtx, T, Count, SymbolTag);
129
162
}
130
163
131
164
// Implement isa<T> support.
@@ -533,18 +566,12 @@ class SymbolManager {
533
566
template <typename SymExprT, typename ... Args>
534
567
const SymExprT *acquire (Args &&...args);
535
568
536
- const SymbolConjured *conjureSymbol (const Stmt *E ,
569
+ const SymbolConjured *conjureSymbol (ConstCFGElementRef Elem ,
537
570
const LocationContext *LCtx, QualType T,
538
571
unsigned VisitCount,
539
572
const void *SymbolTag = nullptr ) {
540
- return acquire<SymbolConjured>(E, LCtx, T, VisitCount, SymbolTag);
541
- }
542
573
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);
574
+ return acquire<SymbolConjured>(Elem, LCtx, T, VisitCount, SymbolTag);
548
575
}
549
576
550
577
QualType getType (const SymExpr *SE) const {
0 commit comments