Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxxabi / include / cxxabi.h
blob6f4f823bc273ff3b1147d9029e50960cad5d752f
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef __CXXABI_H
10 #define __CXXABI_H
13 * This header provides the interface to the C++ ABI as defined at:
14 * https://itanium-cxx-abi.github.io/cxx-abi/
17 #include <stddef.h>
18 #include <stdint.h>
20 #include <__cxxabi_config.h>
22 #define _LIBCPPABI_VERSION 15000
23 #define _LIBCXXABI_NORETURN __attribute__((noreturn))
24 #define _LIBCXXABI_ALWAYS_COLD __attribute__((cold))
26 #ifdef __cplusplus
28 namespace std {
29 #if defined(_WIN32)
30 class _LIBCXXABI_TYPE_VIS type_info; // forward declaration
31 #else
32 class type_info; // forward declaration
33 #endif
37 // runtime routines use C calling conventions, but are in __cxxabiv1 namespace
38 namespace __cxxabiv1 {
39 extern "C" {
41 // 2.4.2 Allocating the Exception Object
42 extern _LIBCXXABI_FUNC_VIS void *
43 __cxa_allocate_exception(size_t thrown_size) throw();
44 extern _LIBCXXABI_FUNC_VIS void
45 __cxa_free_exception(void *thrown_exception) throw();
47 // 2.4.3 Throwing the Exception Object
48 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
49 __cxa_throw(void *thrown_exception, std::type_info *tinfo,
50 #ifdef __USING_WASM_EXCEPTIONS__
51 // In Wasm, a destructor returns its argument
52 void *(_LIBCXXABI_DTOR_FUNC *dest)(void *));
53 #else
54 void (_LIBCXXABI_DTOR_FUNC *dest)(void *));
55 #endif
57 // 2.5.3 Exception Handlers
58 extern _LIBCXXABI_FUNC_VIS void *
59 __cxa_get_exception_ptr(void *exceptionObject) throw();
60 extern _LIBCXXABI_FUNC_VIS void *
61 __cxa_begin_catch(void *exceptionObject) throw();
62 extern _LIBCXXABI_FUNC_VIS void __cxa_end_catch();
63 #if defined(_LIBCXXABI_ARM_EHABI)
64 extern _LIBCXXABI_FUNC_VIS bool
65 __cxa_begin_cleanup(void *exceptionObject) throw();
66 extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
67 #endif
68 extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
70 // 2.5.4 Rethrowing Exceptions
71 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();
73 // 2.6 Auxiliary Runtime APIs
74 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_cast(void);
75 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_bad_typeid(void);
76 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
77 __cxa_throw_bad_array_new_length(void);
79 // 3.2.6 Pure Virtual Function API
80 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_pure_virtual(void);
82 // 3.2.7 Deleted Virtual Function API
83 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_deleted_virtual(void);
85 // 3.3.2 One-time Construction API
86 #if defined(_LIBCXXABI_GUARD_ABI_ARM)
87 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint32_t *);
88 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint32_t *);
89 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_abort(uint32_t *);
90 #else
91 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD int __cxa_guard_acquire(uint64_t *);
92 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_release(uint64_t *);
93 extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_ALWAYS_COLD void __cxa_guard_abort(uint64_t *);
94 #endif
96 // 3.3.3 Array Construction and Destruction API
97 extern _LIBCXXABI_FUNC_VIS void *
98 __cxa_vec_new(size_t element_count, size_t element_size, size_t padding_size,
99 void (*constructor)(void *), void (*destructor)(void *));
101 extern _LIBCXXABI_FUNC_VIS void *
102 __cxa_vec_new2(size_t element_count, size_t element_size, size_t padding_size,
103 void (*constructor)(void *), void (*destructor)(void *),
104 void *(*alloc)(size_t), void (*dealloc)(void *));
106 extern _LIBCXXABI_FUNC_VIS void *
107 __cxa_vec_new3(size_t element_count, size_t element_size, size_t padding_size,
108 void (*constructor)(void *), void (*destructor)(void *),
109 void *(*alloc)(size_t), void (*dealloc)(void *, size_t));
111 extern _LIBCXXABI_FUNC_VIS void
112 __cxa_vec_ctor(void *array_address, size_t element_count, size_t element_size,
113 void (*constructor)(void *), void (*destructor)(void *));
115 extern _LIBCXXABI_FUNC_VIS void __cxa_vec_dtor(void *array_address,
116 size_t element_count,
117 size_t element_size,
118 void (*destructor)(void *));
120 extern _LIBCXXABI_FUNC_VIS void __cxa_vec_cleanup(void *array_address,
121 size_t element_count,
122 size_t element_size,
123 void (*destructor)(void *));
125 extern _LIBCXXABI_FUNC_VIS void __cxa_vec_delete(void *array_address,
126 size_t element_size,
127 size_t padding_size,
128 void (*destructor)(void *));
130 extern _LIBCXXABI_FUNC_VIS void
131 __cxa_vec_delete2(void *array_address, size_t element_size, size_t padding_size,
132 void (*destructor)(void *), void (*dealloc)(void *));
134 extern _LIBCXXABI_FUNC_VIS void
135 __cxa_vec_delete3(void *__array_address, size_t element_size,
136 size_t padding_size, void (*destructor)(void *),
137 void (*dealloc)(void *, size_t));
139 extern _LIBCXXABI_FUNC_VIS void
140 __cxa_vec_cctor(void *dest_array, void *src_array, size_t element_count,
141 size_t element_size, void (*constructor)(void *, void *),
142 void (*destructor)(void *));
144 // 3.3.5.3 Runtime API
145 // These functions are part of the C++ ABI, but they are not defined in libc++abi:
146 // int __cxa_atexit(void (*)(void *), void *, void *);
147 // void __cxa_finalize(void *);
149 // 3.4 Demangler API
150 extern _LIBCXXABI_FUNC_VIS char *__cxa_demangle(const char *mangled_name,
151 char *output_buffer,
152 size_t *length, int *status);
154 // Apple additions to support C++ 0x exception_ptr class
155 // These are primitives to wrap a smart pointer around an exception object
156 extern _LIBCXXABI_FUNC_VIS void *__cxa_current_primary_exception() throw();
157 extern _LIBCXXABI_FUNC_VIS void
158 __cxa_rethrow_primary_exception(void *primary_exception);
159 extern _LIBCXXABI_FUNC_VIS void
160 __cxa_increment_exception_refcount(void *primary_exception) throw();
161 extern _LIBCXXABI_FUNC_VIS void
162 __cxa_decrement_exception_refcount(void *primary_exception) throw();
164 // Apple extension to support std::uncaught_exception()
165 extern _LIBCXXABI_FUNC_VIS bool __cxa_uncaught_exception() throw();
166 extern _LIBCXXABI_FUNC_VIS unsigned int __cxa_uncaught_exceptions() throw();
168 #if defined(__linux__) || defined(__Fuchsia__)
169 // Linux and Fuchsia TLS support. Not yet an official part of the Itanium ABI.
170 // https://sourceware.org/glibc/wiki/Destructor%20support%20for%20thread_local%20variables
171 extern _LIBCXXABI_FUNC_VIS int __cxa_thread_atexit(void (*)(void *), void *,
172 void *) throw();
173 #endif
175 } // extern "C"
176 } // namespace __cxxabiv1
178 namespace abi = __cxxabiv1;
180 #endif // __cplusplus
182 #endif // __CXXABI_H