@@ -204,13 +204,19 @@ class VISIBILITY_HIDDEN GRConstants : public CFGStmtVisitor<GRConstants> {
204
204
void BlockStmt_VisitStmt (Stmt* S) { DoStmt (S); }
205
205
206
206
void VisitAssign (BinaryOperator* O);
207
- void VisitIntegerLiteral (IntegerLiteral* L);
208
207
void VisitBinAdd (BinaryOperator* O);
209
208
void VisitBinSub (BinaryOperator* O);
210
209
void VisitBinAssign (BinaryOperator* D);
211
210
};
212
211
} // end anonymous namespace
213
212
213
+ static inline Expr* IgnoreParen (Expr* E) {
214
+ while (ParenExpr* P = dyn_cast<ParenExpr>(E))
215
+ E = P->getSubExpr ();
216
+
217
+ return E;
218
+ }
219
+
214
220
void GRConstants::ProcessStmt (Stmt* S, NodeBuilder& builder) {
215
221
Builder = &builder;
216
222
Nodes->clear ();
@@ -224,9 +230,20 @@ void GRConstants::ProcessStmt(Stmt* S, NodeBuilder& builder) {
224
230
225
231
ExprVariantTy GRConstants::GetBinding (Expr* E) {
226
232
DSPtr P (NULL );
233
+ E = IgnoreParen (E);
227
234
228
- if (DeclRefExpr* D = dyn_cast<DeclRefExpr>(E)) P = DSPtr (D->getDecl ());
229
- else P = DSPtr (E, getCFG ().isBlkExpr (E));
235
+ switch (E->getStmtClass ()) {
236
+ case Stmt::DeclRefExprClass:
237
+ P = DSPtr (cast<DeclRefExpr>(E)->getDecl ());
238
+ break ;
239
+
240
+ case Stmt::IntegerLiteralClass:
241
+ return cast<IntegerLiteral>(E)->getValue ().getZExtValue ();
242
+
243
+ default :
244
+ P = DSPtr (E, getCFG ().isBlkExpr (E));
245
+ break ;
246
+ }
230
247
231
248
StateTy::iterator I = CurrentState.find (P);
232
249
@@ -297,10 +314,6 @@ void GRConstants::DoStmt(Stmt* S) {
297
314
SwitchNodeSets ();
298
315
}
299
316
300
- void GRConstants::VisitIntegerLiteral (IntegerLiteral* L) {
301
- AddBinding (L, L->getValue ().getZExtValue ());
302
- }
303
-
304
317
void GRConstants::VisitBinAdd (BinaryOperator* B) {
305
318
AddBinding (B, GetBinding (B->getLHS ()) + GetBinding (B->getRHS ()));
306
319
}
@@ -310,14 +323,6 @@ void GRConstants::VisitBinSub(BinaryOperator* B) {
310
323
}
311
324
312
325
313
- static inline Expr* IgnoreParen (Expr* E) {
314
- while (ParenExpr* P = dyn_cast<ParenExpr>(E))
315
- E = P->getSubExpr ();
316
-
317
- return E;
318
- }
319
-
320
-
321
326
void GRConstants::VisitBinAssign (BinaryOperator* B) {
322
327
if (DeclRefExpr* D = dyn_cast<DeclRefExpr>(IgnoreParen (B->getLHS ())))
323
328
AddBinding (D->getDecl (), GetBinding (B->getRHS ()));
0 commit comments