diff options
| author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-02-17 08:50:05 +0000 |
|---|---|---|
| committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-02-17 08:50:05 +0000 |
| commit | b2ef2f14273913d4a5b54489dcfaa46c2fd85ea3 (patch) | |
| tree | 502e6ea65e1e6ea3a186bac398b19712d32ac934 /clang/lib | |
| parent | daf4616455c769b04ec70131550c9d73a3bc9dc5 (diff) | |
| download | bcm5719-llvm-b2ef2f14273913d4a5b54489dcfaa46c2fd85ea3.tar.gz bcm5719-llvm-b2ef2f14273913d4a5b54489dcfaa46c2fd85ea3.zip | |
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.
llvm-svn: 96473
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Checker/CallInliner.cpp | 17 | ||||
| -rw-r--r-- | clang/lib/Checker/SymbolManager.cpp | 7 |
2 files changed, 20 insertions, 4 deletions
diff --git a/clang/lib/Checker/CallInliner.cpp b/clang/lib/Checker/CallInliner.cpp index d94994b1943..0279d46f228 100644 --- a/clang/lib/Checker/CallInliner.cpp +++ b/clang/lib/Checker/CallInliner.cpp @@ -65,6 +65,7 @@ bool CallInliner::EvalCallExpr(CheckerContext &C, const CallExpr *CE) { 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 @@ bool CallInliner::EvalCallExpr(CheckerContext &C, const CallExpr *CE) { 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; diff --git a/clang/lib/Checker/SymbolManager.cpp b/clang/lib/Checker/SymbolManager.cpp index 40bdcf65bca..7278b4189c2 100644 --- a/clang/lib/Checker/SymbolManager.cpp +++ b/clang/lib/Checker/SymbolManager.cpp @@ -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(SymbolRef sym) { 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() {} |

