]> granicus.if.org Git - clang/commitdiff
In a report-XXXXX.html, make the title include the name of the file with the bug...
authorTed Kremenek <kremenek@apple.com>
Mon, 7 Jul 2008 18:31:05 +0000 (18:31 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 7 Jul 2008 18:31:05 +0000 (18:31 +0000)
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-July/002166.html

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53184 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/HTMLDiagnostics.cpp
Driver/HTMLPrint.cpp
include/clang/Rewrite/HTMLRewrite.h
lib/Rewrite/HTMLRewrite.cpp

index 760ef25379dc417f9e99e2007e08cfea878251bb..541e49b4299ec187fac06908212eb816b054bc8a 100644 (file)
@@ -233,7 +233,7 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
 
   // Add CSS, header, and footer.
   
-  html::AddHeaderFooterInternalBuiltinCSS(R, FileID);
+  html::AddHeaderFooterInternalBuiltinCSS(R, FileID, Entry->getName());
   
   // Get the rewrite buffer.
   const RewriteBuffer *Buf = R.getRewriteBufferFor(FileID);
index e6e6ab7edf764bf6f1e6ea845803c6820603f326..b06d52df86ea259d2cdfcc74951d66aa9814fb41 100644 (file)
@@ -17,6 +17,7 @@
 #include "clang/Rewrite/HTMLRewrite.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/FileManager.h"
 #include "clang/AST/ASTContext.h"
 
 using namespace clang;
@@ -59,8 +60,10 @@ HTMLPrinter::~HTMLPrinter() {
 
   // Format the file.
   unsigned FileID = R.getSourceMgr().getMainFileID();
+  const FileEntry* Entry = R.getSourceMgr().getFileEntryForID(FileID);
+  
   html::AddLineNumbers(R, FileID);
-  html::AddHeaderFooterInternalBuiltinCSS(R, FileID);
+  html::AddHeaderFooterInternalBuiltinCSS(R, FileID, Entry->getName());
 
   // If we have a preprocessor, relex the file and syntax highlight.
   // We might not have a preprocessor if we come from a deserialized AST file,
index 1ebbade1613b79650dd9b58815b8ae5d126b67a3..dc4d3bf2ab744f8b0cdf43912bc944396e9cb816 100644 (file)
@@ -62,7 +62,8 @@ namespace html {
 
   void AddLineNumbers(Rewriter& R, unsigned FileID);  
   
-  void AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID);
+  void AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID, 
+                                         const char *title = NULL);
 
   /// SyntaxHighlight - Relex the specified FileID and annotate the HTML with
   /// information about keywords, comments, etc.
index f17aa537ef290bf5c32564967fd9c4dc281772d1..0a32df1c61593ef2029aed43677791a0f256e1eb 100644 (file)
@@ -257,7 +257,8 @@ void html::AddLineNumbers(Rewriter& R, unsigned FileID) {
   RB.InsertTextAfter(FileEnd - FileBeg, "</table>", strlen("</table>"));
 }
 
-void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID) {
+void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID, 
+                                             const char *title) {
 
   const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID);
   const char* FileStart = Buf->getBufferStart();
@@ -266,11 +267,14 @@ void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID) {
   SourceLocation StartLoc = SourceLocation::getFileLoc(FileID, 0);
   SourceLocation EndLoc = SourceLocation::getFileLoc(FileID, FileEnd-FileStart);
 
-  // Generate header
-  R.InsertCStrBefore(StartLoc,
-      "<!doctype html>\n" // Use HTML 5 doctype
-      "<html>\n<head>\n"
-      "<style type=\"text/css\">\n"
+  std::ostringstream os;
+  os << "<!doctype html>\n" // Use HTML 5 doctype
+        "<html>\n<head>\n";
+  
+  if (title)
+    os << "<title>" << html::EscapeText(title) << "</title>\n";
+  
+  os << "<style type=\"text/css\">\n"
       " body { color:#000000; background-color:#ffffff }\n"
       " body { font-family:Helvetica, sans-serif; font-size:10pt }\n"
       " h1 { font-size:14pt }\n"
@@ -314,8 +318,10 @@ void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID) {
       " td.rowname {\n"
       "   text-align:right; font-weight:bold; color:#444444;\n"
       "   padding-right:2ex; }\n"
-      "</style>\n</head>\n<body>");
+      "</style>\n</head>\n<body>";
 
+  // Generate header
+  R.InsertStrBefore(StartLoc, os.str());
   // Generate footer
   
   R.InsertCStrAfter(EndLoc, "</body></html>\n");