@@ -80,29 +80,64 @@ 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
+ CFGBlock::ConstCFGElementRef ElemRef ;
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),
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).
90
+ SymbolConjured (SymbolID sym, CFGBlock::ConstCFGElementRef elemRef,
91
+ const LocationContext *lctx, QualType t, unsigned count,
92
+ const void *symbolTag)
93
+ : SymbolData(SymbolConjuredKind, sym), ElemRef(elemRef), T(t),
94
+ Count (count), LCtx(lctx), SymbolTag(symbolTag) {
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
+ const CFGBlock::ConstCFGElementRef getCFGElementRef () const {
101
+ return ElemRef;
102
+ }
103
+
104
+ // It might return null.
105
+ const Stmt *getStmt () const {
106
+ switch (ElemRef->getKind ()) {
107
+ case CFGElement::Initializer:
108
+ return ElemRef->castAs <CFGInitializer>().getInitializer ()->getInit ();
109
+ case CFGElement::ScopeBegin:
110
+ return ElemRef->castAs <CFGScopeBegin>().getTriggerStmt ();
111
+ case CFGElement::ScopeEnd:
112
+ return ElemRef->castAs <CFGScopeEnd>().getTriggerStmt ();
113
+ case CFGElement::NewAllocator:
114
+ return ElemRef->castAs <CFGNewAllocator>().getAllocatorExpr ();
115
+ case CFGElement::LifetimeEnds:
116
+ return ElemRef->castAs <CFGLifetimeEnds>().getTriggerStmt ();
117
+ case CFGElement::LoopExit:
118
+ return ElemRef->castAs <CFGLoopExit>().getLoopStmt ();
119
+ case CFGElement::Statement:
120
+ return ElemRef->castAs <CFGStmt>().getStmt ();
121
+ case CFGElement::Constructor:
122
+ return ElemRef->castAs <CFGConstructor>().getStmt ();
123
+ case CFGElement::CXXRecordTypedCall:
124
+ return ElemRef->castAs <CFGCXXRecordTypedCall>().getStmt ();
125
+ case CFGElement::AutomaticObjectDtor:
126
+ return ElemRef->castAs <CFGAutomaticObjDtor>().getTriggerStmt ();
127
+ case CFGElement::DeleteDtor:
128
+ return ElemRef->castAs <CFGDeleteDtor>().getDeleteExpr ();
129
+ case CFGElement::BaseDtor:
130
+ return nullptr ;
131
+ case CFGElement::MemberDtor:
132
+ return nullptr ;
133
+ case CFGElement::TemporaryDtor:
134
+ return ElemRef->castAs <CFGTemporaryDtor>().getBindTemporaryExpr ();
135
+ case CFGElement::CleanupFunction:
136
+ return nullptr ;
137
+ }
138
+ return nullptr ;
139
+ }
140
+
106
141
unsigned getCount () const { return Count; }
107
142
// / It might return null.
108
143
const void *getTag () const { return SymbolTag; }
@@ -113,19 +148,20 @@ class SymbolConjured : public SymbolData {
113
148
114
149
void dumpToStream (raw_ostream &os) const override ;
115
150
116
- static void Profile (llvm::FoldingSetNodeID &profile, const Stmt *S,
151
+ static void Profile (llvm::FoldingSetNodeID &profile,
152
+ CFGBlock::ConstCFGElementRef ElemRef,
117
153
const LocationContext *LCtx, QualType T, unsigned Count,
118
154
const void *SymbolTag) {
119
155
profile.AddInteger ((unsigned )SymbolConjuredKind);
120
- profile.AddPointer (S );
156
+ profile.Add (ElemRef );
121
157
profile.AddPointer (LCtx);
122
158
profile.Add (T);
123
159
profile.AddInteger (Count);
124
160
profile.AddPointer (SymbolTag);
125
161
}
126
162
127
163
void Profile (llvm::FoldingSetNodeID& profile) override {
128
- Profile (profile, S , LCtx, T, Count, SymbolTag);
164
+ Profile (profile, ElemRef , LCtx, T, Count, SymbolTag);
129
165
}
130
166
131
167
// Implement isa<T> support.
@@ -533,18 +569,12 @@ class SymbolManager {
533
569
template <typename SymExprT, typename ... Args>
534
570
const SymExprT *acquire (Args &&...args);
535
571
536
- const SymbolConjured *conjureSymbol (const Stmt *E ,
572
+ const SymbolConjured *conjureSymbol (CFGBlock::ConstCFGElementRef ElemRef ,
537
573
const LocationContext *LCtx, QualType T,
538
574
unsigned VisitCount,
539
575
const void *SymbolTag = nullptr ) {
540
- return acquire<SymbolConjured>(E, LCtx, T, VisitCount, SymbolTag);
541
- }
542
576
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);
577
+ return acquire<SymbolConjured>(ElemRef, LCtx, T, VisitCount, SymbolTag);
548
578
}
549
579
550
580
QualType getType (const SymExpr *SE) const {
0 commit comments