[cfe-commits] r53184 - in /cfe/trunk: Driver/HTMLDiagnostics.cpp Driver/HTMLPrint.cpp include/clang/Rewrite/HTMLRewrite.h lib/Rewrite/HTMLRewrite.cpp
Ted Kremenek
kremenek at apple.com
Mon Jul 7 11:31:05 PDT 2008
Author: kremenek
Date: Mon Jul 7 13:31:05 2008
New Revision: 53184
URL: http://llvm.org/viewvc/llvm-project?rev=53184&view=rev
Log:
In a report-XXXXX.html, make the title include the name of the file with the bug. Patch by Jean-Daniel Dupas!
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-July/002166.html
Modified:
cfe/trunk/Driver/HTMLDiagnostics.cpp
cfe/trunk/Driver/HTMLPrint.cpp
cfe/trunk/include/clang/Rewrite/HTMLRewrite.h
cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
Modified: cfe/trunk/Driver/HTMLDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/HTMLDiagnostics.cpp?rev=53184&r1=53183&r2=53184&view=diff
==============================================================================
--- cfe/trunk/Driver/HTMLDiagnostics.cpp (original)
+++ cfe/trunk/Driver/HTMLDiagnostics.cpp Mon Jul 7 13:31:05 2008
@@ -233,7 +233,7 @@
// 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);
Modified: cfe/trunk/Driver/HTMLPrint.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/HTMLPrint.cpp?rev=53184&r1=53183&r2=53184&view=diff
==============================================================================
--- cfe/trunk/Driver/HTMLPrint.cpp (original)
+++ cfe/trunk/Driver/HTMLPrint.cpp Mon Jul 7 13:31:05 2008
@@ -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 @@
// 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,
Modified: cfe/trunk/include/clang/Rewrite/HTMLRewrite.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/HTMLRewrite.h?rev=53184&r1=53183&r2=53184&view=diff
==============================================================================
--- cfe/trunk/include/clang/Rewrite/HTMLRewrite.h (original)
+++ cfe/trunk/include/clang/Rewrite/HTMLRewrite.h Mon Jul 7 13:31:05 2008
@@ -62,7 +62,8 @@
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.
Modified: cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/HTMLRewrite.cpp?rev=53184&r1=53183&r2=53184&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/HTMLRewrite.cpp (original)
+++ cfe/trunk/lib/Rewrite/HTMLRewrite.cpp Mon Jul 7 13:31:05 2008
@@ -257,7 +257,8 @@
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 @@
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 @@
" 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");
More information about the cfe-commits
mailing list