1 // RUN: %clang_cc1 -I %S/Inputs -triple armv7-apple-ios8.0.0 -emit-llvm -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: [[TEMP_CAST:%.*]] = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
21 // CHECK: [[LOCAL_CAST:%.*]] = bitcast %struct._NSRange* [[LOCAL_VAR]]{{.*}}
22 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
23 // CHECK: [[PARAM_CAST:%.*]] = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
24 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8*
25 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]]
26 NSRange ns_range = { .location = 0, .length = 42 };
27 // CHECK: call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[PARAM_CAST]], i8* noundef {{.*}}[[RANGE_STR]]{{.*}})
28 NSValue *range = @(ns_range);
32 // CHECK-LABEL: define{{.*}} void @doPoint()
34 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGPoint{{.*}}
35 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGPoint{{.*}}
36 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
37 // CHECK: [[TEMP_CAST:%.*]] = bitcast %struct.CGPoint* [[TEMP_VAR]]{{.*}}
38 // CHECK: [[LOCAL_CAST:%.*]] = bitcast %struct.CGPoint* [[LOCAL_VAR]]{{.*}}
39 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
40 // CHECK: [[PARAM_CAST:%.*]] = bitcast %struct.CGPoint* [[TEMP_VAR]]{{.*}}
41 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8*
42 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]]
43 CGPoint cg_point = { .x = 42, .y = 24 };
44 // CHECK: call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[PARAM_CAST]], i8* noundef {{.*}}[[POINT_STR]]{{.*}})
45 NSValue *point = @(cg_point);
49 // CHECK-LABEL: define{{.*}} void @doSize()
51 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGSize{{.*}}
52 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGSize{{.*}}
53 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
54 // CHECK: [[TEMP_CAST:%.*]] = bitcast %struct.CGSize* [[TEMP_VAR]]{{.*}}
55 // CHECK: [[LOCAL_CAST:%.*]] = bitcast %struct.CGSize* [[LOCAL_VAR]]{{.*}}
56 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
57 // CHECK: [[PARAM_CAST:%.*]] = bitcast %struct.CGSize* [[TEMP_VAR]]{{.*}}
58 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8*
59 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]]
60 CGSize cg_size = { .width = 42, .height = 24 };
61 // CHECK: call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[PARAM_CAST]], i8* noundef {{.*}}[[SIZE_STR]]{{.*}})
62 NSValue *size = @(cg_size);
66 // CHECK-LABEL: define{{.*}} void @doRect()
68 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGRect{{.*}}
69 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGRect{{.*}}
70 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
71 // CHECK: [[TEMP_CAST:%.*]] = bitcast %struct.CGRect* [[TEMP_VAR]]{{.*}}
72 // CHECK: [[LOCAL_CAST:%.*]] = bitcast %struct.CGRect* [[LOCAL_VAR]]{{.*}}
73 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
74 // CHECK: [[PARAM_CAST:%.*]] = bitcast %struct.CGRect* [[TEMP_VAR]]{{.*}}
75 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8*
76 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]]
77 CGPoint cg_point = { .x = 42, .y = 24 };
78 CGSize cg_size = { .width = 42, .height = 24 };
79 CGRect cg_rect = { .origin = cg_point, .size = cg_size };
80 // CHECK: call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[PARAM_CAST]], i8*{{.*}}[[RECT_STR]]{{.*}})
81 NSValue *rect = @(cg_rect);
85 // CHECK-LABEL: define{{.*}} void @doNSEdgeInsets()
86 void doNSEdgeInsets(void) {
87 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
88 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
89 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
90 // CHECK: [[TEMP_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
91 // CHECK: [[LOCAL_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[LOCAL_VAR]]{{.*}}
92 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
93 // CHECK: [[PARAM_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
94 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8*
95 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]]
96 NSEdgeInsets ns_edge_insets;
97 // CHECK: call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[PARAM_CAST]], i8*{{.*}}[[EDGE_STR]]{{.*}})
98 NSValue *edge_insets = @(ns_edge_insets);
102 // CHECK-LABEL: define{{.*}} void @doRangeRValue()
103 void doRangeRValue(void) {
104 // CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}}
105 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
106 // CHECK: call {{.*}} @getRange({{.*}} [[COERCE]])
107 // CHECK: [[COERCE_CAST:%.*]] = bitcast %struct._NSRange* [[COERCE]]{{.*}}
108 // CHECK: [[RECV:%.*]] = bitcast %struct._class_t* [[RECV_PTR]] to i8*
109 // CHECK: [[SEL:%.*]] = load i8*, i8** [[VALUE_SEL]]
110 // CHECK: call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[COERCE_CAST]], i8* noundef {{.*}}[[RANGE_STR]]{{.*}})
111 NSValue *range_rvalue = @(getRange());