[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / catch-implicit-integer-arithmetic-value-change-incdec-basics.c
blob50cde38bb85470fb034c88270aefe786f0d2e297
1 // RUN: %clang_cc1 -fsanitize=implicit-signed-integer-truncation,implicit-integer-sign-change -fsanitize-recover=implicit-signed-integer-truncation,implicit-integer-sign-change -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_implicit_conversion" --check-prefixes=CHECK
3 // CHECK-DAG: @[[INT:.*]] = {{.*}} c"'int'\00" }
4 // CHECK-DAG: @[[UNSIGNED_SHORT:.*]] = {{.*}} c"'unsigned short'\00" }
5 // CHECK-DAG: @[[LINE_100:.*]] = {{.*}}, i32 100, i32 4 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 2, i32 0 }
6 // CHECK-DAG: @[[LINE_200:.*]] = {{.*}}, i32 200, i32 4 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 2, i32 0 }
7 // CHECK-DAG: @[[LINE_300:.*]] = {{.*}}, i32 300, i32 3 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 2, i32 0 }
8 // CHECK-DAG: @[[LINE_400:.*]] = {{.*}}, i32 400, i32 3 }, ptr @[[INT]], ptr @[[UNSIGNED_SHORT]], i8 2, i32 0 }
9 // CHECK-DAG: @[[SHORT:.*]] = {{.*}} c"'short'\00" }
10 // CHECK-DAG: @[[LINE_500:.*]] = {{.*}}, i32 500, i32 4 }, ptr @[[INT]], ptr @[[SHORT]], i8 2, i32 0 }
11 // CHECK-DAG: @[[LINE_600:.*]] = {{.*}}, i32 600, i32 4 }, ptr @[[INT]], ptr @[[SHORT]], i8 2, i32 0 }
12 // CHECK-DAG: @[[LINE_700:.*]] = {{.*}}, i32 700, i32 3 }, ptr @[[INT]], ptr @[[SHORT]], i8 2, i32 0 }
13 // CHECK-DAG: @[[LINE_800:.*]] = {{.*}}, i32 800, i32 3 }, ptr @[[INT]], ptr @[[SHORT]], i8 2, i32 0 }
14 // CHECK-DAG: @[[UNSIGNED_CHAR:.*]] = {{.*}} c"'unsigned char'\00" }
15 // CHECK-DAG: @[[LINE_900:.*]] = {{.*}}, i32 900, i32 4 }, ptr @[[INT]], ptr @[[UNSIGNED_CHAR]], i8 2, i32 0 }
16 // CHECK-DAG: @[[LINE_1000:.*]] = {{.*}}, i32 1000, i32 4 }, ptr @[[INT]], ptr @[[UNSIGNED_CHAR]], i8 2, i32 0 }
17 // CHECK-DAG: @[[LINE_1100:.*]] = {{.*}}, i32 1100, i32 3 }, ptr @[[INT]], ptr @[[UNSIGNED_CHAR]], i8 2, i32 0 }
18 // CHECK-DAG: @[[LINE_1200:.*]] = {{.*}}, i32 1200, i32 3 }, ptr @[[INT]], ptr @[[UNSIGNED_CHAR]], i8 2, i32 0 }
19 // CHECK-DAG: @[[SIGNED_CHAR:.*]] = {{.*}} c"'signed char'\00" }
20 // CHECK-DAG: @[[LINE_1300:.*]] = {{.*}}, i32 1300, i32 4 }, ptr @[[INT]], ptr @[[SIGNED_CHAR]], i8 2, i32 0 }
21 // CHECK-DAG: @[[LINE_1400:.*]] = {{.*}}, i32 1400, i32 4 }, ptr @[[INT]], ptr @[[SIGNED_CHAR]], i8 2, i32 0 }
22 // CHECK-DAG: @[[LINE_1500:.*]] = {{.*}}, i32 1500, i32 3 }, ptr @[[INT]], ptr @[[SIGNED_CHAR]], i8 2, i32 0 }
23 // CHECK-DAG: @[[LINE_1600:.*]] = {{.*}}, i32 1600, i32 3 }, ptr @[[INT]], ptr @[[SIGNED_CHAR]], i8 2, i32 0 }
25 // CHECK-LABEL: @t0(
26 unsigned short t0(unsigned short x) {
27 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_100]]
28 #line 100
29 x++;
30 return x;
32 // CHECK-LABEL: @t1(
33 unsigned short t1(unsigned short x) {
34 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_200]]
35 #line 200
36 x--;
37 return x;
39 // CHECK-LABEL: @t2(
40 unsigned short t2(unsigned short x) {
41 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_300]]
42 #line 300
43 ++x;
44 return x;
46 // CHECK-LABEL: @t3(
47 unsigned short t3(unsigned short x) {
48 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_400]]
49 #line 400
50 --x;
51 return x;
54 // CHECK-LABEL: @t4(
55 signed short t4(signed short x) {
56 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_500]]
57 #line 500
58 x++;
59 return x;
61 // CHECK-LABEL: @t5(
62 signed short t5(signed short x) {
63 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_600]]
64 #line 600
65 x--;
66 return x;
68 // CHECK-LABEL: @t6(
69 signed short t6(signed short x) {
70 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_700]]
71 #line 700
72 ++x;
73 return x;
75 // CHECK-LABEL: @t7(
76 signed short t7(signed short x) {
77 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_800]]
78 #line 800
79 --x;
80 return x;
83 // CHECK-LABEL: @t8(
84 unsigned char t8(unsigned char x) {
85 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_900]]
86 #line 900
87 x++;
88 return x;
90 // CHECK-LABEL: @t9(
91 unsigned char t9(unsigned char x) {
92 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_1000]]
93 #line 1000
94 x--;
95 return x;
97 // CHECK-LABEL: @t10(
98 unsigned char t10(unsigned char x) {
99 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_1100]]
100 #line 1100
101 ++x;
102 return x;
104 // CHECK-LABEL: @t11(
105 unsigned char t11(unsigned char x) {
106 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_1200]]
107 #line 1200
108 --x;
109 return x;
112 // CHECK-LABEL: @t12(
113 signed char t12(signed char x) {
114 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_1300]]
115 #line 1300
116 x++;
117 return x;
119 // CHECK-LABEL: @t13(
120 signed char t13(signed char x) {
121 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_1400]]
122 #line 1400
123 x--;
124 return x;
126 // CHECK-LABEL: @t14(
127 signed char t14(signed char x) {
128 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_1500]]
129 #line 1500
130 ++x;
131 return x;
133 // CHECK-LABEL: @t15(
134 signed char t15(signed char x) {
135 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_1600]]
136 #line 1600
137 --x;
138 return x;