[LLVM][IR] Use splat syntax when printing ConstantExpr based splats. (#116856)
[llvm-project.git] / clang / test / CodeGen / catch-implicit-integer-sign-changes-true-negatives.c
blob0f028b41dc2c80abe033b3c216330fb546c1d701
1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_implicit_conversion"
2 // RUN: %clang_cc1 -fsanitize=implicit-integer-sign-change -fno-sanitize-recover=implicit-integer-sign-change -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_implicit_conversion" --check-prefixes=CHECK,CHECK-SANITIZE
3 // RUN: %clang_cc1 -fsanitize=implicit-integer-sign-change -fsanitize-recover=implicit-integer-sign-change -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_implicit_conversion" --check-prefixes=CHECK,CHECK-SANITIZE
4 // RUN: %clang_cc1 -fsanitize=implicit-integer-sign-change -fsanitize-trap=implicit-integer-sign-change -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_implicit_conversion" --check-prefixes=CHECK,CHECK-SANITIZE
6 // ========================================================================== //
7 // The expected true-negatives.
8 // ========================================================================== //
10 // Sanitization is explicitly disabled.
11 // ========================================================================== //
13 // CHECK-LABEL: @ignorelist_0
14 __attribute__((no_sanitize("undefined"))) unsigned int ignorelist_0(signed int src) {
15 // We are not in "undefined" group, so that doesn't work.
16 // CHECK-SANITIZE: call
17 return src;
20 // CHECK-LABEL: @ignorelist_1
21 __attribute__((no_sanitize("integer"))) unsigned int ignorelist_1(signed int src) {
22 return src;
25 // CHECK-LABEL: @ignorelist_2
26 __attribute__((no_sanitize("implicit-conversion"))) unsigned int ignorelist_2(signed int src) {
27 return src;
30 // CHECK-LABEL: @ignorelist_3
31 __attribute__((no_sanitize("implicit-integer-sign-change"))) unsigned int ignorelist_3(signed int src) {
32 return src;
35 // Explicit sign-changing conversions.
36 // ========================================================================== //
38 // CHECK-LABEL: explicit_signed_int_to_unsigned_int
39 unsigned int explicit_signed_int_to_unsigned_int(signed int src) {
40 return (unsigned int)src;
43 // CHECK-LABEL: explicit_unsigned_int_to_signed_int
44 signed int explicit_unsigned_int_to_signed_int(unsigned int src) {
45 return (signed int)src;
48 // Explicit NOP conversions.
49 // ========================================================================== //
51 // CHECK-LABEL: @explicit_ununsigned_int_to_ununsigned_int
52 unsigned int explicit_ununsigned_int_to_ununsigned_int(unsigned int src) {
53 return (unsigned int)src;
56 // CHECK-LABEL: @explicit_unsigned_int_to_unsigned_int
57 signed int explicit_unsigned_int_to_unsigned_int(signed int src) {
58 return (signed int)src;
61 // conversions to to boolean type are not counted as sign-change.
62 // ========================================================================== //
64 // CHECK-LABEL: @unsigned_int_to_bool
65 _Bool unsigned_int_to_bool(unsigned int src) {
66 return src;
69 // CHECK-LABEL: @signed_int_to_bool
70 _Bool signed_int_to_bool(signed int src) {
71 return src;
74 // CHECK-LABEL: @explicit_unsigned_int_to_bool
75 _Bool explicit_unsigned_int_to_bool(unsigned int src) {
76 return (_Bool)src;
79 // CHECK-LABEL: @explicit_signed_int_to_bool
80 _Bool explicit_signed_int_to_bool(signed int src) {
81 return (_Bool)src;
84 // Explicit conversions from pointer to an integer.
85 // Can not have an implicit conversion from pointer to an integer.
86 // Can not have an implicit conversion between two enums.
87 // ========================================================================== //
89 // CHECK-LABEL: @explicit_voidptr_to_unsigned_int
90 unsigned int explicit_voidptr_to_unsigned_int(void *src) {
91 return (unsigned int)src;
94 // CHECK-LABEL: @explicit_voidptr_to_signed_int
95 signed int explicit_voidptr_to_signed_int(void *src) {
96 return (signed int)src;
99 // Implicit conversions from floating-point.
100 // ========================================================================== //
102 // CHECK-LABEL: @float_to_unsigned_int
103 unsigned int float_to_unsigned_int(float src) {
104 return src;
107 // CHECK-LABEL: @float_to_signed_int
108 signed int float_to_signed_int(float src) {
109 return src;
112 // CHECK-LABEL: @double_to_unsigned_int
113 unsigned int double_to_unsigned_int(double src) {
114 return src;
117 // CHECK-LABEL: @double_to_signed_int
118 signed int double_to_signed_int(double src) {
119 return src;
122 // Sugar.
123 // ========================================================================== //
125 typedef unsigned int uint32_t;
127 // CHECK-LABEL: @uint32_to_unsigned_int
128 unsigned int uint32_to_unsigned_int(uint32_t src) {
129 return src;
132 // CHECK-LABEL: @unsigned_int_to_uint32
133 uint32_t unsigned_int_to_uint32(unsigned int src) {
134 return src;
137 // CHECK-LABEL: @uint32_to_uint32
138 uint32_t uint32_to_uint32(uint32_t src) {
139 return src;
142 // "Transparent" Enum.
143 // ========================================================================== //
145 enum a { b = ~2147483647 };
146 enum a c(void);
147 void d(int);
148 void e(void);
149 void e(void) {
150 enum a f = c();
151 d(f);