[cfe-commits] r46096 - /cfe/trunk/Analysis/GRConstants.cpp

Ted Kremenek kremenek at apple.com
Wed Jan 16 14:28:09 PST 2008


Author: kremenek
Date: Wed Jan 16 16:28:08 2008
New Revision: 46096

URL: http://llvm.org/viewvc/llvm-project?rev=46096&view=rev
Log:
IntegerLiterals are no longer evaluated to create separate nodes; their
values are determined when evaluating the parent expression.

Modified:
    cfe/trunk/Analysis/GRConstants.cpp

Modified: cfe/trunk/Analysis/GRConstants.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRConstants.cpp?rev=46096&r1=46095&r2=46096&view=diff

==============================================================================
--- cfe/trunk/Analysis/GRConstants.cpp (original)
+++ cfe/trunk/Analysis/GRConstants.cpp Wed Jan 16 16:28:08 2008
@@ -204,13 +204,19 @@
   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 @@
 
 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 @@
   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 @@
 }
 
 
-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()));





More information about the cfe-commits mailing list