aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Mihelich <cmihelic@google.com>2024-06-06 11:48:09 -0700
committerCopybara-Service <copybara-worker@google.com>2024-06-06 11:49:03 -0700
commit586a541d2bd9f66f7a7115338f3a2402ae5c46b6 (patch)
tree9496e868a4c6e6b4f033ae7926102b4cf9de6f1e
parent66ef711d6846771b8e725e377de37bedae6c1527 (diff)
downloadabseil-586a541d2bd9f66f7a7115338f3a2402ae5c46b6.tar.gz
abseil-586a541d2bd9f66f7a7115338f3a2402ae5c46b6.tar.bz2
abseil-586a541d2bd9f66f7a7115338f3a2402ae5c46b6.zip
Demangle elaborated type names, (Ts | Tu | Te) <name>.
PiperOrigin-RevId: 640972027 Change-Id: I810aaa10e7761686d03854abab3198be8b2868cf
-rw-r--r--absl/debugging/internal/demangle.cc15
-rw-r--r--absl/debugging/internal/demangle_test.cc24
2 files changed, 38 insertions, 1 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index 58749478..1a5828fa 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -1544,10 +1544,23 @@ static bool ParseOverloadAttribute(State *state) {
}
// <class-enum-type> ::= <name>
+// ::= Ts <name> # struct Name or class Name
+// ::= Tu <name> # union Name
+// ::= Te <name> # enum Name
+//
+// See http://shortn/_W3YrltiEd0.
static bool ParseClassEnumType(State *state) {
ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false;
- return ParseName(state);
+ ParseState copy = state->parse_state;
+ if (Optional(ParseTwoCharToken(state, "Ts") ||
+ ParseTwoCharToken(state, "Tu") ||
+ ParseTwoCharToken(state, "Te")) &&
+ ParseName(state)) {
+ return true;
+ }
+ state->parse_state = copy;
+ return false;
}
// <array-type> ::= A <(positive dimension) number> _ <(element) type>
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc
index c1308de9..0b12234f 100644
--- a/absl/debugging/internal/demangle_test.cc
+++ b/absl/debugging/internal/demangle_test.cc
@@ -739,6 +739,30 @@ TEST(Demangle, TypeNestedUnderDecltype) {
EXPECT_STREQ("f<>()", tmp);
}
+TEST(Demangle, ElaboratedTypes) {
+ char tmp[80];
+
+ // Source:
+ //
+ // template <class T> struct S { class C {}; };
+ // template <class T> void f(class S<T>::C) {}
+ // template void f<int>(class S<int>::C);
+ //
+ // LLVM demangling:
+ //
+ // void f<int>(struct S<int>::C)
+ EXPECT_TRUE(Demangle("_Z1fIiEvTsN1SIT_E1CE", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+
+ // The like for unions.
+ EXPECT_TRUE(Demangle("_Z1fIiEvTuN1SIT_E1CE", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+
+ // The like for enums.
+ EXPECT_TRUE(Demangle("_Z1fIiEvTeN1SIT_E1CE", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+}
+
// Test subobject-address template parameters.
TEST(Demangle, SubobjectAddresses) {
char tmp[80];