xref: /llvm-project/compiler-rt/test/lsan/TestCases/ignore_object_errors.cpp (revision 300dc054e695ee18beb6f4a23898e50938251e2b)
197ccf6b8SFangrui Song // Test for incorrect use of __lsan_ignore_object().
297ccf6b8SFangrui Song // RUN: %clangxx_lsan %s -o %t
3*300dc054SVitaly Buka // RUN: %run %t 2>&1 | FileCheck %s
497ccf6b8SFangrui Song 
597ccf6b8SFangrui Song #include <stdio.h>
697ccf6b8SFangrui Song #include <stdlib.h>
797ccf6b8SFangrui Song 
897ccf6b8SFangrui Song #include "sanitizer/lsan_interface.h"
997ccf6b8SFangrui Song 
main()1097ccf6b8SFangrui Song int main() {
1197ccf6b8SFangrui Song   void *p = malloc(1337);
1297ccf6b8SFangrui Song   fprintf(stderr, "Test alloc: %p.\n", p);
1397ccf6b8SFangrui Song   __lsan_ignore_object(p);
1497ccf6b8SFangrui Song   __lsan_ignore_object(p);
1597ccf6b8SFangrui Song   free(p);
1697ccf6b8SFangrui Song   __lsan_ignore_object(p);
1797ccf6b8SFangrui Song   return 0;
1897ccf6b8SFangrui Song }
1997ccf6b8SFangrui Song // CHECK: Test alloc: [[ADDR:.*]].
2097ccf6b8SFangrui Song // CHECK-NOT: SUMMARY: {{.*}} leaked
21