Skip to content

Commit eb37ea3

Browse files
committed
IRGen: Avoid emitting Obj-C method metadata for unavailable methods.
Resolves rdar://109911571
1 parent af1df92 commit eb37ea3

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

lib/IRGen/GenClass.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,9 @@ namespace {
18311831

18321832
void buildMethod(ConstantArrayBuilder &descriptors,
18331833
AbstractFunctionDecl *method) {
1834+
if (Lowering::shouldSkipLowering(method))
1835+
return;
1836+
18341837
auto accessor = dyn_cast<AccessorDecl>(method);
18351838
if (!accessor)
18361839
return emitObjCMethodDescriptor(IGM, descriptors, method);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library -module-name Test -validate-tbd-against-ir=missing %s -emit-ir | %FileCheck %s --check-prefixes=CHECK,CHECK-NO-STRIP
2+
3+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -parse-as-library -module-name Test -validate-tbd-against-ir=missing -unavailable-decl-optimization=complete %s -emit-ir | %FileCheck %s --check-prefixes=CHECK,CHECK-STRIP
4+
5+
// REQUIRES: objc_interop
6+
7+
import Foundation
8+
9+
public class Derived: SecureCodingObject {
10+
// CHECK-NO-STRIP: define {{.*}} @"$s4Test7DerivedC5coderACSgSo7NSCoderC_tcfc"
11+
// CHECK-STRIP-NOT: define {{.*}} @"$s4Test7DerivedC5coderACSgSo7NSCoderC_tcfc"
12+
13+
// CHECK-NO-STRIP: define {{.*}} @"$s4Test7DerivedC5coderACSgSo7NSCoderC_tcfcTo"
14+
// CHECK-STRIP-NOT: define {{.*}} @"$s4Test7DerivedC5coderACSgSo7NSCoderC_tcfcTo"
15+
@available(*, unavailable)
16+
required init?(coder: NSCoder) {
17+
fatalError()
18+
}
19+
}

test/Inputs/clang-importer-sdk/usr/include/Foundation.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@ typedef NSPoint *NSPointArray;
315315
- (void)setObject:(id)object forKeyedSubscript:(id)key;
316316
@end
317317

318+
@interface SecureCodingObject: NSObject <NSSecureCoding>
319+
- (instancetype)init;
320+
- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder;
321+
@end
322+
318323
//===---
319324
// Enums.
320325
//===---

0 commit comments

Comments
 (0)