]> granicus.if.org Git - clang/commitdiff
Simplify, in anticipation of introducing explicit action instances.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 13 Nov 2009 09:57:06 +0000 (09:57 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 13 Nov 2009 09:57:06 +0000 (09:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87101 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-cc/clang-cc.cpp

index 8e969479e7e1e8010868236bd00ec55ce7581f22..7cdf2ac8b016f2d8a1af78e56eb83447b4c0e091 100644 (file)
@@ -460,27 +460,33 @@ static void ProcessInputFile(CompilerInstance &CI, const std::string &InFile,
     }
   }
 
-  const std::string &ImplicitPCHInclude =
-    CI.getPreprocessorOpts().getImplicitPCHInclude();
   if (Consumer) {
     // Create the ASTContext.
     CI.createASTContext();
 
+    // Create the external AST source when using PCH.
+    const std::string &ImplicitPCHInclude =
+      CI.getPreprocessorOpts().getImplicitPCHInclude();
     if (!ImplicitPCHInclude.empty()) {
       CI.createPCHExternalASTSource(ImplicitPCHInclude);
       if (!CI.getASTContext().getExternalSource())
         return;
-    } else {
-      // Initialize builtin info when not using PCH.
-      PP.getBuiltinInfo().InitializeBuiltins(PP.getIdentifierTable(),
-                                             PP.getLangOptions().NoBuiltin);
     }
+  }
 
-    // Initialize the main file entry. This needs to be delayed until after PCH
-    // has loaded.
-    if (InitializeSourceManager(PP, CI.getFrontendOpts(), InFile))
-      return;
+  // Initialize builtin info as long as we aren't using an external AST
+  // source.
+  if (!CI.hasASTContext() || !CI.getASTContext().getExternalSource())
+    PP.getBuiltinInfo().InitializeBuiltins(PP.getIdentifierTable(),
+                                           PP.getLangOptions().NoBuiltin);
+
+  // Initialize the main file entry. This needs to be delayed until after PCH
+  // has loaded.
+  if (InitializeSourceManager(PP, CI.getFrontendOpts(), InFile))
+    return;
 
+  if (Consumer) {
+    // FIXME: Move the truncation aspect of this into Sema.
     if (!FEOpts.CodeCompletionAt.FileName.empty())
       CI.createCodeCompletionConsumer();
 
@@ -490,15 +496,6 @@ static void ProcessInputFile(CompilerInstance &CI, const std::string &InFile,
     ParseAST(PP, Consumer.get(), CI.getASTContext(), FEOpts.ShowStats,
              CompleteTranslationUnit, CompletionConsumer);
   } else {
-    // Initialize builtin info.
-    PP.getBuiltinInfo().InitializeBuiltins(PP.getIdentifierTable(),
-                                           PP.getLangOptions().NoBuiltin);
-
-    // Initialize the main file entry. This needs to be delayed until after PCH
-    // has loaded.
-    if (InitializeSourceManager(PP, CI.getFrontendOpts(), InFile))
-      return;
-
     // Run the preprocessor actions.
     llvm::TimeRegion Timer(ClangFrontendTimer);
     switch (PA) {