Skip to content

Commit 3b3d6c8

Browse files
committed
[interop][SwiftToCxx] Annotate emitted declarations with Clang's external_source_symbol attribute
Each emitted declaration is annotated with the external_source_symbol with its own USR, to allow Clang's indexer to recognize this declaration as a Swift declaration with a specific USR
1 parent 1d7c0ee commit 3b3d6c8

File tree

58 files changed

+482
-402
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+482
-402
lines changed

lib/PrintAsClang/ClangSyntaxPrinter.cpp

+20-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212

1313
#include "ClangSyntaxPrinter.h"
1414
#include "swift/ABI/MetadataValues.h"
15+
#include "swift/AST/ASTContext.h"
1516
#include "swift/AST/Decl.h"
1617
#include "swift/AST/Module.h"
1718
#include "swift/AST/SwiftNameTranslation.h"
19+
#include "swift/AST/TypeCheckRequests.h"
1820
#include "clang/AST/ASTContext.h"
1921
#include "clang/AST/DeclTemplate.h"
2022
#include "clang/AST/NestedNameSpecifier.h"
@@ -140,18 +142,21 @@ void ClangSyntaxPrinter::printModuleNamespaceStart(
140142
os << "namespace ";
141143
printBaseName(&moduleContext);
142144
os << " __attribute__((swift_private))";
145+
printSymbolUSRAttribute(&moduleContext);
143146
os << " {\n";
144147
}
145148

146149
/// Print a C++ namespace declaration with the give name and body.
147150
void ClangSyntaxPrinter::printNamespace(
148151
llvm::function_ref<void(raw_ostream &OS)> namePrinter,
149152
llvm::function_ref<void(raw_ostream &OS)> bodyPrinter,
150-
NamespaceTrivia trivia) const {
153+
NamespaceTrivia trivia, const ModuleDecl *moduleContext) const {
151154
os << "namespace ";
152155
namePrinter(os);
153156
if (trivia == NamespaceTrivia::AttributeSwiftPrivate)
154157
os << " __attribute__((swift_private))";
158+
if (moduleContext)
159+
printSymbolUSRAttribute(moduleContext);
155160
os << " {\n\n";
156161
bodyPrinter(os);
157162
os << "\n} // namespace ";
@@ -405,3 +410,17 @@ void ClangSyntaxPrinter::printIgnoredCxx17ExtensionDiagnosticBlock(
405410
llvm::function_ref<void()> bodyPrinter) {
406411
printIgnoredDiagnosticBlock("c++17-extensions", bodyPrinter);
407412
}
413+
414+
void ClangSyntaxPrinter::printSymbolUSRAttribute(const ValueDecl *D) const {
415+
if (isa<ModuleDecl>(D)) {
416+
os << " SWIFT_SYMBOL_MODULE(\"";
417+
printBaseName(D);
418+
os << "\")";
419+
return;
420+
}
421+
auto result = evaluateOrDefault(D->getASTContext().evaluator,
422+
USRGenerationRequest{D}, std::string());
423+
if (result.empty())
424+
return;
425+
os << " SWIFT_SYMBOL(\"" << result << "\")";
426+
}

lib/PrintAsClang/ClangSyntaxPrinter.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ class ClangSyntaxPrinter {
125125
/// Print a C++ namespace declaration with the give name and body.
126126
void printNamespace(llvm::function_ref<void(raw_ostream &OS)> namePrinter,
127127
llvm::function_ref<void(raw_ostream &OS)> bodyPrinter,
128-
NamespaceTrivia trivia = NamespaceTrivia::None) const;
128+
NamespaceTrivia trivia = NamespaceTrivia::None,
129+
const ModuleDecl *moduleContext = nullptr) const;
129130

130131
void printNamespace(StringRef name,
131132
llvm::function_ref<void(raw_ostream &OS)> bodyPrinter,
@@ -220,6 +221,10 @@ class ClangSyntaxPrinter {
220221
void printIgnoredCxx17ExtensionDiagnosticBlock(
221222
llvm::function_ref<void()> bodyPrinter);
222223

224+
/// Print the macro that applies Clang's `external_source_symbol` attribute
225+
/// on the generated declaration.
226+
void printSymbolUSRAttribute(const ValueDecl *D) const;
227+
223228
protected:
224229
raw_ostream &os;
225230
};

lib/PrintAsClang/ModuleContentsWriter.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,14 @@ EmittedClangHeaderDependencyInfo swift::printModuleContentsAsCxx(
788788
llvm::raw_string_ostream prologueOS{modulePrologueBuf};
789789
EmittedClangHeaderDependencyInfo info;
790790

791+
// Define the `SWIFT_SYMBOL` macro.
792+
os << "#ifdef SWIFT_SYMBOL\n";
793+
os << "#undef SWIFT_SYMBOL\n";
794+
os << "#endif\n";
795+
os << "#define SWIFT_SYMBOL(usrValue) SWIFT_SYMBOL_MODULE_USR(\"";
796+
ClangSyntaxPrinter(os).printBaseName(&M);
797+
os << "\", usrValue)\n";
798+
791799
// FIXME: Use getRequiredAccess once @expose is supported.
792800
ModuleWriter writer(moduleOS, prologueOS, info.imports, M, interopContext,
793801
AccessLevel::Public, requiresExposedAttribute,
@@ -824,6 +832,7 @@ EmittedClangHeaderDependencyInfo swift::printModuleContentsAsCxx(
824832
os << "namespace ";
825833
M.ValueDecl::getName().print(os);
826834
os << " __attribute__((swift_private))";
835+
ClangSyntaxPrinter(os).printSymbolUSRAttribute(&M);
827836
os << " {\n";
828837
os << "namespace " << cxx_synthesis::getCxxImplNamespaceName() << " {\n";
829838
os << "extern \"C\" {\n";
@@ -842,10 +851,11 @@ EmittedClangHeaderDependencyInfo swift::printModuleContentsAsCxx(
842851
ClangSyntaxPrinter(os).printNamespace(
843852
[&](raw_ostream &os) { M.ValueDecl::getName().print(os); },
844853
[&](raw_ostream &os) { os << moduleOS.str(); },
845-
ClangSyntaxPrinter::NamespaceTrivia::AttributeSwiftPrivate);
854+
ClangSyntaxPrinter::NamespaceTrivia::AttributeSwiftPrivate, &M);
846855

847856
if (M.isStdlibModule()) {
848857
os << "#pragma clang diagnostic pop\n";
849858
}
859+
os << "#undef SWIFT_SYMBOL\n";
850860
return info;
851861
}

lib/PrintAsClang/PrintClangClassType.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ void ClangClassTypePrinter::printClassTypeDecl(
5858
baseClassQualifiedName = "swift::_impl::RefCountedClass";
5959
}
6060

61-
os << "class ";
61+
os << "class";
62+
ClangSyntaxPrinter(os).printSymbolUSRAttribute(typeDecl);
63+
os << ' ';
6264
printer.printBaseName(typeDecl);
6365
if (typeDecl->isFinal())
6466
os << " final";

lib/PrintAsClang/PrintClangFunction.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,9 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
905905
os << " const";
906906
if (modifiers.isNoexcept)
907907
os << " noexcept";
908+
if (modifiers.hasSymbolUSR)
909+
ClangSyntaxPrinter(os).printSymbolUSRAttribute(
910+
modifiers.symbolUSROverride ? modifiers.symbolUSROverride : FD);
908911
return resultingRepresentation;
909912
}
910913

@@ -1311,6 +1314,7 @@ void DeclAndTypeClangFunctionPrinter::printCxxMethod(
13111314
isa<FuncDecl>(FD) ? cast<FuncDecl>(FD)->isMutating() : false;
13121315
modifiers.isConst =
13131316
!isa<ClassDecl>(typeDeclContext) && !isMutating && !isConstructor;
1317+
modifiers.hasSymbolUSR = !isDefinition;
13141318
auto result = printFunctionSignature(
13151319
FD, signature,
13161320
isConstructor ? getConstructorName(FD)
@@ -1375,6 +1379,8 @@ void DeclAndTypeClangFunctionPrinter::printCxxPropertyAccessorMethod(
13751379
modifiers.isInline = true;
13761380
modifiers.isConst =
13771381
!isStatic && accessor->isGetter() && !isa<ClassDecl>(typeDeclContext);
1382+
modifiers.hasSymbolUSR = !isDefinition;
1383+
modifiers.symbolUSROverride = accessor->getStorage();
13781384
auto result = printFunctionSignature(
13791385
accessor, signature, remapPropertyName(accessor, resultTy), resultTy,
13801386
FunctionSignatureKind::CxxInlineThunk, modifiers);

lib/PrintAsClang/PrintClangFunction.h

+4
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ class DeclAndTypeClangFunctionPrinter {
8787
bool isInline = false;
8888
bool isConst = false;
8989
bool isNoexcept = false;
90+
bool hasSymbolUSR = true;
91+
/// Specific declaration that should be used to emit the symbol's
92+
/// USR instead of the original function declaration.
93+
const ValueDecl *symbolUSROverride = nullptr;
9094

9195
FunctionSignatureModifiers() {}
9296
};

lib/PrintAsClang/PrintClangValueType.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ void ClangValueTypePrinter::forwardDeclType(raw_ostream &os,
8888
typeDecl->getGenericSignature().getCanonicalSignature();
8989
ClangSyntaxPrinter(os).printGenericSignature(genericSignature);
9090
}
91-
os << "class ";
91+
os << "class";
92+
ClangSyntaxPrinter(os).printSymbolUSRAttribute(typeDecl);
93+
os << ' ';
9294
ClangSyntaxPrinter(os).printBaseName(typeDecl);
9395
os << ";\n";
9496
printTypePrecedingGenericTraits(os, typeDecl, typeDecl->getModuleContext());
@@ -259,7 +261,9 @@ void ClangValueTypePrinter::printValueTypeDecl(
259261

260262
// Print out the C++ class itself.
261263
printGenericSignature(os);
262-
os << "class ";
264+
os << "class";
265+
ClangSyntaxPrinter(os).printSymbolUSRAttribute(typeDecl);
266+
os << ' ';
263267
ClangSyntaxPrinter(os).printBaseName(typeDecl);
264268
os << " final {\n";
265269
os << "public:\n";

lib/PrintAsClang/_SwiftCxxInteroperability.h

+23
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,29 @@
3131
// FIXME: Use always_inline, artificial.
3232
#define SWIFT_INLINE_THUNK inline
3333

34+
/// The `SWIFT_SYMBOL_MODULE` and `SWIFT_SYMBOL_MODULE_USR` macros apply
35+
/// `external_source_symbol` Clang attributes to C++ declarations that represent
36+
/// Swift declarations. This allows Clang to index them as external
37+
/// declarations, using the specified Swift USR values.
38+
#if __has_attribute(external_source_symbol)
39+
#define SWIFT_SYMBOL_MODULE(moduleValue) \
40+
__attribute__((external_source_symbol( \
41+
language = "Swift", defined_in = moduleValue, generated_declaration)))
42+
#if __has_attribute(external_source_symbol_with_usr)
43+
#define SWIFT_SYMBOL_MODULE_USR(moduleValue, usrValue) \
44+
__attribute__(( \
45+
external_source_symbol(language = "Swift", defined_in = moduleValue, \
46+
generated_declaration, USR = usrValue)))
47+
#else
48+
#define SWIFT_SYMBOL_MODULE_USR(moduleValue, usrValue) \
49+
__attribute__((external_source_symbol( \
50+
language = "Swift", defined_in = moduleValue, generated_declaration)))
51+
#endif
52+
#else
53+
#define SWIFT_SYMBOL_MODULE_USR(moduleValue, usrValue)
54+
#define SWIFT_SYMBOL_MODULE(moduleValue)
55+
#endif
56+
3457
namespace swift {
3558
namespace _impl {
3659

test/Interop/CxxToSwiftToCxx/bridge-cxx-struct-back-to-cxx.swift

+14-14
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ public func takeTrivialInout(_ x: inout Trivial) {
156156
// CHECK: SWIFT_EXTERN void $s8UseCxxTy13retNonTrivialSo2nsO02__b18TemplateInstN2ns18efH4IiEEVyF(SWIFT_INDIRECT_RESULT void * _Nonnull) SWIFT_NOEXCEPT SWIFT_CALL; // retNonTrivial()
157157
// CHECK: SWIFT_EXTERN struct swift_interop_returnStub_UseCxxTy_uint32_t_0_4 $s8UseCxxTy10retTrivialSo0E0VyF(void) SWIFT_NOEXCEPT SWIFT_CALL; // retTrivial()
158158

159-
// CHECK: ns::Immortal *_Nonnull retImmortal() noexcept SWIFT_WARN_UNUSED_RESULT {
159+
// CHECK: ns::Immortal *_Nonnull retImmortal() noexcept SWIFT_SYMBOL({{.*}}) SWIFT_WARN_UNUSED_RESULT {
160160
// CHECK-NEXT: return _impl::$s8UseCxxTy11retImmortalSo2nsO0E0VyF();
161161
// CHECK-NEXT: }
162162

163-
// CHECK: ns::ImmortalTemplate<int> *_Nonnull retImmortalTemplate() noexcept SWIFT_WARN_UNUSED_RESULT {
163+
// CHECK: ns::ImmortalTemplate<int> *_Nonnull retImmortalTemplate() noexcept SWIFT_SYMBOL({{.*}}) SWIFT_WARN_UNUSED_RESULT {
164164
// CHECK-NEXT: return _impl::$s8UseCxxTy19retImmortalTemplateSo2nsO02__bf10InstN2ns16eF4IiEEVyF();
165165
// CHECK-NEXT: }
166166

@@ -192,9 +192,9 @@ public func takeTrivialInout(_ x: inout Trivial) {
192192
// CHECK-NEXT: #pragma clang diagnostic pop
193193
// CHECK-NEXT: } // namespace swift
194194
// CHECK-EMPTY:
195-
// CHECK-NEXT: namespace UseCxxTy __attribute__((swift_private)) {
195+
// CHECK-NEXT: namespace UseCxxTy __attribute__((swift_private)) SWIFT_SYMBOL_MODULE("UseCxxTy") {
196196

197-
// CHECK: inline ns::NonTrivialTemplate<int> retNonTrivial() noexcept SWIFT_WARN_UNUSED_RESULT {
197+
// CHECK: inline ns::NonTrivialTemplate<int> retNonTrivial() noexcept SWIFT_SYMBOL({{.*}}) SWIFT_WARN_UNUSED_RESULT {
198198
// CHECK-NEXT: alignas(alignof(ns::NonTrivialTemplate<int>)) char storage[sizeof(ns::NonTrivialTemplate<int>)];
199199
// CHECK-NEXT: auto * _Nonnull storageObjectPtr = reinterpret_cast<ns::NonTrivialTemplate<int> *>(storage);
200200
// CHECK-NEXT: _impl::$s8UseCxxTy13retNonTrivialSo2nsO02__b18TemplateInstN2ns18efH4IiEEVyF(storage);
@@ -231,9 +231,9 @@ public func takeTrivialInout(_ x: inout Trivial) {
231231
// CHECK-NEXT: #pragma clang diagnostic pop
232232
// CHECK-NEXT: } // namespace swift
233233
// CHECK-EMPTY:
234-
// CHECK-NEXT: namespace UseCxxTy __attribute__((swift_private)) {
234+
// CHECK-NEXT: namespace UseCxxTy __attribute__((swift_private)) SWIFT_SYMBOL_MODULE("UseCxxTy") {
235235
// CHECK-EMPTY:
236-
// CHECK-NEXT: inline ns::NonTrivialTemplate<ns::TrivialinNS> retNonTrivial2() noexcept SWIFT_WARN_UNUSED_RESULT {
236+
// CHECK-NEXT: inline ns::NonTrivialTemplate<ns::TrivialinNS> retNonTrivial2() noexcept SWIFT_SYMBOL({{.*}}) SWIFT_WARN_UNUSED_RESULT {
237237
// CHECK-NEXT: alignas(alignof(ns::NonTrivialTemplate<ns::TrivialinNS>)) char storage[sizeof(ns::NonTrivialTemplate<ns::TrivialinNS>)];
238238
// CHECK-NEXT: auto * _Nonnull storageObjectPtr = reinterpret_cast<ns::NonTrivialTemplate<ns::TrivialinNS> *>(storage);
239239
// CHECK-NEXT: _impl::$s8UseCxxTy14retNonTrivial2So2nsO02__b18TemplateInstN2ns18e7TrivialH20INS_11TrivialinNSEEEVyF(storage);
@@ -242,7 +242,7 @@ public func takeTrivialInout(_ x: inout Trivial) {
242242
// CHECK-NEXT: return result;
243243
// CHECK-NEXT: }
244244

245-
// CHECK: inline ns::NonTrivialImplicitMove retNonTrivialImplicitMove() noexcept SWIFT_WARN_UNUSED_RESULT {
245+
// CHECK: inline ns::NonTrivialImplicitMove retNonTrivialImplicitMove() noexcept SWIFT_SYMBOL({{.*}}) SWIFT_WARN_UNUSED_RESULT {
246246
// CHECK-NEXT: alignas(alignof(ns::NonTrivialImplicitMove)) char storage[sizeof(ns::NonTrivialImplicitMove)];
247247
// CHECK-NEXT: auto * _Nonnull storageObjectPtr = reinterpret_cast<ns::NonTrivialImplicitMove *>(storage);
248248
// CHECK-NEXT: _impl::$s8UseCxxTy25retNonTrivialImplicitMoveSo2nsO0efgH0VyF(storage);
@@ -251,31 +251,31 @@ public func takeTrivialInout(_ x: inout Trivial) {
251251
// CHECK-NEXT: return result;
252252
// CHECK-NEXT: }
253253

254-
// CHECK: ns::NonTrivialTemplate<ns::TrivialinNS> retNonTrivialTypeAlias() noexcept SWIFT_WARN_UNUSED_RESULT {
254+
// CHECK: ns::NonTrivialTemplate<ns::TrivialinNS> retNonTrivialTypeAlias() noexcept SWIFT_SYMBOL({{.*}}) SWIFT_WARN_UNUSED_RESULT {
255255

256-
// CHECK: inline Trivial retTrivial() noexcept SWIFT_WARN_UNUSED_RESULT {
256+
// CHECK: inline Trivial retTrivial() noexcept SWIFT_SYMBOL({{.*}}) SWIFT_WARN_UNUSED_RESULT {
257257
// CHECK-NEXT: alignas(alignof(Trivial)) char storage[sizeof(Trivial)];
258258
// CHECK-NEXT: auto * _Nonnull storageObjectPtr = reinterpret_cast<Trivial *>(storage);
259259
// CHECK-NEXT: _impl::swift_interop_returnDirect_UseCxxTy_uint32_t_0_4(storage, _impl::$s8UseCxxTy10retTrivialSo0E0VyF());
260260
// CHECK-NEXT: return *storageObjectPtr;
261261
// CHECK-NEXT: }
262262

263-
// CHECK: void takeImmortal(ns::Immortal *_Nonnull x) noexcept {
263+
// CHECK: void takeImmortal(ns::Immortal *_Nonnull x) noexcept SWIFT_SYMBOL({{.*}}) {
264264
// CHECK-NEXT: return _impl::$s8UseCxxTy12takeImmortalyySo2nsO0E0VF(x);
265265
// CHECK-NEXT: }
266266

267-
// CHECK: void takeImmortalTemplate(ns::ImmortalTemplate<int> *_Nonnull x) noexcept {
267+
// CHECK: void takeImmortalTemplate(ns::ImmortalTemplate<int> *_Nonnull x) noexcept SWIFT_SYMBOL({{.*}}) {
268268
// CHECK-NEXT: return _impl::$s8UseCxxTy20takeImmortalTemplateyySo2nsO02__bf10InstN2ns16eF4IiEEVF(x);
269269
// CHECK-NEXT: }
270270

271-
// CHECK: inline void takeNonTrivial2(const ns::NonTrivialTemplate<ns::TrivialinNS>& x) noexcept {
271+
// CHECK: inline void takeNonTrivial2(const ns::NonTrivialTemplate<ns::TrivialinNS>& x) noexcept SWIFT_SYMBOL({{.*}}) {
272272
// CHECK-NEXT: return _impl::$s8UseCxxTy15takeNonTrivial2yySo2nsO02__b18TemplateInstN2ns18e7TrivialH20INS_11TrivialinNSEEEVF(swift::_impl::getOpaquePointer(x));
273273
// CHECK-NEXT: }
274274

275-
// CHECK: inline void takeTrivial(const Trivial& x) noexcept {
275+
// CHECK: inline void takeTrivial(const Trivial& x) noexcept SWIFT_SYMBOL({{.*}}) {
276276
// CHECK-NEXT: return _impl::$s8UseCxxTy11takeTrivialyySo0E0VF(_impl::swift_interop_passDirect_UseCxxTy_uint32_t_0_4(reinterpret_cast<const char *>(swift::_impl::getOpaquePointer(x))));
277277
// CHECK-NEXT: }
278278

279-
// CHECK: inline void takeTrivialInout(Trivial& x) noexcept {
279+
// CHECK: inline void takeTrivialInout(Trivial& x) noexcept SWIFT_SYMBOL({{.*}}) {
280280
// CHECK-NEXT: return _impl::$s8UseCxxTy16takeTrivialInoutyySo0E0VzF(swift::_impl::getOpaquePointer(x));
281281
// CHECK-NEXT: }

test/Interop/ObjCToSwiftToObjCxx/bridge-objc-types-back-to-objcxx.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ public func retObjClassNullable() -> ObjCKlass? {
5959
// CHECK-NEXT: void $s9UseObjCTy04takeB11CClassInoutyySo0B6CKlassCzF(ObjCKlass *_Nonnull __strong * _Nonnull x) SWIFT_NOEXCEPT SWIFT_CALL;
6060
// CHECK-NEXT: void $s9UseObjCTy04takeB14CClassNullableyySo0B6CKlassCSgF(ObjCKlass *_Nullable x) SWIFT_NOEXCEPT SWIFT_CALL;
6161

62-
// CHECK: inline ObjCKlass *_Nonnull retObjClass() noexcept SWIFT_WARN_UNUSED_RESULT {
62+
// CHECK: inline ObjCKlass *_Nonnull retObjClass() noexcept SWIFT_SYMBOL({{.*}}) SWIFT_WARN_UNUSED_RESULT {
6363
// CHECK-NEXT: return (__bridge_transfer ObjCKlass *)(__bridge void *)_impl::$s9UseObjCTy03retB5ClassSo0B6CKlassCyF();
6464

65-
// CHECK: inline ObjCKlass *_Nullable retObjClassNullable() noexcept SWIFT_WARN_UNUSED_RESULT {
65+
// CHECK: inline ObjCKlass *_Nullable retObjClassNullable() noexcept SWIFT_SYMBOL({{.*}}) SWIFT_WARN_UNUSED_RESULT {
6666
// CHECK-NEXT: return (__bridge_transfer ObjCKlass *)(__bridge void *)_impl::$s9UseObjCTy03retB13ClassNullableSo0B6CKlassCSgyF();
6767

68-
// CHECK: void takeObjCClass(ObjCKlass *_Nonnull x) noexcept {
68+
// CHECK: void takeObjCClass(ObjCKlass *_Nonnull x) noexcept SWIFT_SYMBOL({{.*}}) {
6969
// CHECK-NEXT: return _impl::$s9UseObjCTy04takeB6CClassyySo0B6CKlassCF(x);
7070

71-
// CHECK: inline void takeObjCClassInout(ObjCKlass *_Nonnull __strong & x) noexcept {
71+
// CHECK: inline void takeObjCClassInout(ObjCKlass *_Nonnull __strong & x) noexcept SWIFT_SYMBOL({{.*}}) {
7272
// CHECK-NEXT: return _impl::$s9UseObjCTy04takeB11CClassInoutyySo0B6CKlassCzF(&x);
7373

74-
// CHECK: inline void takeObjCClassNullable(ObjCKlass *_Nullable x) noexcept {
74+
// CHECK: inline void takeObjCClassNullable(ObjCKlass *_Nullable x) noexcept SWIFT_SYMBOL({{.*}}) {
7575
// CHECK-NEXT: return _impl::$s9UseObjCTy04takeB14CClassNullableyySo0B6CKlassCSgF(x);

test/Interop/SwiftToCxx/class/swift-actor-in-cxx.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ public final actor ActorWithField {
3030
}
3131
}
3232

33-
// CHECK: namespace Actor __attribute__((swift_private)) {
33+
// CHECK: namespace Actor __attribute__((swift_private)) SWIFT_SYMBOL_MODULE("Actor") {
3434
// CHECK: SWIFT_EXTERN void * _Nonnull $s5Actor0A9WithFieldCACycfC(SWIFT_CONTEXT void * _Nonnull _self) SWIFT_NOEXCEPT SWIFT_CALL; // init()
3535
// CHECK: SWIFT_EXTERN void $s5Actor0A9WithFieldC6methodyyF(SWIFT_CONTEXT void * _Nonnull _self) SWIFT_NOEXCEPT SWIFT_CALL; // method()
3636

37-
// CHECK: class ActorWithField final : public swift::_impl::RefCountedClass {
38-
// CHECK: static inline ActorWithField init();
39-
// CHECK: inline void method();
37+
// CHECK: class SWIFT_SYMBOL("s:5Actor0A9WithFieldC") ActorWithField final : public swift::_impl::RefCountedClass {
38+
// CHECK: static inline ActorWithField init() SWIFT_SYMBOL("s:5Actor0A9WithFieldCACycfc");
39+
// CHECK: inline void method() SWIFT_SYMBOL("s:5Actor0A9WithFieldC6methodyyF");
4040

4141
@_expose(Cxx)
4242
public func takeActorWithIntField(_ x: ActorWithField) {

0 commit comments

Comments
 (0)