[RISCV][MCA] Move sifive-x280 tests to directory SiFiveX280 (#120522)
[llvm-project.git] / clang / test / CodeGen / catch-implicit-unsigned-integer-truncations-basics.c
blob156ab208107d28890ce0a400aaf483c4a8aa10ca
1 // RUN: %clang_cc1 -fsanitize=implicit-unsigned-integer-truncation -fsanitize-recover=implicit-unsigned-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_500_UNSIGNED_TRUNCATION:.*]] = {{.*}}, i32 500, i32 10 }, {{.*}}, {{.*}}, i8 1, i32 0 }
14 // CHECK-LABEL: @convert_unsigned_int_to_unsigned_int
15 unsigned int convert_unsigned_int_to_unsigned_int(unsigned int x) {
16 #line 100
17 return x;
20 // CHECK-LABEL: @convert_unsigned_char_to_unsigned_char
21 unsigned char convert_unsigned_char_to_unsigned_char(unsigned char x) {
22 #line 200
23 return x;
26 // CHECK-LABEL: @convert_signed_int_to_signed_int
27 signed int convert_signed_int_to_signed_int(signed int x) {
28 #line 300
29 return x;
32 // CHECK-LABEL: @convert_signed_char_to_signed_char
33 signed char convert_signed_char_to_signed_char(signed char x) {
34 #line 400
35 return x;
38 // CHECK-LABEL: @convert_unsigned_int_to_unsigned_char
39 unsigned char convert_unsigned_int_to_unsigned_char(unsigned int x) {
40 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_500_UNSIGNED_TRUNCATION]]
41 #line 500
42 return x;
45 // CHECK-LABEL: @convert_unsigned_char_to_unsigned_int
46 unsigned int convert_unsigned_char_to_unsigned_int(unsigned char x) {
47 #line 600
48 return x;
51 // CHECK-LABEL: @convert_unsigned_char_to_signed_int
52 signed int convert_unsigned_char_to_signed_int(unsigned char x) {
53 #line 700
54 return x;
57 // CHECK-LABEL: @convert_signed_char_to_signed_int
58 signed int convert_signed_char_to_signed_int(signed char x) {
59 #line 800
60 return x;
63 // CHECK-LABEL: @convert_unsigned_int_to_signed_int
64 signed int convert_unsigned_int_to_signed_int(unsigned int x) {
65 #line 900
66 return x;
69 // CHECK-LABEL: @convert_signed_int_to_unsigned_int
70 unsigned int convert_signed_int_to_unsigned_int(signed int x) {
71 #line 1000
72 return x;
75 // CHECK-LABEL: @convert_signed_int_to_unsigned_char
76 unsigned char convert_signed_int_to_unsigned_char(signed int x) {
77 #line 1100
78 return x;
81 // CHECK-LABEL: @convert_signed_char_to_unsigned_char
82 unsigned char convert_signed_char_to_unsigned_char(signed char x) {
83 #line 1200
84 return x;
87 // CHECK-LABEL: @convert_unsigned_char_to_signed_char
88 signed char convert_unsigned_char_to_signed_char(unsigned char x) {
89 #line 1300
90 return x;
93 // CHECK-LABEL: @convert_signed_char_to_unsigned_int
94 unsigned int convert_signed_char_to_unsigned_int(signed char x) {
95 #line 1400
96 return x;
99 // CHECK-LABEL: @convert_unsigned_int_to_signed_char
100 signed char convert_unsigned_int_to_signed_char(unsigned int x) {
101 #line 1500
102 return x;
105 // CHECK-LABEL: @convert_signed_int_to_signed_char
106 signed char convert_signed_int_to_signed_char(signed int x) {
107 #line 1600
108 return x;