]> granicus.if.org Git - clang/commitdiff
IntegerLiterals are no longer evaluated to create separate nodes; their
authorTed Kremenek <kremenek@apple.com>
Wed, 16 Jan 2008 22:28:08 +0000 (22:28 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 16 Jan 2008 22:28:08 +0000 (22:28 +0000)
values are determined when evaluating the parent expression.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46096 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRConstants.cpp

index 2173f9b671b2f4235200b701a0b2f487e1755932..5acaf79b34acdf94478c9d77de0aa38c5182515d 100644 (file)
@@ -204,13 +204,19 @@ public:
   void BlockStmt_VisitStmt(Stmt* S) { DoStmt(S); }
   
   void VisitAssign(BinaryOperator* O);
-  void VisitIntegerLiteral(IntegerLiteral* L);
   void VisitBinAdd(BinaryOperator* O);
   void VisitBinSub(BinaryOperator* O);
   void VisitBinAssign(BinaryOperator* D);
 };
 } // end anonymous namespace
 
+static inline Expr* IgnoreParen(Expr* E) {
+  while (ParenExpr* P = dyn_cast<ParenExpr>(E))
+    E = P->getSubExpr();
+  
+  return E;
+}
+
 void GRConstants::ProcessStmt(Stmt* S, NodeBuilder& builder) {
   Builder = &builder;
   Nodes->clear();
@@ -224,9 +230,20 @@ void GRConstants::ProcessStmt(Stmt* S, NodeBuilder& builder) {
 
 ExprVariantTy GRConstants::GetBinding(Expr* E) {
   DSPtr P(NULL);
+  E = IgnoreParen(E);
   
-  if (DeclRefExpr* D = dyn_cast<DeclRefExpr>(E)) P = DSPtr(D->getDecl());
-  else P = DSPtr(E, getCFG().isBlkExpr(E));
+  switch (E->getStmtClass()) {
+    case Stmt::DeclRefExprClass:
+      P = DSPtr(cast<DeclRefExpr>(E)->getDecl());
+      break;
+
+    case Stmt::IntegerLiteralClass:
+      return cast<IntegerLiteral>(E)->getValue().getZExtValue();
+      
+    default:    
+      P = DSPtr(E, getCFG().isBlkExpr(E));
+      break;
+  }
 
   StateTy::iterator I = CurrentState.find(P);
 
@@ -297,10 +314,6 @@ void GRConstants::DoStmt(Stmt* S) {
   SwitchNodeSets();
 }
 
-void GRConstants::VisitIntegerLiteral(IntegerLiteral* L) {
-  AddBinding(L, L->getValue().getZExtValue());
-}
-
 void GRConstants::VisitBinAdd(BinaryOperator* B) {
   AddBinding(B, GetBinding(B->getLHS()) + GetBinding(B->getRHS()));
 }
@@ -310,14 +323,6 @@ void GRConstants::VisitBinSub(BinaryOperator* B) {
 }
 
 
-static inline Expr* IgnoreParen(Expr* E) {
-  while (ParenExpr* P = dyn_cast<ParenExpr>(E))
-    E = P->getSubExpr();
-  
-  return E;
-}
-
-
 void GRConstants::VisitBinAssign(BinaryOperator* B) {
   if (DeclRefExpr* D = dyn_cast<DeclRefExpr>(IgnoreParen(B->getLHS())))
     AddBinding(D->getDecl(), GetBinding(B->getRHS()));