[cfe-commits] r87101 - /cfe/trunk/tools/clang-cc/clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Fri Nov 13 01:57:06 PST 2009


Author: ddunbar
Date: Fri Nov 13 03:57:06 2009
New Revision: 87101

URL: http://llvm.org/viewvc/llvm-project?rev=87101&view=rev
Log:
Simplify, in anticipation of introducing explicit action instances.

Modified:
    cfe/trunk/tools/clang-cc/clang-cc.cpp

Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=87101&r1=87100&r2=87101&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Fri Nov 13 03:57:06 2009
@@ -460,27 +460,33 @@
     }
   }
 
-  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 @@
     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) {





More information about the cfe-commits mailing list