Skip to content

Commit e2a95df

Browse files
NuriAmariNuri Amari
authored andcommitted
Fix -conditional-runtime-records crash with @objc annotated protocols
1 parent 3d36113 commit e2a95df

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
@@ -3811,7 +3811,7 @@ getTypeContextDescriptorEntityReference(IRGenModule &IGM,
38113811

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

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)