From 9428723d6730f4fd257e15b78d24991ae95bbd84 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Thu, 6 Dec 2012 18:58:26 +0000 Subject: [PATCH] [analyzer] Remove unused fields from ExprEngine. 'currStmt', 'CleanedState', and 'EntryNode' were being set, but only ever used locally. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169529 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Core/PathSensitive/ExprEngine.h | 9 -------- lib/StaticAnalyzer/Core/ExprEngine.cpp | 21 +++++++------------ lib/StaticAnalyzer/Core/ExprEngineObjC.cpp | 6 +++--- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index 6253a70f21..f4cb9a641f 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -64,15 +64,6 @@ class ExprEngine : public SubEngine { /// svalBuilder - SValBuilder object that creates SVals from expressions. SValBuilder &svalBuilder; - /// EntryNode - The immediate predecessor node. - ExplodedNode *EntryNode; - - /// CleanedState - The state for EntryNode "cleaned" of all dead - /// variables and symbols (as determined by a liveness analysis). - ProgramStateRef CleanedState; - - /// currStmt - The current block-level statement. - const Stmt *currStmt; unsigned int currStmtIdx; const NodeBuilderContext *currBldrCtx; diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index c5105412b6..2294519b7a 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -66,8 +66,7 @@ ExprEngine::ExprEngine(AnalysisManager &mgr, bool gcEnabled, this), SymMgr(StateMgr.getSymbolManager()), svalBuilder(StateMgr.getSValBuilder()), - EntryNode(NULL), - currStmt(NULL), currStmtIdx(0), currBldrCtx(0), + currStmtIdx(0), currBldrCtx(0), ObjCNoRet(mgr.getASTContext()), ObjCGCEnabled(gcEnabled), BR(mgr, *this), VisitedCallees(VisitedCalleesIn) @@ -282,7 +281,7 @@ void ExprEngine::removeDead(ExplodedNode *Pred, ExplodedNodeSet &Out, } NumRemoveDeadBindings++; - CleanedState = Pred->getState(); + ProgramStateRef CleanedState = Pred->getState(); // LC is the location context being destroyed, but SymbolReaper wants a // location context that is still live. (If this is the top-level stack @@ -353,18 +352,17 @@ void ExprEngine::ProcessStmt(const CFGStmt S, // Reclaim any unnecessary nodes in the ExplodedGraph. G.reclaimRecentlyAllocatedNodes(); - currStmt = S.getStmt(); + const Stmt *currStmt = S.getStmt(); PrettyStackTraceLoc CrashInfo(getContext().getSourceManager(), currStmt->getLocStart(), "Error evaluating statement"); // Remove dead bindings and symbols. - EntryNode = Pred; ExplodedNodeSet CleanedStates; - if (shouldRemoveDeadBindings(AMgr, S, Pred, EntryNode->getLocationContext())){ - removeDead(EntryNode, CleanedStates, currStmt, Pred->getLocationContext()); + if (shouldRemoveDeadBindings(AMgr, S, Pred, Pred->getLocationContext())){ + removeDead(Pred, CleanedStates, currStmt, Pred->getLocationContext()); } else - CleanedStates.Add(EntryNode); + CleanedStates.Add(Pred); // Visit the statement. ExplodedNodeSet Dst; @@ -378,11 +376,6 @@ void ExprEngine::ProcessStmt(const CFGStmt S, // Enqueue the new nodes onto the work list. Engine.enqueue(Dst, currBldrCtx->getBlock(), currStmtIdx); - - // NULL out these variables to cleanup. - CleanedState = NULL; - EntryNode = NULL; - currStmt = 0; } void ExprEngine::ProcessInitializer(const CFGInitializer Init, @@ -393,7 +386,7 @@ void ExprEngine::ProcessInitializer(const CFGInitializer Init, BMI->getSourceLocation(), "Error evaluating initializer"); - // We don't set EntryNode and currStmt. And we don't clean up state. + // We don't clean up dead bindings here. const StackFrameContext *stackFrame = cast(Pred->getLocationContext()); const CXXConstructorDecl *decl = diff --git a/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp b/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp index 51dda19b53..de73dd7c3e 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp @@ -179,13 +179,13 @@ void ExprEngine::VisitObjCMessage(const ObjCMessageExpr *ME, if (ObjCNoRet.isImplicitNoReturn(ME)) { // If we raise an exception, for now treat it as a sink. // Eventually we will want to handle exceptions properly. - Bldr.generateSink(currStmt, Pred, State); + Bldr.generateSink(ME, Pred, State); continue; } // Generate a transition to non-Nil state. if (notNilState != State) { - Pred = Bldr.generateNode(currStmt, Pred, notNilState); + Pred = Bldr.generateNode(ME, Pred, notNilState); assert(Pred && "Should have cached out already!"); } } @@ -195,7 +195,7 @@ void ExprEngine::VisitObjCMessage(const ObjCMessageExpr *ME, if (ObjCNoRet.isImplicitNoReturn(ME)) { // If we raise an exception, for now treat it as a sink. // Eventually we will want to handle exceptions properly. - Bldr.generateSink(currStmt, Pred, Pred->getState()); + Bldr.generateSink(ME, Pred, Pred->getState()); continue; } } -- 2.40.0