Make test more lenient for custom clang version strings
[llvm-project.git] / compiler-rt / test / asan / TestCases / global-location.cpp
blob7aa694159d03e16c625ee7ad1608d8cb34b5a911
1 // RUN: %clangxx_asan -g -O2 %s -o %t
2 // RUN: not %run %t g 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=GLOB
3 // RUN: not %run %t c 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=CLASS_STATIC
4 // RUN: not %run %t f 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=FUNC_STATIC
5 // RUN: not %run %t l 2>&1 | FileCheck %s --check-prefix=CHECK --check-prefix=LITERAL
7 // COFF doesn't support debuginfo for globals. For the non-debuginfo tests, see global-location-nodebug.cpp.
8 // XFAIL: target={{.*windows-msvc.*}}
10 // FIXME: Investigate failure on MinGW
11 // XFAIL: target={{.*-windows-gnu}}
13 // atos doesn't show source line numbers for global variables.
14 // UNSUPPORTED: darwin
16 // CHECK: AddressSanitizer: global-buffer-overflow
18 #include <string.h>
20 struct C {
21 static int array[10];
22 // CLASS_STATIC: 0x{{.*}} is located 4 bytes after global variable 'C::array' defined in '{{.*}}global-location.cpp:[[@LINE-1]]' {{.*}} of size 40
25 int global[10];
26 // GLOB: 0x{{.*}} is located 4 bytes after global variable 'global' defined in '{{.*}}global-location.cpp:[[@LINE-1]]' {{.*}} of size 40
27 int C::array[10];
29 int main(int argc, char **argv) {
30 int one = argc - 1;
31 switch (argv[1][0]) {
32 case 'g': return global[one * 11];
33 case 'c': return C::array[one * 11];
34 case 'f':
35 static int array[10];
36 // FUNC_STATIC: 0x{{.*}} is located 4 bytes after global variable 'main::array' defined in '{{.*}}global-location.cpp:[[@LINE-1]]' {{.*}} of size 40
37 memset(array, 0, 10);
38 return array[one * 11];
39 case 'l':
40 const char *str = "0123456789";
41 // LITERAL: 0x{{.*}} is located 0 bytes after global variable {{.*}} defined in '{{.*}}global-location.cpp:[[@LINE-1]]' {{.*}} of size 11
42 return str[one * 11];
44 return 0;
47 // CHECK: SUMMARY: AddressSanitizer: global-buffer-overflow