diff options
author | Louis Dionne <ldionne.2@gmail.com> | 2023-07-11 14:40:11 -0400 |
---|---|---|
committer | Louis Dionne <ldionne.2@gmail.com> | 2023-07-17 18:00:03 -0400 |
commit | c9c3cddb5e99a4d73a29580e1ba4cd8165424bab (patch) | |
tree | 8d56677b7d68e5bf5c5ae5f144f025b47dc22e91 /libcxx | |
parent | 49b209d5cca3750f71e8a6fda1c5870295ef3a9c (diff) | |
download | llvm-c9c3cddb5e99a4d73a29580e1ba4cd8165424bab.zip llvm-c9c3cddb5e99a4d73a29580e1ba4cd8165424bab.tar.gz llvm-c9c3cddb5e99a4d73a29580e1ba4cd8165424bab.tar.bz2 |
[libc++] Use _LIBCPP_VERBOSE_ABORT in a few remaining __throw_FOO functions
This provides better error messages when the program terminates due to
an exception being thrown in -fno-exceptions mode. Those seem to have
been missed in https://reviews.llvm.org/D141222.
Differential Revision: https://reviews.llvm.org/D154995
Diffstat (limited to 'libcxx')
-rw-r--r-- | libcxx/docs/ReleaseNotes.rst | 2 | ||||
-rw-r--r-- | libcxx/include/__format/format_error.h | 5 | ||||
-rw-r--r-- | libcxx/src/locale.cpp | 7 | ||||
-rw-r--r-- | libcxx/src/string.cpp | 15 | ||||
-rw-r--r-- | libcxx/src/system_error.cpp | 5 | ||||
-rw-r--r-- | libcxx/test/libcxx/transitive_includes/cxx03.csv | 3 | ||||
-rw-r--r-- | libcxx/test/libcxx/transitive_includes/cxx11.csv | 3 | ||||
-rw-r--r-- | libcxx/test/libcxx/transitive_includes/cxx14.csv | 3 | ||||
-rw-r--r-- | libcxx/test/libcxx/transitive_includes/cxx17.csv | 3 | ||||
-rw-r--r-- | libcxx/test/libcxx/transitive_includes/cxx20.csv | 3 | ||||
-rw-r--r-- | libcxx/test/libcxx/transitive_includes/cxx23.csv | 4 | ||||
-rw-r--r-- | libcxx/test/libcxx/transitive_includes/cxx26.csv | 4 |
12 files changed, 11 insertions, 46 deletions
diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst index b93c2c8..f5b568f 100644 --- a/libcxx/docs/ReleaseNotes.rst +++ b/libcxx/docs/ReleaseNotes.rst @@ -143,6 +143,8 @@ Deprecations and Removals - ``<atomic>``, ``<barrier>``, ``<latch>``, ``<numeric>``, ``<semaphore>`` and ``<shared_mutex>`` no longer include ``<iosfwd>`` (it was previously included in all Standard versions). +- ``<format>``, ``<chrono>`` and ``<thread>`` no longer transitively include ``<cstdlib>``. + - The headers ``<experimental/algorithm>`` and ``<experimental/functional>`` have been removed, since all the contents have been implemented in namespace ``std`` for at least two releases. diff --git a/libcxx/include/__format/format_error.h b/libcxx/include/__format/format_error.h index 5faea1c..f22cb0b 100644 --- a/libcxx/include/__format/format_error.h +++ b/libcxx/include/__format/format_error.h @@ -11,7 +11,7 @@ #define _LIBCPP___FORMAT_FORMAT_ERROR_H #include <__config> -#include <cstdlib> +#include <__verbose_abort> #include <stdexcept> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -40,8 +40,7 @@ __throw_format_error(const char* __s) { #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw format_error(__s); #else - (void)__s; - _VSTD::abort(); + _LIBCPP_VERBOSE_ABORT("format_error was thrown in -fno-exceptions mode with message \"%s\"", __s); #endif } diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp index 1eea9cf..bd70a27 100644 --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include <__utility/unreachable.h> +#include <__verbose_abort> #include <algorithm> #include <clocale> #include <codecvt> @@ -115,8 +116,7 @@ _LIBCPP_NORETURN static void __throw_runtime_error(const string &msg) #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw runtime_error(msg); #else - (void)msg; - _VSTD::abort(); + _LIBCPP_VERBOSE_ABORT("runtime_error was thrown in -fno-exceptions mode with message \"%s\"", msg.c_str()); #endif } @@ -6532,8 +6532,7 @@ void __throw_runtime_error(const char* msg) #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw runtime_error(msg); #else - (void)msg; - _VSTD::abort(); + _LIBCPP_VERBOSE_ABORT("runtime_error was thrown in -fno-exceptions mode with message \"%s\"", msg); #endif } diff --git a/libcxx/src/string.cpp b/libcxx/src/string.cpp index 01313e6..3d671bc 100644 --- a/libcxx/src/string.cpp +++ b/libcxx/src/string.cpp @@ -12,7 +12,6 @@ #include <cstdlib> #include <limits> #include <stdexcept> -#include <stdio.h> #include <string> #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS @@ -61,22 +60,12 @@ template string operator+<char, char_traits<char>, allocator<char>>(char const*, namespace { -template<typename T> -inline void throw_helper(const string& msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS - throw T(msg); -#else - fprintf(stderr, "%s\n", msg.c_str()); - _VSTD::abort(); -#endif -} - inline void throw_from_string_out_of_range(const string& func) { - throw_helper<out_of_range>(func + ": out of range"); + std::__throw_out_of_range((func + ": out of range").c_str()); } inline void throw_from_string_invalid_arg(const string& func) { - throw_helper<invalid_argument>(func + ": no conversion"); + std::__throw_invalid_argument((func + ": no conversion").c_str()); } // as_integer diff --git a/libcxx/src/system_error.cpp b/libcxx/src/system_error.cpp index 1502c7d..7875f59 100644 --- a/libcxx/src/system_error.cpp +++ b/libcxx/src/system_error.cpp @@ -12,6 +12,7 @@ #endif #include <__assert> +#include <__verbose_abort> #include <cerrno> #include <cstdio> #include <cstdlib> @@ -289,9 +290,7 @@ __throw_system_error(int ev, const char* what_arg) #ifndef _LIBCPP_HAS_NO_EXCEPTIONS throw system_error(error_code(ev, system_category()), what_arg); #else - (void)ev; - (void)what_arg; - _VSTD::abort(); + _LIBCPP_VERBOSE_ABORT("system_error was thrown in -fno-exceptions mode with error %i and message \"%s\"", ev, what_arg); #endif } diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv index 495d23a..7a6ba4f 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx03.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv @@ -116,7 +116,6 @@ chrono compare chrono concepts chrono cstddef chrono cstdint -chrono cstdlib chrono cstring chrono ctime chrono limits @@ -302,7 +301,6 @@ format array format cmath format cstddef format cstdint -format cstdlib format initializer_list format limits format locale @@ -857,7 +855,6 @@ thread chrono thread compare thread cstddef thread cstdint -thread cstdlib thread cstring thread ctime thread functional diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv index 319be83..cfce8c0 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx11.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv @@ -116,7 +116,6 @@ chrono compare chrono concepts chrono cstddef chrono cstdint -chrono cstdlib chrono cstring chrono ctime chrono limits @@ -302,7 +301,6 @@ format array format cmath format cstddef format cstdint -format cstdlib format initializer_list format limits format locale @@ -858,7 +856,6 @@ thread chrono thread compare thread cstddef thread cstdint -thread cstdlib thread cstring thread ctime thread functional diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index 9c4df80..7c6e8c9 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -116,7 +116,6 @@ chrono compare chrono concepts chrono cstddef chrono cstdint -chrono cstdlib chrono cstring chrono ctime chrono limits @@ -304,7 +303,6 @@ format array format cmath format cstddef format cstdint -format cstdlib format initializer_list format limits format locale @@ -860,7 +858,6 @@ thread chrono thread compare thread cstddef thread cstdint -thread cstdlib thread cstring thread ctime thread functional diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv index 9c4df80..7c6e8c9 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx17.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv @@ -116,7 +116,6 @@ chrono compare chrono concepts chrono cstddef chrono cstdint -chrono cstdlib chrono cstring chrono ctime chrono limits @@ -304,7 +303,6 @@ format array format cmath format cstddef format cstdint -format cstdlib format initializer_list format limits format locale @@ -860,7 +858,6 @@ thread chrono thread compare thread cstddef thread cstdint -thread cstdlib thread cstring thread ctime thread functional diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv index ef5ba26..603d789 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx20.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv @@ -118,7 +118,6 @@ chrono compare chrono concepts chrono cstddef chrono cstdint -chrono cstdlib chrono cstring chrono ctime chrono limits @@ -311,7 +310,6 @@ format array format cmath format cstddef format cstdint -format cstdlib format initializer_list format limits format locale @@ -865,7 +863,6 @@ thread cerrno thread compare thread cstddef thread cstdint -thread cstdlib thread cstring thread ctime thread functional diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv index 2745d93..c1cd8e9 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx23.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv @@ -71,7 +71,6 @@ chrono cmath chrono compare chrono cstddef chrono cstdint -chrono cstdlib chrono ctime chrono initializer_list chrono limits @@ -214,7 +213,6 @@ format array format cmath format cstddef format cstdint -format cstdlib format initializer_list format limits format locale @@ -615,7 +613,6 @@ thread cerrno thread compare thread cstddef thread cstdint -thread cstdlib thread ctime thread initializer_list thread iosfwd @@ -691,7 +688,6 @@ vector climits vector compare vector cstddef vector cstdint -vector cstdlib vector cstring vector cwchar vector initializer_list diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv index 2745d93..c1cd8e9 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx26.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv @@ -71,7 +71,6 @@ chrono cmath chrono compare chrono cstddef chrono cstdint -chrono cstdlib chrono ctime chrono initializer_list chrono limits @@ -214,7 +213,6 @@ format array format cmath format cstddef format cstdint -format cstdlib format initializer_list format limits format locale @@ -615,7 +613,6 @@ thread cerrno thread compare thread cstddef thread cstdint -thread cstdlib thread ctime thread initializer_list thread iosfwd @@ -691,7 +688,6 @@ vector climits vector compare vector cstddef vector cstdint -vector cstdlib vector cstring vector cwchar vector initializer_list |