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) {
2908
2908
!excludeForObjCImplementation (VD);
2909
2909
}
2910
2910
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
+
2911
2917
void DeclAndTypePrinter::print (const Decl *D) {
2912
2918
getImpl ().print (D);
2913
2919
}
Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ class DeclAndTypePrinter {
106
106
// / the options the printer was constructed with.
107
107
bool shouldInclude (const ValueDecl *VD);
108
108
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
+
109
113
void print (const Decl *D);
110
114
void print (Type ty);
111
115
Original file line number Diff line number Diff line change @@ -820,18 +820,18 @@ class ModuleWriter {
820
820
emissionScope.additionalUnrepresentableDeclarations )
821
821
removedVDList.push_back (removedVD);
822
822
823
+ // Do not report internal/private decls as unavailable.
823
824
// @objc declarations are emitted in the Objective-C section, so do not
824
825
// report them as unavailable. Also skip underscored decls from the standard
825
826
// library. Also skip structs from the standard library, they can cause
826
827
// ambiguities because of the arithmetic types that conflict with types we
827
828
// already have in `swift::` namespace. Also skip `Error` protocol from
828
829
// stdlib, we have experimental support for it.
829
- // FIXME: Note unrepresented type aliases too.
830
830
removedVDList.erase (
831
831
llvm::remove_if (
832
832
removedVDList,
833
- [](const ValueDecl *vd) {
834
- return vd->isObjC () ||
833
+ [& ](const ValueDecl *vd) {
834
+ return !printer. isVisible (vd) || vd->isObjC () ||
835
835
(vd->isStdlibDecl () && !vd->getName ().isSpecial () &&
836
836
vd->getBaseIdentifier ().str ().startswith (" _" )) ||
837
837
(vd->isStdlibDecl () && isa<StructDecl>(vd)) ||
@@ -897,6 +897,7 @@ class ModuleWriter {
897
897
898
898
// FIXME: Emit an unavailable stub for a function / function overload set
899
899
// / variable.
900
+ // FIXME: Note unrepresented type aliases too.
900
901
emitStubComment ();
901
902
}
902
903
}
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