summaryrefslogtreecommitdiff
path: root/absl/base
diff options
context:
space:
mode:
authorGravatar Devin Jeanpierre <jeanpierreda@google.com>2023-03-01 17:56:57 -0800
committerGravatar Copybara-Service <copybara-worker@google.com>2023-03-01 17:57:39 -0800
commit02f4b999763c2c71b7a5e00d1c4b2cf6317eecae (patch)
treed734640d459590851cf0fea4513d98c2c04ea4fa /absl/base
parent6c2630fe513378db47708d9000e45754a954d3a5 (diff)
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
Diffstat (limited to 'absl/base')
-rw-r--r--absl/base/internal/throw_delegate.cc55
1 files changed, 23 insertions, 32 deletions
diff --git a/absl/base/internal/throw_delegate.cc b/absl/base/internal/throw_delegate.cc
index c260ff1e..337e870c 100644
--- a/absl/base/internal/throw_delegate.cc
+++ b/absl/base/internal/throw_delegate.cc
@@ -26,22 +26,13 @@ namespace absl {
ABSL_NAMESPACE_BEGIN
namespace base_internal {
-// NOTE: The various STL exception throwing functions are placed within the
-// #ifdef blocks so the symbols aren't exposed on platforms that don't support
-// them, such as the Android NDK. For example, ANGLE fails to link when building
-// 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
+// NOTE: The exception types, like `std::logic_error`, do not exist on all
+// platforms. (For example, the Android NDK does not have them.)
+// Therefore, their use must be guarded by `#ifdef` or equivalent.
void ThrowStdLogicError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::logic_error(what_arg));
+ throw std::logic_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
@@ -49,7 +40,7 @@ void ThrowStdLogicError(const std::string& what_arg) {
}
void ThrowStdLogicError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::logic_error(what_arg));
+ throw std::logic_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
@@ -57,7 +48,7 @@ void ThrowStdLogicError(const char* what_arg) {
}
void ThrowStdInvalidArgument(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::invalid_argument(what_arg));
+ throw std::invalid_argument(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
@@ -65,7 +56,7 @@ void ThrowStdInvalidArgument(const std::string& what_arg) {
}
void ThrowStdInvalidArgument(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::invalid_argument(what_arg));
+ throw std::invalid_argument(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
@@ -74,7 +65,7 @@ void ThrowStdInvalidArgument(const char* what_arg) {
void ThrowStdDomainError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::domain_error(what_arg));
+ throw std::domain_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
@@ -82,7 +73,7 @@ void ThrowStdDomainError(const std::string& what_arg) {
}
void ThrowStdDomainError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::domain_error(what_arg));
+ throw std::domain_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
@@ -91,7 +82,7 @@ void ThrowStdDomainError(const char* what_arg) {
void ThrowStdLengthError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::length_error(what_arg));
+ throw std::length_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
@@ -99,7 +90,7 @@ void ThrowStdLengthError(const std::string& what_arg) {
}
void ThrowStdLengthError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::length_error(what_arg));
+ throw std::length_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
@@ -108,7 +99,7 @@ void ThrowStdLengthError(const char* what_arg) {
void ThrowStdOutOfRange(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::out_of_range(what_arg));
+ throw std::out_of_range(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
@@ -116,7 +107,7 @@ void ThrowStdOutOfRange(const std::string& what_arg) {
}
void ThrowStdOutOfRange(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::out_of_range(what_arg));
+ throw std::out_of_range(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
@@ -125,7 +116,7 @@ void ThrowStdOutOfRange(const char* what_arg) {
void ThrowStdRuntimeError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::runtime_error(what_arg));
+ throw std::runtime_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
@@ -133,7 +124,7 @@ void ThrowStdRuntimeError(const std::string& what_arg) {
}
void ThrowStdRuntimeError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::runtime_error(what_arg));
+ throw std::runtime_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
@@ -142,7 +133,7 @@ void ThrowStdRuntimeError(const char* what_arg) {
void ThrowStdRangeError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::range_error(what_arg));
+ throw std::range_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
@@ -150,7 +141,7 @@ void ThrowStdRangeError(const std::string& what_arg) {
}
void ThrowStdRangeError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::range_error(what_arg));
+ throw std::range_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
@@ -159,7 +150,7 @@ void ThrowStdRangeError(const char* what_arg) {
void ThrowStdOverflowError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::overflow_error(what_arg));
+ throw std::overflow_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
@@ -167,7 +158,7 @@ void ThrowStdOverflowError(const std::string& what_arg) {
}
void ThrowStdOverflowError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::overflow_error(what_arg));
+ throw std::overflow_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
@@ -176,7 +167,7 @@ void ThrowStdOverflowError(const char* what_arg) {
void ThrowStdUnderflowError(const std::string& what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::underflow_error(what_arg));
+ throw std::underflow_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg.c_str());
std::abort();
@@ -184,7 +175,7 @@ void ThrowStdUnderflowError(const std::string& what_arg) {
}
void ThrowStdUnderflowError(const char* what_arg) {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::underflow_error(what_arg));
+ throw std::underflow_error(what_arg);
#else
ABSL_RAW_LOG(FATAL, "%s", what_arg);
std::abort();
@@ -193,7 +184,7 @@ void ThrowStdUnderflowError(const char* what_arg) {
void ThrowStdBadFunctionCall() {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::bad_function_call());
+ throw std::bad_function_call();
#else
std::abort();
#endif
@@ -201,7 +192,7 @@ void ThrowStdBadFunctionCall() {
void ThrowStdBadAlloc() {
#ifdef ABSL_HAVE_EXCEPTIONS
- Throw(std::bad_alloc());
+ throw std::bad_alloc();
#else
std::abort();
#endif