1// Test for the leak_check_at_exit flag.
2// RUN: %clangxx_lsan %s -o %t
3// RUN: %env_lsan_opts=use_stacks=0:use_registers=0 not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
4// RUN: %env_lsan_opts=use_stacks=0:use_registers=0 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-do
5// RUN: %env_lsan_opts=use_stacks=0:use_registers=0:leak_check_at_exit=0 not %run %t foo 2>&1 | FileCheck %s --check-prefix=CHECK-do
6// RUN: %env_lsan_opts=use_stacks=0:use_registers=0:leak_check_at_exit=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-dont
7
8#include <stdio.h>
9#include <stdlib.h>
10#include <sanitizer/lsan_interface.h>
11
12int main(int argc, char *argv[]) {
13 fprintf(stderr, format: "Test alloc: %p.\n", malloc(size: 1337));
14 if (argc > 1)
15 __lsan_do_leak_check();
16 return 0;
17}
18
19// CHECK-do: SUMMARY: {{.*}}Sanitizer:
20// CHECK-dont-NOT: SUMMARY: {{.*}}Sanitizer:
21

source code of compiler-rt/test/lsan/TestCases/leak_check_at_exit.cpp