diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-16 06:11:58 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-16 06:11:58 +0000 |
commit | 3245a0a1c7a4fd74fca845b2edba275bb126d773 (patch) | |
tree | ab2aab4b4acc1ce3427c823ee94da56635472898 /Driver/HTMLPrint.cpp | |
parent | 8ac661c3c5ffaeedfb3268994ad864ade77b3ba0 (diff) |
Add a mode of hackily syntax highlighting comments. This has a number of
problems, including the fact that it doesn't work well with multi-line
comments due to Ted's crazy table. However, that could be fixed, and it
does work with single-line ones :).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49778 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/HTMLPrint.cpp')
-rw-r--r-- | Driver/HTMLPrint.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Driver/HTMLPrint.cpp b/Driver/HTMLPrint.cpp index 44cd6244ec..cb32afd817 100644 --- a/Driver/HTMLPrint.cpp +++ b/Driver/HTMLPrint.cpp @@ -30,9 +30,10 @@ namespace { Rewriter R; std::string OutFilename; Diagnostic &Diags; + Preprocessor *PP; public: - HTMLPrinter(const std::string &OutFile, Diagnostic &D) - : OutFilename(OutFile), Diags(D) {} + HTMLPrinter(const std::string &OutFile, Diagnostic &D, Preprocessor *pp) + : OutFilename(OutFile), Diags(D), PP(pp) {} virtual ~HTMLPrinter(); void Initialize(ASTContext &context); @@ -40,8 +41,8 @@ namespace { } ASTConsumer* clang::CreateHTMLPrinter(const std::string &OutFile, - Diagnostic &D) { - return new HTMLPrinter(OutFile, D); + Diagnostic &D, Preprocessor *PP) { + return new HTMLPrinter(OutFile, D, PP); } void HTMLPrinter::Initialize(ASTContext &context) { @@ -58,6 +59,12 @@ HTMLPrinter::~HTMLPrinter() { html::AddLineNumbers(R, FileID); html::AddHeaderFooterInternalBuiltinCSS(R, FileID); + // If we have a preprocessor, relex the file and syntax hilight. We might not + // have a preprocessor if we come from a deserialized AST file, for example. + if (PP) + html::SyntaxHighlight(R, FileID, *PP); + + // Open the output. FILE *OutputFILE; if (OutFilename.empty() || OutFilename == "-") |