aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h23
-rw-r--r--lib/StaticAnalyzer/Core/BugReporter.cpp12
2 files changed, 14 insertions, 21 deletions
diff --git a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h b/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 5506cb0173..d2f92b230c 100644
--- a/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/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<SourceRange, 4> 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<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(); }
-};
-
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index a06dc369d7..95303a034d 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/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<MemberExpr>(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);
}