diff options
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Frontend/FrontendAction.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Frontend/FrontendActions.cpp | 12 |
3 files changed, 20 insertions, 13 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index f12f6303f0d..267d318fa98 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -870,8 +870,9 @@ static void compileModuleImpl(CompilerInstance &ImportingInstance, SourceMgr.overrideFileContents(ModuleMapFile, ModuleMapBuffer); } - // Construct a module-generating action. - GenerateModuleAction CreateModuleAction(Module->IsSystem); + // Construct a module-generating action. Passing through Module->ModuleMap is + // safe because the FileManager is shared between the compiler instances. + GenerateModuleAction CreateModuleAction(Module->ModuleMap, Module->IsSystem); // Execute the action to actually build the module in-place. Use a separate // thread so that we get a stack large enough. diff --git a/clang/lib/Frontend/FrontendAction.cpp b/clang/lib/Frontend/FrontendAction.cpp index d2ece7e732d..dc4dd89371a 100644 --- a/clang/lib/Frontend/FrontendAction.cpp +++ b/clang/lib/Frontend/FrontendAction.cpp @@ -256,6 +256,10 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (!BeginSourceFileAction(CI, InputFile)) goto failure; + // Initialize the main file entry. + if (!CI.InitializeSourceManager(CurrentInput)) + goto failure; + return true; } @@ -302,6 +306,11 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, if (!BeginSourceFileAction(CI, InputFile)) goto failure; + // Initialize the main file entry. It is important that this occurs after + // BeginSourceFileAction, which may change CurrentInput during module builds. + if (!CI.InitializeSourceManager(CurrentInput)) + goto failure; + // Create the AST context and consumer unless this is a preprocessor only // action. if (!usesPreprocessorOnly()) { @@ -389,13 +398,6 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI, bool FrontendAction::Execute() { CompilerInstance &CI = getCompilerInstance(); - // Initialize the main file entry. This needs to be delayed until after PCH - // has loaded. - if (!isCurrentFileAST()) { - if (!CI.InitializeSourceManager(getCurrentInput())) - return false; - } - if (CI.hasFrontendTimer()) { llvm::TimeRegion Timer(CI.getFrontendTimer()); ExecuteAction(); diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 3f1d2c6106f..bbd2dff46c0 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -299,6 +299,11 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI, return false; } + if (!ModuleMapForUniquing) + ModuleMapForUniquing = ModuleMap; + Module->ModuleMap = ModuleMapForUniquing; + assert(Module->ModuleMap && "missing module map file"); + FileManager &FileMgr = CI.getFileManager(); // Collect the set of #includes we need to build the module. @@ -337,10 +342,9 @@ bool GenerateModuleAction::ComputeASTConsumerArguments(CompilerInstance &CI, // in the module cache. if (CI.getFrontendOpts().OutputFile.empty()) { HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo(); - SmallString<256> ModuleFileName(HS.getModuleCachePath()); - llvm::sys::path::append(ModuleFileName, - CI.getLangOpts().CurrentModule + ".pcm"); - CI.getFrontendOpts().OutputFile = ModuleFileName.str(); + CI.getFrontendOpts().OutputFile = + HS.getModuleFileName(CI.getLangOpts().CurrentModule, + ModuleMapForUniquing->getName()); } // We use createOutputFile here because this is exposed via libclang, and we |