summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-11-03 02:54:20 +0000
committerAnna Zaks <ganna@apple.com>2012-11-03 02:54:20 +0000
commit8d1f6ed9a862a516e50f40b88bae09205316b10a (patch)
treec0bc60ddfec48a3aa69429a0796cdce7267e3955 /clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
parent44dc91b4df5d6e0264e9fd799ac8b473b25d0f32 (diff)
downloadbcm5719-llvm-8d1f6ed9a862a516e50f40b88bae09205316b10a.tar.gz
bcm5719-llvm-8d1f6ed9a862a516e50f40b88bae09205316b10a.zip
[analyzer] Run remove dead on end of path.
This will simplify checkers that need to register for leaks. Currently, they have to register for both: check dead and check end of path. I've modified the SymbolReaper to consider everything on the stack dead if the input StackLocationContext is 0. (This is a bit disruptive, so I'd like to flash out all the issues asap.) llvm-svn: 167352
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/SymbolManager.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/SymbolManager.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp b/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
index 9a119459241..0c5098b1e7d 100644
--- a/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SymbolManager.cpp
@@ -510,6 +510,9 @@ bool SymbolReaper::isLive(SymbolRef sym) {
bool
SymbolReaper::isLive(const Stmt *ExprVal, const LocationContext *ELCtx) const {
+ if (LCtx == 0)
+ return false;
+
if (LCtx != ELCtx) {
// If the reaper's location context is a parent of the expression's
// location context, then the expression value is now "out of scope".
@@ -517,6 +520,7 @@ SymbolReaper::isLive(const Stmt *ExprVal, const LocationContext *ELCtx) const {
return false;
return true;
}
+
// If no statement is provided, everything is this and parent contexts is live.
if (!Loc)
return true;
@@ -526,6 +530,12 @@ SymbolReaper::isLive(const Stmt *ExprVal, const LocationContext *ELCtx) const {
bool SymbolReaper::isLive(const VarRegion *VR, bool includeStoreBindings) const{
const StackFrameContext *VarContext = VR->getStackFrame();
+
+ if (!VarContext)
+ return true;
+
+ if (!LCtx)
+ return false;
const StackFrameContext *CurrentContext = LCtx->getCurrentStackFrame();
if (VarContext == CurrentContext) {
@@ -557,7 +567,7 @@ bool SymbolReaper::isLive(const VarRegion *VR, bool includeStoreBindings) const{
return false;
}
- return !VarContext || VarContext->isParentOf(CurrentContext);
+ return VarContext->isParentOf(CurrentContext);
}
SymbolVisitor::~SymbolVisitor() {}
OpenPOWER on IntegriCloud