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

Ted Kremenek kremenek at apple.com
Fri Apr 18 15:56:56 PDT 2008


Author: kremenek
Date: Fri Apr 18 17:56:53 2008
New Revision: 49939

URL: http://llvm.org/viewvc/llvm-project?rev=49939&view=rev
Log:
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.

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=49939&r1=49938&r2=49939&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/BugReporter.cpp (original)
+++ cfe/trunk/lib/Analysis/BugReporter.cpp Fri Apr 18 17:56:53 2008
@@ -410,21 +410,29 @@
   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);
+  }
 }





More information about the cfe-commits mailing list