Skip to content

Commit bd8c874

Browse files
committed
[interop][SwiftToCxx] experimentally expose Swift::String type to C++
The only member that's currently exposed is the default initializer, everything else is in extensions
1 parent 288e4cb commit bd8c874

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/PrintAsClang/DeclAndTypePrinter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2397,6 +2397,11 @@ static bool isAsyncAlternativeOfOtherDecl(const ValueDecl *VD) {
23972397
}
23982398

23992399
static bool hasExposeAttr(const ValueDecl *VD) {
2400+
if (isa<NominalTypeDecl>(VD) && VD->getModuleContext()->isStdlibModule()) {
2401+
if (VD == VD->getASTContext().getStringDecl())
2402+
return true;
2403+
return false;
2404+
}
24002405
if (VD->getAttrs().hasAttribute<ExposeAttr>())
24012406
return true;
24022407
if (const auto *NMT = dyn_cast<NominalTypeDecl>(VD->getDeclContext()))

test/Interop/SwiftToCxx/stdlib/swift-stdlib-in-cxx.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,15 @@
55
// RUN: %check-interop-cxx-header-in-clang(%t/Swift.h -Wno-unused-private-field -Wno-unused-function)
66

77
// CHECK: namespace Swift {
8+
9+
// CHECK: class String final {
10+
// CHECK-NEXT: public:
11+
// CHECK-NEXT: inline ~String() {
12+
// CHECK: }
13+
// CHECK-NEXT: inline String(const String &other) {
14+
// CHECK: }
15+
// CHECK-NEXT: inline String(String &&) = default;
16+
// CHECK-NEXT: static inline String init();
17+
// CHECK-NEXT: private:
18+
819
// CHECK: } // namespace Swift

0 commit comments

Comments
 (0)