summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2013-04-10 21:42:02 +0000
committerAnna Zaks <ganna@apple.com>2013-04-10 21:42:02 +0000
commit7c19abeba62b2dac60538cbccca066c646ae5aa5 (patch)
treecf27ac586750d963b3ea87b3323422bfb3d4034d /clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
parenta75018aebaaf2e046d57327acc6734cba6ae7e5d (diff)
downloadbcm5719-llvm-7c19abeba62b2dac60538cbccca066c646ae5aa5.tar.gz
bcm5719-llvm-7c19abeba62b2dac60538cbccca066c646ae5aa5.zip
[analyzer] Cleanup leak warnings: do not print the names of variables from other functions.
llvm-svn: 179219
Diffstat (limited to 'clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index cc5c6040f33..03471a52362 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -1527,13 +1527,19 @@ MallocChecker::getAllocationSite(const ExplodedNode *N, SymbolRef Sym,
// Find the most recent expression bound to the symbol in the current
// context.
- if (!ReferenceRegion) {
- if (const MemRegion *MR = C.getLocationRegionIfPostStore(N)) {
- SVal Val = State->getSVal(MR);
- if (Val.getAsLocSymbol() == Sym)
- ReferenceRegion = MR;
+ if (!ReferenceRegion) {
+ if (const MemRegion *MR = C.getLocationRegionIfPostStore(N)) {
+ SVal Val = State->getSVal(MR);
+ if (Val.getAsLocSymbol() == Sym) {
+ const VarRegion* VR = MR->getAs<VarRegion>();
+ // Do not show local variables belonging to a function other than
+ // where the error is reported.
+ if (!VR ||
+ (VR->getStackFrame() == LeakContext->getCurrentStackFrame()))
+ ReferenceRegion = MR;
+ }
+ }
}
- }
// Allocation node, is the last node in the current context in which the
// symbol was tracked.
OpenPOWER on IntegriCloud