• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
4 // CHECK-LABEL: @f
f(int b,int i)5 double f(int b, int i) {
6   double a[b];
7   // CHECK: call {{.*}} @llvm.trap
8   return a[i];
9 }
10 
11 // CHECK-LABEL: @f2
f2()12 void f2() {
13   // everything is constant; no trap possible
14   // CHECK-NOT: call {{.*}} @llvm.trap
15   int a[2];
16   a[1] = 42;
17 
18 #ifndef NO_DYNAMIC
19   short *b = malloc(64);
20   b[5] = *a + a[1] + 2;
21 #endif
22 }
23 
24 // CHECK-LABEL: @f3
f3()25 void f3() {
26   int a[1];
27   // CHECK: call {{.*}} @llvm.trap
28   a[2] = 1;
29 }
30