19fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov// Test for disabling LSan at link-time.
27ddf3c9899c39485d6a70fe294a1e4893897f424Sergey Matveev// RUN: LSAN_BASE="use_stacks=0:use_registers=0"
39fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov// RUN: %clangxx_lsan %s -o %t
42d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: LSAN_OPTIONS=$LSAN_BASE %run %t
52d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t foo 2>&1 | FileCheck %s
69fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov
79fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov#include <sanitizer/lsan_interface.h>
89fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov
99fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonovint argc_copy;
109fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov
119fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonovextern "C" {
129fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonovint __lsan_is_turned_off() {
139fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov  return (argc_copy == 1);
149fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov}
159fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov}
169fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov
179fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonovint main(int argc, char *argv[]) {
189fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov  volatile int *x = new int;
199fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov  *x = 42;
209fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov  argc_copy = argc;
219fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov  return 0;
229fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov}
239fbfd96608070eb71e11fbfe42ec9e84016429aeAlexey Samsonov
242fb08720b11b4c339e191b90d85477c6a2dd74dbAlexey Samsonov// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 4 byte(s) leaked in 1 allocation(s)
25