1 // Make sure that ASan works with SEH in both Clang and MSVC. MSVC uses a
2 // different EH personality depending on the -GS setting, so test both -GS+ and
5 // RUN: cl -c %s -Fo%t.obj -DCOMPILE_SEH
6 // RUN: %clangxx_asan -o %t.exe %s %t.obj
9 // RUN: cl -GS- -c %s -Fo%t.obj -DCOMPILE_SEH
10 // RUN: %clangxx_asan -o %t.exe %s %t.obj
13 // RUN: %clang_cl_asan %s -DCOMPILE_SEH -Fe%t.exe
20 // Should just "#include <sanitizer/asan_interface.h>" when C++ exceptions are
21 // supported and we don't need to use CL.
22 extern "C" bool __asan_address_is_poisoned(void *p
);
26 #if defined(COMPILE_SEH)
30 fprintf(stderr
, "Throw: %p\n", &local
);
35 void ThrowAndCatch() {
39 } __except(EXCEPTION_EXECUTE_HANDLER
) {
40 fprintf(stderr
, "__except: %p\n", &local
);
45 #if defined(__clang__)
48 fprintf(stderr
, "Before: %p poisoned: %d\n", &x
,
49 __asan_address_is_poisoned(x
+ 32));
50 assert(__asan_address_is_poisoned(x
+ 32));
52 fprintf(stderr
, "After: %p poisoned: %d\n", &x
,
53 __asan_address_is_poisoned(x
+ 32));
54 // FIXME: Invert this assertion once we fix
55 // https://code.google.com/p/address-sanitizer/issues/detail?id=258
56 assert(!__asan_address_is_poisoned(x
+ 32));