@@ -1805,38 +1805,13 @@ ModuleDecl *ClangImporter::Implementation::finishLoadingClangModule(
1805
1805
// Bump the generation count.
1806
1806
bumpGeneration ();
1807
1807
1808
- auto &cacheEntry = ModuleWrappers[clangModule];
1809
- ModuleDecl *result;
1810
- ClangModuleUnit *wrapperUnit;
1811
- if ((wrapperUnit = cacheEntry.getPointer ())) {
1812
- result = wrapperUnit->getParentModule ();
1813
- if (!cacheEntry.getInt ()) {
1814
- // Force load overlays for all imported modules.
1815
- // FIXME: This forces the creation of wrapper modules for all imports as
1816
- // well, and may do unnecessary work.
1817
- cacheEntry.setInt (true );
1818
- (void ) namelookup::getAllImports (result);
1819
- }
1820
- } else {
1821
- // Build the representation of the Clang module in Swift.
1822
- // FIXME: The name of this module could end up as a key in the ASTContext,
1823
- // but that's not correct for submodules.
1824
- Identifier name = SwiftContext.getIdentifier ((*clangModule).Name );
1825
- result = ModuleDecl::create (name, SwiftContext);
1826
- result->setIsSystemModule (clangModule->IsSystem );
1827
- result->setIsNonSwiftModule ();
1828
- result->setHasResolvedImports ();
1829
-
1830
- wrapperUnit =
1831
- new (SwiftContext) ClangModuleUnit (*result, *this , clangModule);
1832
- result->addFile (*wrapperUnit);
1833
- SwiftContext.getClangModuleLoader ()
1834
- ->findOverlayFiles (importLoc, result, wrapperUnit);
1835
- cacheEntry.setPointerAndInt (wrapperUnit, true );
1836
-
1837
- // Force load overlays for all imported modules.
1838
- // FIXME: This forces the creation of wrapper modules for all imports as
1839
- // well, and may do unnecessary work.
1808
+ // Force load overlays for all imported modules.
1809
+ // FIXME: This forces the creation of wrapper modules for all imports as
1810
+ // well, and may do unnecessary work.
1811
+ ClangModuleUnit *wrapperUnit = getWrapperForModule (clangModule, importLoc);
1812
+ ModuleDecl *result = wrapperUnit->getParentModule ();
1813
+ if (!ModuleWrappers[clangModule].getInt ()) {
1814
+ ModuleWrappers[clangModule].setInt (true );
1840
1815
(void ) namelookup::getAllImports (result);
1841
1816
}
1842
1817
0 commit comments