65 lines · cpp
1// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK2// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK3// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK4// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK5// REQUIRES: stable-runtime6 7// Issue #108194: Incomplete .debug_line at -O1 and above.8// XFAIL: target={{.*sparc.*}}9 10#include "defines.h"11#include <stdlib.h>12ATTRIBUTE_NOINLINE13static void LargeFunction(int *x, int zero) {14 x[0]++;15 x[1]++;16 x[2]++;17 x[3]++;18 x[4]++;19 x[5]++;20 x[6]++;21 x[7]++;22 x[8]++;23 x[9]++;24 25 // CHECK: {{.*ERROR: AddressSanitizer: heap-buffer-overflow on address}}26 // CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}27 // CHECK: {{READ of size 4 at 0x.* thread T0}}28 x[zero + 103]++; // we should report this exact line29 // atos incorrectly extracts the symbol name for the static functions on30 // Darwin.31 // CHECK-Linux: {{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-3]]32 // CHECK-SunOS: {{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-4]]33 // CHECK-Windows:{{#[0-1] 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-5]]34 // CHECK-FreeBSD:{{#0 0x.* in LargeFunction.*large_func_test.cpp:}}[[@LINE-6]]35 // CHECK-Darwin: {{#0 0x.* in .*LargeFunction.*large_func_test.cpp}}:[[@LINE-7]]36 37 x[10]++;38 x[11]++;39 x[12]++;40 x[13]++;41 x[14]++;42 x[15]++;43 x[16]++;44 x[17]++;45 x[18]++;46 x[19]++;47}48 49int main(int argc, char **argv) {50 int *x = new int[100];51 LargeFunction(x, argc - 1);52 // CHECK: {{ #[1-2] 0x.* in main .*large_func_test.cpp:}}[[@LINE-1]]53 // CHECK: {{0x.* is located 12 bytes after 400-byte region}}54 // CHECK: {{allocated by thread T0 here:}}55 // CHECK-Linux: {{ #0 0x.* in operator new}}56 // CHECK-SunOS: {{ #0 0x.* in operator new}}57 // CHECK-Windows:{{ #0 0x.* in operator new}}58 // CHECK-FreeBSD:{{ #0 0x.* in operator new}}59 // CHECK-Darwin: {{ #0 0x.* in .*_Zna}}60 // CHECK-NEXT: {{ #1 0x.* in main .*large_func_test.cpp:}}[[@LINE-10]]61 int y = x[argc];62 delete[] x;63 return y;64}65