diff options
Diffstat (limited to 'absl/debugging')
-rw-r--r-- | absl/debugging/internal/demangle.cc | 14 | ||||
-rw-r--r-- | absl/debugging/internal/demangle_test.cc | 34 |
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]; |