From: Ted Kremenek Date: Mon, 7 Jul 2008 18:31:05 +0000 (+0000) Subject: In a report-XXXXX.html, make the title include the name of the file with the bug... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f6f593fae2f0531b4bc06891941f7fbba5217618;p=clang 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53184 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/HTMLDiagnostics.cpp b/Driver/HTMLDiagnostics.cpp index 760ef25379..541e49b429 100644 --- a/Driver/HTMLDiagnostics.cpp +++ b/Driver/HTMLDiagnostics.cpp @@ -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); diff --git a/Driver/HTMLPrint.cpp b/Driver/HTMLPrint.cpp index e6e6ab7edf..b06d52df86 100644 --- a/Driver/HTMLPrint.cpp +++ b/Driver/HTMLPrint.cpp @@ -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, diff --git a/include/clang/Rewrite/HTMLRewrite.h b/include/clang/Rewrite/HTMLRewrite.h index 1ebbade161..dc4d3bf2ab 100644 --- a/include/clang/Rewrite/HTMLRewrite.h +++ b/include/clang/Rewrite/HTMLRewrite.h @@ -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. diff --git a/lib/Rewrite/HTMLRewrite.cpp b/lib/Rewrite/HTMLRewrite.cpp index f17aa537ef..0a32df1c61 100644 --- a/lib/Rewrite/HTMLRewrite.cpp +++ b/lib/Rewrite/HTMLRewrite.cpp @@ -257,7 +257,8 @@ void html::AddLineNumbers(Rewriter& R, unsigned FileID) { RB.InsertTextAfter(FileEnd - FileBeg, "", strlen("")); } -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, - "\n" // Use HTML 5 doctype - "\n\n" - "\n\n"); + "\n\n"; + // Generate header + R.InsertStrBefore(StartLoc, os.str()); // Generate footer R.InsertCStrAfter(EndLoc, "\n");