aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFRefCount.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-02-07 22:38:00 +0000
committerTed Kremenek <kremenek@apple.com>2009-02-07 22:38:00 +0000
commitd305721d5804edc9942c752d085831ab3556a3ee (patch)
tree84f0b9205e51d7b500d71261eeb4cba67420e119 /lib/Analysis/CFRefCount.cpp
parentfaea26943e57910993602d99b92e26923ec4f228 (diff)
For retain/release leaks, have the BugReport description indicate the allocation site and initial bindings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64041 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFRefCount.cpp')
-rw-r--r--lib/Analysis/CFRefCount.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index bfacae846d..8b3f37f1e5 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/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);
}
}