]> granicus.if.org Git - clang/commitdiff
Frontend: Move some initialization from CompilerInstance to FrontendAction, to parall...
authorDaniel Dunbar <daniel@zuster.org>
Mon, 7 Jun 2010 23:23:50 +0000 (23:23 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 7 Jun 2010 23:23:50 +0000 (23:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105579 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/ASTUnit.cpp
lib/Frontend/CompilerInstance.cpp
lib/Frontend/FrontendAction.cpp

index 2b4eecd2b22438c41f346e72ddb89030884522fe..28000bbb67cee8ca78be261a07f31b0c27c5d1d3 100644 (file)
@@ -354,9 +354,6 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocation(CompilerInvocation *CI,
   // Create the source manager.
   Clang.setSourceManager(&AST->getSourceManager());
 
-  // Create the preprocessor.
-  Clang.createPreprocessor();
-
   Act.reset(new TopLevelDeclTrackerAction(*AST));
   if (!Act->BeginSourceFile(Clang, Clang.getFrontendOpts().Inputs[0].second,
                             Clang.getFrontendOpts().Inputs[0].first))
index 0af355c43190f65b9693c8050e8e8f42fdb6d6b0..0ff70edf8b4ac9cce89ab96b54753962d7ea9bd3 100644 (file)
@@ -489,25 +489,9 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
   for (unsigned i = 0, e = getFrontendOpts().Inputs.size(); i != e; ++i) {
     const std::string &InFile = getFrontendOpts().Inputs[i].second;
 
-    // If we aren't using an AST file, setup the file and source managers and
-    // the preprocessor.
-    bool IsAST = getFrontendOpts().Inputs[i].first == IK_AST;
-    if (!IsAST) {
-      if (!i) {
-        // Create a file manager object to provide access to and cache the
-        // filesystem.
-        createFileManager();
-
-        // Create the source manager.
-        createSourceManager();
-      } else {
-        // Reset the ID tables if we are reusing the SourceManager.
-        getSourceManager().clearIDTables();
-      }
-
-      // Create the preprocessor.
-      createPreprocessor();
-    }
+    // Reset the ID tables if we are reusing the SourceManager.
+    if (hasSourceManager())
+      getSourceManager().clearIDTables();
 
     if (Act.BeginSourceFile(*this, InFile, getFrontendOpts().Inputs[i].first)) {
       Act.Execute();
@@ -530,7 +514,7 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
       OS << " generated.\n";
   }
 
-  if (getFrontendOpts().ShowStats) {
+  if (getFrontendOpts().ShowStats && hasFileManager()) {
     getFileManager().PrintStats();
     OS << "\n";
   }
index 66bec7c4aef1cf852b2a57f104ce2db2506ae9d6..633b82c2e0f9aa25e44f4f440afbb6720765d6b9 100644 (file)
@@ -40,8 +40,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
 
   // AST files follow a very different path, since they share objects via the
   // AST unit.
-  bool IsAST = InputKind == IK_AST;
-  if (IsAST) {
+  if (InputKind == IK_AST) {
     assert(!usesPreprocessorOnly() &&
            "Attempt to pass AST file to preprocessor only action!");
     assert(hasASTSupport() && "This action does not have AST support!");
@@ -73,6 +72,13 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
     return true;
   }
 
+  // Setup the file and source managers, if needed, and the preprocessor.
+  if (!CI.hasFileManager())
+    CI.createFileManager();
+  if (!CI.hasSourceManager())
+    CI.createSourceManager();
+  CI.createPreprocessor();
+
   // Inform the diagnostic client we are processing a source file.
   CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
                                            &CI.getPreprocessor());