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: 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 noundef {{.*}}[[RANGE_STR]]{{.*}})
24 NSValue *range = @(ns_range);
28 // CHECK-LABEL: define{{.*}} void @doPoint()
30 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGPoint{{.*}}
31 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGPoint{{.*}}
32 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
33 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_VAR]]{{.*}} [[LOCAL_VAR]]{{.*}}
34 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
35 CGPoint cg_point = { .x = 42, .y = 24 };
36 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[TEMP_VAR]], ptr noundef {{.*}}[[POINT_STR]]{{.*}})
37 NSValue *point = @(cg_point);
41 // CHECK-LABEL: define{{.*}} void @doSize()
43 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGSize{{.*}}
44 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGSize{{.*}}
45 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
46 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_VAR]]{{.*}} [[LOCAL_VAR]]{{.*}}
47 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
48 CGSize cg_size = { .width = 42, .height = 24 };
49 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[TEMP_VAR]], ptr noundef {{.*}}[[SIZE_STR]]{{.*}})
50 NSValue *size = @(cg_size);
54 // CHECK-LABEL: define{{.*}} void @doRect()
56 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.CGRect{{.*}}
57 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.CGRect{{.*}}
58 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
59 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_VAR]]{{.*}} [[LOCAL_VAR]]{{.*}}
60 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
61 CGPoint cg_point = { .x = 42, .y = 24 };
62 CGSize cg_size = { .width = 42, .height = 24 };
63 CGRect cg_rect = { .origin = cg_point, .size = cg_size };
64 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[TEMP_VAR]], ptr{{.*}}[[RECT_STR]]{{.*}})
65 NSValue *rect = @(cg_rect);
69 // CHECK-LABEL: define{{.*}} void @doNSEdgeInsets()
70 void doNSEdgeInsets(void) {
71 // CHECK: [[LOCAL_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
72 // CHECK: [[TEMP_VAR:%.*]] = alloca %struct.NSEdgeInsets{{.*}}
73 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
74 // CHECK: call void @llvm.memcpy{{.*}} [[TEMP_VAR]]{{.*}} [[LOCAL_VAR]]{{.*}}
75 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
76 NSEdgeInsets ns_edge_insets;
77 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[TEMP_VAR]], ptr{{.*}}[[EDGE_STR]]{{.*}})
78 NSValue *edge_insets = @(ns_edge_insets);
82 // CHECK-LABEL: define{{.*}} void @doRangeRValue()
83 void doRangeRValue(void) {
84 // CHECK: [[COERCE:%.*]] = alloca %struct._NSRange{{.*}}
85 // CHECK: [[RECV_PTR:%.*]] = load {{.*}} [[NSVALUE]]
86 // CHECK: call {{.*}} @getRange({{.*}} [[COERCE]])
87 // CHECK: [[SEL:%.*]] = load ptr, ptr [[VALUE_SEL]]
88 // CHECK: call {{.*objc_msgSend.*}}(ptr noundef [[RECV_PTR]], ptr noundef [[SEL]], ptr noundef [[COERCE]], ptr noundef {{.*}}[[RANGE_STR]]{{.*}})
89 NSValue *range_rvalue = @(getRange());