]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/lsan/TestCases/ignore_object.c
Vendor import of compiler-rt trunk r351319 (just before the release_80
[FreeBSD/FreeBSD.git] / test / lsan / TestCases / ignore_object.c
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: %clang_lsan %s -o %t
4 // RUN: %env_lsan_opts=$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
11 int main() {
12   // Explicitly ignored object.
13   void **p = malloc(sizeof(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)