blob: 15334294d47e7942361532e3bf9b34b5618c936b [file] [log] [blame]
Will Dietzcefb4482013-01-07 22:25:52 +00001// Verify proper type emitted for compound assignments
Dmitri Gribenko7daa1a22013-01-08 14:47:41 +00002// RUN: %clang_cc1 -ffreestanding -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=signed-integer-overflow,unsigned-integer-overflow | FileCheck %s
Will Dietzcefb4482013-01-07 22:25:52 +00003
4#include <stdint.h>
5
6// CHECK: @[[INT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
Will Dietz450f1a12013-01-09 03:39:41 +00007// CHECK: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]]
Will Dietzcefb4482013-01-07 22:25:52 +00008// CHECK: @[[UINT:.*]] = private unnamed_addr constant { i16, i16, [15 x i8] } { i16 0, i16 10, [15 x i8] c"'unsigned int'\00" }
Will Dietz450f1a12013-01-09 03:39:41 +00009// CHECK: @[[LINE_200:.*]] = private unnamed_addr global {{.*}}, i32 200, i32 5 {{.*}} @[[UINT]]
Will Dietz949ec542013-11-08 01:09:22 +000010// CHECK: @[[LINE_300:.*]] = private unnamed_addr global {{.*}}, i32 300, i32 5 {{.*}} @[[INT]]
Will Dietzcefb4482013-01-07 22:25:52 +000011
12int32_t x;
13
14// CHECK: @compaddsigned
15void compaddsigned() {
16#line 100
17 x += ((int32_t)1);
18 // CHECK: @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), {{.*}})
19}
20
21// CHECK: @compaddunsigned
22void compaddunsigned() {
23#line 200
24 x += ((uint32_t)1U);
25 // CHECK: @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), {{.*}})
26}
27
28int8_t a, b;
29
30// CHECK: @compdiv
31void compdiv() {
32#line 300
33 a /= b;
34 // CHECK: @__ubsan_handle_divrem_overflow(i8* bitcast ({{.*}} @[[LINE_300]] to i8*), {{.*}})
35}