From 772909e229cf816838552d34af9f29897dbfb4cf Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Tue, 21 Mar 2023 17:14:12 -0700 Subject: [PATCH] [interop][sourcekit] print submodules of CxxStdlib when printing out IDE interface of it --- .../InterfaceGen/gen_clang_libcxx_sdk_module.swift | 6 ++++++ tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 test/SourceKit/InterfaceGen/gen_clang_libcxx_sdk_module.swift diff --git a/test/SourceKit/InterfaceGen/gen_clang_libcxx_sdk_module.swift b/test/SourceKit/InterfaceGen/gen_clang_libcxx_sdk_module.swift new file mode 100644 index 0000000000000..6a760f8f2b720 --- /dev/null +++ b/test/SourceKit/InterfaceGen/gen_clang_libcxx_sdk_module.swift @@ -0,0 +1,6 @@ +// RUN: %sourcekitd-test -req=interface-gen -module CxxStdlib -- -Xfrontend -disable-implicit-concurrency-module-import -Xfrontend -disable-implicit-string-processing-module-import -cxx-interoperability-mode=swift-5.9 -target %target-triple -sdk %sdk | %FileCheck %s + +// REQUIRES: OS=macosx + +// CHECK: import CxxStdlib.vector +// CHECK: extension std.basic_string, allocator> { diff --git a/tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp b/tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp index bbf96473300cc..1fbc7c52e5c0c 100644 --- a/tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp +++ b/tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp @@ -287,6 +287,13 @@ static bool getModuleInterfaceInfo(ASTContext &Ctx, ErrMsg += ModuleName; return true; } + if (Mod->failedToLoad() && ModuleName == "CxxStdlib") { + // We might fail to load the underlying Clang module + // for a Swift overlay module like 'CxxStdlib'. Make sure an error is reported in this case, so that we can either retry to load with C++ interoperability enabled, and if that fails, we can report this to the user. + ErrMsg = "Could not load underlying module for: "; + ErrMsg += ModuleName; + return true; + } PrintOptions Options = PrintOptions::printModuleInterface( Ctx.TypeCheckerOpts.PrintFullConvention);