C++ Interop: import namespaces redecls as separate extensions

Previously a namespace declaration was imported along with all of its redeclarations, and their members were added to a single Swift extension. This was problematic when a single namespace is declared in multiple modules – the extension belonged to only one of them.
For an example of this, try printing a module interface for `std.string`/`std.iosfwd` – it will be empty, even though the declarations from those modules are actually imported into Swift correctly.

This change makes sure that when we're importing different redeclarations of the same namespace, we're adding them as separate extensions to appropriate modules.
This commit is contained in:
Egor Zhdan
2021-05-23 14:59:52 +03:00
parent 60a195e972
commit cfc9483f1a
13 changed files with 200 additions and 71 deletions

View File

@@ -1,7 +1,7 @@
// RUN: %target-swift-ide-test -print-module -module-to-print=Classes -I %S/Inputs -source-filename=x -enable-cxx-interop | %FileCheck %s
// CHECK-NOT: extension
// CHECK: extension ClassesNS1.ClassesNS2 {
// CHECK: extension ClassesNS1 {
// CHECK: struct BasicStruct {
// CHECK: init()
// CHECK: mutating func basicMember() -> UnsafePointer<CChar>!
@@ -13,7 +13,7 @@
// CHECK: }
// CHECK-NOT: extension
// CHECK: extension ClassesNS1 {
// CHECK: extension ClassesNS1.ClassesNS2 {
// CHECK: struct BasicStruct {
// CHECK: init()
// CHECK: mutating func basicMember() -> UnsafePointer<CChar>!