[libcxx-commits] [libcxxabi] e6d94f4 - [libc++abi] Replace LIBCXXABI_HAS_NO_EXCEPTIONS by TEST_HAS_NO_EXCEPTIONS

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jun 9 13:13:59 PDT 2020


Author: Louis Dionne
Date: 2020-06-09T16:13:17-04:00
New Revision: e6d94f4bd210f01a6dedf3cdd9ac331815cc7874

URL: https://github.com/llvm/llvm-project/commit/e6d94f4bd210f01a6dedf3cdd9ac331815cc7874
DIFF: https://github.com/llvm/llvm-project/commit/e6d94f4bd210f01a6dedf3cdd9ac331815cc7874.diff

LOG: [libc++abi] Replace LIBCXXABI_HAS_NO_EXCEPTIONS by TEST_HAS_NO_EXCEPTIONS

This clarifies the difference between test for exception support in
libc++abi tests and support for exceptions built into libc++abi.
This also removes the rather confusing similarity between the
_LIBCXXABI_NO_EXCEPTIONS and LIBCXXABI_HAS_NO_EXCEPTIONS macros.

Finally, TEST_HAS_NO_EXCEPTIONS is also detected automatically based
on -fno-exceptions, so it doesn't have to be specified explicitly
through Lit's compile_flags.

Added: 
    

Modified: 
    libcxxabi/test/cxa_bad_cast.pass.cpp
    libcxxabi/test/cxa_bad_typeid.pass.cpp
    libcxxabi/test/guard_threaded_test.pass.cpp
    libcxxabi/test/libcxxabi/test/config.py
    libcxxabi/test/test_guard.pass.cpp
    libcxxabi/test/test_vector1.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxxabi/test/cxa_bad_cast.pass.cpp b/libcxxabi/test/cxa_bad_cast.pass.cpp
index c6fb8eee35b1..5ff64e8b078a 100644
--- a/libcxxabi/test/cxa_bad_cast.pass.cpp
+++ b/libcxxabi/test/cxa_bad_cast.pass.cpp
@@ -14,6 +14,8 @@
 #include <exception>
 #include <typeinfo>
 
+#include "test_macros.h"
+
 class Base {
   virtual void foo() {};
 };
@@ -34,13 +36,13 @@ int main ()
     void (*default_handler)() = std::get_terminate();
     std::set_terminate(my_terminate);
 
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
     try {
 #endif
         Derived &d = test_bad_cast(gB);
         assert(false);
         ((void)d);
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
     } catch (std::bad_cast) {
         // success
         return 0;

diff  --git a/libcxxabi/test/cxa_bad_typeid.pass.cpp b/libcxxabi/test/cxa_bad_typeid.pass.cpp
index 116f98f04e7a..fc491d7802b0 100644
--- a/libcxxabi/test/cxa_bad_typeid.pass.cpp
+++ b/libcxxabi/test/cxa_bad_typeid.pass.cpp
@@ -16,6 +16,8 @@
 #include <string>
 #include <iostream>
 
+#include "test_macros.h"
+
 class Base {
   virtual void foo() {};
 };
@@ -34,12 +36,12 @@ int main ()
     void (*default_handler)() = std::get_terminate();
     std::set_terminate(my_terminate);
 
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
     try {
 #endif
         test_bad_typeid(nullptr);
         assert(false);
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
     } catch (std::bad_typeid) {
         // success
         return 0;

diff  --git a/libcxxabi/test/guard_threaded_test.pass.cpp b/libcxxabi/test/guard_threaded_test.pass.cpp
index 43636c5fe577..0dc911c73a49 100644
--- a/libcxxabi/test/guard_threaded_test.pass.cpp
+++ b/libcxxabi/test/guard_threaded_test.pass.cpp
@@ -20,6 +20,8 @@
 #include <memory>
 #include <vector>
 
+#include "test_macros.h"
+
 
 using namespace __cxxabiv1;
 
@@ -88,13 +90,13 @@ InitResult check_guard(GuardType *g, Init init) {
   if (std::__libcpp_atomic_load(first_byte, std::_AO_Acquire) == 0) {
     Impl impl(g);
     if (impl.cxa_guard_acquire() == INIT_IS_PENDING) {
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
       try {
 #endif
         init();
         impl.cxa_guard_release();
         return PERFORMED;
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
       } catch (...) {
         impl.cxa_guard_abort();
         return ABORTED;

diff  --git a/libcxxabi/test/libcxxabi/test/config.py b/libcxxabi/test/libcxxabi/test/config.py
index 37938d53a240..b9b2b6e90c6a 100644
--- a/libcxxabi/test/libcxxabi/test/config.py
+++ b/libcxxabi/test/libcxxabi/test/config.py
@@ -50,8 +50,6 @@ def configure_compile_flags(self):
         ]
         if self.get_lit_bool('enable_exceptions', True):
             self.cxx.compile_flags += ['-funwind-tables']
-        else:
-            self.cxx.compile_flags += ['-fno-exceptions', '-DLIBCXXABI_HAS_NO_EXCEPTIONS']
         if not self.get_lit_bool('enable_threads', True):
             self.cxx.compile_flags += ['-D_LIBCXXABI_HAS_NO_THREADS']
             self.config.available_features.add('libcxxabi-no-threads')

diff  --git a/libcxxabi/test/test_guard.pass.cpp b/libcxxabi/test/test_guard.pass.cpp
index 73f35593c3af..8c96ae891d22 100644
--- a/libcxxabi/test/test_guard.pass.cpp
+++ b/libcxxabi/test/test_guard.pass.cpp
@@ -14,6 +14,8 @@
 #include <thread>
 #endif
 
+#include "test_macros.h"
+
 // Ensure that we initialize each variable once and only once.
 namespace test1 {
     static int run_count = 0;
@@ -40,7 +42,7 @@ namespace test1 {
 // When initialization fails, ensure that we try to initialize it again next
 // time.
 namespace test2 {
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
     static int run_count = 0;
     int increment() {
         ++run_count;

diff  --git a/libcxxabi/test/test_vector1.pass.cpp b/libcxxabi/test/test_vector1.pass.cpp
index 841d1ab986ab..10b77b0c3b04 100644
--- a/libcxxabi/test/test_vector1.pass.cpp
+++ b/libcxxabi/test/test_vector1.pass.cpp
@@ -12,6 +12,8 @@
 #include <cstdlib>
 #include <cassert>
 
+#include "test_macros.h"
+
 //  Wrapper routines
 void *my_alloc2 ( size_t sz ) {
     void *p = std::malloc ( sz );
@@ -47,14 +49,14 @@ int gConstructorThrowTarget;
 int gDestructorCounter;
 int gDestructorThrowTarget;
 void throw_construct ( void * ) {
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
     if ( gConstructorCounter   == gConstructorThrowTarget )
         throw 1;
     ++gConstructorCounter;
 #endif
 }
 void throw_destruct  ( void * ) {
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
     if ( ++gDestructorCounter  == gDestructorThrowTarget  )
         throw 2;
 #endif
@@ -156,7 +158,7 @@ int test_counted ( ) {
     return retVal;
     }
     
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
 //  Make sure the constructors and destructors are matched
 int test_exception_in_constructor ( ) {
     int retVal = 0;
@@ -215,7 +217,7 @@ int test_exception_in_constructor ( ) {
     }
 #endif
 
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
 //  Make sure the constructors and destructors are matched
 int test_exception_in_destructor ( ) {
     int retVal = 0;
@@ -272,7 +274,7 @@ int main () {
     int retVal = 0;
     retVal += test_empty ();
     retVal += test_counted ();
-#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
+#ifndef TEST_HAS_NO_EXCEPTIONS
     retVal += test_exception_in_constructor ();
     retVal += test_exception_in_destructor ();
 #endif


        


More information about the libcxx-commits mailing list