1 // RUN: %clang -fsanitize=implicit-bitfield-conversion -target x86_64-linux -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-BITFIELD-CONVERSION
2 // RUN: %clang -fsanitize=implicit-integer-conversion -target x86_64-linux -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK
3 // RUN: %clang -fsanitize=implicit-conversion -target x86_64-linux -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-BITFIELD-CONVERSION
12 // CHECK-LABEL: define{{.*}} void @foo1
15 // CHECK: store i8 %{{.*}}
16 // CHECK-NEXT: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 5
17 // CHECK-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 5
18 // CHECK-NEXT: [[BFRESULTCAST:%.*]] = sext i8 [[BFRESULTASHR]] to i32
19 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
20 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
21 // CHECK-BITFIELD-CONVERSION: [[CONT]]:
22 // CHECK-NEXT: ret void
25 // CHECK-LABEL: define{{.*}} void @foo2
28 // CHECK: store i8 %{{.*}}
29 // CHECK-NEXT: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 6
30 // CHECK-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 6
31 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
32 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
33 // CHECK-BITFIELD-CONVERSION: [[CONT]]:
34 // CHECK-NEXT: ret void
37 // CHECK-LABEL: define{{.*}} void @foo3
40 // CHECK: store i8 %{{.*}}
41 // CHECK-NEXT: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 5
42 // CHECK-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 5
43 // CHECK-NEXT: [[BFRESULTCAST:%.*]] = sext i8 [[BFRESULTASHR]] to i32
44 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
45 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
46 // CHECK-BITFIELD-CONVERSION: [[CONT]]:
47 // CHECK-NEXT: ret void
50 // CHECK-LABEL: define{{.*}} void @foo4
53 // CHECK: store i8 %{{.*}}
54 // CHECK-NEXT: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 5
55 // CHECK-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 5
56 // CHECK-NEXT: [[BFRESULTCAST:%.*]] = sext i8 [[BFRESULTASHR]] to i32
57 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
58 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
59 // CHECK-BITFIELD-CONVERSION: [[CONT]]:
60 // CHECK-NEXT: ret void