1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fblocks -fobjc-arc -fobjc-runtime-has-weak -std=c++11 -o - %s | FileCheck %s 2 3 __attribute((objc_root_class)) @interface A @end 4 @interface B : A @end 5 6 // rdar://problem/23559789 7 // Ensure that type differences don't cause an assert here. 8 void test0(__weak B **src) { 9 __weak A *dest = *src; 10 } 11 // CHECK-LABEL: define void @_Z5test0PU6__weakP1B( 12 // CHECK: [[SRC:%.*]] = alloca [[B:%.*]]**, align 8 13 // CHECK: [[DEST:%.*]] = alloca [[A:%.*]]*, align 8 14 // CHECK: [[T0:%.*]] = load [[B]]**, [[B]]*** [[SRC]], align 8 15 // CHECK-NEXT: [[T1:%.*]] = bitcast [[B]]** [[T0]] to [[A]]** 16 // CHECK-NEXT: [[T2:%.*]] = bitcast [[A]]** [[DEST]] to i8** 17 // CHECK-NEXT: [[T3:%.*]] = bitcast [[A]]** [[T1]] to i8** 18 // CHECK-NEXT: call void @objc_copyWeak(i8** [[T2]], i8** [[T3]]) 19 // CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]** [[DEST]] to i8** 20 // CHECK: call void @objc_destroyWeak(i8** [[T0]]) 21 22 void test1(__weak B **src) { 23 __weak A *dest = static_cast<__weak B*&&>(*src); 24 } 25 // CHECK-LABEL: define void @_Z5test1PU6__weakP1B( 26 // CHECK: [[SRC:%.*]] = alloca [[B:%.*]]**, align 8 27 // CHECK: [[DEST:%.*]] = alloca [[A:%.*]]*, align 8 28 // CHECK: [[T0:%.*]] = load [[B]]**, [[B]]*** [[SRC]], align 8 29 // CHECK-NEXT: [[T1:%.*]] = bitcast [[B]]** [[T0]] to [[A]]** 30 // CHECK-NEXT: [[T2:%.*]] = bitcast [[A]]** [[DEST]] to i8** 31 // CHECK-NEXT: [[T3:%.*]] = bitcast [[A]]** [[T1]] to i8** 32 // CHECK-NEXT: call void @objc_moveWeak(i8** [[T2]], i8** [[T3]]) 33 // CHECK-NEXT: [[T0:%.*]] = bitcast [[A]]** [[DEST]] to i8** 34 // CHECK: call void @objc_destroyWeak(i8** [[T0]]) 35