Move MSan lit-tests under test/msan
[blocksruntime.git] / lib / asan / lit_tests / TestCases / large_func_test.cc
blob0534bcd311424303db5aa5fc78094e26a7625abb
1 // RUN: %clangxx_asan -O0 %s -o %t && not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
2 // RUN: %clangxx_asan -O1 %s -o %t && not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
3 // RUN: %clangxx_asan -O2 %s -o %t && not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
4 // RUN: %clangxx_asan -O3 %s -o %t && not %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK
6 #include <stdlib.h>
7 __attribute__((noinline))
8 static void LargeFunction(int *x, int zero) {
9 x[0]++;
10 x[1]++;
11 x[2]++;
12 x[3]++;
13 x[4]++;
14 x[5]++;
15 x[6]++;
16 x[7]++;
17 x[8]++;
18 x[9]++;
20 // CHECK: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}}
21 // CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
22 // CHECK: {{READ of size 4 at 0x.* thread T0}}
23 x[zero + 103]++; // we should report this exact line
24 // atos incorrectly extracts the symbol name for the static functions on
25 // Darwin.
26 // CHECK-Linux: {{#0 0x.* in LargeFunction.*large_func_test.cc:}}[[@LINE-3]]
27 // CHECK-Darwin: {{#0 0x.* in .*LargeFunction.*large_func_test.cc}}:[[@LINE-4]]
29 x[10]++;
30 x[11]++;
31 x[12]++;
32 x[13]++;
33 x[14]++;
34 x[15]++;
35 x[16]++;
36 x[17]++;
37 x[18]++;
38 x[19]++;
41 int main(int argc, char **argv) {
42 int *x = new int[100];
43 LargeFunction(x, argc - 1);
44 // CHECK: {{ #1 0x.* in main .*large_func_test.cc:}}[[@LINE-1]]
45 // CHECK: {{0x.* is located 12 bytes to the right of 400-byte region}}
46 // CHECK: {{allocated by thread T0 here:}}
47 // CHECK-Linux: {{ #0 0x.* in operator new.*}}
48 // CHECK-Darwin: {{ #0 0x.* in .*_Zna.*}}
49 // CHECK: {{ #1 0x.* in main .*large_func_test.cc:}}[[@LINE-7]]
50 delete x;