From 9d6448b1370ad67afcdcf90699f9ffddf2d582a9 Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Sat, 9 Aug 2014 00:57:23 +0000 Subject: Refactor the module map file used for uniquing a module name out of class Module. It's almost always going to be the same as getContainingModule() for top-level modules, so just add a map to cover the remaining cases. This lets us do less bookkeeping to keep the ModuleMap fields up to date. llvm-svn: 215268 --- clang/lib/Frontend/CompilerInstance.cpp | 5 +++-- clang/lib/Frontend/FrontendActions.cpp | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'clang/lib/Frontend') diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 4a75058e6af..22788aa5fb0 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -958,9 +958,10 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance, SourceMgr.overrideFileContents(ModuleMapFile, ModuleMapBuffer); } - // Construct a module-generating action. Passing through Module->ModuleMap is + // Construct a module-generating action. Passing through the module map is // safe because the FileManager is shared between the compiler instances. - GenerateModuleAction CreateModuleAction(Module->ModuleMap, Module->IsSystem); + GenerateModuleAction CreateModuleAction( + ModMap.getModuleMapFileForUniquing(Module), 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/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index 6dcaf382c3c..3c247071507 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -301,10 +301,12 @@ bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI, return false; } - if (!ModuleMapForUniquing) + if (ModuleMapForUniquing && ModuleMapForUniquing != ModuleMap) { + Module->IsInferred = true; + HS.getModuleMap().setInferredModuleAllowedBy(Module, ModuleMapForUniquing); + } else { ModuleMapForUniquing = ModuleMap; - Module->ModuleMap = ModuleMapForUniquing; - assert(Module->ModuleMap && "missing module map file"); + } FileManager &FileMgr = CI.getFileManager(); -- cgit v1.2.3