1f4a2713aSLionel Sambuc // Verify proper type emitted for compound assignments
2*0a6a1f1dSLionel Sambuc // 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
3f4a2713aSLionel Sambuc
4f4a2713aSLionel Sambuc #include <stdint.h>
5f4a2713aSLionel Sambuc
6f4a2713aSLionel Sambuc // CHECK: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
7f4a2713aSLionel Sambuc // CHECK: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]]
8f4a2713aSLionel Sambuc // CHECK: @[[UINT:.*]] = private unnamed_addr constant { i16, i16, [15 x i8] } { i16 0, i16 10, [15 x i8] c"'unsigned int'\00" }
9f4a2713aSLionel Sambuc // CHECK: @[[LINE_200:.*]] = private unnamed_addr global {{.*}}, i32 200, i32 5 {{.*}} @[[UINT]]
10f4a2713aSLionel Sambuc // CHECK: @[[LINE_300:.*]] = private unnamed_addr global {{.*}}, i32 300, i32 5 {{.*}} @[[INT]]
11f4a2713aSLionel Sambuc
12f4a2713aSLionel Sambuc int32_t x;
13f4a2713aSLionel Sambuc
14f4a2713aSLionel Sambuc // CHECK: @compaddsigned
compaddsigned()15f4a2713aSLionel Sambuc void compaddsigned() {
16f4a2713aSLionel Sambuc #line 100
17f4a2713aSLionel Sambuc x += ((int32_t)1);
18f4a2713aSLionel Sambuc // CHECK: @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), {{.*}})
19f4a2713aSLionel Sambuc }
20f4a2713aSLionel Sambuc
21f4a2713aSLionel Sambuc // CHECK: @compaddunsigned
compaddunsigned()22f4a2713aSLionel Sambuc void compaddunsigned() {
23f4a2713aSLionel Sambuc #line 200
24f4a2713aSLionel Sambuc x += ((uint32_t)1U);
25f4a2713aSLionel Sambuc // CHECK: @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), {{.*}})
26f4a2713aSLionel Sambuc }
27f4a2713aSLionel Sambuc
28f4a2713aSLionel Sambuc int8_t a, b;
29f4a2713aSLionel Sambuc
30f4a2713aSLionel Sambuc // CHECK: @compdiv
compdiv()31f4a2713aSLionel Sambuc void compdiv() {
32f4a2713aSLionel Sambuc #line 300
33f4a2713aSLionel Sambuc a /= b;
34f4a2713aSLionel Sambuc // CHECK: @__ubsan_handle_divrem_overflow(i8* bitcast ({{.*}} @[[LINE_300]] to i8*), {{.*}})
35f4a2713aSLionel Sambuc }
36