[cfe-commits] r49668 - /cfe/trunk/lib/Analysis/BugReporter.cpp

Ted Kremenek kremenek at apple.com
Mon Apr 14 11:06:51 PDT 2008


Author: kremenek
Date: Mon Apr 14 13:06:42 2008
New Revision: 49668

URL: http://llvm.org/viewvc/llvm-project?rev=49668&view=rev
Log:
Have BugReporter::EmitWarning use the PathDiagnosticClient if it is available.

Modified:
    cfe/trunk/lib/Analysis/BugReporter.cpp

Modified: cfe/trunk/lib/Analysis/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BugReporter.cpp?rev=49668&r1=49667&r2=49668&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Mon Apr 14 13:06:42 2008
@@ -369,17 +369,29 @@
   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);
+  }
 }





More information about the cfe-commits mailing list