CompilerInvocation can have a previously set FileManager and SourceManager, but not a Preprocessor or ASTContext. This stops Clang drivers from being able to declare their own Preprocessor and ASTContext before calling using FrontendAction's BeginSourceFile to compile.

This patch allows a Preprocessor or ASTContext to previously have been set.

Any comments would be appreciated,
-Neil Henning.

Patch (also attached);
Index: lib/Frontend/FrontendAction.cpp
===================================================================
--- lib/Frontend/FrontendAction.cpp    (revision 190499)
+++ lib/Frontend/FrontendAction.cpp    (working copy)
@@ -265,7 +265,8 @@
   }

   // Set up the preprocessor.
-  CI.createPreprocessor();
+  if(!CI.hasPreprocessor())
+    CI.createPreprocessor();

   // Inform the diagnostic client we are processing a source file.
   CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
@@ -279,7 +280,8 @@
// Create the AST context and consumer unless this is a preprocessor only
   // action.
   if (!usesPreprocessorOnly()) {
-    CI.createASTContext();
+    if(!CI.hasASTContext())
+      CI.createASTContext();

     OwningPtr<ASTConsumer> Consumer(
CreateWrappedASTConsumer(CI, InputFile));

Index: lib/Frontend/FrontendAction.cpp
===================================================================
--- lib/Frontend/FrontendAction.cpp     (revision 190499)
+++ lib/Frontend/FrontendAction.cpp     (working copy)
@@ -265,7 +265,8 @@
   }
 
   // Set up the preprocessor.
-  CI.createPreprocessor();
+  if(!CI.hasPreprocessor())
+    CI.createPreprocessor();
 
   // Inform the diagnostic client we are processing a source file.
   CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
@@ -279,7 +280,8 @@
   // Create the AST context and consumer unless this is a preprocessor only
   // action.
   if (!usesPreprocessorOnly()) {
-    CI.createASTContext();
+    if(!CI.hasASTContext())
+      CI.createASTContext();
 
     OwningPtr<ASTConsumer> Consumer(
                                    CreateWrappedASTConsumer(CI, InputFile));
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to