From f42f3fb47d48429fb83198fbed07b8df9241e105 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 17 Apr 2008 22:31:54 +0000 Subject: class Preprocessor: Now owns the "predefines" char*; it deletes [] it in its dstor. clang.cpp: InitializePreprocessor now makes a copy of the contents of PredefinesBuffer and passes it to the preprocessor object. clang.cpp: DriverPreprocessorFactory now calls "InitializePreprocessor" instead of this being done in main(). html::HighlightMacros() now takes a PreprocessorFactory, allowing it to conjure up a new Preprocessor to highlight macros. class HTMLDiagnostics now takes a PreprocessorFactory* that it can use for html::HighlightMacros(). Updated clients of HTMLDiagnostics to use this new interface. llvm-svn: 49875 --- clang/Driver/HTMLPrint.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'clang/Driver/HTMLPrint.cpp') diff --git a/clang/Driver/HTMLPrint.cpp b/clang/Driver/HTMLPrint.cpp index ff04b0e6097..ba9cd9e4002 100644 --- a/clang/Driver/HTMLPrint.cpp +++ b/clang/Driver/HTMLPrint.cpp @@ -31,9 +31,11 @@ namespace { std::string OutFilename; Diagnostic &Diags; Preprocessor *PP; + PreprocessorFactory *PPF; public: - HTMLPrinter(const std::string &OutFile, Diagnostic &D, Preprocessor *pp) - : OutFilename(OutFile), Diags(D), PP(pp) {} + HTMLPrinter(const std::string &OutFile, Diagnostic &D, Preprocessor *pp, + PreprocessorFactory* ppf) + : OutFilename(OutFile), Diags(D), PP(pp), PPF(ppf) {} virtual ~HTMLPrinter(); void Initialize(ASTContext &context); @@ -41,8 +43,10 @@ namespace { } ASTConsumer* clang::CreateHTMLPrinter(const std::string &OutFile, - Diagnostic &D, Preprocessor *PP) { - return new HTMLPrinter(OutFile, D, PP); + Diagnostic &D, Preprocessor *PP, + PreprocessorFactory* PPF) { + + return new HTMLPrinter(OutFile, D, PP, PPF); } void HTMLPrinter::Initialize(ASTContext &context) { @@ -62,13 +66,10 @@ HTMLPrinter::~HTMLPrinter() { // We might not have a preprocessor if we come from a deserialized AST file, // for example. - if (PP) { - html::SyntaxHighlight(R, FileID, *PP); - html::HighlightMacros(R, FileID, *PP); - } + if (PP) html::SyntaxHighlight(R, FileID, *PP); + if (PPF) html::HighlightMacros(R, FileID, *PPF); html::EscapeText(R, FileID, false, true); - // Open the output. FILE *OutputFILE; if (OutFilename.empty() || OutFilename == "-") -- cgit v1.2.3