@@ -3269,19 +3269,6 @@ static void getImportDecls(ClangModuleUnit *ClangUnit, const clang::Module *M,
3269
3269
auto *ID = createImportDecl (Ctx, ClangUnit, ImportedMod, Exported);
3270
3270
Results.push_back (ID);
3271
3271
}
3272
-
3273
- if (Ctx.LangOpts .EnableCXXInterop && requiresCPlusPlus (M)) {
3274
- // Try to load the Cxx module. We don't use it directly here, but we need to
3275
- // make sure that ASTContext has loaded this module.
3276
- auto *cxxModule = Ctx.getModuleByIdentifier (Ctx.Id_Cxx );
3277
- if (cxxModule) {
3278
- ImportPath::Builder builder (Ctx.Id_Cxx );
3279
- auto *importCxx =
3280
- ImportDecl::create (Ctx, ClangUnit, SourceLoc (), ImportKind::Module,
3281
- SourceLoc (), builder.get ());
3282
- Results.push_back (importCxx);
3283
- }
3284
- }
3285
3272
}
3286
3273
3287
3274
void ClangModuleUnit::getDisplayDecls (SmallVectorImpl<Decl*> &results, bool recursive) const {
@@ -3918,6 +3905,17 @@ void ClangModuleUnit::getImportedModulesForLookup(
3918
3905
} else {
3919
3906
clangModule->getExportedModules (imported);
3920
3907
topLevel = clangModule->getTopLevelModule ();
3908
+
3909
+ // If this is a C++ module, implicitly import the Cxx module, which contains
3910
+ // definitions of Swift protocols that C++ types might conform to, such as
3911
+ // CxxSequence.
3912
+ if (owner.SwiftContext .LangOpts .EnableCXXInterop &&
3913
+ requiresCPlusPlus (clangModule) && clangModule->Name != " CxxShim" ) {
3914
+ auto *cxxModule =
3915
+ owner.SwiftContext .getModuleByIdentifier (owner.SwiftContext .Id_Cxx );
3916
+ if (cxxModule)
3917
+ imports.push_back ({ImportPath::Access (), cxxModule});
3918
+ }
3921
3919
}
3922
3920
3923
3921
if (imported.empty ()) {
0 commit comments