[cfe-commits] r49114 - /cfe/trunk/Driver/HTMLDiagnostics.cpp

Ted Kremenek kremenek at apple.com
Wed Apr 2 13:44:16 PDT 2008


Author: kremenek
Date: Wed Apr  2 15:44:16 2008
New Revision: 49114

URL: http://llvm.org/viewvc/llvm-project?rev=49114&view=rev
Log:
Embed BUGLINE, BUGFILE, BUGPATHLENGTH in the emitted HTML file.

Modified:
    cfe/trunk/Driver/HTMLDiagnostics.cpp

Modified: cfe/trunk/Driver/HTMLDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/HTMLDiagnostics.cpp?rev=49114&r1=49113&r2=49114&view=diff

==============================================================================
--- cfe/trunk/Driver/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/Driver/HTMLDiagnostics.cpp Wed Apr  2 15:44:16 2008
@@ -114,27 +114,26 @@
   html::EscapeText(R, FileID);
   html::AddLineNumbers(R, FileID);
   
-  // Add the name of the file.
+  // Get the full directory name of the analyzed file.
+
+  const FileEntry* Entry = SMgr.getFileEntryForID(FileID);
+  std::string DirName(Entry->getDir()->getName());
   
-  {
-    std::ostringstream os;
+  if (DirName == ".")
+    DirName = llvm::sys::Path::GetCurrentDirectory().toString();
     
-    os << "<h1>";
+  // Add the name of the file as an <h1> tag.
 
-    const FileEntry* Entry = SMgr.getFileEntryForID(FileID);
-    const char* dname = Entry->getDir()->getName();
-    
-    if (strcmp(dname,".") == 0)
-      os << html::EscapeText(llvm::sys::Path::GetCurrentDirectory().toString());
-    else
-      os << html::EscapeText(dname);
+  {
+    std::ostringstream os;
     
-    os << "/" << html::EscapeText(Entry->getName()) << "</h1>\n";
+    os << "<h1>" << html::EscapeText(DirName)
+       << "/"    << html::EscapeText(Entry->getName()) << "</h1>\n";
 
     R.InsertStrBefore(SourceLocation::getFileLoc(FileID, 0), os.str());
   }
   
-  // Add the bug description.
+  // Embed meta-data tags.
   
   const std::string& BugDesc = D.getDescription();
   
@@ -142,7 +141,26 @@
     std::ostringstream os;
     os << "\n<!-- BUGDESC " << BugDesc << " -->\n";
     R.InsertStrBefore(SourceLocation::getFileLoc(FileID, 0), os.str());
-  }  
+  }
+  
+  {
+    std::ostringstream os;
+    os << "\n<!-- BUGFILE " << DirName << "/" << Entry->getName() << " -->\n";
+    R.InsertStrBefore(SourceLocation::getFileLoc(FileID, 0), os.str());
+  }
+  
+  {
+    std::ostringstream os;
+    os << "\n<!-- BUGLINE " << D.back()->getLocation().getLineNumber()
+       << " -->\n";
+    R.InsertStrBefore(SourceLocation::getFileLoc(FileID, 0), os.str());
+  }
+  
+  {
+    std::ostringstream os;
+    os << "\n<!-- BUGPATHLENGTH " << D.size() << " -->\n";
+    R.InsertStrBefore(SourceLocation::getFileLoc(FileID, 0), os.str());
+  }
 
   // Add CSS, header, and footer.
   





More information about the cfe-commits mailing list