aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BugReporter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-04-14 18:06:42 +0000
committerTed Kremenek <kremenek@apple.com>2008-04-14 18:06:42 +0000
commit5fcca6881f263b1fde716f33edfe08799bbea177 (patch)
tree6317fe850c59827a867f65bb0fedf597f986aace /lib/Analysis/BugReporter.cpp
parent5fd3e2673a1bd61d5f08f679555d15d23aba9314 (diff)
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
Diffstat (limited to 'lib/Analysis/BugReporter.cpp')
-rw-r--r--lib/Analysis/BugReporter.cpp32
1 files 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);
+ }
}