1 // Clang doesn't support exceptions on Windows yet, so for the time being we
2 // build this program in two parts: the code with exceptions is built with CL,
3 // the rest is built with Clang. This represents the typical scenario when we
4 // build a large project using "clang-cl -fallback -fsanitize=address".
6 // RUN: cl -Zi -FS -c %s -Fo%t.obj
7 // RUN: %clangxx_asan -o %t.exe %s %t.obj
13 // Should just "#include <sanitizer/asan_interface.h>" when C++ exceptions are
14 // supported and we don't need to use CL.
15 extern "C" bool __asan_address_is_poisoned(void *p
);
18 void TestThrowInline();
20 #if !defined(__clang__)
24 fprintf(stderr
, "Throw: %p\n", &local
);
29 void ThrowAndCatch() {
34 fprintf(stderr
, "Catch: %p\n", &local
);
38 void TestThrowInline() {
40 fprintf(stderr
, "Before: %p poisoned: %d\n", &x
,
41 __asan_address_is_poisoned(x
+ 32));
45 fprintf(stderr
, "Catch\n");
47 fprintf(stderr
, "After: %p poisoned: %d\n", &x
,
48 __asan_address_is_poisoned(x
+ 32));
49 // FIXME: Invert this assertion once we fix
50 // https://code.google.com/p/address-sanitizer/issues/detail?id=258
51 assert(!__asan_address_is_poisoned(x
+ 32));
58 fprintf(stderr
, "Before: %p poisoned: %d\n", &x
,
59 __asan_address_is_poisoned(x
+ 32));
60 assert(__asan_address_is_poisoned(x
+ 32));
62 fprintf(stderr
, "After: %p poisoned: %d\n", &x
,
63 __asan_address_is_poisoned(x
+ 32));
64 // FIXME: Invert this assertion once we fix
65 // https://code.google.com/p/address-sanitizer/issues/detail?id=258
66 assert(!__asan_address_is_poisoned(x
+ 32));
69 int main(int argc
, char **argv
) {