]> granicus.if.org Git - clang/commitdiff
Refactored guards for "GRExprEngine::RemoveDeadBindings" directly into the
authorTed Kremenek <kremenek@apple.com>
Sun, 9 Mar 2008 18:05:48 +0000 (18:05 +0000)
committerTed Kremenek <kremenek@apple.com>
Sun, 9 Mar 2008 18:05:48 +0000 (18:05 +0000)
method. This paves the way for other alterations to RemoveDeadBindings that are
transparent to its callers.

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

Analysis/GRExprEngine.cpp
include/clang/Analysis/PathSensitive/GRExprEngine.h

index de6e10cf3c6b668ba451fd4ec7dad93ec0185da4..e8d0306e2184fc0273079de4402ef62a7a5becb0 100644 (file)
@@ -39,6 +39,17 @@ using llvm::dyn_cast;
 using llvm::cast;
 using llvm::APSInt;
 
+ValueState* GRExprEngine::RemoveDeadBindings(ValueState* St) {
+  
+  if (StateCleaned || !CurrentStmt)
+    return St;
+  
+  StateCleaned = true;
+  
+  return StateMgr.RemoveDeadBindings(St, CurrentStmt, Liveness);
+}
+
+
 ValueState* GRExprEngine::getInitialState() {
 
   // The LiveVariables information already has a compilation of all VarDecls
@@ -65,10 +76,7 @@ ValueState* GRExprEngine::getInitialState() {
       
 ValueState* GRExprEngine::SetRVal(ValueState* St, Expr* Ex, RVal V) {
 
-  if (!StateCleaned) {
-    St = RemoveDeadBindings(CurrentStmt, St);
-    StateCleaned = true;
-  }
+  St = RemoveDeadBindings(St);
 
   bool isBlkExpr = false;
     
@@ -83,22 +91,12 @@ ValueState* GRExprEngine::SetRVal(ValueState* St, Expr* Ex, RVal V) {
 }
 
 ValueState* GRExprEngine::SetRVal(ValueState* St, LVal LV, RVal RV) {
-  
-  if (!StateCleaned) {
-    St = RemoveDeadBindings(CurrentStmt, St);
-    StateCleaned = true;
-  }
-  
+  St = RemoveDeadBindings(St);  
   return StateMgr.SetRVal(St, LV, RV);
 }
 
 ValueState* GRExprEngine::SetBlkExprRVal(ValueState* St, Expr* Ex, RVal V) {
-  
-  if (CurrentStmt && !StateCleaned) {
-    St = RemoveDeadBindings(CurrentStmt, St);
-    StateCleaned = true;
-  }
-  
+  St = RemoveDeadBindings(St);  
   return StateMgr.SetRVal(St, Ex, V, true, false);
 }
 
@@ -432,7 +430,7 @@ void GRExprEngine::ProcessStmt(Stmt* S, StmtNodeBuilder& builder) {
   if (Dst.size() == 1 && *Dst.begin() == StmtEntryNode) {
     ValueState* St =
       StateCleaned ? StmtEntryNode->getState() : 
-                     RemoveDeadBindings(S, StmtEntryNode->getState());
+                     RemoveDeadBindings(StmtEntryNode->getState());
     
     builder.generateNode(S, St, StmtEntryNode);
   }
index 37220ff5cd00055747beff446e8fa27bfeae457e..7b1115bee8735eccae26fa6d21b4892871ec6258 100644 (file)
@@ -263,11 +263,9 @@ protected:
   
   /// RemoveDeadBindings - Return a new state that is the same as 'St' except
   ///  that all subexpression mappings are removed and that any
-  ///  block-level expressions that are not live at 'S' also have their
-  ///  mappings removed.
-  inline ValueState* RemoveDeadBindings(Stmt* S, ValueState* St) {
-    return StateMgr.RemoveDeadBindings(St, S, Liveness);
-  }
+  ///  block-level expressions that are not live at 'CurrentStmt' also have 
+  ///  their mappings removed.
+  ValueState* RemoveDeadBindings(ValueState* St);
   
   ValueState* SetRVal(ValueState* St, Expr* Ex, RVal V);