Commit d60c089e by Chris Mihelich Committed by Copybara-Service

Demangle the C++ this pointer (fpT).

PiperOrigin-RevId: 636695970
Change-Id: I22d6f13271ab965563f1f575d9d7ba0ed1af466d
parent b3cd0250
...@@ -300,8 +300,8 @@ static bool ParseOneCharToken(State *state, const char one_char_token) { ...@@ -300,8 +300,8 @@ static bool ParseOneCharToken(State *state, const char one_char_token) {
return false; return false;
} }
// Returns true and advances "mangled_cur" if we find "two_char_token" // Returns true and advances "mangled_idx" if we find "two_char_token"
// at "mangled_cur" position. It is assumed that "two_char_token" does // at "mangled_idx" position. It is assumed that "two_char_token" does
// not contain '\0'. // not contain '\0'.
static bool ParseTwoCharToken(State *state, const char *two_char_token) { static bool ParseTwoCharToken(State *state, const char *two_char_token) {
ComplexityGuard guard(state); ComplexityGuard guard(state);
...@@ -314,6 +314,21 @@ static bool ParseTwoCharToken(State *state, const char *two_char_token) { ...@@ -314,6 +314,21 @@ static bool ParseTwoCharToken(State *state, const char *two_char_token) {
return false; return false;
} }
// Returns true and advances "mangled_idx" if we find "three_char_token"
// at "mangled_idx" position. It is assumed that "three_char_token" does
// not contain '\0'.
static bool ParseThreeCharToken(State *state, const char *three_char_token) {
ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false;
if (RemainingInput(state)[0] == three_char_token[0] &&
RemainingInput(state)[1] == three_char_token[1] &&
RemainingInput(state)[2] == three_char_token[2]) {
state->parse_state.mangled_idx += 3;
return true;
}
return false;
}
// Returns true and advances "mangled_cur" if we find any character in // Returns true and advances "mangled_cur" if we find any character in
// "char_class" at "mangled_cur" position. // "char_class" at "mangled_cur" position.
static bool ParseCharClass(State *state, const char *char_class) { static bool ParseCharClass(State *state, const char *char_class) {
...@@ -1759,6 +1774,7 @@ static bool ParseUnionSelector(State *state) { ...@@ -1759,6 +1774,7 @@ static bool ParseUnionSelector(State *state) {
// ::= fp <(top-level) CV-qualifiers> <number> _ // ::= fp <(top-level) CV-qualifiers> <number> _
// ::= fL <number> p <(top-level) CV-qualifiers> _ // ::= fL <number> p <(top-level) CV-qualifiers> _
// ::= fL <number> p <(top-level) CV-qualifiers> <number> _ // ::= fL <number> p <(top-level) CV-qualifiers> <number> _
// ::= fpT # this
static bool ParseFunctionParam(State *state) { static bool ParseFunctionParam(State *state) {
ComplexityGuard guard(state); ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false; if (guard.IsTooComplex()) return false;
...@@ -1780,7 +1796,7 @@ static bool ParseFunctionParam(State *state) { ...@@ -1780,7 +1796,7 @@ static bool ParseFunctionParam(State *state) {
} }
state->parse_state = copy; state->parse_state = copy;
return false; return ParseThreeCharToken(state, "fpT");
} }
// <braced-expression> ::= <expression> // <braced-expression> ::= <expression>
......
...@@ -308,6 +308,14 @@ TEST(Demangle, AbiTags) { ...@@ -308,6 +308,14 @@ TEST(Demangle, AbiTags) {
EXPECT_STREQ("C[abi:bar][abi:foo]()", tmp); EXPECT_STREQ("C[abi:bar][abi:foo]()", tmp);
} }
TEST(Demangle, ThisPointerInDependentSignature) {
char tmp[80];
// decltype(g<int>(this)) S::f<int>()
EXPECT_TRUE(Demangle("_ZN1S1fIiEEDTcl1gIT_EfpTEEv", tmp, sizeof(tmp)));
EXPECT_STREQ("S::f<>()", tmp);
}
// Test subobject-address template parameters. // Test subobject-address template parameters.
TEST(Demangle, SubobjectAddresses) { TEST(Demangle, SubobjectAddresses) {
char tmp[80]; char tmp[80];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment