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 //----------------------------------------------------------------------------//
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]]
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
) {
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
) {
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
) {
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
) {
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]]
48 //----------------------------------------------------------------------------//
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]]
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
) {
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
) {
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
) {
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
) {
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]]