Have BugReporter::EmitWarning use the PathDiagnosticClient if it is available.

llvm-svn: 49668
This commit is contained in:
Ted Kremenek 2008-04-14 18:06:42 +00:00
parent ea3aa5bf11
commit bae225d57a
1 changed files with 22 additions and 10 deletions

View File

@ -369,17 +369,29 @@ void BugReporter::EmitWarning(BugReport& R) {
if (N && IsCached(N))
return;
FullSourceLoc L = R.getLocation(Ctx.getSourceManager());
const SourceRange *Beg, *End;
R.getRanges(Beg, End);
if (!PD) {
std::ostringstream os;
os << "[CHECKER] " << R.getDescription();
unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning,
os.str().c_str());
// FIXME: Add support for multiple ranges.
FullSourceLoc L = R.getLocation(Ctx.getSourceManager());
const SourceRange *Beg, *End;
R.getRanges(Beg, End);
Diag.Report(L, ErrorDiag, NULL, 0, Beg, End - Beg);
}
else {
PathDiagnostic D(R.getName());
PathDiagnosticPiece* piece = new PathDiagnosticPiece(L, R.getDescription());
for ( ; Beg != End; ++Beg)
piece->addRange(*Beg);
D.push_back(piece);
PD->HandlePathDiagnostic(D);
}
}