From ad0a203130dc5d1fb7231b88767174511424fa98 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 19 Mar 2008 06:14:37 +0000 Subject: [PATCH] Moved generation of html header/footer with builtin CSS to the rewriter library. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48537 91177308-0d34-0410-b5e6-96231b3b80d8 --- Driver/HTMLPrint.cpp | 34 +--------------------- include/clang/Rewrite/HTMLRewrite.h | 3 ++ lib/Rewrite/HTMLRewrite.cpp | 44 +++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 33 deletions(-) diff --git a/Driver/HTMLPrint.cpp b/Driver/HTMLPrint.cpp index 93e544fc96..a513bf975d 100644 --- a/Driver/HTMLPrint.cpp +++ b/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/include/clang/Rewrite/HTMLRewrite.h b/include/clang/Rewrite/HTMLRewrite.h index 0111602612..1b0aa28a9d 100644 --- a/include/clang/Rewrite/HTMLRewrite.h +++ b/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/lib/Rewrite/HTMLRewrite.cpp b/lib/Rewrite/HTMLRewrite.cpp index 9bd18109bb..9690ecb74a 100644 --- a/lib/Rewrite/HTMLRewrite.cpp +++ b/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()); + } +} + + -- 2.40.0