Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/PrintAsClang/DeclAndTypePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2784,8 +2784,12 @@ static bool isExposedToThisModule(const ModuleDecl &M, const ValueDecl *VD,
if (VD->hasClangNode())
return true;
auto *mc = VD->getModuleContext();
if (mc == &M || mc->isStdlibModule())
if (mc == &M)
return true;
// Only certain declarations are exposed from
// the standard library.
if (mc->isStdlibModule())
return hasExposeAttr(VD);
return exposedModules.count(mc->getName().str());
}

Expand Down
17 changes: 17 additions & 0 deletions test/Interop/SwiftToCxx/enums/swift-enum-implementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

// RUN: %check-interop-cxx-header-in-clang(%t/enums.h -Wno-unused-private-field -Wno-unused-function)

// RUN: %target-swift-frontend %s -typecheck -module-name Enums -enable-experimental-cxx-interop -emit-clang-header-path %t/enums-default.h
// RUN: %FileCheck %s < %t/enums-default.h

public enum E {
case x(Double)
case y(UnsafeRawPointer?)
Expand All @@ -25,6 +28,11 @@ public enum E {
}
}

public enum E2 {
case foobar
case baz
}

public struct S {
public var x: Int64

Expand Down Expand Up @@ -166,6 +174,15 @@ public struct S {
// CHECK-NEXT: #endif
// CHECK-NEXT: vwTable->initializeWithTake(destStorage, srcStorage, metadata._0);
// CHECK-NEXT: }

// CHECK: class SWIFT_SYMBOL({{.*}}) E2 final {
// CHECK: SWIFT_INLINE_THUNK operator cases() const {
// CHECK: }
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: SWIFT_INLINE_THUNK swift::Int getHashValue() const SWIFT_SYMBOL({{.*}});
// CHECK-NEXT: private:

// CHECK: namespace Enums SWIFT_PRIVATE_ATTR SWIFT_SYMBOL_MODULE("Enums") {
// CHECK: SWIFT_INLINE_THUNK E E::_impl_x::operator()(double val) const {
// CHECK-NEXT: auto result = E::_make();
Expand Down