2012-06-20 14:18:46 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - | FileCheck %s
|
2011-03-31 00:11:20 +08:00
|
|
|
// rdar://9208606
|
|
|
|
|
2011-09-13 14:00:03 +08:00
|
|
|
struct MyStruct {
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int z;
|
2011-03-31 00:11:20 +08:00
|
|
|
};
|
|
|
|
|
2011-09-13 14:00:03 +08:00
|
|
|
@interface MyClass {
|
|
|
|
MyStruct _foo;
|
2011-03-31 00:11:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
@property (assign, readwrite) const MyStruct& foo;
|
|
|
|
|
|
|
|
- (const MyStruct&) foo;
|
|
|
|
- (void) setFoo:(const MyStruct&)inFoo;
|
|
|
|
@end
|
|
|
|
|
2011-09-13 14:00:03 +08:00
|
|
|
void test0() {
|
|
|
|
MyClass* myClass;
|
|
|
|
MyStruct myStruct;
|
2011-03-31 00:11:20 +08:00
|
|
|
|
2011-09-13 14:00:03 +08:00
|
|
|
myClass.foo = myStruct;
|
2011-03-31 00:11:20 +08:00
|
|
|
|
2011-09-13 14:00:03 +08:00
|
|
|
const MyStruct& currentMyStruct = myClass.foo;
|
2011-03-31 00:11:20 +08:00
|
|
|
}
|
|
|
|
|
2021-11-09 01:09:49 +08:00
|
|
|
// CHECK: [[C:%.*]] = call nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %struct.MyStruct* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend
|
2011-03-31 00:11:20 +08:00
|
|
|
// CHECK: store %struct.MyStruct* [[C]], %struct.MyStruct** [[D:%.*]]
|
2011-09-13 14:00:03 +08:00
|
|
|
|
|
|
|
namespace test1 {
|
|
|
|
struct A { A(); A(const A&); A&operator=(const A&); ~A(); };
|
|
|
|
}
|
|
|
|
@interface Test1 {
|
|
|
|
test1::A ivar;
|
|
|
|
}
|
2012-01-07 06:33:54 +08:00
|
|
|
@property (nonatomic) const test1::A &prop1;
|
2011-09-13 14:00:03 +08:00
|
|
|
@end
|
|
|
|
@implementation Test1
|
|
|
|
@synthesize prop1 = ivar;
|
|
|
|
@end
|
2021-11-09 01:09:49 +08:00
|
|
|
// CHECK: define internal nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[A:%.*]]* @"\01-[Test1 prop1]"(
|
2011-09-13 14:00:03 +08:00
|
|
|
// CHECK: [[SELF:%.*]] = alloca [[TEST1:%.*]]*, align 8
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[T0:%.*]] = load [[TEST1]]*, [[TEST1]]** [[SELF]]
|
2011-09-13 14:00:03 +08:00
|
|
|
// CHECK-NEXT: [[T1:%.*]] = bitcast [[TEST1]]* [[T0]] to i8*
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds i8, i8* [[T1]], i64 0
|
2011-09-13 14:00:03 +08:00
|
|
|
// CHECK-NEXT: [[T3:%.*]] = bitcast i8* [[T2]] to [[A]]*
|
|
|
|
// CHECK-NEXT: ret [[A]]* [[T3]]
|
|
|
|
|
|
|
|
// CHECK: define internal void @"\01-[Test1 setProp1:]"(
|
2021-11-09 01:09:49 +08:00
|
|
|
// CHECK: call nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[A]]* @_ZN5test11AaSERKS0_(
|
2011-09-13 14:00:03 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
|
2011-11-30 12:42:31 +08:00
|
|
|
// rdar://problem/10497174
|
|
|
|
@interface Test2
|
|
|
|
@property int prop;
|
|
|
|
@end
|
|
|
|
|
|
|
|
// The fact that these are all non-dependent is critical.
|
|
|
|
template <class T> void test2(Test2 *a) {
|
|
|
|
int x = a.prop;
|
|
|
|
a.prop = x;
|
|
|
|
a.prop += x;
|
|
|
|
}
|
|
|
|
template void test2<int>(Test2*);
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z5test2IiEvP5Test2(
|
2011-11-30 12:42:31 +08:00
|
|
|
// CHECK: [[X:%.*]] = alloca i32,
|
|
|
|
// CHECK: @objc_msgSend
|
|
|
|
// CHECK: store i32 {{%.*}}, i32* [[X]],
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: load i32, i32* [[X]],
|
2011-11-30 12:42:31 +08:00
|
|
|
// CHECK: @objc_msgSend
|
|
|
|
// CHECK: @objc_msgSend
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: load i32, i32* [[X]],
|
2011-11-30 12:42:31 +08:00
|
|
|
// CHECK-NEXT: add nsw
|
|
|
|
// CHECK: @objc_msgSend
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
|
|
|
|
// Same as the previous test, but instantiation-dependent.
|
|
|
|
template <class T> void test3(Test2 *a) {
|
|
|
|
int x = (sizeof(T), a).prop;
|
|
|
|
a.prop = (sizeof(T), x);
|
|
|
|
a.prop += (sizeof(T), x);
|
|
|
|
}
|
|
|
|
template void test3<int>(Test2*);
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define weak_odr void @_Z5test3IiEvP5Test2(
|
2011-11-30 12:42:31 +08:00
|
|
|
// CHECK: [[X:%.*]] = alloca i32,
|
|
|
|
// CHECK: @objc_msgSend
|
|
|
|
// CHECK: store i32 {{%.*}}, i32* [[X]],
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: load i32, i32* [[X]],
|
2011-11-30 12:42:31 +08:00
|
|
|
// CHECK: @objc_msgSend
|
|
|
|
// CHECK: @objc_msgSend
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: load i32, i32* [[X]],
|
2011-11-30 12:42:31 +08:00
|
|
|
// CHECK-NEXT: add nsw
|
|
|
|
// CHECK: @objc_msgSend
|
|
|
|
// CHECK-NEXT: ret void
|