1 // RUN: %clang_cc1 -fsanitize=local-bounds -emit-llvm -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -fsanitize=array-bounds -O -fsanitize-trap=array-bounds -emit-llvm -triple x86_64-apple-darwin10 -DNO_DYNAMIC %s -o - | FileCheck %s
3 // RUN: %clang_cc1 -fsanitize=local-bounds -fsanitize-trap=local-bounds -O3 -mllvm -bounds-checking-unique-traps -emit-llvm -triple x86_64-apple-darwin10 %s -o - | FileCheck %s --check-prefixes=NOOPTLOCAL
4 // RUN: %clang_cc1 -fsanitize=array-bounds -fsanitize-trap=array-bounds -O3 -mllvm -ubsan-unique-traps -emit-llvm -triple x86_64-apple-darwin10 %s -o - | FileCheck %s --check-prefixes=NOOPTARRAY
6 // REQUIRES: x86-registered-target
9 double f1(int b
, int i
) {
11 // CHECK: call {{.*}} @llvm.{{(ubsan)?trap}}
17 // everything is constant; no trap possible
18 // CHECK-NOT: call {{.*}} @llvm.{{(ubsan)?trap}}
23 extern void *malloc(__typeof__(sizeof(0)));
24 short *b
= malloc(64);
32 // CHECK: call {{.*}} @llvm.{{(ubsan)?trap}}
37 __attribute__((no_sanitize("bounds")))
40 // CHECK-NOT: call void @llvm.trap()
46 // Union flexible-array memebers are a C99 extension. All array members with a
47 // constant size should be considered FAMs.
49 union U
{ int a
[0]; int b
[1]; int c
[2]; };
52 int f5(union U
*u
, int i
) {
53 // a is treated as a flexible array member.
54 // CHECK-NOT: @llvm.ubsantrap
59 int f6(union U
*u
, int i
) {
60 // b is treated as a flexible array member.
61 // CHECK-NOT: call {{.*}} @llvm.{{(ubsan)?trap}}
66 int f7(union U
*u
, int i
) {
67 // c is treated as a flexible array member.
68 // CHECK-NOT: @llvm.ubsantrap
75 void f8(int i
, int k
) {
76 // NOOPTLOCAL: call void @llvm.ubsantrap(i8 3)
77 // NOOPTARRAY: call void @llvm.ubsantrap(i8 2)
80 // NOOPTLOCAL: call void @llvm.ubsantrap(i8 5)
81 // NOOPTARRAY: call void @llvm.ubsantrap(i8 4)
85 // See commit 9a954c6 that caused a SEGFAULT in this code.