xref: /llvm-project/compiler-rt/test/lsan/TestCases/disabler.cpp (revision 55a2c4eb04b2c0c193d8d993ff1b8d4d94097c82)
1 // Test for ScopedDisabler.
2 // RUN: %clangxx_lsan %s -o %t
3 // RUN: %env_lsan_opts=report_objects=1:use_registers=0:use_stacks=0 not %run %t 2>&1 | FileCheck %s
4 
5 #include <stdio.h>
6 #include <stdlib.h>
7 
8 #include "sanitizer/lsan_interface.h"
9 
main()10 int main() {
11   void **p;
12   {
13     __lsan::ScopedDisabler d;
14     p = new void *;
15     fprintf(stderr, "Test alloc p: %p.\n", p);
16   }
17   *p = malloc(666);
18   void *q = malloc(1337);
19   fprintf(stderr, "Test alloc q: %p.\n", q);
20   return 0;
21 }
22 
23 // CHECK: Test alloc p: [[ADDR:.*]].
24 // CHECK-NOT: [[ADDR]]
25