aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-03-09 18:28:41 +0000
committerTed Kremenek <kremenek@apple.com>2008-03-09 18:28:41 +0000
commit512c913a6f93d225faacdb8e20308f5c4065c3eb (patch)
treeba1ac1c78850d57aeb4ec008e482e19ff3885c51
parentdaa497e3ae567ba6684226b86e6e1fe900112dab (diff)
When processing the transfer function for a statement, evaluate
RemoveDeadBindings early because (1) it will always be called and (2) we can dispatch to a plug-in transfer function that can evaluate the effect of dead symbols (not yet added). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48114 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Analysis/GRExprEngine.cpp25
-rw-r--r--include/clang/Analysis/PathSensitive/GRExprEngine.h8
2 files changed, 16 insertions, 17 deletions
diff --git a/Analysis/GRExprEngine.cpp b/Analysis/GRExprEngine.cpp
index e8d0306e21..932372c3a3 100644
--- a/Analysis/GRExprEngine.cpp
+++ b/Analysis/GRExprEngine.cpp
@@ -39,16 +39,6 @@ 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() {
@@ -420,7 +410,13 @@ void GRExprEngine::ProcessStmt(Stmt* S, StmtNodeBuilder& builder) {
StmtEntryNode = builder.getLastNode();
CurrentStmt = S;
NodeSet Dst;
- StateCleaned = false;
+
+ // Create the cleaned state.
+
+ RDBInState = StmtEntryNode->getState();
+ RDBOutState = StateMgr.RemoveDeadBindings(RDBInState, CurrentStmt, Liveness);
+
+ // Visit the statement.
Visit(S, StmtEntryNode, Dst);
@@ -428,10 +424,7 @@ void GRExprEngine::ProcessStmt(Stmt* S, StmtNodeBuilder& builder) {
// dead mappings removed.
if (Dst.size() == 1 && *Dst.begin() == StmtEntryNode) {
- ValueState* St =
- StateCleaned ? StmtEntryNode->getState() :
- RemoveDeadBindings(StmtEntryNode->getState());
-
+ ValueState* St = RemoveDeadBindings(StmtEntryNode->getState());
builder.generateNode(S, St, StmtEntryNode);
}
@@ -440,6 +433,8 @@ void GRExprEngine::ProcessStmt(Stmt* S, StmtNodeBuilder& builder) {
CurrentStmt = NULL;
StmtEntryNode = NULL;
Builder = NULL;
+ RDBInState = NULL;
+ RDBOutState = NULL;
}
void GRExprEngine::VisitDeclRefExpr(DeclRefExpr* D, NodeTy* Pred, NodeSet& Dst){
diff --git a/include/clang/Analysis/PathSensitive/GRExprEngine.h b/include/clang/Analysis/PathSensitive/GRExprEngine.h
index 7b1115bee8..74ad499ab7 100644
--- a/include/clang/Analysis/PathSensitive/GRExprEngine.h
+++ b/include/clang/Analysis/PathSensitive/GRExprEngine.h
@@ -120,7 +120,8 @@ protected:
/// where a pass-by-value argument has an undefined value.
UndefArgsTy UndefArgs;
- bool StateCleaned;
+ ValueState* RDBInState;
+ ValueState* RDBOutState;
public:
GRExprEngine(GraphTy& g) :
@@ -265,7 +266,10 @@ protected:
/// that all subexpression mappings are removed and that any
/// block-level expressions that are not live at 'CurrentStmt' also have
/// their mappings removed.
- ValueState* RemoveDeadBindings(ValueState* St);
+ ValueState* RemoveDeadBindings(ValueState* St) {
+ assert (St);
+ return St == RDBInState ? RDBOutState : St;
+ }
ValueState* SetRVal(ValueState* St, Expr* Ex, RVal V);