[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / compound-assign-overflow.c
blobf8efa14ccf38104084dc5d95f5b886256e6f9ecb
1 // Verify proper type emitted for compound assignments
2 // RUN: %clang_cc1 -ffreestanding -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=signed-integer-overflow,unsigned-integer-overflow -fsanitize-recover=signed-integer-overflow,unsigned-integer-overflow | FileCheck %s
4 #include <stdint.h>
6 // CHECK: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [22 x i8] } { i16 0, i16 11, [22 x i8] c"'int32_t' (aka 'int')\00" }
7 // CHECK: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]]
8 // CHECK: @[[UINT:.*]] = private unnamed_addr constant { i16, i16, [32 x i8] } { i16 0, i16 10, [32 x i8] c"'uint32_t' (aka 'unsigned int')\00" }
9 // CHECK: @[[LINE_200:.*]] = private unnamed_addr global {{.*}}, i32 200, i32 5 {{.*}} @[[UINT]]
10 // CHECK: @[[LINE_300:.*]] = private unnamed_addr global {{.*}}, i32 300, i32 5 {{.*}} @[[INT]]
12 int32_t x;
14 // CHECK: @compaddsigned
15 void compaddsigned(void) {
16 #line 100
17 x += ((int32_t)1);
18 // CHECK: @__ubsan_handle_add_overflow(ptr @[[LINE_100]], {{.*}})
21 // CHECK: @compaddunsigned
22 void compaddunsigned(void) {
23 #line 200
24 x += ((uint32_t)1U);
25 // CHECK: @__ubsan_handle_add_overflow(ptr @[[LINE_200]], {{.*}})
28 // CHECK: @compdiv
29 void compdiv(void) {
30 #line 300
31 x /= x;
32 // CHECK: @__ubsan_handle_divrem_overflow(ptr @[[LINE_300]], {{.*}})