[cfe-commits] r138719 - in /cfe/trunk/lib/StaticAnalyzer/Core: ExprEngine.cpp ExprEngineCallAndReturn.cpp ExprEngineObjC.cpp
Jordy Rose
jediknil at belkadan.com
Sat Aug 27 22:54:24 PDT 2011
Author: jrose
Date: Sun Aug 28 00:54:23 2011
New Revision: 138719
URL: http://llvm.org/viewvc/llvm-project?rev=138719&view=rev
Log:
[analyzer] Eliminate almost all uses of TransferFuncs from ExprEngine.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=138719&r1=138718&r2=138719&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Sun Aug 28 00:54:23 2011
@@ -172,17 +172,8 @@
/// evalAssume - Called by ConstraintManager. Used to call checker-specific
/// logic for handling assumptions on symbolic values.
const ProgramState *ExprEngine::processAssume(const ProgramState *state,
- SVal cond,
- bool assumption) {
-
- state = getCheckerManager().runCheckersForEvalAssume(state, cond,
- assumption);
-
- // If the state is infeasible at this point, bail out.
- if (!state)
- return NULL;
-
- return TF->evalAssume(state, cond, assumption);
+ SVal cond, bool assumption) {
+ return getCheckerManager().runCheckersForEvalAssume(state, cond, assumption);
}
bool ExprEngine::wantsRegionChangeUpdate(const ProgramState *state) {
@@ -279,23 +270,15 @@
// Call checkers with the non-cleaned state so that they could query the
// values of the soon to be dead symbols.
- // FIXME: This should soon be removed.
- ExplodedNodeSet Tmp2;
- getTF().evalDeadSymbols(Tmp2, *this, *Builder, EntryNode,
- EntryState, SymReaper);
- if (Tmp2.empty()) {
- Builder->MakeNode(Tmp2, currentStmt, EntryNode, EntryState);
- }
-
- ExplodedNodeSet Tmp3;
- getCheckerManager().runCheckersForDeadSymbols(Tmp3, Tmp2,
+ ExplodedNodeSet CheckedSet;
+ getCheckerManager().runCheckersForDeadSymbols(CheckedSet, EntryNode,
SymReaper, currentStmt, *this);
- // For each node in Tmp3, generate CleanedNodes that have the environment,
- // the store, and the constraints cleaned up but have the user supplied
- // states as the predecessors.
- for (ExplodedNodeSet::const_iterator I = Tmp3.begin(), E = Tmp3.end();
- I != E; ++I) {
+ // For each node in CheckedSet, generate CleanedNodes that have the
+ // environment, the store, and the constraints cleaned up but have the
+ // user-supplied states as the predecessors.
+ for (ExplodedNodeSet::const_iterator
+ I = CheckedSet.begin(), E = CheckedSet.end(); I != E; ++I) {
const ProgramState *CheckerState = (*I)->getState();
// The constraint manager has not been cleaned up yet, so clean up now.
@@ -1067,7 +1050,6 @@
/// ProcessEndPath - Called by CoreEngine. Used to generate end-of-path
/// nodes when the control reaches the end of a function.
void ExprEngine::processEndOfFunction(EndOfFunctionNodeBuilder& builder) {
- getTF().evalEndPath(*this, builder);
StateMgr.EndPath(builder.getState());
getCheckerManager().runCheckersForEndPath(builder, *this);
}
@@ -1297,52 +1279,30 @@
ExplodedNode *Pred, const ProgramState *state,
SVal location, SVal Val, bool atDeclInit) {
+ // FIXME: We probably shouldn't be passing a state and then dropping it on the
+ // floor, but while we are, we can at least assert that we're doing it right.
+ assert(state == Pred->getState());
// Do a previsit of the bind.
- ExplodedNodeSet CheckedSet, Src;
- Src.Add(Pred);
- getCheckerManager().runCheckersForBind(CheckedSet, Src, location, Val, StoreE,
- *this);
+ ExplodedNodeSet CheckedSet;
+ getCheckerManager().runCheckersForBind(CheckedSet, Pred, location, Val,
+ StoreE, *this);
for (ExplodedNodeSet::iterator I = CheckedSet.begin(), E = CheckedSet.end();
I!=E; ++I) {
- if (Pred != *I)
- state = (*I)->getState();
-
- const ProgramState *newState = 0;
+ state = (*I)->getState();
if (atDeclInit) {
const VarRegion *VR =
cast<VarRegion>(cast<loc::MemRegionVal>(location).getRegion());
- newState = state->bindDecl(VR, Val);
+ state = state->bindDecl(VR, Val);
+ } else {
+ state = state->bindLoc(location, Val);
}
- else {
- if (location.isUnknown()) {
- // We know that the new state will be the same as the old state since
- // the location of the binding is "unknown". Consequently, there
- // is no reason to just create a new node.
- newState = state;
- }
- else {
- // We are binding to a value other than 'unknown'. Perform the binding
- // using the StoreManager.
- newState = state->bindLoc(cast<Loc>(location), Val);
- }
- }
-
- // The next thing to do is check if the TransferFuncs object wants to
- // update the state based on the new binding. If the GRTransferFunc object
- // doesn't do anything, just auto-propagate the current state.
-
- // NOTE: We use 'AssignE' for the location of the PostStore if 'AssignE'
- // is non-NULL. Checkers typically care about
-
- StmtNodeBuilderRef BuilderRef(Dst, *Builder, *this, *I, newState, StoreE,
- true);
- getTF().evalBind(BuilderRef, location, Val);
+ MakeNode(Dst, StoreE, *I, state);
}
}
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp?rev=138719&r1=138718&r2=138719&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp Sun Aug 28 00:54:23 2011
@@ -210,18 +210,8 @@
const LocationContext *LC = Pred->getLocationContext();
state = Eng.invalidateArguments(state, CallOrObjCMessage(CE, state), LC);
- // Then handle everything else.
- unsigned oldSize = Dst.size();
- SaveOr OldHasGen(Builder.hasGeneratedNode);
-
- // Dispatch to transfer function logic to handle the rest of the call.
- //Eng.getTF().evalCall(Dst, Eng, Builder, CE, L, Pred);
-
- // Handle the case where no nodes where generated. Auto-generate that
- // contains the updated state if we aren't generating sinks.
- if (!Builder.BuildSinks && Dst.size() == oldSize &&
- !Builder.hasGeneratedNode)
- Eng.MakeNode(Dst, CE, Pred, state);
+ // And make the result node.
+ Eng.MakeNode(Dst, CE, Pred, state);
}
};
@@ -259,25 +249,5 @@
Src.Add(Pred);
}
- ExplodedNodeSet CheckedSet;
- getCheckerManager().runCheckersForPreStmt(CheckedSet, Src, RS, *this);
-
- for (ExplodedNodeSet::iterator I = CheckedSet.begin(), E = CheckedSet.end();
- I != E; ++I) {
-
- assert(Builder && "StmtNodeBuilder must be defined.");
-
- Pred = *I;
- unsigned size = Dst.size();
-
- SaveAndRestore<bool> OldSink(Builder->BuildSinks);
- SaveOr OldHasGen(Builder->hasGeneratedNode);
-
- getTF().evalReturn(Dst, *this, *Builder, RS, Pred);
-
- // Handle the case where no nodes where generated.
- if (!Builder->BuildSinks && Dst.size() == size &&
- !Builder->hasGeneratedNode)
- MakeNode(Dst, RS, Pred, Pred->getState());
- }
+ getCheckerManager().runCheckersForPreStmt(Dst, Src, RS, *this);
}
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp?rev=138719&r1=138718&r2=138719&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp Sun Aug 28 00:54:23 2011
@@ -142,7 +142,6 @@
ExplodedNode *Pred = *DI;
bool RaisesException = false;
- unsigned oldSize = dstEval.size();
SaveAndRestore<bool> OldSink(Builder->BuildSinks);
SaveOr OldHasGen(Builder->hasGeneratedNode);
@@ -225,12 +224,8 @@
// Dispatch to plug-in transfer function.
evalObjCMessage(dstEval, msg, Pred, Pred->getState());
}
-
- // Handle the case where no nodes where generated. Auto-generate that
- // contains the updated state if we aren't generating sinks.
- if (!Builder->BuildSinks && dstEval.size() == oldSize &&
- !Builder->hasGeneratedNode)
- MakeNode(dstEval, msg.getOriginExpr(), Pred, Pred->getState());
+
+ assert(Builder->BuildSinks || Builder->hasGeneratedNode);
}
// Finally, perform the post-condition check of the ObjCMessageExpr and store
@@ -276,9 +271,8 @@
// Invalidate the arguments (and the receiver)
const LocationContext *LC = Pred->getLocationContext();
state = invalidateArguments(state, CallOrObjCMessage(msg, state), LC);
- Builder->MakeNode(Dst, msg.getOriginExpr(), Pred, state);
- // Now we can handle the other aspects of the message.
- //getTF().evalObjCMessage(Dst, *this, *Builder, msg, Pred, state);
+ // And create the new node.
+ MakeNode(Dst, msg.getOriginExpr(), Pred, state);
}
More information about the cfe-commits
mailing list