• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 | FileCheck %s
3 
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" }
7 // CHECK: @[[LINE_100:.*]] = private unnamed_addr global {{.*}}, i32 100, i32 5 {{.*}} @[[INT]]
8 // CHECK: @[[UINT:.*]] = private unnamed_addr constant { i16, i16, [15 x i8] } { i16 0, i16 10, [15 x i8] c"'unsigned int'\00" }
9 // CHECK: @[[LINE_200:.*]] = private unnamed_addr global {{.*}}, i32 200, i32 5 {{.*}} @[[UINT]]
10 // CHECK: @[[DIVINT:.*]] = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" }
11 // CHECK: @[[LINE_300:.*]] = private unnamed_addr global {{.*}}, i32 300, i32 5 {{.*}} @[[DIVINT]]
12 
13 int32_t x;
14 
15 // CHECK: @compaddsigned
compaddsigned()16 void compaddsigned() {
17 #line 100
18   x += ((int32_t)1);
19   // CHECK: @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_100]] to i8*), {{.*}})
20 }
21 
22 // CHECK: @compaddunsigned
compaddunsigned()23 void compaddunsigned() {
24 #line 200
25   x += ((uint32_t)1U);
26   // CHECK: @__ubsan_handle_add_overflow(i8* bitcast ({{.*}} @[[LINE_200]] to i8*), {{.*}})
27 }
28 
29 int8_t a, b;
30 
31 // CHECK: @compdiv
compdiv()32 void compdiv() {
33 #line 300
34   a /= b;
35   // CHECK: @__ubsan_handle_divrem_overflow(i8* bitcast ({{.*}} @[[LINE_300]] to i8*), {{.*}})
36 }
37