2017-06-02 03:22:18 +08:00
|
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -w -emit-llvm -o - %s -fsanitize=pointer-overflow | FileCheck %s
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @variable_len_array_arith
|
|
|
|
void variable_len_array_arith(int n, int k) {
|
|
|
|
int vla[n];
|
|
|
|
int (*p)[n] = &vla;
|
|
|
|
|
|
|
|
// CHECK: getelementptr inbounds i32, i32* {{.*}}, i64 [[INC:%.*]]
|
|
|
|
// CHECK: @llvm.smul.with.overflow.i64(i64 4, i64 [[INC]]), !nosanitize
|
2017-06-13 02:42:51 +08:00
|
|
|
// CHECK-NOT: select
|
2017-06-02 03:22:18 +08:00
|
|
|
// CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
|
|
|
|
++p;
|
|
|
|
|
|
|
|
// CHECK: getelementptr inbounds i32, i32* {{.*}}, i64 [[IDXPROM:%.*]]
|
|
|
|
// CHECK: @llvm.smul.with.overflow.i64(i64 4, i64 [[IDXPROM]]), !nosanitize
|
2017-06-13 02:42:51 +08:00
|
|
|
// CHECK: select
|
2017-06-02 03:22:18 +08:00
|
|
|
// CHECK: call void @__ubsan_handle_pointer_overflow{{.*}}
|
|
|
|
p + k;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @objc_id
|
|
|
|
void objc_id(id *p) {
|
|
|
|
// CHECK: add i64 {{.*}}, 8, !nosanitize
|
2017-06-13 02:42:51 +08:00
|
|
|
// CHECK-NOT: select
|
2017-06-02 03:22:18 +08:00
|
|
|
// CHECK: @__ubsan_handle_pointer_overflow{{.*}}
|
|
|
|
p++;
|
|
|
|
}
|