From dbafb6c3384301f6217b6ad851eceae3a363c243 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 29 Jun 2017 23:23:46 +0000 Subject: Teach ASTReader how to read only the Preprocessor state from an AST file, not the ASTContext state. We use this when running a preprocessor-only action on an AST file in order to avoid paying the runtime cost of loading the extra information. llvm-svn: 306760 --- clang/lib/Frontend/FrontendAction.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'clang/lib/Frontend/FrontendAction.cpp') diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index eed8631bdb8..704d5150985 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -536,8 +536,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, ASTDiags->setClient(Diags->getClient(), /*OwnsClient*/false); std::unique_ptr AST = ASTUnit::LoadFromASTFile( - InputFile, CI.getPCHContainerReader(), ASTDiags, CI.getFileSystemOpts(), - CI.getCodeGenOpts().DebugTypeExtRefs); + InputFile, CI.getPCHContainerReader(), ASTUnit::LoadPreprocessorOnly, + ASTDiags, CI.getFileSystemOpts(), CI.getCodeGenOpts().DebugTypeExtRefs); if (!AST) goto failure; @@ -576,6 +576,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, Module *ASTModule = AST->getPreprocessor().getHeaderSearchInfo().lookupModule( AST->getLangOpts().CurrentModule, /*AllowSearch*/ false); + assert(ASTModule && "module file does not define its own module"); Input = FrontendInputFile(ASTModule->PresumedModuleMapFile, Kind); } else { auto &SM = CI.getSourceManager(); @@ -598,8 +599,8 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, IntrusiveRefCntPtr Diags(&CI.getDiagnostics()); std::unique_ptr AST = ASTUnit::LoadFromASTFile( - InputFile, CI.getPCHContainerReader(), Diags, CI.getFileSystemOpts(), - CI.getCodeGenOpts().DebugTypeExtRefs); + InputFile, CI.getPCHContainerReader(), ASTUnit::LoadEverything, Diags, + CI.getFileSystemOpts(), CI.getCodeGenOpts().DebugTypeExtRefs); if (!AST) goto failure; -- cgit v1.2.3