]> granicus.if.org Git - clang/commitdiff
optimization: no longer create ExplodedNodes for IntegerLiteral and
authorTed Kremenek <kremenek@apple.com>
Tue, 26 Feb 2008 19:17:09 +0000 (19:17 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 26 Feb 2008 19:17:09 +0000 (19:17 +0000)
CharacterLiteral expressions.

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

Analysis/GRExprEngine.cpp
Analysis/ValueState.cpp

index 4479ecf30b2a8949eb10f2cf219b4c8640c1fd5f..c0f53fe8c70075c841d798650eb40ecf418dff9e 100644 (file)
@@ -1170,7 +1170,7 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
       
     default:
       // Cases we intentionally have "default" handle:
-      //   AddrLabelExpr
+      //   AddrLabelExpr, IntegerLiteral, CharacterLiteral
       
       Dst.Add(Pred); // No-op. Simply propagate the current state unchanged.
       break;
@@ -1203,20 +1203,7 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
       VisitCast(C, C->getSubExpr(), Pred, Dst);
       break;
     }
-      
-      // While explicitly creating a node+state for visiting a CharacterLiteral
-      // seems wasteful, it also solves a bunch of problems when handling
-      // the ?, &&, and ||.
-      
-    case Stmt::CharacterLiteralClass: {
-      CharacterLiteral* C = cast<CharacterLiteral>(S);
-      StateTy St = Pred->getState();
-      NonLVal X = NonLVal::MakeVal(ValMgr, C->getValue(), C->getType(),
-                                        C->getLoc());
-      Nodify(Dst, C, Pred, SetRVal(St, C, X));
-      break;      
-    }
-      
+
       // FIXME: ChooseExpr is really a constant.  We need to fix
       //        the CFG do not model them as explicit control-flow.
       
@@ -1244,18 +1231,6 @@ void GRExprEngine::Visit(Stmt* S, NodeTy* Pred, NodeSet& Dst) {
       VisitDeclStmt(cast<DeclStmt>(S), Pred, Dst);
       break;
       
-      // While explicitly creating a node+state for visiting an IntegerLiteral
-      // seems wasteful, it also solves a bunch of problems when handling
-      // the ?, &&, and ||.
-      
-    case Stmt::IntegerLiteralClass: {      
-      StateTy St = Pred->getState();
-      IntegerLiteral* I = cast<IntegerLiteral>(S);
-      NonLVal X = NonLVal::MakeVal(ValMgr, I);
-      Nodify(Dst, I, Pred, SetRVal(St, I, X));
-      break;      
-    }
-      
     case Stmt::ImplicitCastExprClass: {
       ImplicitCastExpr* C = cast<ImplicitCastExpr>(S);
       VisitCast(C, C->getSubExpr(), Pred, Dst);
index ab208ff0fe2e02e359f001dc2a3ca262eeafc2aa..7f3e733dbb97c269e24eb3681e88a513d8b3c794 100644 (file)
@@ -264,6 +264,16 @@ RVal ValueStateManager::GetRVal(ValueState St, Expr* E) {
         
         return UnknownVal();
       }
+        
+      case Stmt::CharacterLiteralClass: {
+        CharacterLiteral* C = cast<CharacterLiteral>(E);
+        return NonLVal::MakeVal(ValMgr, C->getValue(), C->getType(),
+                                C->getLoc());
+      }
+        
+      case Stmt::IntegerLiteralClass: {
+        return NonLVal::MakeVal(ValMgr, cast<IntegerLiteral>(E));
+      }
 
         // Casts where the source and target type are the same
         // are no-ops.  We blast through these to get the descendant
@@ -332,9 +342,23 @@ RVal ValueStateManager::GetRVal(ValueState St, Expr* E) {
 RVal ValueStateManager::GetBlkExprRVal(ValueState St, Expr* E) {
   
   assert (!isa<ParenExpr>(E));
-
-  ValueState::ExprBindingsTy::TreeTy* T = St->BlockExprBindings.SlimFind(E);    
-  return T ? T->getValue().second : UnknownVal();
+  
+  switch (E->getStmtClass()) {
+    case Stmt::CharacterLiteralClass: {
+      CharacterLiteral* C = cast<CharacterLiteral>(E);
+      return NonLVal::MakeVal(ValMgr, C->getValue(), C->getType(),
+                              C->getLoc());
+    }
+      
+    case Stmt::IntegerLiteralClass: {
+      return NonLVal::MakeVal(ValMgr, cast<IntegerLiteral>(E));
+    }
+      
+    default: {
+      ValueState::ExprBindingsTy::TreeTy* T = St->BlockExprBindings.SlimFind(E);    
+      return T ? T->getValue().second : UnknownVal();
+    }
+  }
 }
 
 RVal ValueStateManager::GetLVal(ValueState St, Expr* E) {