[libcxx-commits] [libcxx] 308bcb3 - [libc++] Use the _LIBCPP_VERBOSE_ABORT macro instead of calling the function directly
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Mar 17 16:34:34 PDT 2023
Author: Nikolas Klauser
Date: 2023-03-18T00:34:28+01:00
New Revision: 308bcb3f7babcf324d8f7b5dd9002bc1d967a92f
URL: https://github.com/llvm/llvm-project/commit/308bcb3f7babcf324d8f7b5dd9002bc1d967a92f
DIFF: https://github.com/llvm/llvm-project/commit/308bcb3f7babcf324d8f7b5dd9002bc1d967a92f.diff
LOG: [libc++] Use the _LIBCPP_VERBOSE_ABORT macro instead of calling the function directly
These calls were added in D141222.
Reviewed By: #libc, ldionne
Spies: ldionne, libcxx-commits, smeenai, mikhail.ramalho
Differential Revision: https://reviews.llvm.org/D146227
Added:
Modified:
libcxx/include/__expected/expected.h
libcxx/include/__filesystem/filesystem_error.h
libcxx/include/__functional/function.h
libcxx/include/__memory/shared_ptr.h
libcxx/include/__verbose_abort
libcxx/include/any
libcxx/include/future
libcxx/include/ios
libcxx/include/new
libcxx/include/optional
libcxx/include/regex
libcxx/include/stdexcept
libcxx/include/typeinfo
libcxx/include/variant
Removed:
################################################################################
diff --git a/libcxx/include/__expected/expected.h b/libcxx/include/__expected/expected.h
index 263207cd994bf..9a8d4047cdefa 100644
--- a/libcxx/include/__expected/expected.h
+++ b/libcxx/include/__expected/expected.h
@@ -69,7 +69,7 @@ _LIBCPP_HIDE_FROM_ABI void __throw_bad_expected_access(_Arg&& __arg) {
throw bad_expected_access<_Err>(std::forward<_Arg>(__arg));
# else
(void)__arg;
- std::__libcpp_verbose_abort("bad_expected_access was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("bad_expected_access was thrown in -fno-exceptions mode");
# endif
}
diff --git a/libcxx/include/__filesystem/filesystem_error.h b/libcxx/include/__filesystem/filesystem_error.h
index 304d87bdd006f..def7e3f6d17a0 100644
--- a/libcxx/include/__filesystem/filesystem_error.h
+++ b/libcxx/include/__filesystem/filesystem_error.h
@@ -92,7 +92,7 @@ void __throw_filesystem_error(_Args&&... __args) {
}
#else
void __throw_filesystem_error(_Args&&...) {
- std::__libcpp_verbose_abort("filesystem_error was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("filesystem_error was thrown in -fno-exceptions mode");
}
#endif
_LIBCPP_AVAILABILITY_FILESYSTEM_POP
diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h
index bd62344eff3ba..92e0d24f60b70 100644
--- a/libcxx/include/__functional/function.h
+++ b/libcxx/include/__functional/function.h
@@ -74,7 +74,7 @@ void __throw_bad_function_call()
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw bad_function_call();
#else
- std::__libcpp_verbose_abort("bad_function_call was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("bad_function_call was thrown in -fno-exceptions mode");
#endif
}
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index dd10d4cd14ab9..f22a918cd536e 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -137,7 +137,7 @@ void __throw_bad_weak_ptr()
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw bad_weak_ptr();
#else
- std::__libcpp_verbose_abort("bad_weak_ptr was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("bad_weak_ptr was thrown in -fno-exceptions mode");
#endif
}
diff --git a/libcxx/include/__verbose_abort b/libcxx/include/__verbose_abort
index a16d75d5ac4c3..40b0e07da5489 100644
--- a/libcxx/include/__verbose_abort
+++ b/libcxx/include/__verbose_abort
@@ -46,7 +46,8 @@ void __libcpp_verbose_abort(const char *__format, ...);
# endif
# if defined(_LIBCPP_HAS_NO_VERBOSE_ABORT_IN_LIBRARY)
-# define _LIBCPP_VERBOSE_ABORT(...) __builtin_abort()
+// The decltype is there to suppress -Wunused warnings in this configuration.
+# define _LIBCPP_VERBOSE_ABORT(...) (decltype(std::__libcpp_verbose_abort(__VA_ARGS__))(), __builtin_abort())
# else
# define _LIBCPP_VERBOSE_ABORT(...) ::std::__libcpp_verbose_abort(__VA_ARGS__)
# endif
diff --git a/libcxx/include/any b/libcxx/include/any
index 6ffbd6441f3c9..e139756f65f4c 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -135,7 +135,7 @@ void __throw_bad_any_cast()
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw bad_any_cast();
#else
- std::__libcpp_verbose_abort("bad_any_cast was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("bad_any_cast was thrown in -fno-exceptions mode");
#endif
}
diff --git a/libcxx/include/future b/libcxx/include/future
index d8a404f1fcdb4..dee9d0a71404d 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -534,7 +534,7 @@ void __throw_future_error(future_errc __ev)
throw future_error(make_error_code(__ev));
#else
(void)__ev;
- std::__libcpp_verbose_abort("future_error was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("future_error was thrown in -fno-exceptions mode");
#endif
}
diff --git a/libcxx/include/ios b/libcxx/include/ios
index 056ede16a1040..afe42a6866dda 100644
--- a/libcxx/include/ios
+++ b/libcxx/include/ios
@@ -452,7 +452,7 @@ void __throw_failure(char const* __msg) {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw ios_base::failure(__msg);
#else
- std::__libcpp_verbose_abort("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg);
+ _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg);
#endif
}
diff --git a/libcxx/include/new b/libcxx/include/new
index ce1d9169f623e..871ace09a2428 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -177,7 +177,7 @@ void __throw_bad_array_new_length()
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw bad_array_new_length();
#else
- std::__libcpp_verbose_abort("bad_array_new_length was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode");
#endif
}
diff --git a/libcxx/include/optional b/libcxx/include/optional
index d31c5088ca4d3..9f896bd16945a 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -221,7 +221,7 @@ void __throw_bad_optional_access() {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw bad_optional_access();
#else
- std::__libcpp_verbose_abort("bad_optional_access was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("bad_optional_access was thrown in -fno-exceptions mode");
#endif
}
diff --git a/libcxx/include/regex b/libcxx/include/regex
index b4a58c27f3360..9a367c3aabe79 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -1018,7 +1018,7 @@ void __throw_regex_error()
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw regex_error(_Ev);
#else
- std::__libcpp_verbose_abort("regex_error was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("regex_error was thrown in -fno-exceptions mode");
#endif
}
diff --git a/libcxx/include/stdexcept b/libcxx/include/stdexcept
index 826c6f4192f38..ef4740959e274 100644
--- a/libcxx/include/stdexcept
+++ b/libcxx/include/stdexcept
@@ -224,7 +224,7 @@ void __throw_logic_error(const char*__msg)
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw logic_error(__msg);
#else
- std::__libcpp_verbose_abort("logic_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
+ _LIBCPP_VERBOSE_ABORT("logic_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
#endif
}
@@ -234,7 +234,7 @@ void __throw_domain_error(const char*__msg)
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw domain_error(__msg);
#else
- std::__libcpp_verbose_abort("domain_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
+ _LIBCPP_VERBOSE_ABORT("domain_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
#endif
}
@@ -244,7 +244,7 @@ void __throw_invalid_argument(const char*__msg)
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw invalid_argument(__msg);
#else
- std::__libcpp_verbose_abort("invalid_argument was thrown in -fno-exceptions mode with message \"%s\"", __msg);
+ _LIBCPP_VERBOSE_ABORT("invalid_argument was thrown in -fno-exceptions mode with message \"%s\"", __msg);
#endif
}
@@ -254,7 +254,7 @@ void __throw_length_error(const char*__msg)
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw length_error(__msg);
#else
- std::__libcpp_verbose_abort("length_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
+ _LIBCPP_VERBOSE_ABORT("length_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
#endif
}
@@ -264,7 +264,7 @@ void __throw_out_of_range(const char*__msg)
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw out_of_range(__msg);
#else
- std::__libcpp_verbose_abort("out_of_range was thrown in -fno-exceptions mode with message \"%s\"", __msg);
+ _LIBCPP_VERBOSE_ABORT("out_of_range was thrown in -fno-exceptions mode with message \"%s\"", __msg);
#endif
}
@@ -274,7 +274,7 @@ void __throw_range_error(const char*__msg)
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw range_error(__msg);
#else
- std::__libcpp_verbose_abort("range_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
+ _LIBCPP_VERBOSE_ABORT("range_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
#endif
}
@@ -284,7 +284,7 @@ void __throw_overflow_error(const char*__msg)
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw overflow_error(__msg);
#else
- std::__libcpp_verbose_abort("overflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
+ _LIBCPP_VERBOSE_ABORT("overflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
#endif
}
@@ -294,7 +294,7 @@ void __throw_underflow_error(const char*__msg)
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw underflow_error(__msg);
#else
- std::__libcpp_verbose_abort("underflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
+ _LIBCPP_VERBOSE_ABORT("underflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg);
#endif
}
diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo
index 6a40c969d9719..ca35150644552 100644
--- a/libcxx/include/typeinfo
+++ b/libcxx/include/typeinfo
@@ -409,7 +409,7 @@ void __throw_bad_cast()
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw bad_cast();
#else
- std::__libcpp_verbose_abort("bad_cast was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("bad_cast was thrown in -fno-exceptions mode");
#endif
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/variant b/libcxx/include/variant
index d154d3d93637b..a88662e9fd08d 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -291,7 +291,7 @@ void __throw_bad_variant_access() {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
throw bad_variant_access();
#else
- std::__libcpp_verbose_abort("bad_variant_access was thrown in -fno-exceptions mode");
+ _LIBCPP_VERBOSE_ABORT("bad_variant_access was thrown in -fno-exceptions mode");
#endif
}
More information about the libcxx-commits
mailing list