]> granicus.if.org Git - clang/commitdiff
Enable -dump-deserialized-decls and -error-on-deserialized-decl for modules.
authorVassil Vassilev <v.g.vassilev@gmail.com>
Tue, 7 Feb 2017 21:49:41 +0000 (21:49 +0000)
committerVassil Vassilev <v.g.vassilev@gmail.com>
Tue, 7 Feb 2017 21:49:41 +0000 (21:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294359 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/FrontendAction.cpp

index 39fc1371a9ef527b1f68c43a39a7d594e4abd14f..261b3c4fa4aa573b501faf04cb2390623e9f5834 100644 (file)
@@ -352,8 +352,9 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
         goto failure;
       CI.setModuleManager(static_cast<ASTReader *>(FinalReader.get()));
       CI.getASTContext().setExternalSource(source);
-    } else if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
-      // Use PCH.
+    } else if (CI.getLangOpts().Modules ||
+               !CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+      // Use PCM or PCH.
       assert(hasPCHSupport() && "This action does not have PCH support!");
       ASTDeserializationListener *DeserialListener =
           Consumer->GetASTDeserializationListener();
@@ -370,13 +371,24 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
             DeserialListener, DeleteDeserialListener);
         DeleteDeserialListener = true;
       }
-      CI.createPCHExternalASTSource(
-          CI.getPreprocessorOpts().ImplicitPCHInclude,
-          CI.getPreprocessorOpts().DisablePCHValidation,
+      if (!CI.getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+        CI.createPCHExternalASTSource(
+            CI.getPreprocessorOpts().ImplicitPCHInclude,
+            CI.getPreprocessorOpts().DisablePCHValidation,
           CI.getPreprocessorOpts().AllowPCHWithCompilerErrors, DeserialListener,
-          DeleteDeserialListener);
-      if (!CI.getASTContext().getExternalSource())
-        goto failure;
+            DeleteDeserialListener);
+        if (!CI.getASTContext().getExternalSource())
+          goto failure;
+      }
+      // If modules are enabled, create the module manager before creating
+      // any builtins, so that all declarations know that they might be
+      // extended by an external source.
+      if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
+          !CI.getASTContext().getExternalSource()) {
+        CI.createModuleManager();
+        CI.getModuleManager()->setDeserializationListener(DeserialListener,
+                                                        DeleteDeserialListener);
+      }
     }
 
     CI.setASTConsumer(std::move(Consumer));
@@ -386,15 +398,9 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
 
   // Initialize built-in info as long as we aren't using an external AST
   // source.
-  if (!CI.hasASTContext() || !CI.getASTContext().getExternalSource()) {
+  if (CI.getLangOpts().Modules || !CI.hasASTContext() ||
+      !CI.getASTContext().getExternalSource()) {
     Preprocessor &PP = CI.getPreprocessor();
-
-    // If modules are enabled, create the module manager before creating
-    // any builtins, so that all declarations know that they might be
-    // extended by an external source.
-    if (CI.getLangOpts().Modules)
-      CI.createModuleManager();
-
     PP.getBuiltinInfo().initializeBuiltins(PP.getIdentifierTable(),
                                            PP.getLangOpts());
   } else {