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
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
) {
20 // CHECK-LABEL: @convert_unsigned_char_to_unsigned_char
21 unsigned char convert_unsigned_char_to_unsigned_char(unsigned char x
) {
26 // CHECK-LABEL: @convert_signed_int_to_signed_int
27 signed int convert_signed_int_to_signed_int(signed int x
) {
32 // CHECK-LABEL: @convert_signed_char_to_signed_char
33 signed char convert_signed_char_to_signed_char(signed char 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]]
45 // CHECK-LABEL: @convert_unsigned_char_to_unsigned_int
46 unsigned int convert_unsigned_char_to_unsigned_int(unsigned char x
) {
51 // CHECK-LABEL: @convert_unsigned_char_to_signed_int
52 signed int convert_unsigned_char_to_signed_int(unsigned char x
) {
57 // CHECK-LABEL: @convert_signed_char_to_signed_int
58 signed int convert_signed_char_to_signed_int(signed char x
) {
63 // CHECK-LABEL: @convert_unsigned_int_to_signed_int
64 signed int convert_unsigned_int_to_signed_int(unsigned int x
) {
69 // CHECK-LABEL: @convert_signed_int_to_unsigned_int
70 unsigned int convert_signed_int_to_unsigned_int(signed int x
) {
75 // CHECK-LABEL: @convert_signed_int_to_unsigned_char
76 unsigned char convert_signed_int_to_unsigned_char(signed int x
) {
81 // CHECK-LABEL: @convert_signed_char_to_unsigned_char
82 unsigned char convert_signed_char_to_unsigned_char(signed char x
) {
87 // CHECK-LABEL: @convert_unsigned_char_to_signed_char
88 signed char convert_unsigned_char_to_signed_char(unsigned char x
) {
93 // CHECK-LABEL: @convert_signed_char_to_unsigned_int
94 unsigned int convert_signed_char_to_unsigned_int(signed char x
) {
99 // CHECK-LABEL: @convert_unsigned_int_to_signed_char
100 signed char convert_unsigned_int_to_signed_char(unsigned int x
) {
105 // CHECK-LABEL: @convert_signed_int_to_signed_char
106 signed char convert_signed_int_to_signed_char(signed int x
) {