@@ -192,6 +192,8 @@ class VISIBILITY_HIDDEN GRConstants : public CFGStmtVisitor<GRConstants> {
192
192
StateTy RemoveGrandchildrenMappings (Stmt* S, StateTy M);
193
193
194
194
void AddBinding (Expr* E, ExprVariantTy V, bool isBlkLvl = false );
195
+ void AddBinding (Decl* D, ExprVariantTy V);
196
+
195
197
ExprVariantTy GetBinding (Expr* E);
196
198
197
199
void BlockStmt_VisitStmt (Stmt* S) { DoStmt (S); }
@@ -200,6 +202,7 @@ class VISIBILITY_HIDDEN GRConstants : public CFGStmtVisitor<GRConstants> {
200
202
void VisitIntegerLiteral (IntegerLiteral* L);
201
203
void VisitBinAdd (BinaryOperator* O);
202
204
void VisitBinSub (BinaryOperator* O);
205
+ void VisitBinAssign (BinaryOperator* D);
203
206
};
204
207
} // end anonymous namespace
205
208
@@ -229,6 +232,13 @@ void GRConstants::AddBinding(Expr* E, ExprVariantTy V, bool isBlkLvl) {
229
232
CurrentState = StateMgr.Add (CurrentState, DSPtr (E,isBlkLvl), V.getVal ());
230
233
}
231
234
235
+ void GRConstants::AddBinding (Decl* D, ExprVariantTy V) {
236
+ if (V)
237
+ CurrentState = StateMgr.Add (CurrentState, DSPtr (D), V.getVal ());
238
+ else
239
+ CurrentState = StateMgr.Remove (CurrentState, DSPtr (D));
240
+ }
241
+
232
242
void GRConstants::SwitchNodeSets () {
233
243
NodeSetTy* Tmp = OldNodes;
234
244
OldNodes = Nodes;
@@ -290,6 +300,20 @@ void GRConstants::VisitBinSub(BinaryOperator* B) {
290
300
AddBinding (B, GetBinding (B->getLHS ()) - GetBinding (B->getRHS ()));
291
301
}
292
302
303
+
304
+ static inline Expr* IgnoreParen (Expr* E) {
305
+ while (ParenExpr* P = dyn_cast<ParenExpr>(E))
306
+ E = P->getSubExpr ();
307
+
308
+ return E;
309
+ }
310
+
311
+
312
+ void GRConstants::VisitBinAssign (BinaryOperator* B) {
313
+ if (DeclRefExpr* D = dyn_cast<DeclRefExpr>(IgnoreParen (B->getLHS ())))
314
+ AddBinding (D->getDecl (), GetBinding (B->getRHS ()));
315
+ }
316
+
293
317
// ===----------------------------------------------------------------------===//
294
318
// Driver.
295
319
// ===----------------------------------------------------------------------===//
0 commit comments