]> granicus.if.org Git - clang/commitdiff
Have BugReporter::EmitWarning use the PathDiagnosticClient if it is available.
authorTed Kremenek <kremenek@apple.com>
Mon, 14 Apr 2008 18:06:42 +0000 (18:06 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 14 Apr 2008 18:06:42 +0000 (18:06 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49668 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BugReporter.cpp

index 310fdc9accb272a7fec569a1fe34f152f32088eb..7572a556799468bfd67a2004595d1579178f8929 100644 (file)
@@ -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);
+  }
 }