1 // RUN: %clang -x c++ -fsanitize=implicit-bitfield-conversion -target x86_64-linux -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-BITFIELD-CONVERSION
2 // RUN: %clang -x c++ -fsanitize=implicit-integer-conversion -target x86_64-linux -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK
3 // RUN: %clang -x c++ -fsanitize=implicit-conversion -target x86_64-linux -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-BITFIELD-CONVERSION
18 // CHECK-LABEL: define{{.*}} void @{{.*foo1.*}}
21 // CHECK: store i8 %{{.*}}
22 // CHECK-BITFIELD-CONVERSION: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 5
23 // CHECK-BITFIELD-CONVERSION-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 5
24 // CHECK-BITFIELD-CONVERSION-NEXT: [[BFRESULTCAST:%.*]] = sext i8 [[BFRESULTASHR]] to i32
25 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
26 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
28 // CHECK: store i8 %{{.*}}
29 // CHECK-BITFIELD-CONVERSION: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 5
30 // CHECK-BITFIELD-CONVERSION-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 5
31 // CHECK-BITFIELD-CONVERSION-NEXT: [[BFRESULTCAST:%.*]] = sext i8 [[BFRESULTASHR]] to i32
32 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
33 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
34 // CHECK-BITFIELD-CONVERSION: [[CONT]]:
35 // CHECK-NEXT: ret void
38 // CHECK-LABEL: define{{.*}} void @{{.*foo2.*}}
41 // CHECK: store i8 %{{.*}}
42 // CHECK-BITFIELD-CONVERSION: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 6
43 // CHECK-BITFIELD-CONVERSION-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 6
44 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
45 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
47 // CHECK: store i8 %{{.*}}
48 // CHECK-BITFIELD-CONVERSION: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 6
49 // CHECK-BITFIELD-CONVERSION-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 6
50 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
51 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
52 // CHECK-BITFIELD-CONVERSION: [[CONT]]:
53 // CHECK-NEXT: ret void
56 // CHECK-LABEL: define{{.*}} void @{{.*foo3.*}}
59 // CHECK: store i8 %{{.*}}
60 // CHECK-NEXT: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 5
61 // CHECK-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 5
62 // CHECK-NEXT: [[BFRESULTCAST:%.*]] = sext i8 [[BFRESULTASHR]] to i32
63 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
64 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
66 // CHECK: store i8 %{{.*}}
67 // CHECK-NEXT: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 5
68 // CHECK-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 5
69 // CHECK-NEXT: [[BFRESULTCAST:%.*]] = sext i8 [[BFRESULTASHR]] to i32
70 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
71 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
72 // CHECK-BITFIELD-CONVERSION: [[CONT]]:
73 // CHECK-NEXT: ret void
76 // CHECK-LABEL: define{{.*}} void @{{.*foo4.*}}
79 // CHECK: store i8 %{{.*}}
80 // CHECK-NEXT: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 5
81 // CHECK-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 5
82 // CHECK-NEXT: [[BFRESULTCAST:%.*]] = sext i8 [[BFRESULTASHR]] to i32
83 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
84 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
86 // CHECK: store i8 %{{.*}}
87 // CHECK-NEXT: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 5
88 // CHECK-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 [[BFRESULTSHL]], 5
89 // CHECK-NEXT: [[BFRESULTCAST:%.*]] = sext i8 [[BFRESULTASHR]] to i32
90 // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
91 // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize
92 // CHECK-BITFIELD-CONVERSION: [[CONT]]:
93 // CHECK-NEXT: ret void