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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49875 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/HTMLPrint.cpp b/Driver/HTMLPrint.cpp
index ff04b0e..ba9cd9e 100644
--- a/Driver/HTMLPrint.cpp
+++ b/Driver/HTMLPrint.cpp
@@ -31,9 +31,11 @@
     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 @@
 }
 
 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 @@
   // 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 == "-")