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