summaryrefslogtreecommitdiff
path: root/absl/debugging
diff options
context:
space:
mode:
authorGravatar Chris Mihelich <cmihelic@google.com>2024-06-05 12:44:15 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2024-06-05 12:45:11 -0700
commit49e0099abce54b50fee77a75b90ddc73567f5692 (patch)
tree31433239d82d70c3a91844a1a0b173bf820da169 /absl/debugging
parent8ece6dc4356abe76d3cd7b4742d01f53a95a8e3b (diff)
Demangle ti... and te... expressions (typeid).
PiperOrigin-RevId: 640616282 Change-Id: I2aa94673283d89458886f0634adec87bbf0e57de
Diffstat (limited to 'absl/debugging')
-rw-r--r--absl/debugging/internal/demangle.cc14
-rw-r--r--absl/debugging/internal/demangle_test.cc34
2 files changed, 48 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index 787edcee..1d14ac6c 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -1995,6 +1995,8 @@ static bool ParseBracedExpression(State *state) {
// ::= sc <type> <expression>
// ::= cc <type> <expression>
// ::= rc <type> <expression>
+// ::= ti <type>
+// ::= te <expression>
// ::= st <type>
// ::= at <type>
// ::= az <expression>
@@ -2119,6 +2121,18 @@ static bool ParseExpression(State *state) {
}
state->parse_state = copy;
+ // typeid(type)
+ if (ParseTwoCharToken(state, "ti") && ParseType(state)) {
+ return true;
+ }
+ state->parse_state = copy;
+
+ // typeid(expression)
+ if (ParseTwoCharToken(state, "te") && ParseExpression(state)) {
+ return true;
+ }
+ state->parse_state = copy;
+
// sizeof type
if (ParseTwoCharToken(state, "st") && ParseType(state)) {
return true;
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc
index 5dc2d03b..9050e96e 100644
--- a/absl/debugging/internal/demangle_test.cc
+++ b/absl/debugging/internal/demangle_test.cc
@@ -1098,6 +1098,40 @@ TEST(Demangle, ReinterpretCast) {
EXPECT_STREQ("f<>()", tmp);
}
+TEST(Demangle, TypeidType) {
+ char tmp[80];
+
+ // Source:
+ //
+ // #include <typeinfo>
+ //
+ // template <class T> decltype(typeid(T).name()) f(T) { return nullptr; }
+ // template decltype(typeid(int).name()) f<int>(int);
+ //
+ // Full LLVM demangling of the instantiation of f:
+ //
+ // decltype(typeid (int).name()) f<int>(int)
+ EXPECT_TRUE(Demangle("_Z1fIiEDTcldttiT_4nameEES0_", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+}
+
+TEST(Demangle, TypeidExpression) {
+ char tmp[80];
+
+ // Source:
+ //
+ // #include <typeinfo>
+ //
+ // template <class T> decltype(typeid(T{}).name()) f(T) { return nullptr; }
+ // template decltype(typeid(int{}).name()) f<int>(int);
+ //
+ // Full LLVM demangling of the instantiation of f:
+ //
+ // decltype(typeid (int{}).name()) f<int>(int)
+ EXPECT_TRUE(Demangle("_Z1fIiEDTcldttetlT_E4nameEES0_", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+}
+
TEST(Demangle, AlignofType) {
char tmp[80];