1 // RUN: %clang_cc1 -I %S/Inputs -triple armv7-apple-ios8.0.0 -emit-llvm -fobjc-arc -O2 -disable-llvm-passes -o - %s | FileCheck %s
3 #import "nsvalue-boxed-expressions-support.h"
5 // CHECK: [[CLASS:@.*]] = external global %struct._class_t
6 // CHECK: [[NSVALUE:@.*]] = {{.*}}[[CLASS]]{{.*}}
7 // CHECK: [[RANGE_STR:.*]] = {{.*}}_NSRange=II{{.*}}
8 // CHECK: [[METH:@.*]] = private unnamed_addr constant {{.*}}valueWithBytes:objCType:{{.*}}
9 // CHECK: [[VALUE_SEL:@.*]] = {{.*}}[[METH]]{{.*}}
10 // CHECK: [[POINT_STR:.*]] = {{.*}}CGPoint=dd{{.*}}
11 // CHECK: [[SIZE_STR:.*]] = {{.*}}CGSize=dd{{.*}}
12 // CHECK: [[RECT_STR:.*]] = {{.*}}CGRect={CGPoint=dd}{CGSize=dd}}{{.*}}
13 // CHECK: [[EDGE_STR:.*]] = {{.*}}NSEdgeInsets=dddd{{.*}}
15 // CHECK-LABEL: define{{.*}} void @doRange()
17 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct._NSRange{{.*}}
18 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct._NSRange{{.*}}
19 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
20 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_VAR]]{{.*}} [[LOCAL_VAR]]{{.*}}
21 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
22 NSRange ns_range = { .location = 0, .length = 42 };
23 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[TEMP_VAR]], ptr {{.*}}[[RANGE_STR]]{{.*}})
24 // CHECK: call ptr @llvm.objc.retainAutoreleasedReturnValue
25 NSValue *range = @(ns_range);
26 // CHECK: call void @llvm.objc.release
30 // CHECK-LABEL: define{{.*}} void @doPoint()
32 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGPoint{{.*}}
33 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGPoint{{.*}}
34 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
35 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_VAR]]{{.*}} [[LOCAL_VAR]]{{.*}}
36 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
37 CGPoint cg_point = { .x = 42, .y = 24 };
38 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[TEMP_VAR]], ptr {{.*}}[[POINT_STR]]{{.*}})
39 // CHECK: call ptr @llvm.objc.retainAutoreleasedReturnValue
40 NSValue *point = @(cg_point);
41 // CHECK: call void @llvm.objc.release
45 // CHECK-LABEL: define{{.*}} void @doSize()
47 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGSize{{.*}}
48 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGSize{{.*}}
49 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
50 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_VAR]]{{.*}} [[LOCAL_VAR]]{{.*}}
51 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
52 CGSize cg_size = { .width = 42, .height = 24 };
53 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[TEMP_VAR]], ptr {{.*}}[[SIZE_STR]]{{.*}})
54 // CHECK: call ptr @llvm.objc.retainAutoreleasedReturnValue
55 NSValue *size = @(cg_size);
56 // CHECK: call void @llvm.objc.release
60 // CHECK-LABEL: define{{.*}} void @doRect()
62 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGRect{{.*}}
63 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGRect{{.*}}
64 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
65 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_VAR]]{{.*}} [[LOCAL_VAR]]{{.*}}
66 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
67 CGPoint cg_point = { .x = 42, .y = 24 };
68 CGSize cg_size = { .width = 42, .height = 24 };
69 CGRect cg_rect = { .origin = cg_point, .size = cg_size };
70 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[TEMP_VAR]], ptr{{.*}}[[RECT_STR]]{{.*}})
71 // CHECK: call ptr @llvm.objc.retainAutoreleasedReturnValue
72 NSValue *rect = @(cg_rect);
73 // CHECK: call void @llvm.objc.release
77 // CHECK-LABEL: define{{.*}} void @doNSEdgeInsets()
78 void doNSEdgeInsets(void) {
79 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
80 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
81 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
82 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_VAR]]{{.*}} [[LOCAL_VAR]]{{.*}}
83 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
84 NSEdgeInsets ns_edge_insets;
85 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[TEMP_VAR]], ptr{{.*}}[[EDGE_STR]]{{.*}})
86 // CHECK: call ptr @llvm.objc.retainAutoreleasedReturnValue
87 NSValue *edge_insets = @(ns_edge_insets);
88 // CHECK: call void @llvm.objc.release
92 // CHECK-LABEL: define{{.*}} void @doRangeRValue()
93 void doRangeRValue(void) {
94 // CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}}
95 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
96 // CHECK: call {{.*}} @getRange({{.*}} [[COERCE]])
97 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
98 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[COERCE]], ptr {{.*}}[[RANGE_STR]]{{.*}})
99 // CHECK: call ptr @llvm.objc.retainAutoreleasedReturnValue
100 NSValue *range_rvalue = @(getRange());
101 // CHECK: call void @llvm.objc.release