| 1 |
// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-linux %s \ |
| 2 |
// RUN: | FileCheck %s --check-prefixes=CHECK-RUNTIME \ |
| 3 |
// RUN: --implicit-check-not="__asan_stack_malloc_always_" |
| 4 |
// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-linux %s \ |
| 5 |
// RUN: -fsanitize-address-use-after-return=runtime \ |
| 6 |
// RUN: | FileCheck %s --check-prefixes=CHECK-RUNTIME \ |
| 7 |
// RUN: --implicit-check-not="__asan_stack_malloc_always_" |
| 8 |
// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-linux %s \ |
| 9 |
// RUN: -fsanitize-address-use-after-return=always \ |
| 10 |
// RUN: | FileCheck %s --check-prefixes=CHECK-ALWAYS \ |
| 11 |
// RUN: --implicit-check-not=__asan_option_detect_stack_use_after_return \ |
| 12 |
// RUN: --implicit-check-not="__asan_stack_malloc_{{[0-9]}}" |
| 13 |
// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-linux %s \ |
| 14 |
// RUN: -fsanitize-address-use-after-return=never \ |
| 15 |
// RUN: | FileCheck %s \ |
| 16 |
// RUN: --implicit-check-not=__asan_option_detect_stack_use_after_return \ |
| 17 |
// RUN: --implicit-check-not="__asan_stack_malloc_" |
| 18 |
|
| 19 |
// CHECK-RUNTIME: load{{.*}}@__asan_option_detect_stack_use_after_return |
| 20 |
// CHECK-RUNTIME: call{{.*}}__asan_stack_malloc_0 |
| 21 |
// CHECK-ALWAYS: call{{.*}}__asan_stack_malloc_always_0 |
| 22 |
|
| 23 |
int *function1() { |
| 24 |
int x = 0; |
| 25 |
|
| 26 |
#pragma clang diagnostic ignored "-Wreturn-stack-address" |
| 27 |
return &x; |
| 28 |
} |
| 29 |
|
| 30 |
int main() { |
| 31 |
auto px = function1(); |
| 32 |
return 0; |
| 33 |
} |