Commit 02f4b999 by Devin Jeanpierre Committed by Copybara-Service

Delete the `Throw()` function from `absl::base_internal`.

This was originally added in order to centralize the ifdefs, in cl/164484905. However, cl/337142938 undid this aspect of the change, because it broke on Android. What is left is vestigial: `Throw()` can be deleted at no loss, with a warning that should discourage us from ever reintroducing it.

PiperOrigin-RevId: 513391041
Change-Id: I1608a2007eb26ee95df07f3b4b1672c034743832
parent 6c2630fe
...@@ -26,22 +26,13 @@ namespace absl { ...@@ -26,22 +26,13 @@ namespace absl {
ABSL_NAMESPACE_BEGIN ABSL_NAMESPACE_BEGIN
namespace base_internal { namespace base_internal {
// NOTE: The various STL exception throwing functions are placed within the // NOTE: The exception types, like `std::logic_error`, do not exist on all
// #ifdef blocks so the symbols aren't exposed on platforms that don't support // platforms. (For example, the Android NDK does not have them.)
// them, such as the Android NDK. For example, ANGLE fails to link when building // Therefore, their use must be guarded by `#ifdef` or equivalent.
// within AOSP without them, since the STL functions don't exist.
namespace {
#ifdef ABSL_HAVE_EXCEPTIONS
template <typename T>
[[noreturn]] void Throw(const T& error) {
throw error;
}
#endif
} // namespace
void ThrowStdLogicError(const std::string& what_arg) { void ThrowStdLogicError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::logic_error(what_arg)); throw std::logic_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str()); ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort(); std::abort();
...@@ -49,7 +40,7 @@ void ThrowStdLogicError(const std::string& what_arg) { ...@@ -49,7 +40,7 @@ void ThrowStdLogicError(const std::string& what_arg) {
} }
void ThrowStdLogicError(const char* what_arg) { void ThrowStdLogicError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::logic_error(what_arg)); throw std::logic_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg); ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort(); std::abort();
...@@ -57,7 +48,7 @@ void ThrowStdLogicError(const char* what_arg) { ...@@ -57,7 +48,7 @@ void ThrowStdLogicError(const char* what_arg) {
} }
void ThrowStdInvalidArgument(const std::string& what_arg) { void ThrowStdInvalidArgument(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::invalid_argument(what_arg)); throw std::invalid_argument(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str()); ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort(); std::abort();
...@@ -65,7 +56,7 @@ void ThrowStdInvalidArgument(const std::string& what_arg) { ...@@ -65,7 +56,7 @@ void ThrowStdInvalidArgument(const std::string& what_arg) {
} }
void ThrowStdInvalidArgument(const char* what_arg) { void ThrowStdInvalidArgument(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::invalid_argument(what_arg)); throw std::invalid_argument(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg); ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort(); std::abort();
...@@ -74,7 +65,7 @@ void ThrowStdInvalidArgument(const char* what_arg) { ...@@ -74,7 +65,7 @@ void ThrowStdInvalidArgument(const char* what_arg) {
void ThrowStdDomainError(const std::string& what_arg) { void ThrowStdDomainError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::domain_error(what_arg)); throw std::domain_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str()); ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort(); std::abort();
...@@ -82,7 +73,7 @@ void ThrowStdDomainError(const std::string& what_arg) { ...@@ -82,7 +73,7 @@ void ThrowStdDomainError(const std::string& what_arg) {
} }
void ThrowStdDomainError(const char* what_arg) { void ThrowStdDomainError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::domain_error(what_arg)); throw std::domain_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg); ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort(); std::abort();
...@@ -91,7 +82,7 @@ void ThrowStdDomainError(const char* what_arg) { ...@@ -91,7 +82,7 @@ void ThrowStdDomainError(const char* what_arg) {
void ThrowStdLengthError(const std::string& what_arg) { void ThrowStdLengthError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::length_error(what_arg)); throw std::length_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str()); ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort(); std::abort();
...@@ -99,7 +90,7 @@ void ThrowStdLengthError(const std::string& what_arg) { ...@@ -99,7 +90,7 @@ void ThrowStdLengthError(const std::string& what_arg) {
} }
void ThrowStdLengthError(const char* what_arg) { void ThrowStdLengthError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::length_error(what_arg)); throw std::length_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg); ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort(); std::abort();
...@@ -108,7 +99,7 @@ void ThrowStdLengthError(const char* what_arg) { ...@@ -108,7 +99,7 @@ void ThrowStdLengthError(const char* what_arg) {
void ThrowStdOutOfRange(const std::string& what_arg) { void ThrowStdOutOfRange(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::out_of_range(what_arg)); throw std::out_of_range(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str()); ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort(); std::abort();
...@@ -116,7 +107,7 @@ void ThrowStdOutOfRange(const std::string& what_arg) { ...@@ -116,7 +107,7 @@ void ThrowStdOutOfRange(const std::string& what_arg) {
} }
void ThrowStdOutOfRange(const char* what_arg) { void ThrowStdOutOfRange(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::out_of_range(what_arg)); throw std::out_of_range(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg); ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort(); std::abort();
...@@ -125,7 +116,7 @@ void ThrowStdOutOfRange(const char* what_arg) { ...@@ -125,7 +116,7 @@ void ThrowStdOutOfRange(const char* what_arg) {
void ThrowStdRuntimeError(const std::string& what_arg) { void ThrowStdRuntimeError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::runtime_error(what_arg)); throw std::runtime_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str()); ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort(); std::abort();
...@@ -133,7 +124,7 @@ void ThrowStdRuntimeError(const std::string& what_arg) { ...@@ -133,7 +124,7 @@ void ThrowStdRuntimeError(const std::string& what_arg) {
} }
void ThrowStdRuntimeError(const char* what_arg) { void ThrowStdRuntimeError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::runtime_error(what_arg)); throw std::runtime_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg); ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort(); std::abort();
...@@ -142,7 +133,7 @@ void ThrowStdRuntimeError(const char* what_arg) { ...@@ -142,7 +133,7 @@ void ThrowStdRuntimeError(const char* what_arg) {
void ThrowStdRangeError(const std::string& what_arg) { void ThrowStdRangeError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::range_error(what_arg)); throw std::range_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str()); ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort(); std::abort();
...@@ -150,7 +141,7 @@ void ThrowStdRangeError(const std::string& what_arg) { ...@@ -150,7 +141,7 @@ void ThrowStdRangeError(const std::string& what_arg) {
} }
void ThrowStdRangeError(const char* what_arg) { void ThrowStdRangeError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::range_error(what_arg)); throw std::range_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg); ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort(); std::abort();
...@@ -159,7 +150,7 @@ void ThrowStdRangeError(const char* what_arg) { ...@@ -159,7 +150,7 @@ void ThrowStdRangeError(const char* what_arg) {
void ThrowStdOverflowError(const std::string& what_arg) { void ThrowStdOverflowError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::overflow_error(what_arg)); throw std::overflow_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str()); ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort(); std::abort();
...@@ -167,7 +158,7 @@ void ThrowStdOverflowError(const std::string& what_arg) { ...@@ -167,7 +158,7 @@ void ThrowStdOverflowError(const std::string& what_arg) {
} }
void ThrowStdOverflowError(const char* what_arg) { void ThrowStdOverflowError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::overflow_error(what_arg)); throw std::overflow_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg); ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort(); std::abort();
...@@ -176,7 +167,7 @@ void ThrowStdOverflowError(const char* what_arg) { ...@@ -176,7 +167,7 @@ void ThrowStdOverflowError(const char* what_arg) {
void ThrowStdUnderflowError(const std::string& what_arg) { void ThrowStdUnderflowError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::underflow_error(what_arg)); throw std::underflow_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str()); ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort(); std::abort();
...@@ -184,7 +175,7 @@ void ThrowStdUnderflowError(const std::string& what_arg) { ...@@ -184,7 +175,7 @@ void ThrowStdUnderflowError(const std::string& what_arg) {
} }
void ThrowStdUnderflowError(const char* what_arg) { void ThrowStdUnderflowError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::underflow_error(what_arg)); throw std::underflow_error(what_arg);
#else #else
ABSL_RAW_LOG(FATAL, "%s", what_arg); ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort(); std::abort();
...@@ -193,7 +184,7 @@ void ThrowStdUnderflowError(const char* what_arg) { ...@@ -193,7 +184,7 @@ void ThrowStdUnderflowError(const char* what_arg) {
void ThrowStdBadFunctionCall() { void ThrowStdBadFunctionCall() {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::bad_function_call()); throw std::bad_function_call();
#else #else
std::abort(); std::abort();
#endif #endif
...@@ -201,7 +192,7 @@ void ThrowStdBadFunctionCall() { ...@@ -201,7 +192,7 @@ void ThrowStdBadFunctionCall() {
void ThrowStdBadAlloc() { void ThrowStdBadAlloc() {
#ifdef ABSL_HAVE_EXCEPTIONS #ifdef ABSL_HAVE_EXCEPTIONS
Throw(std::bad_alloc()); throw std::bad_alloc();
#else #else
std::abort(); std::abort();
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment