[RISCV] Rename a lambda to have plural nouns to reflect that it contains a loop. NFC
[llvm-project.git] / clang / test / CodeGen / catch-implicit-signed-integer-truncations-basics.c
blob76d522799a6bb388abbd39175da3627a22f0c469
1 // RUN: %clang_cc1 -fsanitize=implicit-signed-integer-truncation -fsanitize-recover=implicit-signed-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_implicit_conversion" --check-prefixes=CHECK
3 // Test plan:
4 // * Two types - int and char
5 // * Two signs - signed and unsigned
6 // * Square that - we have input and output types.
7 // Thus, there are total of (2*2)^2 == 16 tests.
8 // These are all the possible variations/combinations of casts.
9 // However, not all of them should result in the check.
10 // So here, we *only* check which should and which should not result in checks.
12 // CHECK-DAG: @[[LINE_1100_SIGNED_TRUNCATION:.*]] = {{.*}}, i32 1100, i32 10 }, {{.*}}, {{.*}}, i8 2, i32 0 }
13 // CHECK-DAG: @[[LINE_1500_SIGNED_TRUNCATION:.*]] = {{.*}}, i32 1500, i32 10 }, {{.*}}, {{.*}}, i8 2, i32 0 }
14 // CHECK-DAG: @[[LINE_1600_SIGNED_TRUNCATION:.*]] = {{.*}}, i32 1600, i32 10 }, {{.*}}, {{.*}}, i8 2, i32 0 }
16 // CHECK-LABEL: @convert_unsigned_int_to_unsigned_int
17 unsigned int convert_unsigned_int_to_unsigned_int(unsigned int x) {
18 #line 100
19 return x;
22 // CHECK-LABEL: @convert_unsigned_char_to_unsigned_char
23 unsigned char convert_unsigned_char_to_unsigned_char(unsigned char x) {
24 #line 200
25 return x;
28 // CHECK-LABEL: @convert_signed_int_to_signed_int
29 signed int convert_signed_int_to_signed_int(signed int x) {
30 #line 300
31 return x;
34 // CHECK-LABEL: @convert_signed_char_to_signed_char
35 signed char convert_signed_char_to_signed_char(signed char x) {
36 #line 400
37 return x;
40 // CHECK-LABEL: @convert_unsigned_int_to_unsigned_char
41 unsigned char convert_unsigned_int_to_unsigned_char(unsigned int x) {
42 #line 500
43 return x;
46 // CHECK-LABEL: @convert_unsigned_char_to_unsigned_int
47 unsigned int convert_unsigned_char_to_unsigned_int(unsigned char x) {
48 #line 600
49 return x;
52 // CHECK-LABEL: @convert_unsigned_char_to_signed_int
53 signed int convert_unsigned_char_to_signed_int(unsigned char x) {
54 #line 700
55 return x;
58 // CHECK-LABEL: @convert_signed_char_to_signed_int
59 signed int convert_signed_char_to_signed_int(signed char x) {
60 #line 800
61 return x;
64 // CHECK-LABEL: @convert_unsigned_int_to_signed_int
65 signed int convert_unsigned_int_to_signed_int(unsigned int x) {
66 #line 900
67 return x;
70 // CHECK-LABEL: @convert_signed_int_to_unsigned_int
71 unsigned int convert_signed_int_to_unsigned_int(signed int x) {
72 #line 1000
73 return x;
76 // CHECK-LABEL: @convert_signed_int_to_unsigned_char
77 unsigned char convert_signed_int_to_unsigned_char(signed int x) {
78 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_1100_SIGNED_TRUNCATION]]
79 #line 1100
80 return x;
83 // CHECK-LABEL: @convert_signed_char_to_unsigned_char
84 unsigned char convert_signed_char_to_unsigned_char(signed char x) {
85 #line 1200
86 return x;
89 // CHECK-LABEL: @convert_unsigned_char_to_signed_char
90 signed char convert_unsigned_char_to_signed_char(unsigned char x) {
91 #line 1300
92 return x;
95 // CHECK-LABEL: @convert_signed_char_to_unsigned_int
96 unsigned int convert_signed_char_to_unsigned_int(signed char x) {
97 #line 1400
98 return x;
101 // CHECK-LABEL: @convert_unsigned_int_to_signed_char
102 signed char convert_unsigned_int_to_signed_char(unsigned int x) {
103 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_1500_SIGNED_TRUNCATION]]
104 #line 1500
105 return x;
108 // CHECK-LABEL: @convert_signed_int_to_signed_char
109 signed char convert_signed_int_to_signed_char(signed int x) {
110 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_1600_SIGNED_TRUNCATION]]
111 #line 1600
112 return x;