Skip to content

Commit ce96484

Browse files
committed
[interop][SwiftToCxx] ensure all emitted 'swift' namespaces are marked as swift_private
1 parent 953dfec commit ce96484

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/PrintAsClang/PrintClangValueType.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ void ClangValueTypePrinter::printTypePrecedingGenericTraits(
544544
ClangSyntaxPrinter printer(os);
545545
// FIXME: avoid popping out of the module's namespace here.
546546
os << "} // end namespace \n\n";
547-
os << "namespace swift {\n";
547+
os << "namespace swift SWIFT_PRIVATE_ATTR {\n";
548548

549549
os << "#pragma clang diagnostic push\n";
550550
os << "#pragma clang diagnostic ignored \"-Wc++17-extensions\"\n";
@@ -570,7 +570,7 @@ void ClangValueTypePrinter::printTypeGenericTraits(
570570
ClangSyntaxPrinter printer(os);
571571
// FIXME: avoid popping out of the module's namespace here.
572572
os << "} // end namespace \n\n";
573-
os << "namespace swift {\n";
573+
os << "namespace swift SWIFT_PRIVATE_ATTR {\n";
574574

575575
if (typeDecl->hasClangNode()) {
576576
/// Print a reference to the type metadata fucntion for a C++ type.

test/Interop/SwiftToCxxToSwift/hide-swift-module-namespace-in-swift.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// RUN: %check-interop-cxx-header-in-clang(%t/swiftMod2.h -DSWIFT_CXX_INTEROP_HIDE_STL_OVERLAY -Wno-error)
1111

12-
// RUN: %target-swift-ide-test -print-module -module-to-print=SwiftToCxxTest -I %t -source-filename=x -enable-experimental-cxx-interop -Xcc -DSWIFT_CXX_INTEROP_HIDE_SWIFT_ERROR
12+
// RUN: %target-swift-ide-test -print-module -module-to-print=SwiftToCxxTest -I %t -source-filename=x -enable-experimental-cxx-interop -Xcc -DSWIFT_CXX_INTEROP_HIDE_SWIFT_ERROR | %FileCheck --check-prefix=INTERFACE %s
1313

1414
// XFAIL: OS=linux-android, OS=linux-androideabi
1515

@@ -37,3 +37,5 @@ public func testFunction() -> String {
3737
// CHECK: namespace swift SWIFT_PRIVATE_ATTR SWIFT_SYMBOL_MODULE("swift") {
3838
// CHECK: namespace SwiftMod SWIFT_PRIVATE_ATTR SWIFT_SYMBOL_MODULE("SwiftMod") {
3939
// CHECK-NOT: namespace swift {
40+
41+
// INTERFACE-NOT: enum swift

0 commit comments

Comments
 (0)