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