diff --git a/clang/Driver/HTMLPrint.cpp b/clang/Driver/HTMLPrint.cpp index 93e544fc9662..a513bf975dda 100644 --- a/clang/Driver/HTMLPrint.cpp +++ b/clang/Driver/HTMLPrint.cpp @@ -50,39 +50,7 @@ HTMLPrinter::~HTMLPrinter() { html::EscapeText(R, FileID); html::AddLineNumbers(R, FileID); - - // Generate header - - { - std::ostringstream os; - - os << "\n\n" - << " \n" - << "\n" - << ""; - - R.InsertStrBefore(StartLoc, os.str()); - } - - // Generate footer - - { - std::ostringstream os; - - os << "\n"; - R.InsertStrAfter(EndLoc, os.str()); - } - + html::AddHeaderFooterInternalBuiltinCSS(R, FileID); // Emit the HTML. diff --git a/clang/include/clang/Rewrite/HTMLRewrite.h b/clang/include/clang/Rewrite/HTMLRewrite.h index 01116026125e..1b0aa28a9d80 100644 --- a/clang/include/clang/Rewrite/HTMLRewrite.h +++ b/clang/include/clang/Rewrite/HTMLRewrite.h @@ -26,6 +26,9 @@ namespace html { void EscapeText(Rewriter& R, unsigned FileID, bool EscapeSpaces = false); void AddLineNumbers(Rewriter& R, unsigned FileID); + + void AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID); + } // end html namespace } // end clang namespace diff --git a/clang/lib/Rewrite/HTMLRewrite.cpp b/clang/lib/Rewrite/HTMLRewrite.cpp index 9bd18109bbb4..9690ecb74acd 100644 --- a/clang/lib/Rewrite/HTMLRewrite.cpp +++ b/clang/lib/Rewrite/HTMLRewrite.cpp @@ -118,3 +118,47 @@ void html::AddLineNumbers(Rewriter& R, unsigned FileID) { R.InsertCStrAfter(SourceLocation::getFileLoc(FileID, FileEnd - FileBeg), ""); } + +void html::AddHeaderFooterInternalBuiltinCSS(Rewriter& R, unsigned FileID) { + + const llvm::MemoryBuffer *Buf = R.getSourceMgr().getBuffer(FileID); + const char* FileStart = Buf->getBufferStart(); + const char* FileEnd = Buf->getBufferEnd(); + + SourceLocation StartLoc = SourceLocation::getFileLoc(FileID, 0); + SourceLocation EndLoc = SourceLocation::getFileLoc(FileID, FileEnd-FileStart); + + // Generate header + + { + std::ostringstream os; + + os << "\n\n" + << " \n" + << "\n" + << ""; + + R.InsertStrBefore(StartLoc, os.str()); + } + + // Generate footer + + { + std::ostringstream os; + + os << "\n"; + R.InsertStrAfter(EndLoc, os.str()); + } +} + +