From 7336edd8b292eefcb6e3f951506cc0be1e4d1ddf Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Thu, 12 Nov 2009 02:53:06 +0000 Subject: [PATCH] clang-cc: Unify InitializeSourceManager calls. llvm-svn: 86934 --- clang/tools/clang-cc/clang-cc.cpp | 39 ++++++++----------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/clang/tools/clang-cc/clang-cc.cpp b/clang/tools/clang-cc/clang-cc.cpp index f6b38dfe1544..4f0fd5de45ca 100644 --- a/clang/tools/clang-cc/clang-cc.cpp +++ b/clang/tools/clang-cc/clang-cc.cpp @@ -717,7 +717,6 @@ static void ProcessInputFile(const CompilerInvocation &CompOpts, } } - llvm::OwningPtr ContextOwner; if (Consumer) ContextOwner.reset(new ASTContext(PP.getLangOptions(), @@ -770,27 +769,18 @@ static void ProcessInputFile(const CompilerInvocation &CompOpts, // No suitable PCH file could be found. Return an error. return; } - - // Finish preprocessor initialization. We do this now (rather - // than earlier) because this initialization creates new source - // location entries in the source manager, which must come after - // the source location entries for the PCH file. - if (InitializeSourceManager(PP, InFile)) - return; - } else if (!ImplicitPCHInclude.empty()) { - // If we have an implicit PCH, the source manager initialization was - // delayed, do it now. - // - // FIXME: Clean this up. - - // Finish preprocessor initialization. We do this now (rather - // than earlier) because this initialization creates new source - // location entries in the source manager, which must come after - // the source location entries for the PCH file. - if (InitializeSourceManager(PP, InFile)) - return; } + // Initialize the main file entry. This needs to be delayed until after PCH + // has loaded. + if (InitializeSourceManager(PP, InFile)) + return; + + // Initialize builtin info unless we are using PCH. + if (!Consumer || ImplicitPCHInclude.empty()) + PP.getBuiltinInfo().InitializeBuiltins(PP.getIdentifierTable(), + PP.getLangOptions().NoBuiltin); + // If we have an ASTConsumer, run the parser with it. if (Consumer) { CodeCompleteConsumer *(*CreateCodeCompleter)(Sema &, void *) = 0; @@ -1232,15 +1222,6 @@ int main(int argc, char **argv) { CompOpts.getDependencyOutputOpts(), *Target, SourceMgr, FileMgr)); - if (CompOpts.getPreprocessorOpts().getImplicitPCHInclude().empty()) { - if (InitializeSourceManager(*PP.get(), InFile)) - continue; - - // Initialize builtin info. - PP->getBuiltinInfo().InitializeBuiltins(PP->getIdentifierTable(), - PP->getLangOptions().NoBuiltin); - } - // Process the source file. Diags.getClient()->BeginSourceFile(CompOpts.getLangOpts()); ProcessInputFile(CompOpts, *PP, InFile, ProgAction, Context);