diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2018-07-12 17:38:48 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2018-07-12 17:38:48 +0000 |
commit | 76bc0933505a0195df31966fc4634ca96fe005a7 (patch) | |
tree | 9152f947e86f94cbfd36e06c4823a3f6738213bc /lib | |
parent | 1d0cf8aa79a6542390f7e2ecc74dff3f10970c2a (diff) |
Revert "[modules] Fix 37878; Autoload subdirectory modulemaps with specific LangOpts"
This reverts commit f40124d4f05ecf4f880cf4e8f26922d861f705f3 / r336660.
This change shouldn't be affecting `@import` behavior, but turns out it is:
https://ci.swift.org/view/swift-master-next/job/oss-swift-incremental-RA-osx-master-next/2800/consoleFull#-12570166563122a513-f36a-4c87-8ed7-cbc36a1ec144
Working on a reduced testcase for this, reverting in the meantime.
rdar://problem/42102222
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@336920 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Frontend/CompilerInstance.cpp | 15 | ||||
-rw-r--r-- | lib/Lex/HeaderSearch.cpp | 17 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 4 |
3 files changed, 13 insertions, 23 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 155ead4ac8..5727aae5f1 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -1653,10 +1653,8 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, // Retrieve the cached top-level module. Module = Known->second; } else if (ModuleName == getLangOpts().CurrentModule) { - // This is the module we're building. - Module = PP->getHeaderSearchInfo().lookupModule( - ModuleName, /*AllowSearch*/ true, - /*AllowExtraModuleMapSearch*/ !IsInclusionDirective); + // This is the module we're building. + Module = PP->getHeaderSearchInfo().lookupModule(ModuleName); /// FIXME: perhaps we should (a) look for a module using the module name // to file map (PrebuiltModuleFiles) and (b) diagnose if still not found? //if (Module == nullptr) { @@ -1668,8 +1666,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first; } else { // Search for a module with the given name. - Module = PP->getHeaderSearchInfo().lookupModule(ModuleName, true, - !IsInclusionDirective); + Module = PP->getHeaderSearchInfo().lookupModule(ModuleName); HeaderSearchOptions &HSOpts = PP->getHeaderSearchInfo().getHeaderSearchOpts(); @@ -1746,8 +1743,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, ImportLoc, ARRFlags)) { case ASTReader::Success: { if (Source != ModuleCache && !Module) { - Module = PP->getHeaderSearchInfo().lookupModule(ModuleName, true, - !IsInclusionDirective); + Module = PP->getHeaderSearchInfo().lookupModule(ModuleName); if (!Module || !Module->getASTFile() || FileMgr->getFile(ModuleFileName) != Module->getASTFile()) { // Error out if Module does not refer to the file in the prebuilt @@ -1878,8 +1874,7 @@ CompilerInstance::loadModule(SourceLocation ImportLoc, PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID()); PrivPath.push_back(std::make_pair(&II, Path[0].second)); - if (PP->getHeaderSearchInfo().lookupModule(PrivateModule, true, - !IsInclusionDirective)) + if (PP->getHeaderSearchInfo().lookupModule(PrivateModule)) Sub = loadModule(ImportLoc, PrivPath, Visibility, IsInclusionDirective); if (Sub) { diff --git a/lib/Lex/HeaderSearch.cpp b/lib/Lex/HeaderSearch.cpp index b1a2ef1212..312bd2d061 100644 --- a/lib/Lex/HeaderSearch.cpp +++ b/lib/Lex/HeaderSearch.cpp @@ -198,15 +198,14 @@ std::string HeaderSearch::getCachedModuleFileName(StringRef ModuleName, return Result.str().str(); } -Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch, - bool AllowExtraModuleMapSearch) { +Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch) { // Look in the module map to determine if there is a module by this name. Module *Module = ModMap.findModule(ModuleName); if (Module || !AllowSearch || !HSOpts->ImplicitModuleMaps) return Module; StringRef SearchName = ModuleName; - Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch); + Module = lookupModule(ModuleName, SearchName); // The facility for "private modules" -- adjacent, optional module maps named // module.private.modulemap that are supposed to define private submodules -- @@ -217,14 +216,13 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, bool AllowSearch, // could force building unwanted dependencies into the parent module and cause // dependency cycles. if (!Module && SearchName.consume_back("_Private")) - Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch); + Module = lookupModule(ModuleName, SearchName); if (!Module && SearchName.consume_back("Private")) - Module = lookupModule(ModuleName, SearchName, AllowExtraModuleMapSearch); + Module = lookupModule(ModuleName, SearchName); return Module; } -Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName, - bool AllowExtraModuleMapSearch) { +Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName) { Module *Module = nullptr; // Look through the various header search paths to load any available module @@ -283,9 +281,8 @@ Module *HeaderSearch::lookupModule(StringRef ModuleName, StringRef SearchName, continue; // Load all module maps in the immediate subdirectories of this search - // directory if ModuleName was from @import. - if (AllowExtraModuleMapSearch) - loadSubdirectoryModuleMaps(SearchDirs[Idx]); + // directory. + loadSubdirectoryModuleMaps(SearchDirs[Idx]); // Look again for the module. Module = ModMap.findModule(ModuleName); diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 78ca5f7406..3277243667 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2626,9 +2626,7 @@ ASTReader::ReadControlBlock(ModuleFile &F, "MODULE_DIRECTORY found before MODULE_NAME"); // If we've already loaded a module map file covering this module, we may // have a better path for it (relative to the current build). - Module *M = PP.getHeaderSearchInfo().lookupModule( - F.ModuleName, /*AllowSearch*/ true, - /*AllowExtraModuleMapSearch*/ true); + Module *M = PP.getHeaderSearchInfo().lookupModule(F.ModuleName); if (M && M->Directory) { // If we're implicitly loading a module, the base directory can't // change between the build and use. |