[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.
This commit is contained in:
Louis Dionne 2020-06-09 15:47:37 -04:00
parent fac5d05eb7
commit e6d94f4bd2
6 changed files with 22 additions and 14 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -50,8 +50,6 @@ class Configuration(LibcxxConfiguration):
]
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')

View File

@ -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;

View File

@ -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