Remove DiagBugReport by pulling it into its parent BugReport.

llvm-svn: 137899
This commit is contained in:
Anna Zaks 2011-08-17 23:21:23 +00:00
parent 1b43828958
commit 525cfe7d28
2 changed files with 14 additions and 21 deletions

View File

@ -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(); }
};
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//

View File

@ -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);
}