[cfe-commits] r96473 - in /cfe/trunk/lib/Checker: CallInliner.cpp SymbolManager.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Wed Feb 17 00:50:06 PST 2010
Author: zhongxingxu
Date: Wed Feb 17 02:50:05 2010
New Revision: 96473
URL: http://llvm.org/viewvc/llvm-project?rev=96473&view=rev
Log:
In symbol reaper, a variable is live if its stack frame is the parent of the
current stack frame.
When leaving a callee, remove all bindings belonging to that callee.
Modified:
cfe/trunk/lib/Checker/CallInliner.cpp
cfe/trunk/lib/Checker/SymbolManager.cpp
Modified: cfe/trunk/lib/Checker/CallInliner.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CallInliner.cpp?rev=96473&r1=96472&r2=96473&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CallInliner.cpp (original)
+++ cfe/trunk/lib/Checker/CallInliner.cpp Wed Feb 17 02:50:05 2010
@@ -65,6 +65,7 @@
BlockEdge Loc(Entry, SuccB, LocCtx);
state = C.getStoreManager().EnterStackFrame(state, LocCtx);
+
// This is a hack. We really should not use the GRStmtNodeBuilder.
bool isNew;
GRExprEngine &Eng = C.getEngine();
@@ -86,16 +87,26 @@
void CallInliner::EvalEndPath(GREndPathNodeBuilder &B, void *tag,
GRExprEngine &Eng) {
const GRState *state = B.getState();
+
ExplodedNode *Pred = B.getPredecessor();
+
const StackFrameContext *LocCtx =
cast<StackFrameContext>(Pred->getLocationContext());
-
- const Stmt *CE = LocCtx->getCallSite();
-
// Check if this is the top level stack frame.
if (!LocCtx->getParent())
return;
+ const StackFrameContext *ParentSF =
+ cast<StackFrameContext>(LocCtx->getParent());
+
+ SymbolReaper SymReaper(*ParentSF->getLiveVariables(), Eng.getSymbolManager(),
+ ParentSF);
+ const Stmt *CE = LocCtx->getCallSite();
+
+ state = Eng.getStateManager().RemoveDeadBindings(state, const_cast<Stmt*>(CE),
+ SymReaper);
+
+
PostStmt NodeLoc(CE, LocCtx->getParent());
bool isNew;
Modified: cfe/trunk/lib/Checker/SymbolManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SymbolManager.cpp?rev=96473&r1=96472&r2=96473&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/SymbolManager.cpp (original)
+++ cfe/trunk/lib/Checker/SymbolManager.cpp Wed Feb 17 02:50:05 2010
@@ -14,6 +14,7 @@
#include "clang/Checker/PathSensitive/SymbolManager.h"
#include "clang/Checker/PathSensitive/MemRegion.h"
+#include "clang/Analysis/AnalysisContext.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
@@ -222,7 +223,11 @@
bool SymbolReaper::isLive(const Stmt *Loc, const VarRegion *VR) const {
const StackFrameContext *SFC = VR->getStackFrame();
- return SFC == CurrentStackFrame ? Liveness.isLive(Loc, VR->getDecl()) : true;
+
+ if (SFC == CurrentStackFrame)
+ return Liveness.isLive(Loc, VR->getDecl());
+ else
+ return SFC->isParentOf(CurrentStackFrame);
}
SymbolVisitor::~SymbolVisitor() {}
More information about the cfe-commits
mailing list