Another bug fix in emitting warnings without a path: construct a unit PathDiagnostic as we did

before.  This allows the HTMLDiagnostic object to retrieve the bug type, bug description, etc.

llvm-svn: 49939
This commit is contained in:
Ted Kremenek 2008-04-18 22:56:53 +00:00
parent 42dd577238
commit 423edc2384
1 changed files with 25 additions and 17 deletions

View File

@ -410,21 +410,29 @@ void BugReporter::EmitWarning(BugReport& R) {
else
R.getRanges(Beg, End);
// Compute the message.
std::ostringstream os;
os << "[CHECKER] ";
if (D.empty())
os << R.getDescription();
else
os << D.back()->getString();
unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning,
os.str().c_str());
if (PD)
Diag.Report(PD, L, ErrorDiag, NULL, 0, Beg, End - Beg);
else
Diag.Report(L, ErrorDiag, NULL, 0, Beg, End - Beg);
if (PD) {
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);
}
else {
std::ostringstream os;
os << "[CHECKER] ";
if (D.empty())
os << R.getDescription();
else
os << D.back()->getString();
unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning,
os.str().c_str());
Diag.Report(L, ErrorDiag, NULL, 0, Beg, End - Beg);
}
}