diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-02-07 22:38:00 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-02-07 22:38:00 +0000 |
commit | 2a4028b728cc8377b89e0f9b02972e4f94a8fb5b (patch) | |
tree | 99223088f4d9c5f6f436cc7a8e02d127fde386c2 /clang/lib/Analysis/CFRefCount.cpp | |
parent | d8f0786c3172d966ab1ec48ed38e7b09aeb076a4 (diff) | |
download | bcm5719-llvm-2a4028b728cc8377b89e0f9b02972e4f94a8fb5b.tar.gz bcm5719-llvm-2a4028b728cc8377b89e0f9b02972e4f94a8fb5b.zip |
For retain/release leaks, have the BugReport description indicate the allocation site and initial bindings.
llvm-svn: 64041
Diffstat (limited to 'clang/lib/Analysis/CFRefCount.cpp')
-rw-r--r-- | clang/lib/Analysis/CFRefCount.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp index bfacae846dc..8b3f37f1e53 100644 --- a/clang/lib/Analysis/CFRefCount.cpp +++ b/clang/lib/Analysis/CFRefCount.cpp @@ -2068,8 +2068,7 @@ namespace { : CFRefBug(tf, name), isReturn(isRet) {} public: - // FIXME: Remove once reports have better descriptions. - const char* getDescription() const { return "leak"; } + const char* getDescription() const { return ""; } bool isLeak() const { return true; } }; @@ -2133,7 +2132,7 @@ namespace { const MemRegion* AllocBinding; public: CFRefLeakReport(CFRefBug& D, ExplodedNode<GRState> *n, SymbolRef sym, - GRStateManager& StateMgr); + GRExprEngine& Eng); PathDiagnosticPiece* getEndPath(BugReporter& BR, const ExplodedNode<GRState>* N); @@ -2519,7 +2518,7 @@ CFRefLeakReport::getEndPath(BugReporter& br, const ExplodedNode<GRState>* EndN){ CFRefLeakReport::CFRefLeakReport(CFRefBug& D, ExplodedNode<GRState> *n, - SymbolRef sym, GRStateManager& StateMgr) + SymbolRef sym, GRExprEngine& Eng) : CFRefReport(D, n, sym) { @@ -2534,13 +2533,19 @@ CFRefLeakReport::CFRefLeakReport(CFRefBug& D, ExplodedNode<GRState> *n, const ExplodedNode<GRState>* AllocNode = 0; llvm::tie(AllocNode, AllocBinding) = // Set AllocBinding. - GetAllocationSite(StateMgr, getEndNode(), getSymbol()); + GetAllocationSite(Eng.getStateManager(), getEndNode(), getSymbol()); - ProgramPoint P = - GetAllocationSite(StateMgr, getEndNode(), getSymbol()).first->getLocation(); - // Get the SourceLocation for the allocation site. + ProgramPoint P = AllocNode->getLocation(); AllocSite = cast<PostStmt>(P).getStmt()->getLocStart(); + + // Fill in the description of the bug. + Description.clear(); + llvm::raw_string_ostream os(Description); + SourceManager& SMgr = Eng.getContext().getSourceManager(); + unsigned AllocLine = SMgr.getInstantiationLineNumber(AllocSite); + os << "Potential leak of object allocated on line " << AllocLine + << " and store into '" << AllocBinding->getString() << '\''; } //===----------------------------------------------------------------------===// @@ -2581,8 +2586,7 @@ void CFRefCount::EvalEndPath(GRExprEngine& Eng, CFRefBug *BT = static_cast<CFRefBug*>(I->second ? leakAtReturn : leakWithinFunction); assert(BT && "BugType not initialized."); - CFRefLeakReport* report = new CFRefLeakReport(*BT, N, I->first, - Eng.getStateManager()); + CFRefLeakReport* report = new CFRefLeakReport(*BT, N, I->first, Eng); BR->EmitReport(report); } } @@ -2631,8 +2635,7 @@ void CFRefCount::EvalDeadSymbols(ExplodedNodeSet<GRState>& Dst, CFRefBug *BT = static_cast<CFRefBug*>(I->second ? leakAtReturn : leakWithinFunction); assert(BT && "BugType not initialized."); - CFRefLeakReport* report = new CFRefLeakReport(*BT, N, I->first, - Eng.getStateManager()); + CFRefLeakReport* report = new CFRefLeakReport(*BT, N, I->first, Eng); BR->EmitReport(report); } } |