diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-07 00:12:43 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-07 00:12:43 +0000 |
commit | 6fd0921bdbb5de0cb023ba1445b9378f86ad23b4 (patch) | |
tree | a4ce0a9297d1fd6e7e9f2db8fb42b34487fc063c /clang/lib | |
parent | d7c1aaa6c50d77522eda5510b20c9b628764c2d1 (diff) | |
download | bcm5719-llvm-6fd0921bdbb5de0cb023ba1445b9378f86ad23b4.tar.gz bcm5719-llvm-6fd0921bdbb5de0cb023ba1445b9378f86ad23b4.zip |
retain/release checker: When hunting for the leak location, don't walk the
ExplodedGraph backwards. That may inadvertently result in reverse control-flow
edges in the PathDiagostic.
llvm-svn: 68477
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Analysis/CFRefCount.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp index 859e6cad1f9..d045ee46746 100644 --- a/clang/lib/Analysis/CFRefCount.cpp +++ b/clang/lib/Analysis/CFRefCount.cpp @@ -2900,12 +2900,40 @@ CFRefLeakReport::getEndPath(BugReporter& br, const ExplodedNode<GRState>* EndN){ GetAllocationSite(BR.getStateManager(), EndN, Sym); // Get the allocate site. - assert (AllocNode); + assert(AllocNode); Stmt* FirstStmt = cast<PostStmt>(AllocNode->getLocation()).getStmt(); SourceManager& SMgr = BR.getContext().getSourceManager(); unsigned AllocLine =SMgr.getInstantiationLineNumber(FirstStmt->getLocStart()); +#if 1 + const ExplodedNode<GRState>* LeakN = EndN; + PathDiagnosticLocation L; + + while (LeakN) { + ProgramPoint P = LeakN->getLocation(); + + if (const PostStmt *PS = dyn_cast<PostStmt>(&P)) { + L = PathDiagnosticLocation(PS->getStmt()->getLocStart(), SMgr); + break; + } + else if (const BlockEdge *BE = dyn_cast<BlockEdge>(&P)) { + if (const Stmt* Term = BE->getSrc()->getTerminator()) { + L = PathDiagnosticLocation(Term->getLocStart(), SMgr); + break; + } + } + + + LeakN = LeakN->succ_empty() ? 0 : *(LeakN->succ_begin()); + } + + if (!L.isValid()) { + CompoundStmt *CS = BR.getStateManager().getCodeDecl().getBody(); + L = PathDiagnosticLocation(CS->getRBracLoc(), SMgr); + } + +#else // Get the leak site. We want to find the last place where the symbol // was used in an expression. const ExplodedNode<GRState>* LeakN = EndN; @@ -2963,6 +2991,7 @@ CFRefLeakReport::getEndPath(BugReporter& br, const ExplodedNode<GRState>* EndN){ // FIXME: We need to do a better job at determing the leak site, e.g., at // the end of function bodies. PathDiagnosticLocation L(S, SMgr); +#endif std::string sbuf; llvm::raw_string_ostream os(sbuf); |