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
8int *x, *y, *z;
9
10int main() {
11 x = new int;
12 __lsan_ignore_object(p: x);
13
14 z = new int[1000000]; // Large enough for the secondary allocator.
15 __lsan_ignore_object(p: z);
16
17 {
18 __lsan::ScopedDisabler disabler;
19 y = new int;
20 }
21
22 x = y = z = nullptr;
23 return 0;
24}
25

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