[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / asan / TestCases / uar_and_exceptions.cpp
blob8b70380e3bee338e850a3132aa679f68ef463eba
1 // Test that use-after-return works with exceptions.
2 // RUN: %clangxx_asan -O0 %s -o %t
3 // RUN: %env_asan_opts=detect_stack_use_after_return=1 %run %t
4 // RUN: %clangxx_asan -O0 %s -o %t -fsanitize-address-use-after-return=always
5 // RUN: %run %t
7 #include <stdio.h>
9 volatile char *g;
11 #ifndef FRAME_SIZE
12 # define FRAME_SIZE 100
13 #endif
15 #ifndef NUM_ITER
16 # define NUM_ITER 4000
17 #endif
19 #ifndef DO_THROW
20 # define DO_THROW 1
21 #endif
23 void Func(int depth) {
24 char frame[FRAME_SIZE];
25 g = &frame[0];
26 if (depth)
27 Func(depth - 1);
28 else if (DO_THROW)
29 throw 1;
32 int main(int argc, char **argv) {
33 for (int i = 0; i < NUM_ITER; i++) {
34 try {
35 Func(argc * 100);
36 } catch(...) {
38 if ((i % (NUM_ITER / 10)) == 0)
39 fprintf(stderr, "done [%d]\n", i);
41 return 0;