Skip to content

Commit 0f266b8

Browse files
authored
Merge pull request #63081 from apple/conditional-runtime-records-fix
Fix -conditional-runtime-records crash on @objc protocols
2 parents d192bfc + e2a95df commit 0f266b8

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3810,7 +3810,7 @@ getTypeContextDescriptorEntityReference(IRGenModule &IGM,
38103810

38113811
static TypeEntityReference
38123812
getProtocolDescriptorEntityReference(IRGenModule &IGM, ProtocolDecl *protocol) {
3813-
assert(!protocol->isObjC() &&
3813+
assert(!protocol->hasClangNode() &&
38143814
"objc protocols don't have swift protocol descriptors");
38153815
auto entity = LinkEntity::forProtocolDescriptor(protocol);
38163816
return getContextDescriptorEntityReference(IGM, entity);
@@ -3830,7 +3830,7 @@ getObjCClassByNameReference(IRGenModule &IGM, ClassDecl *cls) {
38303830
TypeEntityReference
38313831
IRGenModule::getTypeEntityReference(GenericTypeDecl *decl) {
38323832
if (auto protocol = dyn_cast<ProtocolDecl>(decl)) {
3833-
assert(!protocol->isObjC() && "imported protocols not handled here");
3833+
assert(!protocol->hasClangNode() && "imported protocols not handled here");
38343834
return getProtocolDescriptorEntityReference(*this, protocol);
38353835
}
38363836

test/IRGen/conditional-dead-strip-objc-ir.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@
66

77
// RUN: %target-build-swift -Xfrontend -conditional-runtime-records %s -emit-ir -o - | %FileCheck %s
88

9+
import Foundation
10+
911
public class Class {
1012
}
1113

14+
@objc public protocol ObjCAnnotatedProtocol {
15+
}
16+
1217
// CHECK: @llvm.{{(compiler.)?}}used = appending global [
1318
// CHECK-SAME: @"$s4main5ClassCHn"
1419
// CHECK-SAME: ], section "llvm.metadata"
1520

16-
// CHECK: !llvm.used.conditional = !{[[M1:!.*]], [[M2:!.*]], [[O1:!.*]]}
21+
// CHECK: !llvm.used.conditional = !{[[M1:!.*]], [[M2:!.*]], [[M3:!.*]], [[O1:!.*]]}
1722

1823
// CHECK-DAG: [[M1]] = !{{{.*}} @"$s4main5ClassCMF", i32 0, [[M1A:!.*]]}
1924
// CHECK-DAG: [[M1A]] = !{{{.*}} @"$s4main5ClassCMn"
20-
// CHECK-DAG: [[M2]] = !{{{.*}} @"$s4main5ClassCHn", i32 0, [[M1A:!.*]]}
25+
// CHECK-DAG: [[M2]] = !{{{.*}} @"$s4main21ObjCAnnotatedProtocol_pMF", i32 0, [[M2A:!.*]]}
26+
// CHECK-DAG: [[M2A]] = !{{{.*}} @"$s4main21ObjCAnnotatedProtocolMp"
27+
// CHECK-DAG: [[M3]] = !{{{.*}} @"$s4main5ClassCHn", i32 0, [[M1A:!.*]]}
2128

2229
// CHECK-DAG: [[O1]] = !{{{.*}} @"objc_classes_$s4main5ClassCN", i32 0, [[O1A:!.*]]}
2330
// CHECK-DAG: [[O1A]] = !{{{.*}} @"$s4main5ClassCN"}

0 commit comments

Comments
 (0)