brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 28586ef Raw
93 lines · plain
1// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - | FileCheck %s2 3struct MyStruct {4  int x;5  int y;6  int z;7};8 9@interface MyClass {10  MyStruct _foo;11}12 13@property (assign, readwrite) const MyStruct& foo;14 15- (const MyStruct&) foo;16- (void) setFoo:(const MyStruct&)inFoo;17@end18 19void test0() {20  MyClass* myClass;21  MyStruct myStruct;22 23  myClass.foo = myStruct;24 25  const MyStruct& currentMyStruct = myClass.foo;   26}27 28// CHECK: [[C:%.*]] = call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @objc_msgSend29// CHECK:   store ptr [[C]], ptr [[D:%.*]]30 31namespace test1 {32  struct A { A(); A(const A&); A&operator=(const A&); ~A(); };33}34@interface Test1 {35  test1::A ivar;36}37@property (nonatomic) const test1::A &prop1;38@end39@implementation Test140@synthesize prop1 = ivar;41@end42// CHECK:    define internal noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @"\01-[Test1 prop1]"(43// CHECK:      [[SELF:%.*]] = alloca ptr, align 844// CHECK:      [[T0:%.*]] = load ptr, ptr [[SELF]]45// CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds i8, ptr [[T0]], i64 046// CHECK-NEXT: ret ptr [[T2]]47 48// CHECK:    define internal void @"\01-[Test1 setProp1:]"(49// CHECK:      call noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_ZN5test11AaSERKS0_(50// CHECK-NEXT: ret void51 52@interface Test253@property int prop;54@end55 56// The fact that these are all non-dependent is critical.57template <class T> void test2(Test2 *a) {58  int x = a.prop;59  a.prop = x;60  a.prop += x;61}62template void test2<int>(Test2*);63// CHECK-LABEL: define weak_odr void @_Z5test2IiEvP5Test2(64// CHECK: [[X:%.*]] = alloca i32,65// CHECK:      @objc_msgSend66// CHECK:      store i32 {{%.*}}, ptr [[X]],67// CHECK:      load i32, ptr [[X]],68// CHECK:      @objc_msgSend69// CHECK:      @objc_msgSend70// CHECK:      load i32, ptr [[X]],71// CHECK-NEXT: add nsw72// CHECK:      @objc_msgSend73// CHECK-NEXT: ret void74 75// Same as the previous test, but instantiation-dependent.76template <class T> void test3(Test2 *a) {77  int x = (sizeof(T), a).prop;78  a.prop = (sizeof(T), x);79  a.prop += (sizeof(T), x);80}81template void test3<int>(Test2*);82// CHECK-LABEL: define weak_odr void @_Z5test3IiEvP5Test2(83// CHECK: [[X:%.*]] = alloca i32,84// CHECK:      @objc_msgSend85// CHECK:      store i32 {{%.*}}, ptr [[X]],86// CHECK:      load i32, ptr [[X]],87// CHECK:      @objc_msgSend88// CHECK:      @objc_msgSend89// CHECK:      load i32, ptr [[X]],90// CHECK-NEXT: add nsw91// CHECK:      @objc_msgSend92// CHECK-NEXT: ret void93