xref: /aosp_15_r20/external/clang/test/CodeGenObjC/property-list-in-extension.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-weak -fobjc-runtime-has-weak -emit-llvm %s -o - | FileCheck %s
2*67e74705SXin Li
3*67e74705SXin Li// Checks metadata for properties in a few cases.
4*67e74705SXin Li
5*67e74705SXin Li
6*67e74705SXin Li// Property from a class extension:
7*67e74705SXin Li__attribute__((objc_root_class))
8*67e74705SXin Li@interface Foo
9*67e74705SXin Li@end
10*67e74705SXin Li
11*67e74705SXin Li@interface Foo()
12*67e74705SXin Li@property int myprop;
13*67e74705SXin Li@end
14*67e74705SXin Li
15*67e74705SXin Li@implementation Foo
16*67e74705SXin Li@synthesize myprop = _myprop;
17*67e74705SXin Li@end
18*67e74705SXin Li// Metadata for _myprop should be present, and PROP_LIST for Foo should have
19*67e74705SXin Li// only one entry.
20*67e74705SXin Li// CHECK: = private global [12 x i8] c"Ti,V_myprop\00",
21*67e74705SXin Li// CHECK: @"\01l_OBJC_$_PROP_LIST_Foo" = private global { i32, i32, [1 x %struct._prop_t] }
22*67e74705SXin Li
23*67e74705SXin Li// Readonly property in interface made readwrite in a category:
24*67e74705SXin Li__attribute__((objc_root_class))
25*67e74705SXin Li@interface FooRO
26*67e74705SXin Li@property (readonly) int evolvingprop;
27*67e74705SXin Li@property (nonatomic,readonly,getter=isBooleanProp) int booleanProp;
28*67e74705SXin Li@property (nonatomic,readonly,weak) Foo *weakProp;
29*67e74705SXin Li@end
30*67e74705SXin Li
31*67e74705SXin Li@interface FooRO ()
32*67e74705SXin Li@property int evolvingprop;
33*67e74705SXin Li@property int booleanProp;
34*67e74705SXin Li@property Foo *weakProp;
35*67e74705SXin Li@end
36*67e74705SXin Li
37*67e74705SXin Li@implementation FooRO
38*67e74705SXin Li@synthesize evolvingprop = _evolvingprop;
39*67e74705SXin Li@end
40*67e74705SXin Li// Metadata for _evolvingprop should be present, and PROP_LIST for FooRO should
41*67e74705SXin Li// still have only one entry, and the one entry should point to the version of
42*67e74705SXin Li// the property with a getter and setter.
43*67e74705SXin Li// CHECK: [[evolvinggetter:@OBJC_PROP_NAME_ATTR[^ ]+]] = private global [13 x i8] c"evolvingprop\00"
44*67e74705SXin Li// CHECK: [[evolvingsetter:@OBJC_PROP_NAME_ATTR[^ ]+]] = private global [18 x i8] c"Ti,V_evolvingprop\00",
45*67e74705SXin Li// CHECK: [[booleanmetadata:@OBJC_PROP_NAME_ATTR[^ ]+]] = private global [34 x i8] c"Ti,N,GisBooleanProp,V_booleanProp\00"
46*67e74705SXin Li// CHECK: [[weakmetadata:@OBJC_PROP_NAME_ATTR[^ ]+]] = private global [23 x i8] c"T@\22Foo\22,W,N,V_weakProp\00"
47*67e74705SXin Li// CHECK: @"\01l_OBJC_$_PROP_LIST_FooRO" = private global { i32, i32, [3 x %struct._prop_t] }{{.*}}[[evolvinggetter]]{{.*}}[[evolvingsetter]]{{.*}}[[booleanmetadata]]
48