1// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-10.7 -emit-llvm -o - | FileCheck %s
2// RUN: %clang_cc1 %s -triple x86_64-unknown-freebsd -fobjc-runtime=gnustep-1.7 -emit-llvm -o - | FileCheck -check-prefix=CHECK-GNUSTEP %s
3// rdar://6137845
4
5extern int DEFAULT();
6
7struct TCPPObject
8{
9 TCPPObject();
10 ~TCPPObject();
11 TCPPObject(const TCPPObject& inObj, int i = DEFAULT());
12 TCPPObject& operator=(const TCPPObject& inObj);
13 int filler[64];
14};
15
16
17@interface MyDocument
18{
19@private
20 TCPPObject _cppObject;
21 TCPPObject _cppObject1;
22}
23@property (assign, readwrite, atomic) const TCPPObject MyProperty;
24@property (assign, readwrite, atomic) const TCPPObject MyProperty1;
25@end
26
27@implementation MyDocument
28  @synthesize MyProperty = _cppObject;
29  @synthesize MyProperty1 = _cppObject1;
30@end
31
32// CHECK-LABEL: define internal void @__copy_helper_atomic_property_(
33// CHECK: [[TWO:%.*]] = load %struct.TCPPObject** [[ADDR:%.*]], align 8
34// CHECK: [[THREE:%.*]] = load %struct.TCPPObject** [[ADDR1:%.*]], align 8
35// CHECK: [[CALL:%.*]] = call i32 @_Z7DEFAULTv()
36// CHECK:  call void @_ZN10TCPPObjectC1ERKS_i(%struct.TCPPObject* [[TWO]], %struct.TCPPObject* [[THREE]], i32 [[CALL]])
37// CHECK:  ret void
38
39// CHECK: define internal void @"\01-[MyDocument MyProperty]"(
40// CHECK: [[ONE:%.*]] = bitcast i8* [[ADDPTR:%.*]] to %struct.TCPPObject*
41// CHECK: [[TWO:%.*]] = bitcast %struct.TCPPObject* [[ONE]] to i8*
42// CHECK: [[THREE:%.*]] = bitcast %struct.TCPPObject* [[AGGRESULT:%.*]] to i8*
43// CHECK: call void @objc_copyCppObjectAtomic(i8* [[THREE]], i8* [[TWO]], i8* bitcast (void (%struct.TCPPObject*, %struct.TCPPObject*)* @__copy_helper_atomic_property_ to i8*))
44// CHECK: ret void
45
46// CHECK-LABEL: define internal void @__assign_helper_atomic_property_(
47// CHECK: [[TWO:%.*]] = load %struct.TCPPObject** [[ADDR:%.*]], align 8
48// CHECK: [[THREE:%.*]] = load %struct.TCPPObject** [[ADDR1:%.*]], align 8
49// CHECK: [[CALL:%.*]] = call %struct.TCPPObject* @_ZN10TCPPObjectaSERKS_(%struct.TCPPObject* [[TWO]], %struct.TCPPObject* [[THREE]])
50// CHECK:  ret void
51
52// CHECK: define internal void @"\01-[MyDocument setMyProperty:]"(
53// CHECK: [[ONE:%.*]] = bitcast i8* [[ADDRPTR:%.*]] to %struct.TCPPObject*
54// CHECK: [[TWO:%.*]] = bitcast %struct.TCPPObject* [[ONE]] to i8*
55// CHECK: [[THREE:%.*]] = bitcast %struct.TCPPObject* [[MYPROPERTY:%.*]] to i8*
56// CHECK: call void @objc_copyCppObjectAtomic(i8* [[TWO]], i8* [[THREE]], i8* bitcast (void (%struct.TCPPObject*, %struct.TCPPObject*)* @__assign_helper_atomic_property_ to i8*))
57// CHECK: ret void
58
59// CHECK-GNUSTEP: objc_getCppObjectAtomic
60// CHECK-GNUSTEP: objc_setCppObjectAtomic
61