Skip to content

Commit e6d94f4

Browse files
committed
[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.
1 parent fac5d05 commit e6d94f4

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

libcxxabi/test/cxa_bad_cast.pass.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <exception>
1515
#include <typeinfo>
1616

17+
#include "test_macros.h"
18+
1719
class Base {
1820
virtual void foo() {};
1921
};
@@ -34,13 +36,13 @@ int main ()
3436
void (*default_handler)() = std::get_terminate();
3537
std::set_terminate(my_terminate);
3638

37-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
39+
#ifndef TEST_HAS_NO_EXCEPTIONS
3840
try {
3941
#endif
4042
Derived &d = test_bad_cast(gB);
4143
assert(false);
4244
((void)d);
43-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
45+
#ifndef TEST_HAS_NO_EXCEPTIONS
4446
} catch (std::bad_cast) {
4547
// success
4648
return 0;

libcxxabi/test/cxa_bad_typeid.pass.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include <string>
1717
#include <iostream>
1818

19+
#include "test_macros.h"
20+
1921
class Base {
2022
virtual void foo() {};
2123
};
@@ -34,12 +36,12 @@ int main ()
3436
void (*default_handler)() = std::get_terminate();
3537
std::set_terminate(my_terminate);
3638

37-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
39+
#ifndef TEST_HAS_NO_EXCEPTIONS
3840
try {
3941
#endif
4042
test_bad_typeid(nullptr);
4143
assert(false);
42-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
44+
#ifndef TEST_HAS_NO_EXCEPTIONS
4345
} catch (std::bad_typeid) {
4446
// success
4547
return 0;

libcxxabi/test/guard_threaded_test.pass.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <memory>
2121
#include <vector>
2222

23+
#include "test_macros.h"
24+
2325

2426
using namespace __cxxabiv1;
2527

@@ -88,13 +90,13 @@ InitResult check_guard(GuardType *g, Init init) {
8890
if (std::__libcpp_atomic_load(first_byte, std::_AO_Acquire) == 0) {
8991
Impl impl(g);
9092
if (impl.cxa_guard_acquire() == INIT_IS_PENDING) {
91-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
93+
#ifndef TEST_HAS_NO_EXCEPTIONS
9294
try {
9395
#endif
9496
init();
9597
impl.cxa_guard_release();
9698
return PERFORMED;
97-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
99+
#ifndef TEST_HAS_NO_EXCEPTIONS
98100
} catch (...) {
99101
impl.cxa_guard_abort();
100102
return ABORTED;

libcxxabi/test/libcxxabi/test/config.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ def configure_compile_flags(self):
5050
]
5151
if self.get_lit_bool('enable_exceptions', True):
5252
self.cxx.compile_flags += ['-funwind-tables']
53-
else:
54-
self.cxx.compile_flags += ['-fno-exceptions', '-DLIBCXXABI_HAS_NO_EXCEPTIONS']
5553
if not self.get_lit_bool('enable_threads', True):
5654
self.cxx.compile_flags += ['-D_LIBCXXABI_HAS_NO_THREADS']
5755
self.config.available_features.add('libcxxabi-no-threads')

libcxxabi/test/test_guard.pass.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include <thread>
1515
#endif
1616

17+
#include "test_macros.h"
18+
1719
// Ensure that we initialize each variable once and only once.
1820
namespace test1 {
1921
static int run_count = 0;
@@ -40,7 +42,7 @@ namespace test1 {
4042
// When initialization fails, ensure that we try to initialize it again next
4143
// time.
4244
namespace test2 {
43-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
45+
#ifndef TEST_HAS_NO_EXCEPTIONS
4446
static int run_count = 0;
4547
int increment() {
4648
++run_count;

libcxxabi/test/test_vector1.pass.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <cstdlib>
1313
#include <cassert>
1414

15+
#include "test_macros.h"
16+
1517
// Wrapper routines
1618
void *my_alloc2 ( size_t sz ) {
1719
void *p = std::malloc ( sz );
@@ -47,14 +49,14 @@ int gConstructorThrowTarget;
4749
int gDestructorCounter;
4850
int gDestructorThrowTarget;
4951
void throw_construct ( void * ) {
50-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
52+
#ifndef TEST_HAS_NO_EXCEPTIONS
5153
if ( gConstructorCounter == gConstructorThrowTarget )
5254
throw 1;
5355
++gConstructorCounter;
5456
#endif
5557
}
5658
void throw_destruct ( void * ) {
57-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
59+
#ifndef TEST_HAS_NO_EXCEPTIONS
5860
if ( ++gDestructorCounter == gDestructorThrowTarget )
5961
throw 2;
6062
#endif
@@ -156,7 +158,7 @@ int test_counted ( ) {
156158
return retVal;
157159
}
158160

159-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
161+
#ifndef TEST_HAS_NO_EXCEPTIONS
160162
// Make sure the constructors and destructors are matched
161163
int test_exception_in_constructor ( ) {
162164
int retVal = 0;
@@ -215,7 +217,7 @@ int test_exception_in_constructor ( ) {
215217
}
216218
#endif
217219

218-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
220+
#ifndef TEST_HAS_NO_EXCEPTIONS
219221
// Make sure the constructors and destructors are matched
220222
int test_exception_in_destructor ( ) {
221223
int retVal = 0;
@@ -272,7 +274,7 @@ int main () {
272274
int retVal = 0;
273275
retVal += test_empty ();
274276
retVal += test_counted ();
275-
#ifndef LIBCXXABI_HAS_NO_EXCEPTIONS
277+
#ifndef TEST_HAS_NO_EXCEPTIONS
276278
retVal += test_exception_in_constructor ();
277279
retVal += test_exception_in_destructor ();
278280
#endif

0 commit comments

Comments
 (0)