1 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime-has-weak -o - -std=c++11 %s | FileCheck %s
3 // CHECK: @[[CFSTRING:[a-z0-9_]+]] = private global %struct.__NSConstantString_tag
6 // CHECK-LABEL: define{{.*}} void @_Z5test1v
7 // CHECK: %[[ALLOCA:[A-Z]+]] = alloca ptr
8 // CHECK: %[[V0:[0-9]+]] = call ptr @llvm.objc.retain(ptr @[[CFSTRING]]
9 // CHECK: store ptr %[[V0]], ptr %[[ALLOCA]]
10 // CHECK: call void @llvm.objc.storeStrong(ptr %[[ALLOCA]], ptr null)
12 constexpr NSString *S = @"abc";
15 // CHECK-LABEL: define{{.*}} void @_Z5test2v
16 // CHECK: %[[CONST:[a-zA-Z]+]] = alloca ptr
17 // CHECK: %[[REF_CONST:[a-zA-Z]+]] = alloca ptr
18 // CHECK: %[[V0:[0-9]+]] = call ptr @llvm.objc.retain(ptr @[[CFSTRING]]
19 // CHECK-NEXT: store ptr %[[V0]], ptr %[[CONST]]
20 // CHECK: %[[V2:[0-9]+]] = call ptr @llvm.objc.retain(ptr @[[CFSTRING]]
21 // CHECK-NEXT: store ptr %[[V2]], ptr %[[REF_CONST]]
22 // CHECK-NEXT: call void @llvm.objc.storeStrong(ptr %[[REF_CONST]], ptr null)
23 // CHECK-NEXT: call void @llvm.objc.storeStrong(ptr %[[CONST]], ptr null)
25 constexpr NSString *Const = @"abc";
26 // In IR RefConst should be initialized with Const initializer instead of
27 // reading from variable.
28 NSString* RefConst = Const;
31 // CHECK-LABEL: define{{.*}} void @_Z5test3v
32 // CHECK: %[[WEAK_CONST:[a-zA-Z]+]] = alloca ptr
33 // CHECK: %[[REF_WEAK_CONST:[a-zA-Z]+]] = alloca ptr
34 // CHECK-NEXT: %[[V1:[0-9]+]] = call ptr @llvm.objc.initWeak(ptr %[[WEAK_CONST]], ptr @[[CFSTRING]]
35 // CHECK: store ptr @[[CFSTRING]], ptr %[[REF_WEAK_CONST]]
36 // CHECK-NEXT: call void @llvm.objc.storeStrong(ptr %[[REF_WEAK_CONST]], ptr null)
37 // CHECK-NEXT: call void @llvm.objc.destroyWeak(ptr %[[WEAK_CONST]])
39 __weak constexpr NSString *WeakConst = @"abc";
40 NSString* RefWeakConst = WeakConst;