]> git.proxmox.com Git - rustc.git/blame - src/libcompiler_builtins/compiler-rt/test/lsan/TestCases/ignore_object.c
New upstream version 1.25.0+dfsg1
[rustc.git] / src / libcompiler_builtins / compiler-rt / test / lsan / TestCases / ignore_object.c
CommitLineData
1a4d82fc 1// Test for __lsan_ignore_object().
92a42be0 2// RUN: LSAN_BASE="report_objects=1:use_registers=0:use_stacks=0:use_globals=0:use_tls=0"
3157f602 3// RUN: %clang_lsan %s -o %t
2c00a5a8 4// RUN: %env_lsan_opts=$LSAN_BASE not %run %t 2>&1 | FileCheck %s
1a4d82fc
JJ
5
6#include <stdio.h>
7#include <stdlib.h>
8
9#include "sanitizer/lsan_interface.h"
10
11int main() {
12 // Explicitly ignored object.
3157f602 13 void **p = malloc(sizeof(void *));
1a4d82fc
JJ
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:.*]].
1a4d82fc 23// CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)