xref: /llvm-project/compiler-rt/test/lsan/TestCases/suppressions_default.cpp (revision b2aa0a465013aca2fc43ca729fdb714eb52150b3)
1 // RUN: %clangxx_lsan %s -o %t
2 // RUN: %env_lsan_opts=use_registers=0:use_stacks=0 not %run %t 2>&1 | FileCheck %s
3 
4 #include <stdio.h>
5 #include <stdlib.h>
6 
7 #include "sanitizer/lsan_interface.h"
8 
9 extern "C"
__lsan_default_suppressions()10 const char *__lsan_default_suppressions() {
11   return "leak:*LSanTestLeakingFunc*";
12 }
13 
LSanTestLeakingFunc()14 void LSanTestLeakingFunc() {
15   void *p = malloc(666);
16   fprintf(stderr, "Test alloc: %p.\n", p);
17 }
18 
main()19 int main() {
20   LSanTestLeakingFunc();
21   void *q = malloc(1337);
22   fprintf(stderr, "Test alloc: %p.\n", q);
23   return 0;
24 }
25 // CHECK: Suppressions used:
26 // CHECK: 1 666 *LSanTestLeakingFunc*
27 // CHECK: SUMMARY: {{.*}}Sanitizer: 1337 byte(s) leaked in 1 allocation(s)
28