[LVI] Add trunc to i1 handling. (#124480)
[llvm-project.git] / compiler-rt / test / asan / TestCases / Windows / heapalloc_transfer.cpp
blob0731a02ed1b63f880870a9cd9ac9487ce508c7d3
1 #include "sanitizer\allocator_interface.h"
2 #include <cassert>
3 #include <stdio.h>
4 #include <windows.h>
5 // RUN: %clang_cl_asan %s -o%t
6 // RUN: %env_asan_opts=windows_hook_rtl_allocators=true %run %t 2>&1 | FileCheck %s
7 // UNSUPPORTED: asan-64-bits
9 int main() {
10 //owned by rtl
11 void *alloc = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, 100);
12 assert(alloc);
13 // still owned by rtl
14 alloc = HeapReAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, alloc, 100);
15 assert(alloc && !__sanitizer_get_ownership(alloc) && HeapValidate(GetProcessHeap(), 0, alloc));
16 //convert to asan owned
17 void *realloc = HeapReAlloc(GetProcessHeap(), 0, alloc, 500);
18 alloc = nullptr;
19 assert(realloc && __sanitizer_get_ownership(realloc));
20 //convert back to rtl owned;
21 alloc = HeapReAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, realloc, 100);
22 assert(alloc && !__sanitizer_get_ownership(alloc) && HeapValidate(GetProcessHeap(), 0, alloc));
23 printf("Success\n");
26 // CHECK-NOT: assert
27 // CHECK-NOT: AddressSanitizer
28 // CHECK: Success