xref: /llvm-project/compiler-rt/test/lsan/TestCases/lsan_annotations.cpp (revision 3712dd73a1d50b76624ee6a520be2b1ca94c02ee)
1 // Check that LSan annotations work fine.
2 // RUN: %clangxx_lsan -O0 %s -o %t && %run %t
3 // RUN: %clangxx_lsan -O3 %s -o %t && %run %t
4 
5 #include <sanitizer/lsan_interface.h>
6 #include <stdlib.h>
7 
8 int *x, *y, *z;
9 
main()10 int main() {
11   x = new int;
12   __lsan_ignore_object(x);
13 
14   z = new int[1000000];  // Large enough for the secondary allocator.
15   __lsan_ignore_object(z);
16 
17   {
18     __lsan::ScopedDisabler disabler;
19     y = new int;
20   }
21 
22   x = y = z = nullptr;
23   return 0;
24 }
25