1 // Test for __lsan_ignore_object().
2 // RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=0:use_globals=0:use_tls=0"
3 // RUN: %clangxx_lsan %s -o %t
4 // RUN: LSAN_OPTIONS=$LSAN_BASE not %run %t 2>&1 | FileCheck %s
5
6 #include <stdio.h>
7 #include <stdlib.h>
8
9 #include "sanitizer/lsan_interface.h"
10
main()11 int main() {
12 // Explicitly ignored object.
13 void **p = new void *;
14 // Transitively ignored object.
15 *p = malloc(666);
16 // Non-ignored object.
17 volatile void *q = malloc(1337);
18 fprintf(stderr, "Test alloc: %p.\n", p);
19 __lsan_ignore_object(p);
20 return 0;
21 }
22 // CHECK: Test alloc: [[ADDR:.*]].
23 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
24