diff options
author | Anna Zaks <ganna@apple.com> | 2012-02-28 22:39:22 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-02-28 22:39:22 +0000 |
commit | e7e0168f625368032a5d2b4471d3406cd9d9f8ae (patch) | |
tree | 5907a9e7d7d388c535aac70d5e6b0daa8b25fb67 /lib | |
parent | c5685438df6105052b02c9e02f01c34489606308 (diff) | |
download | clang-e7e0168f625368032a5d2b4471d3406cd9d9f8ae.tar.gz clang-e7e0168f625368032a5d2b4471d3406cd9d9f8ae.tar.bz2 clang-e7e0168f625368032a5d2b4471d3406cd9d9f8ae.tar.xz |
[analyzer] Leaks should be uniqued by the allocation point in the
closest function context (RetainCountChecker).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151661 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 2350298b63..6b14013eea 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -2114,14 +2114,16 @@ namespace { }; } +// Find the first node in the current function context that referred to the +// tracked symbol and the memory location that value was stored to. Note, the +// value is only reported if the allocation occurred in the same function as +// the leak. static std::pair<const ExplodedNode*,const MemRegion*> GetAllocationSite(ProgramStateManager& StateMgr, const ExplodedNode *N, SymbolRef Sym) { - - // Find both first node that referred to the tracked symbol and the - // memory location that value was store to. const ExplodedNode *Last = N; const MemRegion* FirstBinding = 0; + const LocationContext *LeakContext = N->getLocationContext(); while (N) { ProgramStateRef St = N->getState(); @@ -2134,10 +2136,20 @@ GetAllocationSite(ProgramStateManager& StateMgr, const ExplodedNode *N, StateMgr.iterBindings(St, FB); if (FB) FirstBinding = FB.getRegion(); - Last = N; + // Allocation node, is the last node in the current context in which the + // symbol was tracked. + if (N->getLocationContext() == LeakContext) + Last = N; + N = N->pred_empty() ? NULL : *(N->pred_begin()); } + // If allocation happened in a function different from the leak node context, + // do not report the binding. + if (N->getLocationContext() != LeakContext) { + FirstBinding = 0; + } + return std::make_pair(Last, FirstBinding); } |