[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / hwasan / TestCases / use-after-scope-inlined.cpp
blobb84656360e8145d6c8e858aee020f7299a153389
1 // This is the ASAN test of the same name ported to HWAsan.
3 // Test with "-O2" only to make sure inlining (leading to use-after-scope)
4 // happens. "always_inline" is not enough, as Clang doesn't emit
5 // llvm.lifetime intrinsics at -O0.
6 //
7 // RUN: %clangxx_hwasan -mllvm -hwasan-use-after-scope -O2 %s -o %t && \
8 // RUN: not %run %t 2>&1 | FileCheck %s
10 // REQUIRES: aarch64-target-arch
11 // REQUIRES: stable-runtime
13 int *arr;
14 __attribute__((always_inline)) void inlined(int arg) {
15 int x[5];
16 for (int i = 0; i < arg; i++)
17 x[i] = i;
18 arr = x;
21 int main(int argc, char *argv[]) {
22 inlined(argc);
23 return arr[argc - 1]; // BOOM
24 // CHECK: ERROR: HWAddressSanitizer: tag-mismatch
25 // CHECK: Cause: stack tag-mismatch