Skip to content

Commit 3ad52da

Browse files
Add C++23 stacktrace
1 parent b35c93f commit 3ad52da

File tree

73 files changed

+3871
-27
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3871
-27
lines changed

libcxx/docs/FeatureTestMacroTable.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ Status
396396
---------------------------------------------------------- -----------------
397397
``__cpp_lib_spanstream`` *unimplemented*
398398
---------------------------------------------------------- -----------------
399-
``__cpp_lib_stacktrace`` *unimplemented*
399+
``__cpp_lib_stacktrace`` ``202011L``
400400
---------------------------------------------------------- -----------------
401401
``__cpp_lib_stdatomic_h`` ``202011L``
402402
---------------------------------------------------------- -----------------

libcxx/docs/ReleaseNotes/22.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Implemented Papers
4646
- P2835R7: Expose ``std::atomic_ref``'s object address (`Github <https://llvm.org/PR118377>`__)
4747
- P2944R3: Comparisons for ``reference_wrapper`` (`Github <https://llvm.org/PR105424>`__)
4848
- P3168R2: Give ``std::optional`` Range Support (`Github <https://llvm.org/PR105430>`__)
49+
- P0881R7: A Proposal to add stacktrace library (`Github <https://github.com/llvm/llvm-project/issues/105131>`__)
50+
- P2301R1: Add a `pmr` alias for `std::stacktrace` (`Github <https://github.com/llvm/llvm-project/issues/105167>`__)
4951

5052
Improvements and New Features
5153
-----------------------------

libcxx/docs/Status/Cxx23Issues.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
"`LWG3028 <https://wg21.link/LWG3028>`__","Container requirements tables should distinguish ``const`` and non-``const`` variables","2022-11 (Kona)","","","`#104995 <https://github.com/llvm/llvm-project/issues/104995>`__",""
190190
"`LWG3118 <https://wg21.link/LWG3118>`__","``fpos`` equality comparison unspecified","2022-11 (Kona)","","","`#104996 <https://github.com/llvm/llvm-project/issues/104996>`__",""
191191
"`LWG3177 <https://wg21.link/LWG3177>`__","Limit permission to specialize variable templates to program-defined types","2022-11 (Kona)","|Nothing To Do|","","`#104997 <https://github.com/llvm/llvm-project/issues/104997>`__",""
192-
"`LWG3515 <https://wg21.link/LWG3515>`__","§[stacktrace.basic.nonmem]: ``operator<<`` should be less templatized","2022-11 (Kona)","","","`#104998 <https://github.com/llvm/llvm-project/issues/104998>`__",""
192+
"`LWG3515 <https://wg21.link/LWG3515>`__","§[stacktrace.basic.nonmem]: ``operator<<`` should be less templatized","2022-11 (Kona)","|Complete|","","`#104998 <https://github.com/llvm/llvm-project/issues/104998>`__",""
193193
"`LWG3545 <https://wg21.link/LWG3545>`__","``std::pointer_traits`` should be SFINAE-friendly","2022-11 (Kona)","|Complete|","18","`#104999 <https://github.com/llvm/llvm-project/issues/104999>`__",""
194194
"`LWG3569 <https://wg21.link/LWG3569>`__","``join_view`` fails to support ranges of ranges with non-default_initializable iterators","2022-11 (Kona)","","","`#105000 <https://github.com/llvm/llvm-project/issues/105000>`__",""
195195
"`LWG3594 <https://wg21.link/LWG3594>`__","``inout_ptr`` — inconsistent ``release()`` in destructor","2022-11 (Kona)","|Complete|","19","`#105001 <https://github.com/llvm/llvm-project/issues/105001>`__",""

libcxx/docs/Status/Cxx23Papers.csv

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"Paper #","Paper Name","Meeting","Status","First released version","GitHub issue","Notes"
2-
"`P0881R7 <https://wg21.link/P0881R7>`__","A Proposal to add stacktrace library","2020-11 (Virtual)","","","`#105131 <https://github.com/llvm/llvm-project/issues/105131>`__",""
2+
"`P0881R7 <https://wg21.link/P0881R7>`__","A Proposal to add stacktrace library","2020-11 (Virtual)","|Complete|","22","`#105131 <https://github.com/llvm/llvm-project/issues/105131>`__",""
33
"`P0943R6 <https://wg21.link/P0943R6>`__","Support C atomics in C++","2020-11 (Virtual)","|Complete|","15","`#105132 <https://github.com/llvm/llvm-project/issues/105132>`__",""
44
"`P1048R1 <https://wg21.link/P1048R1>`__","A proposal for a type trait to detect scoped enumerations","2020-11 (Virtual)","|Complete|","12","`#105134 <https://github.com/llvm/llvm-project/issues/105134>`__",""
55
"`P1679R3 <https://wg21.link/P1679R3>`__","string contains function","2020-11 (Virtual)","|Complete|","12","`#105135 <https://github.com/llvm/llvm-project/issues/105135>`__",""
@@ -32,7 +32,7 @@
3232
"`P1675R2 <https://wg21.link/P1675R2>`__","``rethrow_exception`` must be allowed to copy","2021-10 (Virtual)","|Nothing To Do|","","`#105164 <https://github.com/llvm/llvm-project/issues/105164>`__",""
3333
"`P2077R3 <https://wg21.link/P2077R3>`__","Heterogeneous erasure overloads for associative containers","2021-10 (Virtual)","","","`#105165 <https://github.com/llvm/llvm-project/issues/105165>`__",""
3434
"`P2251R1 <https://wg21.link/P2251R1>`__","Require ``span`` & ``basic_string_view`` to be Trivially Copyable","2021-10 (Virtual)","|Complete|","14","`#105166 <https://github.com/llvm/llvm-project/issues/105166>`__",""
35-
"`P2301R1 <https://wg21.link/P2301R1>`__","Add a ``pmr`` alias for ``std::stacktrace``","2021-10 (Virtual)","","","`#105167 <https://github.com/llvm/llvm-project/issues/105167>`__",""
35+
"`P2301R1 <https://wg21.link/P2301R1>`__","Add a ``pmr`` alias for ``std::stacktrace``","2021-10 (Virtual)","|Complete|","22","`#105167 <https://github.com/llvm/llvm-project/issues/105167>`__",""
3636
"`P2321R2 <https://wg21.link/P2321R2>`__","``zip``","2021-10 (Virtual)","|In Progress|","","`#105169 <https://github.com/llvm/llvm-project/issues/105169>`__",""
3737
"`P2340R1 <https://wg21.link/P2340R1>`__","Clarifying the status of the 'C headers'","2021-10 (Virtual)","|Nothing To Do|","","`#105170 <https://github.com/llvm/llvm-project/issues/105170>`__",""
3838
"`P2393R1 <https://wg21.link/P2393R1>`__","Cleaning up ``integer``-class types","2021-10 (Virtual)","","","`#105171 <https://github.com/llvm/llvm-project/issues/105171>`__",""
@@ -110,7 +110,7 @@
110110
"`P2713R1 <https://wg21.link/P2713R1>`__","Escaping improvements in ``std::format``","2023-02 (Issaquah)","|Complete|","19","`#105254 <https://github.com/llvm/llvm-project/issues/105254>`__",""
111111
"`P2675R1 <https://wg21.link/P2675R1>`__","``format``'s width estimation is too approximate and not forward compatible","2023-02 (Issaquah)","|Complete|","17","`#105255 <https://github.com/llvm/llvm-project/issues/105255>`__",""
112112
"`P2572R1 <https://wg21.link/P2572R1>`__","``std::format`` fill character allowances","2023-02 (Issaquah)","|Complete|","17","`#105256 <https://github.com/llvm/llvm-project/issues/105256>`__",""
113-
"`P2693R1 <https://wg21.link/P2693R1>`__","Formatting ``thread::id`` and ``stacktrace``","2023-02 (Issaquah)","|Partial|","","`#105257 <https://github.com/llvm/llvm-project/issues/105257>`__","The formatter for ``stacktrace`` is not implemented, since ``stacktrace`` is not implemented yet"
113+
"`P2693R1 <https://wg21.link/P2693R1>`__","Formatting ``thread::id`` and ``stacktrace``","2023-02 (Issaquah)","|Partial|","22","`#105257 <https://github.com/llvm/llvm-project/issues/105257>`__",""
114114
"`P2679R2 <https://wg21.link/P2679R2>`__","Fixing ``std::start_lifetime_as`` for arrays","2023-02 (Issaquah)","","","`#105258 <https://github.com/llvm/llvm-project/issues/105258>`__",""
115115
"`P2674R1 <https://wg21.link/P2674R1>`__","A trait for implicit lifetime types","2023-02 (Issaquah)","|Complete|","20","`#105259 <https://github.com/llvm/llvm-project/issues/105259>`__",""
116116
"`P2655R3 <https://wg21.link/P2655R3>`__","``common_reference_t`` of ``reference_wrapper`` Should Be a Reference Type","2023-02 (Issaquah)","|Complete|","21","`#105260 <https://github.com/llvm/llvm-project/issues/105260>`__","The paper is implemented as a DR to C++20"

libcxx/include/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ set(files
741741
__ranges/zip_transform_view.h
742742
__ranges/zip_view.h
743743
__split_buffer
744+
__stacktrace/basic_stacktrace.h
745+
__stacktrace/stacktrace_entry.h
744746
__std_mbstate_t.h
745747
__stop_token/atomic_unique_lock.h
746748
__stop_token/intrusive_list_view.h
@@ -1062,6 +1064,7 @@ set(files
10621064
span
10631065
sstream
10641066
stack
1067+
stacktrace
10651068
stdatomic.h
10661069
stdbool.h
10671070
stddef.h

libcxx/include/__config

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,33 @@ typedef __char32_t char32_t;
965965
# define _LIBCPP_NOINLINE
966966
# endif
967967

968+
// Some functions, e.g. std::stacktrace::current, need to avoid being
969+
// tail-called by (and tail-calling other) functions, for proper enumeration of
970+
// call-stack frames.
971+
// clang-format off
972+
973+
// Disables tail-call optimization for "outbound" calls
974+
// performed in the function annotated with this attribute.
975+
# if __has_cpp_attribute(_Clang::__disable_tail_calls__)
976+
# define _LIBCPP_NO_TAIL_CALLS_OUT [[_Clang::__disable_tail_calls__]]
977+
# elif __has_cpp_attribute(__gnu__::__optimize__)
978+
# define _LIBCPP_NO_TAIL_CALLS_OUT [[__gnu__::__optimize__("no-optimize-sibling-calls")]]
979+
# else
980+
# define _LIBCPP_NO_TAIL_CALLS_OUT
981+
# endif
982+
983+
// Disables tail-call optimization for "inbound" calls -- that is,
984+
// calls from some other function calling the one having this attribute.
985+
# if __has_cpp_attribute(_Clang::__not_tail_called__)
986+
# define _LIBCPP_NO_TAIL_CALLS_IN [[_Clang::__not_tail_called__]]
987+
# else
988+
# define _LIBCPP_NO_TAIL_CALLS_IN
989+
# endif
990+
991+
// Disable TCO for calls into, and out from, the annotated function.
992+
# define _LIBCPP_NO_TAIL_CALLS _LIBCPP_NO_TAIL_CALLS_IN _LIBCPP_NO_TAIL_CALLS_OUT
993+
// clang-format on
994+
968995
// We often repeat things just for handling wide characters in the library.
969996
// When wide characters are disabled, it can be useful to have a quick way of
970997
// disabling it without having to resort to #if-#endif, which has a larger

libcxx/include/__configuration/availability.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@
291291
#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE _LIBCPP_INTRODUCED_IN_LLVM_21
292292
// No attribute, since we've had bad_function_call::what() in the headers before
293293

294+
// This controls the availability of C++23 <stacktrace>.
295+
#define _LIBCPP_AVAILABILITY_HAS_STACKTRACE _LIBCPP_INTRODUCED_IN_LLVM_21
296+
#define _LIBCPP_AVAILABILITY_STACKTRACE _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE
297+
294298
// Define availability attributes that depend on both
295299
// _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI.
296300
#if !_LIBCPP_HAS_EXCEPTIONS || !_LIBCPP_HAS_RTTI

0 commit comments

Comments
 (0)