File tree Expand file tree Collapse file tree 4 files changed +33
-3
lines changed
test/Interop/SwiftToCxx/unsupported Expand file tree Collapse file tree 4 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -2908,6 +2908,12 @@ bool DeclAndTypePrinter::shouldInclude(const ValueDecl *VD) {
29082908 !excludeForObjCImplementation (VD);
29092909}
29102910
2911+ bool DeclAndTypePrinter::isVisible (const ValueDecl *vd) const {
2912+ return outputLang == OutputLanguageMode::Cxx
2913+ ? cxx_translation::isVisibleToCxx (vd, minRequiredAccess)
2914+ : isVisibleToObjC (vd, minRequiredAccess);
2915+ }
2916+
29112917void DeclAndTypePrinter::print (const Decl *D) {
29122918 getImpl ().print (D);
29132919}
Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ class DeclAndTypePrinter {
106106 // / the options the printer was constructed with.
107107 bool shouldInclude (const ValueDecl *VD);
108108
109+ // / Returns true if \p vd is visible given the current access level and thus
110+ // / can be included in the generated header.
111+ bool isVisible (const ValueDecl *vd) const ;
112+
109113 void print (const Decl *D);
110114 void print (Type ty);
111115
Original file line number Diff line number Diff line change @@ -820,18 +820,18 @@ class ModuleWriter {
820820 emissionScope.additionalUnrepresentableDeclarations )
821821 removedVDList.push_back (removedVD);
822822
823+ // Do not report internal/private decls as unavailable.
823824 // @objc declarations are emitted in the Objective-C section, so do not
824825 // report them as unavailable. Also skip underscored decls from the standard
825826 // library. Also skip structs from the standard library, they can cause
826827 // ambiguities because of the arithmetic types that conflict with types we
827828 // already have in `swift::` namespace. Also skip `Error` protocol from
828829 // stdlib, we have experimental support for it.
829- // FIXME: Note unrepresented type aliases too.
830830 removedVDList.erase (
831831 llvm::remove_if (
832832 removedVDList,
833- [](const ValueDecl *vd) {
834- return vd->isObjC () ||
833+ [& ](const ValueDecl *vd) {
834+ return !printer. isVisible (vd) || vd->isObjC () ||
835835 (vd->isStdlibDecl () && !vd->getName ().isSpecial () &&
836836 vd->getBaseIdentifier ().str ().startswith (" _" )) ||
837837 (vd->isStdlibDecl () && isa<StructDecl>(vd)) ||
@@ -897,6 +897,7 @@ class ModuleWriter {
897897
898898 // FIXME: Emit an unavailable stub for a function / function overload set
899899 // / variable.
900+ // FIXME: Note unrepresented type aliases too.
900901 emitStubComment ();
901902 }
902903 }
Original file line number Diff line number Diff line change 1+ // RUN: %empty-directory(%t)
2+ // RUN: %target-swift-frontend %s -typecheck -module-name Functions -clang-header-expose-decls=all-public -emit-clang-header-path %t/apis.h
3+ // RUN: %FileCheck %s < %t/apis.h
4+
5+ internal func takeFloat( _ x: Float ) { }
6+
7+ private struct PrivateStruct { let x : Int }
8+
9+ class InternalClass {
10+ let x : Int
11+ init ( ) { self . x = 0 }
12+ }
13+
14+ protocol InternalProto { }
15+
16+ // CHECK: namespace Functions SWIFT_PRIVATE_ATTR SWIFT_SYMBOL_MODULE("Functions") {
17+ // CHECK-EMPTY:
18+ // CHECK-EMPTY:
19+ // CHECK-NEXT: } // namespace Functions
You can’t perform that action at this time.
0 commit comments