1// Test for disabling LSan at link-time.
2// RUN: %clangxx_lsan %s -o %t
3// RUN: %env_lsan_opts=use_stacks=0:use_registers=0 %run %t
4// RUN: %env_lsan_opts=use_stacks=0:use_registers=0 not %run %t foo 2>&1 | FileCheck %s
5//
6// UNSUPPORTED: darwin
7
8#include <sanitizer/lsan_interface.h>
9
10int argc_copy;
11
12extern "C" {
13int __attribute__((used)) __lsan_is_turned_off() {
14 return (argc_copy == 1);
15}
16}
17
18int main(int argc, char *argv[]) {
19 volatile int *x = new int;
20 *x = 42;
21 argc_copy = argc;
22 return 0;
23}
24
25// CHECK: SUMMARY: {{(.*)}}Sanitizer: 4 byte(s) leaked in 1 allocation(s)
26

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