diff options
| author | Anna Zaks <ganna@apple.com> | 2011-08-19 23:21:56 +0000 |
|---|---|---|
| committer | Anna Zaks <ganna@apple.com> | 2011-08-19 23:21:56 +0000 |
| commit | 071a89c39f42beaecf78ffec1bc5c60a14a18816 (patch) | |
| tree | edb36ede7949fb19f270b414537a841422da2577 /clang/lib/StaticAnalyzer | |
| parent | 67edb5ef36a4e64d5ea787a7a11e36a4b615dcc2 (diff) | |
| download | bcm5719-llvm-071a89c39f42beaecf78ffec1bc5c60a14a18816.tar.gz bcm5719-llvm-071a89c39f42beaecf78ffec1bc5c60a14a18816.zip | |
Static Analyzer Diagnostics: Switch CFRefCount to using the new visitor API. BugReport no longer needs to inherit from BugReporterVisitor.
llvm-svn: 138142
Diffstat (limited to 'clang/lib/StaticAnalyzer')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 11 | ||||
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/CFRefCount.cpp | 45 |
2 files changed, 34 insertions, 22 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index fb0331c2745..df3ebb860d9 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1224,9 +1224,7 @@ void BugReport::addVisitor(BugReporterVisitor* visitor) { BugReport::~BugReport() { for (visitor_iterator I = visitor_begin(), E = visitor_end(); I != E; ++I) { - if ((*I)->isOwnedByReporterContext()) { - delete *I; - } + delete *I; } } @@ -1340,13 +1338,6 @@ SourceLocation BugReport::getLocation() const { return FullSourceLoc(); } -PathDiagnosticPiece *BugReport::VisitNode(const ExplodedNode *N, - const ExplodedNode *PrevN, - BugReporterContext &BRC, - BugReport &BR) { - return NULL; -} - //===----------------------------------------------------------------------===// // Methods for BugReporter and subclasses. //===----------------------------------------------------------------------===// diff --git a/clang/lib/StaticAnalyzer/Core/CFRefCount.cpp b/clang/lib/StaticAnalyzer/Core/CFRefCount.cpp index 78325f366ce..9e6d829a259 100644 --- a/clang/lib/StaticAnalyzer/Core/CFRefCount.cpp +++ b/clang/lib/StaticAnalyzer/Core/CFRefCount.cpp @@ -1959,6 +1959,26 @@ namespace { // Bug Reports. // //===---------===// + class CFRefReportVisitor : public BugReporterVisitor { + SymbolRef Sym; + const CFRefCount &TF; + public: + + CFRefReportVisitor(SymbolRef sym, const CFRefCount &tf) + : Sym(sym), TF(tf) {} + + void Profile(llvm::FoldingSetNodeID &ID) const { + static int x = 0; + ID.AddPointer(&x); + ID.AddPointer(Sym); + } + + PathDiagnosticPiece *VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, + BugReporterContext &BRC, + BugReport &BR); + }; + class CFRefReport : public BugReport { protected: SymbolRef Sym; @@ -1966,11 +1986,15 @@ namespace { public: CFRefReport(CFRefBug& D, const CFRefCount &tf, ExplodedNode *n, SymbolRef sym) - : BugReport(D, D.getDescription(), n), Sym(sym), TF(tf) {} + : BugReport(D, D.getDescription(), n), Sym(sym), TF(tf) { + addVisitor(new CFRefReportVisitor(sym, tf)); + } CFRefReport(CFRefBug& D, const CFRefCount &tf, ExplodedNode *n, SymbolRef sym, StringRef endText) - : BugReport(D, D.getDescription(), endText, n), Sym(sym), TF(tf) {} + : BugReport(D, D.getDescription(), endText, n), Sym(sym), TF(tf) { + addVisitor(new CFRefReportVisitor(sym, tf)); + } virtual ~CFRefReport() {} @@ -1991,11 +2015,6 @@ namespace { const ExplodedNode *N); std::pair<const char**,const char**> getExtraDescriptiveText(); - - PathDiagnosticPiece *VisitNode(const ExplodedNode *N, - const ExplodedNode *PrevN, - BugReporterContext &BRC, - BugReport &BR); }; class CFRefLeakReport : public CFRefReport { @@ -2060,10 +2079,10 @@ static inline bool contains(const SmallVectorImpl<ArgEffect>& V, return false; } -PathDiagnosticPiece *CFRefReport::VisitNode(const ExplodedNode *N, - const ExplodedNode *PrevN, - BugReporterContext &BRC, - BugReport &BR) { +PathDiagnosticPiece *CFRefReportVisitor::VisitNode(const ExplodedNode *N, + const ExplodedNode *PrevN, + BugReporterContext &BRC, + BugReport &BR) { if (!isa<PostStmt>(N->getLocation())) return NULL; @@ -2113,7 +2132,7 @@ PathDiagnosticPiece *CFRefReport::VisitNode(const ExplodedNode *N, if (CurrV.isOwned()) { os << "+1 retain count"; - if (static_cast<CFRefBug&>(getBugType()).getTF().isGCEnabled()) { + if (TF.isGCEnabled()) { assert(CurrV.getObjKind() == RetEffect::CF); os << ". " "Core Foundation objects are not automatically garbage collected."; @@ -2507,6 +2526,8 @@ CFRefLeakReport::CFRefLeakReport(CFRefBug& D, const CFRefCount &tf, // FIXME: AllocBinding doesn't get populated for RegionStore yet. if (AllocBinding) os << " and stored into '" << AllocBinding->getString() << '\''; + + addVisitor(new CFRefReportVisitor(sym, tf)); } //===----------------------------------------------------------------------===// |

