diff options
author | Abseil Team <absl-team@google.com> | 2023-10-02 10:09:34 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-10-02 10:10:25 -0700 |
commit | 302d851a06072a581961970c1e120c2af7b70482 (patch) | |
tree | b100bf8dffd45e44b3d406741f599cbfbaff7c7f /absl/container | |
parent | 44e8609e7ee6ba85ca7bca43fdef51618a806405 (diff) |
Re-submit with a fix for platforms without RTTI.
We test for `ABSL_INTERNAL_HAS_RTTI` in `absl::container_internal::TypeName` before calling `typeid`.
PiperOrigin-RevId: 570101013
Change-Id: I1f2f9b2f475a6beae50d0b88718b17b296311155
Diffstat (limited to 'absl/container')
-rw-r--r-- | absl/container/BUILD.bazel | 1 | ||||
-rw-r--r-- | absl/container/CMakeLists.txt | 1 | ||||
-rw-r--r-- | absl/container/internal/layout.h | 25 |
3 files changed, 7 insertions, 20 deletions
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel index 7462b125..69413ff9 100644 --- a/absl/container/BUILD.bazel +++ b/absl/container/BUILD.bazel @@ -731,6 +731,7 @@ cc_library( deps = [ "//absl/base:config", "//absl/base:core_headers", + "//absl/debugging:demangle_internal", "//absl/meta:type_traits", "//absl/strings", "//absl/types:span", diff --git a/absl/container/CMakeLists.txt b/absl/container/CMakeLists.txt index a1633514..116ddab2 100644 --- a/absl/container/CMakeLists.txt +++ b/absl/container/CMakeLists.txt @@ -777,6 +777,7 @@ absl_cc_library( DEPS absl::config absl::core_headers + absl::debugging_internal absl::meta absl::strings absl::span diff --git a/absl/container/internal/layout.h b/absl/container/internal/layout.h index a59a2430..fbc4e1da 100644 --- a/absl/container/internal/layout.h +++ b/absl/container/internal/layout.h @@ -172,6 +172,7 @@ #include <utility> #include "absl/base/config.h" +#include "absl/debugging/internal/demangle.h" #include "absl/meta/type_traits.h" #include "absl/strings/str_cat.h" #include "absl/types/span.h" @@ -181,14 +182,6 @@ #include <sanitizer/asan_interface.h> #endif -#if defined(__GXX_RTTI) -#define ABSL_INTERNAL_HAS_CXA_DEMANGLE -#endif - -#ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE -#include <cxxabi.h> -#endif - namespace absl { ABSL_NAMESPACE_BEGIN namespace container_internal { @@ -294,19 +287,11 @@ constexpr size_t Max(size_t a, size_t b, Ts... rest) { template <class T> std::string TypeName() { std::string out; - int status = 0; - char* demangled = nullptr; -#ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE - demangled = abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, &status); -#endif - if (status == 0 && demangled != nullptr) { // Demangling succeeded. - absl::StrAppend(&out, "<", demangled, ">"); - free(demangled); - } else { -#if defined(__GXX_RTTI) || defined(_CPPRTTI) - absl::StrAppend(&out, "<", typeid(T).name(), ">"); +#if ABSL_INTERNAL_HAS_RTTI + absl::StrAppend(&out, "<", + absl::debugging_internal::DemangleString(typeid(T).name()), + ">"); #endif - } return out; } |