[llvm-commits] [test-suite] r139737 - in /test-suite/trunk/SingleSource/UnitTests/EH: cleanup-1.cpp cleanup-1.reference_output cleanup-2.cpp cleanup-2.reference_output cleanup-3.cpp cleanup-3.reference_output

Bill Wendling isanbard at gmail.com
Wed Sep 14 14:10:47 PDT 2011


Author: void
Date: Wed Sep 14 16:10:47 2011
New Revision: 139737

URL: http://llvm.org/viewvc/llvm-project?rev=139737&view=rev
Log:
Add some EH cleanup tests.

Added:
    test-suite/trunk/SingleSource/UnitTests/EH/cleanup-1.cpp
    test-suite/trunk/SingleSource/UnitTests/EH/cleanup-1.reference_output
    test-suite/trunk/SingleSource/UnitTests/EH/cleanup-2.cpp
    test-suite/trunk/SingleSource/UnitTests/EH/cleanup-2.reference_output
    test-suite/trunk/SingleSource/UnitTests/EH/cleanup-3.cpp
    test-suite/trunk/SingleSource/UnitTests/EH/cleanup-3.reference_output

Added: test-suite/trunk/SingleSource/UnitTests/EH/cleanup-1.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/EH/cleanup-1.cpp?rev=139737&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/EH/cleanup-1.cpp (added)
+++ test-suite/trunk/SingleSource/UnitTests/EH/cleanup-1.cpp Wed Sep 14 16:10:47 2011
@@ -0,0 +1,53 @@
+#include <iostream>
+
+struct A {
+  ~A() {
+    std::cout << "In A's d'tor\n";
+  }
+};
+
+struct B {
+  ~B() {
+    std::cout << "In B's d'tor\n";
+  }
+};
+
+struct C {
+  void throw_int() {
+    throw 42;
+  }
+
+  ~C() {
+    std::cout << "In C's d'tor\n";
+    try {
+      B b;
+      throw_int();
+    } catch (int e) {
+      std::cout << "(C::~C) Caught int: " << e << "\n";
+    }
+  }
+};
+
+#define DECLARE(FUNC)                           \
+  void FUNC() __attribute__((noinline));        \
+  void FUNC()
+
+DECLARE(throw_char) {
+  C c;
+  throw 'c';
+}
+
+DECLARE(cleanup) {
+  A a;
+  try {
+    B b;
+    throw_char();
+  } catch (char e) {
+    std::cout << "Caught char: " << e << "\n";
+  }
+}
+
+int main() {
+  A a;
+  cleanup();
+}

Added: test-suite/trunk/SingleSource/UnitTests/EH/cleanup-1.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/EH/cleanup-1.reference_output?rev=139737&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/EH/cleanup-1.reference_output (added)
+++ test-suite/trunk/SingleSource/UnitTests/EH/cleanup-1.reference_output Wed Sep 14 16:10:47 2011
@@ -0,0 +1,8 @@
+In C's d'tor
+In B's d'tor
+(C::~C) Caught int: 42
+In B's d'tor
+Caught char: c
+In A's d'tor
+In A's d'tor
+exit 0

Added: test-suite/trunk/SingleSource/UnitTests/EH/cleanup-2.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/EH/cleanup-2.cpp?rev=139737&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/EH/cleanup-2.cpp (added)
+++ test-suite/trunk/SingleSource/UnitTests/EH/cleanup-2.cpp Wed Sep 14 16:10:47 2011
@@ -0,0 +1,53 @@
+#include <iostream>
+
+struct A {
+  ~A() {
+    std::cout << "In A's d'tor\n";
+  }
+};
+
+struct B {
+  ~B() {
+    std::cout << "In B's d'tor\n";
+  }
+};
+
+struct C {
+  void throw_int() {
+    throw 42;
+  }
+
+  ~C() {
+    std::cout << "In C's d'tor\n";
+    try {
+      B b;
+      throw_int();
+    } catch (int e) {
+      std::cout << "(C::~C) Caught int: " << e << "\n";
+    }
+  }
+};
+
+#define DECLARE(FUNC)                                \
+  void FUNC() __attribute__((always_inline));        \
+  void FUNC()
+
+DECLARE(throw_char) {
+  C c;
+  throw 'c';
+}
+
+DECLARE(cleanup) {
+  A a;
+  try {
+    B b;
+    throw_char();
+  } catch (char e) {
+    std::cout << "Caught char: " << e << "\n";
+  }
+}
+
+int main() {
+  A a;
+  cleanup();
+}

Added: test-suite/trunk/SingleSource/UnitTests/EH/cleanup-2.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/EH/cleanup-2.reference_output?rev=139737&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/EH/cleanup-2.reference_output (added)
+++ test-suite/trunk/SingleSource/UnitTests/EH/cleanup-2.reference_output Wed Sep 14 16:10:47 2011
@@ -0,0 +1,8 @@
+In C's d'tor
+In B's d'tor
+(C::~C) Caught int: 42
+In B's d'tor
+Caught char: c
+In A's d'tor
+In A's d'tor
+exit 0

Added: test-suite/trunk/SingleSource/UnitTests/EH/cleanup-3.cpp
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/EH/cleanup-3.cpp?rev=139737&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/EH/cleanup-3.cpp (added)
+++ test-suite/trunk/SingleSource/UnitTests/EH/cleanup-3.cpp Wed Sep 14 16:10:47 2011
@@ -0,0 +1,59 @@
+#include <iostream>
+
+struct A {
+  ~A() {
+    std::cout << "In A's d'tor\n";
+  }
+};
+
+struct B {
+  ~B() {
+    std::cout << "In B's d'tor\n";
+  }
+};
+
+struct C {
+  void throw_int() {
+    throw 42;
+  }
+
+  ~C() {
+    std::cout << "In C's d'tor\n";
+    try {
+      B b;
+      throw_int();
+    } catch (char e) {
+      std::cout << "(C::~C) Caught char: " << e << "\n";
+    }
+  }
+};
+
+#define DECLARE(FUNC)                                \
+  void FUNC() __attribute__((always_inline));        \
+  void FUNC()
+
+DECLARE(throw_char) {
+  C c;
+  throw 'c';
+}
+
+DECLARE(cleanup) {
+  A a;
+  try {
+    B b;
+    throw_char();
+  } catch (char e) {
+    std::cout << "Caught char: " << e << "\n";
+  }
+}
+
+void term() {
+  printf("Inside the terminator\n");
+  exit(EXIT_SUCCESS);
+}
+
+int main() {
+  std::set_terminate(term);
+  A a;
+  cleanup();
+}

Added: test-suite/trunk/SingleSource/UnitTests/EH/cleanup-3.reference_output
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/SingleSource/UnitTests/EH/cleanup-3.reference_output?rev=139737&view=auto
==============================================================================
--- test-suite/trunk/SingleSource/UnitTests/EH/cleanup-3.reference_output (added)
+++ test-suite/trunk/SingleSource/UnitTests/EH/cleanup-3.reference_output Wed Sep 14 16:10:47 2011
@@ -0,0 +1,4 @@
+In C's d'tor
+In B's d'tor
+Inside the terminator
+exit 0





More information about the llvm-commits mailing list