1// RUN: %clangxx_asan -O2 %s -o %t 2// RUN: %t 2>&1 | FileCheck %s 3#include <stdlib.h> 4#include <unistd.h> 5 6extern "C" { 7// Note: avoid calling functions that allocate memory in malloc/free 8// to avoid infinite recursion. 9void __asan_malloc_hook(void *ptr, size_t sz) { 10 write(1, "MallocHook\n", sizeof("MallocHook\n")); 11} 12void __asan_free_hook(void *ptr) { 13 write(1, "FreeHook\n", sizeof("FreeHook\n")); 14} 15} // extern "C" 16 17int main() { 18 volatile int *x = new int; 19 // CHECK: MallocHook 20 *x = 0; 21 delete x; 22 // CHECK: FreeHook 23 return 0; 24} 25