summaryrefslogtreecommitdiff
path: root/absl/container/internal/layout.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-10-02 10:09:34 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-10-02 10:10:25 -0700
commit302d851a06072a581961970c1e120c2af7b70482 (patch)
treeb100bf8dffd45e44b3d406741f599cbfbaff7c7f /absl/container/internal/layout.h
parent44e8609e7ee6ba85ca7bca43fdef51618a806405 (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/internal/layout.h')
-rw-r--r--absl/container/internal/layout.h25
1 files changed, 5 insertions, 20 deletions
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;
}