[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / catch-implicit-integer-truncations-basics-negatives.c
blobc1837f39180d7c6772f0dd3f9515d572b0139c5d
1 // RUN: %clang_cc1 -fsanitize=implicit-unsigned-integer-truncation,implicit-signed-integer-truncation -fsanitize-recover=implicit-unsigned-integer-truncation,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 // CHECK-DAG: @[[LINE_100_UNSIGNED_TRUNCATION:.*]] = {{.*}}, i32 100, i32 10 }, {{.*}}, {{.*}}, i8 1, i32 0 }
4 // CHECK-DAG: @[[LINE_200_UNSIGNED_TRUNCATION:.*]] = {{.*}}, i32 200, i32 10 }, {{.*}}, {{.*}}, i8 1, i32 0 }
5 // CHECK-DAG: @[[LINE_300_SIGNED_TRUNCATION:.*]] = {{.*}}, i32 300, i32 10 }, {{.*}}, {{.*}}, i8 2, i32 0 }
6 // CHECK-DAG: @[[LINE_400_SIGNED_TRUNCATION:.*]] = {{.*}}, i32 400, i32 10 }, {{.*}}, {{.*}}, i8 2, i32 0 }
8 //----------------------------------------------------------------------------//
9 // Unsigned case.
10 //----------------------------------------------------------------------------//
12 // CHECK-LABEL: @ignorelist_0_convert_unsigned_int_to_unsigned_char
13 __attribute__((no_sanitize("undefined"))) unsigned char ignorelist_0_convert_unsigned_int_to_unsigned_char(unsigned int x) {
14 // We are not in "undefined" group, so that doesn't work.
15 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_100_UNSIGNED_TRUNCATION]]
16 #line 100
17 return x;
20 // CHECK-LABEL: @ignorelist_1_convert_unsigned_int_to_unsigned_char
21 __attribute__((no_sanitize("integer"))) unsigned char ignorelist_1_convert_unsigned_int_to_unsigned_char(unsigned int x) {
22 return x;
25 // CHECK-LABEL: @ignorelist_2_convert_unsigned_int_to_unsigned_char
26 __attribute__((no_sanitize("implicit-conversion"))) unsigned char ignorelist_2_convert_unsigned_int_to_unsigned_char(unsigned int x) {
27 return x;
30 // CHECK-LABEL: @ignorelist_3_convert_unsigned_int_to_unsigned_char
31 __attribute__((no_sanitize("implicit-integer-truncation"))) unsigned char ignorelist_3_convert_unsigned_int_to_unsigned_char(unsigned int x) {
32 return x;
35 // CHECK-LABEL: @ignorelist_4_convert_unsigned_int_to_unsigned_char
36 __attribute__((no_sanitize("implicit-unsigned-integer-truncation"))) unsigned char ignorelist_4_convert_unsigned_int_to_unsigned_char(unsigned int x) {
37 return x;
40 // CHECK-LABEL: @ignorelist_5_convert_unsigned_int_to_unsigned_char
41 __attribute__((no_sanitize("implicit-signed-integer-truncation"))) unsigned char ignorelist_5_convert_unsigned_int_to_unsigned_char(unsigned int x) {
42 // This is an unsigned truncation, not signed-one.
43 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_200_UNSIGNED_TRUNCATION]]
44 #line 200
45 return x;
48 //----------------------------------------------------------------------------//
49 // Signed case.
50 //----------------------------------------------------------------------------//
52 // CHECK-LABEL: @ignorelist_0_convert_signed_int_to_signed_char
53 __attribute__((no_sanitize("undefined"))) signed char ignorelist_0_convert_signed_int_to_signed_char(signed int x) {
54 // We are not in "undefined" group, so that doesn't work.
55 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_300_SIGNED_TRUNCATION]]
56 #line 300
57 return x;
60 // CHECK-LABEL: @ignorelist_1_convert_signed_int_to_signed_char
61 __attribute__((no_sanitize("integer"))) signed char ignorelist_1_convert_signed_int_to_signed_char(signed int x) {
62 return x;
65 // CHECK-LABEL: @ignorelist_2_convert_signed_int_to_signed_char
66 __attribute__((no_sanitize("implicit-conversion"))) signed char ignorelist_2_convert_signed_int_to_signed_char(signed int x) {
67 return x;
70 // CHECK-LABEL: @ignorelist_3_convert_signed_int_to_signed_char
71 __attribute__((no_sanitize("implicit-integer-truncation"))) signed char ignorelist_3_convert_signed_int_to_signed_char(signed int x) {
72 return x;
75 // CHECK-LABEL: @ignorelist_4_convert_signed_int_to_signed_char
76 __attribute__((no_sanitize("implicit-signed-integer-truncation"))) signed char ignorelist_4_convert_signed_int_to_signed_char(signed int x) {
77 return x;
80 // CHECK-LABEL: @ignorelist_5_convert_signed_int_to_signed_char
81 __attribute__((no_sanitize("implicit-unsigned-integer-truncation"))) signed char ignorelist_5_convert_signed_int_to_signed_char(signed int x) {
82 // This is an signed truncation, not unsigned-one.
83 // CHECK: call void @__ubsan_handle_implicit_conversion(ptr @[[LINE_400_SIGNED_TRUNCATION]]
84 #line 400
85 return x;