@@ -2261,10 +2261,6 @@ bool ClangImporter::canImportModule(ImportPath::Module modulePath,
2261
2261
clang::Module *
2262
2262
ClangImporter::Implementation::lookupModule (StringRef moduleName) {
2263
2263
auto &clangHeaderSearch = getClangPreprocessor ().getHeaderSearchInfo ();
2264
- if (getClangASTContext ().getLangOpts ().ImplicitModules )
2265
- return clangHeaderSearch.lookupModule (
2266
- moduleName, /* ImportLoc=*/ clang::SourceLocation (),
2267
- /* AllowSearch=*/ true , /* AllowExtraModuleMapSearch=*/ true );
2268
2264
2269
2265
// Explicit module. Try load from modulemap.
2270
2266
auto &PP = Instance->getPreprocessor ();
@@ -2282,8 +2278,13 @@ ClangImporter::Implementation::lookupModule(StringRef moduleName) {
2282
2278
// If not, try load it.
2283
2279
auto &PrebuiltModules = Instance->getHeaderSearchOpts ().PrebuiltModuleFiles ;
2284
2280
auto moduleFile = PrebuiltModules.find (moduleName);
2285
- if (moduleFile == PrebuiltModules.end ())
2281
+ if (moduleFile == PrebuiltModules.end ()) {
2282
+ if (getClangASTContext ().getLangOpts ().ImplicitModules )
2283
+ return clangHeaderSearch.lookupModule (
2284
+ moduleName, /* ImportLoc=*/ clang::SourceLocation (),
2285
+ /* AllowSearch=*/ true , /* AllowExtraModuleMapSearch=*/ true );
2286
2286
return nullptr ;
2287
+ }
2287
2288
2288
2289
clang::serialization::ModuleFile *Loaded = nullptr ;
2289
2290
if (!Instance->loadModuleFile (moduleFile->second , Loaded))
@@ -2293,20 +2294,8 @@ ClangImporter::Implementation::lookupModule(StringRef moduleName) {
2293
2294
2294
2295
ModuleDecl *ClangImporter::Implementation::loadModuleClang (
2295
2296
SourceLoc importLoc, ImportPath::Module path) {
2296
- auto &clangHeaderSearch = getClangPreprocessor ().getHeaderSearchInfo ();
2297
2297
auto realModuleName = SwiftContext.getRealModuleName (path.front ().Item ).str ();
2298
2298
2299
- // For explicit module build, module should always exist but module map might
2300
- // not be exist. Go straight to module loader.
2301
- if (Instance->getInvocation ().getLangOpts ().ImplicitModules ) {
2302
- // Look up the top-level module first, to see if it exists at all.
2303
- clang::Module *clangModule = clangHeaderSearch.lookupModule (
2304
- realModuleName, /* ImportLoc=*/ clang::SourceLocation (),
2305
- /* AllowSearch=*/ true , /* AllowExtraModuleMapSearch=*/ true );
2306
- if (!clangModule)
2307
- return nullptr ;
2308
- }
2309
-
2310
2299
// Convert the Swift import path over to a Clang import path.
2311
2300
SmallVector<std::pair<clang::IdentifierInfo *, clang::SourceLocation>, 4 >
2312
2301
clangPath;
0 commit comments