[PATCH] D44733: Split the `throw_invoke_test.cc` test
Dan Liew via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 29 06:56:54 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL328775: [asan] Split the `throw_invoke_test.cc` into a Linux specific variant (authored by delcypher, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D44733?vs=139283&id=140222#toc
Repository:
rL LLVM
https://reviews.llvm.org/D44733
Files:
compiler-rt/trunk/test/asan/TestCases/Linux/throw_invoke_test_libstdcxx.cc
compiler-rt/trunk/test/asan/TestCases/throw_invoke_test.cc
Index: compiler-rt/trunk/test/asan/TestCases/throw_invoke_test.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/throw_invoke_test.cc
+++ compiler-rt/trunk/test/asan/TestCases/throw_invoke_test.cc
@@ -1,5 +1,4 @@
// RUN: %clangxx_asan %s -o %t && %run %t
-// RUN: %clangxx_asan %s -o %t -stdlib=libstdc++ -static-libstdc++ && %run %t
#include <stdio.h>
static volatile int zero = 0;
Index: compiler-rt/trunk/test/asan/TestCases/Linux/throw_invoke_test_libstdcxx.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/throw_invoke_test_libstdcxx.cc
+++ compiler-rt/trunk/test/asan/TestCases/Linux/throw_invoke_test_libstdcxx.cc
@@ -0,0 +1,48 @@
+// This the basically the `throw_invoke_test.cc` test but using libstdc++
+// instead of the default.
+// RUN: %clangxx_asan %s -o %t -stdlib=libstdc++ -static-libstdc++ && %run %t
+
+#include <stdio.h>
+static volatile int zero = 0;
+inline void pretend_to_do_something(void *x) {
+ __asm__ __volatile__("" : : "r"(x) : "memory");
+}
+
+__attribute__((noinline)) void ReallyThrow() {
+ fprintf(stderr, "ReallyThrow\n");
+ try {
+ if (zero == 0)
+ throw 42;
+ else if (zero == 1)
+ throw 1.;
+ } catch (double x) {
+ }
+}
+
+__attribute__((noinline)) void Throw() {
+ int a, b, c, d, e;
+ pretend_to_do_something(&a);
+ pretend_to_do_something(&b);
+ pretend_to_do_something(&c);
+ pretend_to_do_something(&d);
+ pretend_to_do_something(&e);
+ fprintf(stderr, "Throw stack = %p\n", &a);
+ ReallyThrow();
+}
+
+__attribute__((noinline)) void CheckStack() {
+ int ar[100];
+ pretend_to_do_something(ar);
+ for (int i = 0; i < 100; i++)
+ ar[i] = i;
+ fprintf(stderr, "CheckStack stack = %p, %p\n", ar, ar + 100);
+}
+
+int main(int argc, char **argv) {
+ try {
+ Throw();
+ } catch (int a) {
+ fprintf(stderr, "a = %d\n", a);
+ }
+ CheckStack();
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44733.140222.patch
Type: text/x-patch
Size: 1970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180329/eeb48042/attachment-0001.bin>
More information about the llvm-commits
mailing list