From 5fcca6881f263b1fde716f33edfe08799bbea177 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 14 Apr 2008 18:06:42 +0000 Subject: [PATCH] Have BugReporter::EmitWarning use the PathDiagnosticClient if it is available. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49668 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/BugReporter.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp index 310fdc9acc..7572a55679 100644 --- a/lib/Analysis/BugReporter.cpp +++ b/lib/Analysis/BugReporter.cpp @@ -369,17 +369,29 @@ void BugReporter::EmitWarning(BugReport& R) { if (N && IsCached(N)) return; - 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); + + if (!PD) { + + std::ostringstream os; + os << "[CHECKER] " << R.getDescription(); + + unsigned ErrorDiag = Diag.getCustomDiagID(Diagnostic::Warning, + os.str().c_str()); + + 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); + } } -- 2.40.0