From 525cfe7d28c0bd2751ffac3b3b8b14bf5c298c04 Mon Sep 17 00:00:00 2001 From: Anna Zaks Date: Wed, 17 Aug 2011 23:21:23 +0000 Subject: [PATCH] Remove DiagBugReport by pulling it into its parent BugReport. llvm-svn: 137899 --- .../Core/BugReporter/BugReporter.h | 23 ++++--------------- clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 12 ++++++++-- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h index 5506cb017333..d2f92b230cc5 100644 --- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h +++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h @@ -79,6 +79,7 @@ protected: BugType& BT; std::string ShortDescription; std::string Description; + FullSourceLoc Location; const ExplodedNode *ErrorNode; SmallVector Ranges; Creators creators; @@ -97,6 +98,9 @@ public: : BT(bt), ShortDescription(shortDesc), Description(desc), ErrorNode(errornode) {} + BugReport(BugType& bt, StringRef desc, FullSourceLoc l) + : BT(bt), Description(desc), Location(l), ErrorNode(0) {} + virtual ~BugReport(); bool isOwnedByReporterContext() { return false; } @@ -420,25 +424,6 @@ public: virtual BugReport::NodeResolver& getNodeResolver() = 0; }; -class DiagBugReport : public BugReport { - std::list Strs; - FullSourceLoc L; -public: - DiagBugReport(BugType& D, StringRef desc, FullSourceLoc l) : - BugReport(D, desc, 0), L(l) {} - - virtual ~DiagBugReport() {} - - // FIXME: Move out-of-line (virtual function). - SourceLocation getLocation() const { return L; } - - void addString(StringRef s) { Strs.push_back(s); } - - typedef std::list::const_iterator str_iterator; - str_iterator str_begin() const { return Strs.begin(); } - str_iterator str_end() const { return Strs.end(); } -}; - //===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index a06dc369d7b3..95303a034d93 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1311,7 +1311,10 @@ BugReport::getRanges() { } SourceLocation BugReport::getLocation() const { - if (ErrorNode) + if (ErrorNode) { + (Location.isInvalid() && + "Either Location or ErrorNode should be specified but not both."); + if (const Stmt *S = GetCurrentOrPreviousStmt(ErrorNode)) { // For member expressions, return the location of the '.' or '->'. if (const MemberExpr *ME = dyn_cast(S)) @@ -1323,6 +1326,11 @@ SourceLocation BugReport::getLocation() const { return S->getLocStart(); } + } else { + assert(Location.isValid()); + return Location; + } + return FullSourceLoc(); } @@ -1933,7 +1941,7 @@ void BugReporter::EmitBasicReport(StringRef name, // 'BT' is owned by BugReporter. BugType *BT = getBugTypeForName(name, category); FullSourceLoc L = getContext().getFullLoc(Loc); - BugReport *R = new DiagBugReport(*BT, str, L); + BugReport *R = new BugReport(*BT, str, L); for ( ; NumRanges > 0 ; --NumRanges, ++RBeg) R->addRange(*RBeg); EmitReport(R); }