From 66d9706cabad17ffdd17d77ab726b87569ef02d5 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Sat, 7 Feb 2009 22:04:05 +0000 Subject: [PATCH] Split logic for 'getEndPath()' for CFRefReport and CFRefLeakReport. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64034 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/CFRefCount.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index a530905760..97bf4fc518 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -2091,6 +2091,7 @@ namespace { //===---------===// class VISIBILITY_HIDDEN CFRefReport : public RangedBugReport { + protected: SymbolRef Sym; public: CFRefReport(CFRefBug& D, ExplodedNode *n, SymbolRef sym) @@ -2132,7 +2133,10 @@ namespace { public: CFRefLeakReport(CFRefBug& D, ExplodedNode *n, SymbolRef sym) : CFRefReport(D, n, sym) {} - + + PathDiagnosticPiece* getEndPath(BugReporter& BR, + const ExplodedNode* N); + SourceLocation getLocation() const; }; } // end anonymous namespace @@ -2415,16 +2419,22 @@ PathDiagnosticPiece* CFRefReport::getEndPath(BugReporter& br, const ExplodedNode* EndN) { GRBugReporter& BR = cast(br); - // Tell the BugReporter to report cases when the tracked symbol is // assigned to different variables, etc. cast(BR).addNotableSymbol(Sym); - - if (!getBugType().isLeak()) - return RangedBugReport::getEndPath(BR, EndN); - - // We are a leak. Walk up the graph to get to the first node where the - // symbol appeared, and also get the first VarDecl that tracked object + return RangedBugReport::getEndPath(BR, EndN); +} + +PathDiagnosticPiece* +CFRefLeakReport::getEndPath(BugReporter& br, const ExplodedNode* EndN){ + + GRBugReporter& BR = cast(br); + // Tell the BugReporter to report cases when the tracked symbol is + // assigned to different variables, etc. + cast(BR).addNotableSymbol(Sym); + + // We are reporting a leak. Walk up the graph to get to the first node where + // the symbol appeared, and also get the first VarDecl that tracked object // is stored to. const ExplodedNode* AllocNode = 0; const MemRegion* FirstBinding = 0;