Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 1a520f8

Browse files
committed
ObjC Class Property: don't emit class properties on old deployment targets.
For old deployment targets, emit nil for all class property lists. rdar://25616128 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@266800 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 5ffb3d9 commit 1a520f8

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

lib/CodeGen/CGObjCMac.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,6 +2953,15 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name,
29532953
const ObjCContainerDecl *OCD,
29542954
const ObjCCommonTypesHelper &ObjCTypes,
29552955
bool IsClassProperty) {
2956+
if (IsClassProperty) {
2957+
// Make this entry NULL for OS X with deployment target < 10.11, for iOS
2958+
// with deployment target < 9.0.
2959+
const llvm::Triple &Triple = CGM.getTarget().getTriple();
2960+
if ((Triple.isMacOSX() && Triple.isMacOSXVersionLT(10, 11)) ||
2961+
(Triple.isiOS() && Triple.isOSVersionLT(9)))
2962+
return llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy);
2963+
}
2964+
29562965
SmallVector<llvm::Constant *, 16> Properties;
29572966
llvm::SmallPtrSet<const IdentifierInfo*, 16> PropertySet;
29582967

test/CodeGenObjC/metadata-class-properties.m

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s
2-
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck -check-prefix=CHECK-FRAGILE %s
1+
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - %s | FileCheck %s
2+
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-NULL %s
3+
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11 -emit-llvm -o - -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck -check-prefix=CHECK-FRAGILE %s
34

45
// CHECK: @"\01l_OBJC_$_CLASS_PROP_LIST_Proto" = private global {{.*}} section "__DATA, __objc_const", align 8
56
// CHECK: @"\01l_OBJC_PROTOCOL_$_Proto" = {{.*}} global %struct._protocol_t { {{.*}} i32 96, i32 {{.*}} @"\01l_OBJC_$_CLASS_PROP_LIST_Proto" {{.*}} }
@@ -11,6 +12,16 @@
1112

1213
// CHECK: !{i32 1, !"Objective-C Class Properties", i32 64}
1314

15+
// CHECK-NULL-NOT: @"\01l_OBJC_$_CLASS_PROP_LIST_Proto"
16+
// CHECK-NULL: @"\01l_OBJC_PROTOCOL_$_Proto" = {{.*}} global %struct._protocol_t { {{.*}} %struct._prop_list_t* null, i32 96, i32 {{.*}} %struct._prop_list_t* null }
17+
// CHECK-NULL-NOT: @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_$_Category" = private global {{.*}} section "__DATA, __objc_const", align 8
18+
// CHECK-NULL: @"\01l_OBJC_$_CATEGORY_Foo_$_Category" = private global %struct._category_t { {{.*}} %struct._prop_list_t* null, %struct._prop_list_t* null, {{.*}} }, section "__DATA, __objc_const", align 8
19+
20+
// CHECK-NULL-NOT: @"\01l_OBJC_$_CLASS_PROP_LIST_C" = private global {{.*}} section "__DATA, __objc_const", align 8
21+
// CHECK-NULL: @"\01l_OBJC_METACLASS_RO_$_C" = private global %struct._class_ro_t { {{.*}} %struct._prop_list_t* null }, section "__DATA, __objc_const", align 8
22+
23+
// CHECK-NULL: !{i32 1, !"Objective-C Class Properties", i32 64}
24+
1425
// CHECK-FRAGILE: @"OBJC_$_CLASS_PROP_PROTO_LIST_Proto" = private global {{.*}} section "__OBJC,__property,regular,no_dead_strip", align 8
1526
// CHECK-FRAGILE: @"\01l_OBJC_PROTOCOLEXT_Proto" = private global %struct._objc_protocol_extension { i32 48, {{.*}} @"OBJC_$_CLASS_PROP_PROTO_LIST_Proto" {{.*}} }, align 8
1627
// CHECK-FRAGILE: @"\01l_OBJC_$_CLASS_PROP_LIST_Foo_Category" = private global {{.*}} section "__OBJC,__property,regular,no_dead_strip", align 8

0 commit comments

Comments
 (0)