summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Mihelich <cmihelic@google.com>2024-06-07 09:25:38 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2024-06-07 09:26:29 -0700
commit61e721f41f3e9de4e3a9ef97b32700f84d26ea3b (patch)
tree32fc318979c74ec1ae6361fe09a52959fb9d8551
parent59d0a7d141084dbec666b6f05ffa8c4210d61956 (diff)
Demangle fully general vendor extended types (any <template-args>).
PiperOrigin-RevId: 641271471 Change-Id: Ibeedb4dea3b961955d073f048d293b19aa917792
-rw-r--r--absl/debugging/internal/demangle.cc17
-rw-r--r--absl/debugging/internal/demangle_test.cc5
2 files changed, 7 insertions, 15 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index 9f4a8352..46a63964 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -1444,8 +1444,6 @@ static bool ParseCVQualifiers(State *state) {
//
// Not supported:
// ::= DF <number> _ # _FloatN (N bits)
-//
-// NOTE: [I <type> E] is a vendor extension (http://shortn/_FrINpH1XC5).
static bool ParseBuiltinType(State *state) {
ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false;
@@ -1466,22 +1464,15 @@ static bool ParseBuiltinType(State *state) {
return ParseVendorExtendedType(state);
}
-// <vendor-extended-type> ::= u <source-name> [I <type> E]
-//
-// NOTE: [I <type> E] is a vendor extension (http://shortn/_FrINpH1XC5).
+// <vendor-extended-type> ::= u <source-name> [<template-args>]
static bool ParseVendorExtendedType(State *state) {
ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false;
ParseState copy = state->parse_state;
- if (ParseOneCharToken(state, 'u') && ParseSourceName(state)) {
- copy = state->parse_state;
- if (ParseOneCharToken(state, 'I') && ParseType(state) &&
- ParseOneCharToken(state, 'E')) {
- return true; // ::= u <source-name> I <type> E
- }
- state->parse_state = copy;
- return true; // ::= u <source-name>
+ if (ParseOneCharToken(state, 'u') && ParseSourceName(state) &&
+ Optional(ParseTemplateArgs(state))) {
+ return true;
}
state->parse_state = copy;
return false;
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc
index 974b15f0..6f69cff9 100644
--- a/absl/debugging/internal/demangle_test.cc
+++ b/absl/debugging/internal/demangle_test.cc
@@ -209,15 +209,16 @@ TEST(Demangle, SingleArgTemplateBuiltinType) {
EXPECT_STREQ(tmp, "foo<>()");
}
-TEST(Demangle, FailsOnTwoArgTemplateBuiltinType) {
+TEST(Demangle, TwoArgTemplateBuiltinType) {
char tmp[100];
// template <typename T, typename U>
// __my_builtin_type<T, U> foo();
//
// foo<int, char>();
- ASSERT_FALSE(
+ ASSERT_TRUE(
Demangle("_Z3fooIicEu17__my_builtin_typeIT_T0_Ev", tmp, sizeof(tmp)));
+ EXPECT_STREQ(tmp, "foo<>()");
}
TEST(Demangle, TypeNestedUnderTemplatedBuiltinType) {