diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-04-05 13:16:29 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-04-05 13:16:29 +0000 |
commit | 7b73b92870aa6271ac3d0a91eca83f6dde68c904 (patch) | |
tree | bfcfeea355292a37220aef7f35fe3cc57e4cce81 /lib/Checker/Environment.cpp | |
parent | b3e485c8355d46954078293f297a9d97e7ec09d7 (diff) |
Always assume block-level expressions in the caller are alive when analyzing
the callee.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100429 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/Environment.cpp')
-rw-r--r-- | lib/Checker/Environment.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/lib/Checker/Environment.cpp b/lib/Checker/Environment.cpp index e2568b6637..be1a677d91 100644 --- a/lib/Checker/Environment.cpp +++ b/lib/Checker/Environment.cpp @@ -96,6 +96,19 @@ public: }; } // end anonymous namespace +static bool isBlockExprInCallers(const Stmt *E, const LocationContext *LC) { + const LocationContext *ParentLC = LC->getParent(); + while (ParentLC) { + CFG &C = *ParentLC->getCFG(); + if (C.isBlkExpr(E)) + return true; + ParentLC = ParentLC->getParent(); + } + + return false; +} + + // RemoveDeadBindings: // - Remove subexpression bindings. // - Remove dead block expression bindings. @@ -122,13 +135,27 @@ EnvironmentManager::RemoveDeadBindings(Environment Env, const Stmt *S, I != E; ++I) { const Stmt *BlkExpr = I.getKey(); + const SVal &X = I.getData(); + + // Block-level expressions in callers are assumed always live. + if (isBlockExprInCallers(BlkExpr, SymReaper.getLocationContext())) { + NewEnv.ExprBindings = F.Add(NewEnv.ExprBindings, BlkExpr, X); + + if (isa<loc::MemRegionVal>(X)) { + const MemRegion* R = cast<loc::MemRegionVal>(X).getRegion(); + DRoots.push_back(R); + } + + // Mark all symbols in the block expr's value live. + MarkLiveCallback cb(SymReaper); + ST->scanReachableSymbols(X, cb); + continue; + } // Not a block-level expression? if (!C.isBlkExpr(BlkExpr)) continue; - const SVal &X = I.getData(); - if (SymReaper.isLive(S, BlkExpr)) { // Copy the binding to the new map. NewEnv.ExprBindings = F.Add(NewEnv.ExprBindings, BlkExpr, X); |