Skip to content

Commit 7e542a2

Browse files
authored
[libc++abi] Avoid using deprecated throw specifications in >= C++11 (#109296)
Closes #108426
1 parent 511439b commit 7e542a2

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

libcxxabi/include/__cxxabi_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,10 @@
103103
#define _LIBCXXABI_DTOR_FUNC
104104
#endif
105105

106+
#if __cplusplus < 201103L
107+
# define _LIBCXXABI_NOEXCEPT throw()
108+
#else
109+
# define _LIBCXXABI_NOEXCEPT noexcept
110+
#endif
111+
106112
#endif // ____CXXABI_CONFIG_H

libcxxabi/include/cxxabi.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ extern "C" {
4343

4444
// 2.4.2 Allocating the Exception Object
4545
extern _LIBCXXABI_FUNC_VIS void *
46-
__cxa_allocate_exception(size_t thrown_size) throw();
46+
__cxa_allocate_exception(size_t thrown_size) _LIBCXXABI_NOEXCEPT;
4747
extern _LIBCXXABI_FUNC_VIS void
48-
__cxa_free_exception(void *thrown_exception) throw();
48+
__cxa_free_exception(void *thrown_exception) _LIBCXXABI_NOEXCEPT;
4949
// This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt
5050
extern _LIBCXXABI_FUNC_VIS __cxa_exception*
5151
#ifdef __wasm__
5252
// In Wasm, a destructor returns its argument
53-
__cxa_init_primary_exception(void* object, std::type_info* tinfo, void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
53+
__cxa_init_primary_exception(void* object, std::type_info* tinfo, void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) _LIBCXXABI_NOEXCEPT;
5454
#else
55-
__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
55+
__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) _LIBCXXABI_NOEXCEPT;
5656
#endif
5757

5858
// 2.4.3 Throwing the Exception Object
@@ -66,21 +66,21 @@ __cxa_throw(void *thrown_exception, std::type_info *tinfo,
6666

6767
// 2.5.3 Exception Handlers
6868
extern _LIBCXXABI_FUNC_VIS void *
69-
__cxa_get_exception_ptr(void *exceptionObject) throw();
69+
__cxa_get_exception_ptr(void *exceptionObject) _LIBCXXABI_NOEXCEPT;
7070
extern _LIBCXXABI_FUNC_VIS void *
71-
__cxa_begin_catch(void *exceptionObject) throw();
71+
__cxa_begin_catch(void *exceptionObject) _LIBCXXABI_NOEXCEPT;
7272
extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();
7373
#if defined(_LIBCXXABI_ARM_EHABI)
7474
extern _LIBCXXABI_FUNC_VIS bool
75-
__cxa_begin_cleanup(void *exceptionObject) throw();
75+
__cxa_begin_cleanup(void *exceptionObject) _LIBCXXABI_NOEXCEPT;
7676
extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
7777
#endif
7878
extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
7979

8080
// GNU extension
8181
// Calls `terminate` with the current exception being caught. This function is used by GCC when a `noexcept` function
8282
// throws an exception inside a try/catch block and doesn't catch it.
83-
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_call_terminate(void*) throw();
83+
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_call_terminate(void*) _LIBCXXABI_NOEXCEPT;
8484

8585
// 2.5.4 Rethrowing Exceptions
8686
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();
@@ -168,23 +168,23 @@ extern _LIBCXXABI_FUNC_VIS char *__cxa_demangle(const char *mangled_name,
168168

169169
// Apple additions to support C++ 0x exception_ptr class
170170
// These are primitives to wrap a smart pointer around an exception object
171-
extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() throw();
171+
extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() _LIBCXXABI_NOEXCEPT;
172172
extern _LIBCXXABI_FUNC_VIS void
173173
__cxa_rethrow_primary_exception(void *primary_exception);
174174
extern _LIBCXXABI_FUNC_VIS void
175-
__cxa_increment_exception_refcount(void *primary_exception) throw();
175+
__cxa_increment_exception_refcount(void *primary_exception) _LIBCXXABI_NOEXCEPT;
176176
extern _LIBCXXABI_FUNC_VIS void
177-
__cxa_decrement_exception_refcount(void *primary_exception) throw();
177+
__cxa_decrement_exception_refcount(void *primary_exception) _LIBCXXABI_NOEXCEPT;
178178

179179
// Apple extension to support std::uncaught_exception()
180-
extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() throw();
181-
extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() throw();
180+
extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() _LIBCXXABI_NOEXCEPT;
181+
extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() _LIBCXXABI_NOEXCEPT;
182182

183183
#if defined(__linux__) || defined(__Fuchsia__)
184184
// Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI.
185185
// https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
186186
extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *,
187-
void *) throw();
187+
void *) _LIBCXXABI_NOEXCEPT;
188188
#endif
189189

190190
} // extern "C"

0 commit comments

Comments
 (0)