1 // Tests -fsanitize-coverage=stack-depth 2 // 3 // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=stack-depth %s -o %t 4 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not Assertion{{.*}}failed 5 // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=trace-pc-guard,stack-depth \ 6 // RUN: %s -o %t 7 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not Assertion{{.*}}failed 8 9 #include <cstdint> 10 #include <cstdio> 11 #include <cassert> 12 13 thread_local uintptr_t __sancov_lowest_stack; 14 uintptr_t last_stack; 15 foo(int recurse)16void foo(int recurse) { 17 assert(__sancov_lowest_stack < last_stack); 18 last_stack = __sancov_lowest_stack; 19 if (recurse <= 0) return; 20 foo(recurse - 1); 21 } 22 main()23int main() { 24 last_stack = __sancov_lowest_stack; 25 foo(100); 26 printf("Success!\n"); 27 return 0; 28 } 29 30 // CHECK: Success! 31