Skip to content

Commit 4e1987f

Browse files
authored
[TBDGen] don't add "_" when adding objc classes to swift TBD (#35621)
This entry is incorrect and causes tapi pedantic check to fail. <rdar://problem/73664795>
1 parent 96397ec commit 4e1987f

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lib/TBDGen/TBDGen.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,16 @@ void TBDGenVisitor::addLinkerDirectiveSymbolsLdHide(StringRef name,
396396

397397
void TBDGenVisitor::addSymbol(StringRef name, SymbolSource source,
398398
SymbolKind kind) {
399-
// The linker expects to see mangled symbol names in TBD files, so make sure
400-
// to mangle before inserting the symbol.
399+
// The linker expects to see mangled symbol names in TBD files,
400+
// except when being passed objective c classes,
401+
// so make sure to mangle before inserting the symbol.
401402
SmallString<32> mangled;
402-
llvm::Mangler::getNameWithPrefix(mangled, name, DataLayout);
403+
if (kind == SymbolKind::ObjectiveCClass) {
404+
mangled = name;
405+
} else {
406+
llvm::Mangler::getNameWithPrefix(mangled, name, DataLayout);
407+
}
408+
403409
addSymbolInternal(mangled, kind, source);
404410
if (previousInstallNameMap) {
405411
addLinkerDirectiveSymbolsLdPrevious(mangled, kind);

test/TBD/implied_objc_symbols.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// REQUIRES: VENDOR=apple
2+
// RUN: %empty-directory(%t)
3+
4+
// RUN: echo "import Foundation" > %t/main.swift
5+
// RUN: echo "@objc(CApi) public class Api {}" >> %t/main.swift
6+
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -import-objc-header %S/Inputs/objc_class_header.h -validate-tbd-against-ir=missing %t/main.swift -disable-objc-attr-requires-foundation-module -emit-tbd -emit-tbd-path %t/main.tbd
7+
8+
// RUN: %FileCheck %s < %t/main.tbd
9+
10+
// CHECK: objc-classes: [ CApi ]

0 commit comments

Comments
 (0)