[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / CodeGenObjC / nsvalue-objc-boxable-mac-arc.m
blob573dfa3bf87d1f9c6a294cce433ef420f0008cf3
1 // RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-macosx -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=QQ{{.*}}
8 // CHECK:      [[METH:@.*]]         = private unnamed_addr constant {{.*}}valueWithBytes:objCType:{{.*}}
9 // CHECK:      [[VALUE_SEL:@.*]]    = {{.*}}[[METH]]{{.*}}
10 // CHECK:      [[POINT_STR:.*]]     = {{.*}}_NSPoint=dd{{.*}}
11 // CHECK:      [[SIZE_STR:.*]]      = {{.*}}_NSSize=dd{{.*}}
12 // CHECK:      [[RECT_STR:.*]]      = {{.*}}_NSRect={_NSPoint=dd}{_NSSize=dd}}{{.*}}
13 // CHECK:      [[EDGE_STR:.*]]      = {{.*}}NSEdgeInsets=dddd{{.*}}
15 // CHECK-LABEL: define{{.*}} void @doRange()
16 void doRange(void) {
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* {{.*}}[[RANGE_STR]]{{.*}}) [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
28   NSValue *range = @(ns_range);
29   // CHECK:      call void @llvm.objc.release
30   // CHECK:      ret void
33 // CHECK-LABEL: define{{.*}} void @doPoint()
34 void doPoint(void) {
35   // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSPoint{{.*}}
36   // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSPoint{{.*}}
37   // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
38   // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSPoint* [[TEMP_VAR]]{{.*}}
39   // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSPoint* [[LOCAL_VAR]]{{.*}}
40   // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
41   // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSPoint* [[TEMP_VAR]]{{.*}}
42   // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
43   // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
44   NSPoint ns_point = { .x = 42, .y = 24 };
45   // CHECK:      call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[PARAM_CAST]], i8* {{.*}}[[POINT_STR]]{{.*}}) [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
46   NSValue *point = @(ns_point);
47   // CHECK:      call void @llvm.objc.release
48   // CHECK:      ret void
51 // CHECK-LABEL: define{{.*}} void @doSize()
52 void doSize(void) {
53   // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSSize{{.*}}
54   // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSSize{{.*}}
55   // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
56   // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSSize* [[TEMP_VAR]]{{.*}}
57   // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSSize* [[LOCAL_VAR]]{{.*}}
58   // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
59   // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSSize* [[TEMP_VAR]]{{.*}}
60   // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
61   // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
62   NSSize ns_size = { .width = 42, .height = 24 };
63   // CHECK:      call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[PARAM_CAST]], i8* {{.*}}[[SIZE_STR]]{{.*}}) [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
64   NSValue *size = @(ns_size);
65   // CHECK:      call void @llvm.objc.release
66   // CHECK:      ret void
69 // CHECK-LABEL: define{{.*}} void @doRect()
70 void doRect(void) {
71   // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSRect{{.*}}
72   // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSRect{{.*}}
73   // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
74   // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSRect* [[TEMP_VAR]]{{.*}}
75   // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSRect* [[LOCAL_VAR]]{{.*}}
76   // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
77   // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSRect* [[TEMP_VAR]]{{.*}}
78   // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
79   // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
80   NSPoint ns_point = { .x = 42, .y = 24 };
81   NSSize ns_size = { .width = 42, .height = 24 };
82   NSRect ns_rect = { .origin = ns_point, .size = ns_size };
83   // CHECK:      call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[PARAM_CAST]], i8*{{.*}}[[RECT_STR]]{{.*}}) [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
84   NSValue *rect = @(ns_rect);
85   // CHECK:      call void @llvm.objc.release
86   // CHECK:      ret void
89 // CHECK-LABEL: define{{.*}} void @doNSEdgeInsets()
90 void doNSEdgeInsets(void) {
91   // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.NSEdgeInsets{{.*}}
92   // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.NSEdgeInsets{{.*}}
93   // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
94   // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
95   // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[LOCAL_VAR]]{{.*}}
96   // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
97   // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
98   // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
99   // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
100   NSEdgeInsets ns_edge_insets;
101   // CHECK:      call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[PARAM_CAST]], i8*{{.*}}[[EDGE_STR]]{{.*}}) [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
102   NSValue *edge_insets = @(ns_edge_insets);
103   // CHECK:      call void @llvm.objc.release
104   // CHECK:      ret void
107 // CHECK-LABEL: define{{.*}} void @doRangeRValue() 
108 void doRangeRValue(void) {
109   // CHECK:     [[COERCE:%.*]]          = alloca %struct._NSRange{{.*}}
110   // CHECK:     [[RECV_PTR:%.*]]        = load {{.*}} [[NSVALUE]]
111   // CHECK:     [[RVAL:%.*]]            = call {{.*}} @getRange()
112   // CHECK:     [[COERCE_CAST:%.*]]     = bitcast %struct._NSRange* [[COERCE]]{{.*}}
113   // CHECK:     [[COERCE_CAST_PTR:%.*]] = getelementptr {{.*}} [[COERCE_CAST]], {{.*}}
114   // CHECK:     [[EXTR_RVAL:%.*]]       = extractvalue {{.*}} [[RVAL]]{{.*}}
115   // CHECK:     store {{.*}}[[EXTR_RVAL]]{{.*}}[[COERCE_CAST_PTR]]{{.*}}
116   // CHECK:     [[COERCE_CAST:%.*]]     = bitcast %struct._NSRange* [[COERCE]]{{.*}}
117   // CHECK:     [[RECV:%.*]]            = bitcast %struct._class_t* [[RECV_PTR]] to i8*
118   // CHECK:     [[SEL:%.*]]             = load i8*, i8** [[VALUE_SEL]]
119   // CHECK:     call {{.*objc_msgSend.*}}(i8* noundef [[RECV]], i8* noundef [[SEL]], i8* noundef [[COERCE_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}}) [ "clang.arc.attachedcall"(i8* (i8*)* @llvm.objc.retainAutoreleasedReturnValue) ]
120   NSValue *range_rvalue = @(getRange());
121   // CHECK:     call void @llvm.objc.release
122   // CHECK:     ret void