summaryrefslogtreecommitdiff
path: root/absl/container
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-09-26 15:27:07 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-09-26 15:27:47 -0700
commit6ab667fd8deba75443fdc0d5c5bbf4588431f1b4 (patch)
tree1e001cba5a64ac395b77fa561333487729683baa /absl/container
parentcced061b3e68da386aaadca0d87e03538ce2bc72 (diff)
Add an internal wrapper for `abi::__cxa_demangle()`.
PiperOrigin-RevId: 568665135 Change-Id: I42ec9bc6cfe923777f7b60ea032c7b64428493c9
Diffstat (limited to 'absl/container')
-rw-r--r--absl/container/BUILD.bazel1
-rw-r--r--absl/container/CMakeLists.txt1
-rw-r--r--absl/container/internal/layout.h25
3 files changed, 21 insertions, 6 deletions
diff --git a/absl/container/BUILD.bazel b/absl/container/BUILD.bazel
index 69413ff9..7462b125 100644
--- a/absl/container/BUILD.bazel
+++ b/absl/container/BUILD.bazel
@@ -731,7 +731,6 @@ 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 116ddab2..a1633514 100644
--- a/absl/container/CMakeLists.txt
+++ b/absl/container/CMakeLists.txt
@@ -777,7 +777,6 @@ 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 05de05c9..a59a2430 100644
--- a/absl/container/internal/layout.h
+++ b/absl/container/internal/layout.h
@@ -172,7 +172,6 @@
#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"
@@ -182,6 +181,14 @@
#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 {
@@ -287,9 +294,19 @@ constexpr size_t Max(size_t a, size_t b, Ts... rest) {
template <class T>
std::string TypeName() {
std::string out;
- absl::StrAppend(&out, "<",
- absl::debugging_internal::DemangleString(typeid(T).name()),
- ">");
+ 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(), ">");
+#endif
+ }
return out;
}