[cfe-commits] r137899 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h lib/StaticAnalyzer/Core/BugReporter.cpp
Anna Zaks
ganna at apple.com
Wed Aug 17 16:21:23 PDT 2011
Author: zaks
Date: Wed Aug 17 18:21:23 2011
New Revision: 137899
URL: http://llvm.org/viewvc/llvm-project?rev=137899&view=rev
Log:
Remove DiagBugReport by pulling it into its parent BugReport.
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=137899&r1=137898&r2=137899&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Wed Aug 17 18:21:23 2011
@@ -79,6 +79,7 @@
BugType& BT;
std::string ShortDescription;
std::string Description;
+ FullSourceLoc Location;
const ExplodedNode *ErrorNode;
SmallVector<SourceRange, 4> Ranges;
Creators creators;
@@ -97,6 +98,9 @@
: 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 @@
virtual BugReport::NodeResolver& getNodeResolver() = 0;
};
-class DiagBugReport : public BugReport {
- std::list<std::string> 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<std::string>::const_iterator str_iterator;
- str_iterator str_begin() const { return Strs.begin(); }
- str_iterator str_end() const { return Strs.end(); }
-};
-
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=137899&r1=137898&r2=137899&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Wed Aug 17 18:21:23 2011
@@ -1311,7 +1311,10 @@
}
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<MemberExpr>(S))
@@ -1323,6 +1326,11 @@
return S->getLocStart();
}
+ } else {
+ assert(Location.isValid());
+ return Location;
+ }
+
return FullSourceLoc();
}
@@ -1933,7 +1941,7 @@
// '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);
}
More information about the cfe-commits
mailing list