summaryrefslogtreecommitdiffstats
path: root/googletest/include/gtest/internal/gtest-type-util.h
diff options
context:
space:
mode:
authorJames Dennett <jdennett@google.com>2018-05-11 05:36:50 (GMT)
committerGitHub <noreply@github.com>2018-05-11 05:36:50 (GMT)
commitfc66ae45fc7f935eef23af27347761ba4050ad6e (patch)
treeaa35a103eaf54ffa9535f97a05b7bd7af44fc37e /googletest/include/gtest/internal/gtest-type-util.h
parentb8fa4d275441acae8d4e84f373940869436b1de1 (diff)
downloadgoogletest-fc66ae45fc7f935eef23af27347761ba4050ad6e.zip
googletest-fc66ae45fc7f935eef23af27347761ba4050ad6e.tar.gz
googletest-fc66ae45fc7f935eef23af27347761ba4050ad6e.tar.bz2
Update generated code.
Diffstat (limited to 'googletest/include/gtest/internal/gtest-type-util.h')
-rw-r--r--googletest/include/gtest/internal/gtest-type-util.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/googletest/include/gtest/internal/gtest-type-util.h b/googletest/include/gtest/internal/gtest-type-util.h
index e46f7cf..d0d83f5 100644
--- a/googletest/include/gtest/internal/gtest-type-util.h
+++ b/googletest/include/gtest/internal/gtest-type-util.h
@@ -56,6 +56,22 @@
namespace testing {
namespace internal {
+
+// Canonicalizes a given name with respect to the Standard C++ Library.
+// This handles removing the inline namespace within `std` that is
+// used by various standard libraries (e.g., `std::__1`). Names outside
+// of namespace std are returned unmodified.
+inline std::string CanonicalizeForStdLibVersioning(std::string s) {
+ static constexpr char prefix[] = "std::__";
+ if (s.compare(0, strlen(prefix), prefix) == 0) {
+ auto end = s.find("::", strlen(prefix));
+ if (end != s.npos) {
+ // Erase the `::__` plus whatever was between that and the next `::`.
+ s.erase(strlen("std"), strlen("::__") + end - strlen(prefix));
+ }
+ }
+ return s;
+}
// GetTypeName<T>() returns a human-readable name of type T.
// NB: This function is also used in Google Mock, so don't move it inside of
@@ -73,9 +89,9 @@ std::string GetTypeName() {
using abi::__cxa_demangle;
# endif // GTEST_HAS_CXXABI_H_
char* const readable_name = __cxa_demangle(name, 0, 0, &status);
- const std::string name_str(status == 0 ? readable_name : name);
+ std::string name_str(status == 0 ? readable_name : name);
free(readable_name);
- return name_str;
+ return CanonicalizeForStdLibVersioning(std::move(name_str));
# else
return name;
# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC