1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-weak -fobjc-runtime-has-weak -std=c++11 -o - %s | FileCheck %s
3 struct A { __weak id x; };
8 A c(static_cast<A&&>(b));
10 c = static_cast<A&&>(a);
14 // Copy Assignment Operator
15 // CHECK-LABEL: define linkonce_odr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_ZN1AaSERKS_(
16 // CHECK: [[THISADDR:%this.*]] = alloca ptr
17 // CHECK: [[OBJECTADDR:%.*]] = alloca ptr
18 // CHECK: [[THIS:%this.*]] = load ptr, ptr [[THISADDR]]
19 // CHECK: [[OBJECT:%.*]] = load ptr, ptr [[OBJECTADDR]]
20 // CHECK: [[T0:%.*]] = getelementptr inbounds [[A:.*]], ptr [[OBJECT]], i32 0, i32 0
21 // CHECK-NEXT: [[T1:%.*]] = call ptr @llvm.objc.loadWeak(ptr [[T0]])
22 // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[A:.*]], ptr [[THIS]], i32 0, i32 0
23 // CHECK-NEXT: [[T3:%.*]] = call ptr @llvm.objc.storeWeak(ptr [[T2]], ptr [[T1]])
25 // Move Assignment Operator
26 // CHECK-LABEL: define linkonce_odr noundef nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) ptr @_ZN1AaSEOS_(
27 // CHECK: [[THISADDR:%this.*]] = alloca ptr
28 // CHECK: [[OBJECTADDR:%.*]] = alloca ptr
29 // CHECK: [[THIS:%this.*]] = load ptr, ptr [[THISADDR]]
30 // CHECK: [[OBJECT:%.*]] = load ptr, ptr [[OBJECTADDR]]
31 // CHECK: [[T0:%.*]] = getelementptr inbounds [[A:.*]], ptr [[OBJECT]], i32 0, i32 0
32 // CHECK-NEXT: [[T1:%.*]] = call ptr @llvm.objc.loadWeak(ptr [[T0]])
33 // CHECK-NEXT: [[T2:%.*]] = getelementptr inbounds [[A:.*]], ptr [[THIS]], i32 0, i32 0
34 // CHECK-NEXT: [[T3:%.*]] = call ptr @llvm.objc.storeWeak(ptr [[T2]], ptr [[T1]])
36 // Default Constructor
37 // CHECK-LABEL: define linkonce_odr void @_ZN1AC2Ev(
38 // CHECK: [[THISADDR:%this.*]] = alloca ptr
39 // CHECK: [[THIS:%this.*]] = load ptr, ptr [[THISADDR]]
40 // CHECK: [[T0:%.*]] = getelementptr inbounds [[A:.*]], ptr [[THIS]], i32 0, i32 0
41 // CHECK-NEXT: store ptr null, ptr [[T0]]
44 // CHECK-LABEL: define linkonce_odr void @_ZN1AC2ERKS_(
45 // CHECK: [[THISADDR:%this.*]] = alloca ptr
46 // CHECK: [[OBJECTADDR:%.*]] = alloca ptr
47 // CHECK: [[THIS:%this.*]] = load ptr, ptr [[THISADDR]]
48 // CHECK: [[T0:%.*]] = getelementptr inbounds [[A:.*]], ptr [[THIS]], i32 0, i32 0
49 // CHECK-NEXT: [[OBJECT:%.*]] = load ptr, ptr [[OBJECTADDR]]
50 // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[A:.*]], ptr [[OBJECT]], i32 0, i32 0
51 // CHECK-NEXT: call void @llvm.objc.copyWeak(ptr [[T0]], ptr [[T1]])
54 // CHECK-LABEL: define linkonce_odr void @_ZN1AC2EOS_(
55 // CHECK: [[THISADDR:%this.*]] = alloca ptr
56 // CHECK: [[OBJECTADDR:%.*]] = alloca ptr
57 // CHECK: [[THIS:%this.*]] = load ptr, ptr [[THISADDR]]
58 // CHECK: [[T0:%.*]] = getelementptr inbounds [[A:.*]], ptr [[THIS]], i32 0, i32 0
59 // CHECK-NEXT: [[OBJECT:%.*]] = load ptr, ptr [[OBJECTADDR]]
60 // CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[A:.*]], ptr [[OBJECT]], i32 0, i32 0
61 // CHECK-NEXT: call void @llvm.objc.moveWeak(ptr [[T0]], ptr [[T1]])
64 // CHECK-LABEL: define linkonce_odr void @_ZN1AD2Ev(
65 // CHECK: [[THISADDR:%this.*]] = alloca ptr
66 // CHECK: [[THIS:%this.*]] = load ptr, ptr [[THISADDR]]
67 // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[A:.*]], ptr [[THIS]], i32 0, i32 0
68 // CHECK-NEXT: call void @llvm.objc.destroyWeak(ptr [[T0]])