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
10int main() {
11 void **p;
12 {
13 __lsan::ScopedDisabler d;
14 p = new void *;
15 fprintf(stderr, format: "Test alloc p: %p.\n", p);
16 }
17 *p = malloc(size: 666);
18 void *q = malloc(size: 1337);
19 fprintf(stderr, format: "Test alloc q: %p.\n", q);
20 return 0;
21}
22
23// CHECK: Test alloc p: [[ADDR:.*]].
24// CHECK-NOT: [[ADDR]]
25

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