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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49939 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/BugReporter.cpp b/lib/Analysis/BugReporter.cpp
index b736282..6b68d7f 100644
--- a/lib/Analysis/BugReporter.cpp
+++ b/lib/Analysis/BugReporter.cpp
@@ -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);
+  }
 }