]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/throw_catch.cc
1 // RUN: %clangxx_asan -O %s -o %t && %run %t
5 #include <sanitizer/asan_interface.h>
7 __attribute__((noinline
))
10 fprintf(stderr
, "Throw: %p\n", &local
);
14 __attribute__((noinline
))
15 void ThrowAndCatch() {
20 fprintf(stderr
, "Catch: %p\n", &local
);
26 fprintf(stderr
, "Before: %p poisoned: %d\n", &x
,
27 __asan_address_is_poisoned(x
+ 32));
28 assert(__asan_address_is_poisoned(x
+ 32));
30 fprintf(stderr
, "After: %p poisoned: %d\n", &x
,
31 __asan_address_is_poisoned(x
+ 32));
32 // FIXME: Invert this assertion once we fix
33 // https://code.google.com/p/address-sanitizer/issues/detail?id=258
34 // This assertion works only w/o UAR.
35 if (!__asan_get_current_fake_stack())
36 assert(!__asan_address_is_poisoned(x
+ 32));
39 void TestThrowInline() {
41 fprintf(stderr
, "Before: %p poisoned: %d\n", &x
,
42 __asan_address_is_poisoned(x
+ 32));
43 assert(__asan_address_is_poisoned(x
+ 32));
47 fprintf(stderr
, "Catch\n");
49 fprintf(stderr
, "After: %p poisoned: %d\n", &x
,
50 __asan_address_is_poisoned(x
+ 32));
51 // FIXME: Invert this assertion once we fix
52 // https://code.google.com/p/address-sanitizer/issues/detail?id=258
53 // This assertion works only w/o UAR.
54 if (!__asan_get_current_fake_stack())
55 assert(!__asan_address_is_poisoned(x
+ 32));
58 int main(int argc
, char **argv
) {