annotate clang/test/CodeGen/catch-implicit-signed-integer-truncations-basics-negatives.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
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
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 // CHECK-DAG: @[[LINE_100_SIGNED_TRUNCATION:.*]] = {{.*}}, i32 100, i32 10 }, {{.*}}, {{.*}}, i8 2 }
anatofuz
parents:
diff changeset
4 // CHECK-DAG: @[[LINE_200_SIGNED_TRUNCATION:.*]] = {{.*}}, i32 200, i32 10 }, {{.*}}, {{.*}}, i8 2 }
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 // CHECK-LABEL: @blacklist_0_convert_signed_int_to_signed_char
anatofuz
parents:
diff changeset
7 __attribute__((no_sanitize("undefined"))) signed char blacklist_0_convert_signed_int_to_signed_char(signed int x) {
anatofuz
parents:
diff changeset
8 // We are not in "undefined" group, so that doesn't work.
anatofuz
parents:
diff changeset
9 // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_100_SIGNED_TRUNCATION]] to i8*)
anatofuz
parents:
diff changeset
10 #line 100
anatofuz
parents:
diff changeset
11 return x;
anatofuz
parents:
diff changeset
12 }
anatofuz
parents:
diff changeset
13
anatofuz
parents:
diff changeset
14 // CHECK-LABEL: @blacklist_1_convert_signed_int_to_signed_char
anatofuz
parents:
diff changeset
15 __attribute__((no_sanitize("integer"))) signed char blacklist_1_convert_signed_int_to_signed_char(signed int x) {
anatofuz
parents:
diff changeset
16 return x;
anatofuz
parents:
diff changeset
17 }
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 // CHECK-LABEL: @blacklist_2_convert_signed_int_to_signed_char
anatofuz
parents:
diff changeset
20 __attribute__((no_sanitize("implicit-conversion"))) signed char blacklist_2_convert_signed_int_to_signed_char(signed int x) {
anatofuz
parents:
diff changeset
21 return x;
anatofuz
parents:
diff changeset
22 }
anatofuz
parents:
diff changeset
23
anatofuz
parents:
diff changeset
24 // CHECK-LABEL: @blacklist_3_convert_signed_int_to_signed_char
anatofuz
parents:
diff changeset
25 __attribute__((no_sanitize("implicit-integer-truncation"))) signed char blacklist_3_convert_signed_int_to_signed_char(signed int x) {
anatofuz
parents:
diff changeset
26 return x;
anatofuz
parents:
diff changeset
27 }
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 // CHECK-LABEL: @blacklist_4_convert_signed_int_to_signed_char
anatofuz
parents:
diff changeset
30 __attribute__((no_sanitize("implicit-signed-integer-truncation"))) signed char blacklist_4_convert_signed_int_to_signed_char(signed int x) {
anatofuz
parents:
diff changeset
31 return x;
anatofuz
parents:
diff changeset
32 }
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 // CHECK-LABEL: @blacklist_5_convert_signed_int_to_signed_char
anatofuz
parents:
diff changeset
35 __attribute__((no_sanitize("implicit-unsigned-integer-truncation"))) signed char blacklist_5_convert_signed_int_to_signed_char(signed int x) {
anatofuz
parents:
diff changeset
36 // This is an signed truncation, not unsigned-one.
anatofuz
parents:
diff changeset
37 // CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_200_SIGNED_TRUNCATION]] to i8*)
anatofuz
parents:
diff changeset
38 #line 200
anatofuz
parents:
diff changeset
39 return x;
anatofuz
parents:
diff changeset
40 }