Commit cba68bb9 by Chris Mihelich Committed by Copybara-Service

Demangle modern _ZGR..._ symbols.

PiperOrigin-RevId: 640517212
Change-Id: Ideaaf45d2104a3c82cc9b6807894554335e5b904
parent 29bd16cb
...@@ -1080,12 +1080,13 @@ static bool ParseOperatorName(State *state, int *arity) { ...@@ -1080,12 +1080,13 @@ static bool ParseOperatorName(State *state, int *arity) {
// ::= TH <name> # thread-local initialization // ::= TH <name> # thread-local initialization
// ::= Tc <call-offset> <call-offset> <(base) encoding> // ::= Tc <call-offset> <call-offset> <(base) encoding>
// ::= GV <(object) name> // ::= GV <(object) name>
// ::= GR <(object) name> [<seq-id>] _
// ::= T <call-offset> <(base) encoding> // ::= T <call-offset> <(base) encoding>
// G++ extensions: // G++ extensions:
// ::= TC <type> <(offset) number> _ <(base) type> // ::= TC <type> <(offset) number> _ <(base) type>
// ::= TF <type> // ::= TF <type>
// ::= TJ <type> // ::= TJ <type>
// ::= GR <name> // ::= GR <name> # without final _, perhaps an earlier form?
// ::= GA <encoding> // ::= GA <encoding>
// ::= Th <call-offset> <(base) encoding> // ::= Th <call-offset> <(base) encoding>
// ::= Tv <call-offset> <(base) encoding> // ::= Tv <call-offset> <(base) encoding>
...@@ -1152,10 +1153,22 @@ static bool ParseSpecialName(State *state) { ...@@ -1152,10 +1153,22 @@ static bool ParseSpecialName(State *state) {
} }
state->parse_state = copy; state->parse_state = copy;
if (ParseTwoCharToken(state, "GR") && ParseName(state)) { // <special-name> ::= GR <(object) name> [<seq-id>] _ # modern standard
return true; // ::= GR <(object) name> # also recognized
if (ParseTwoCharToken(state, "GR")) {
MaybeAppend(state, "reference temporary for ");
if (!ParseName(state)) {
state->parse_state = copy;
return false;
} }
const bool has_seq_id = ParseSeqId(state);
const bool has_underscore = ParseOneCharToken(state, '_');
if (has_seq_id && !has_underscore) {
state->parse_state = copy; state->parse_state = copy;
return false;
}
return true;
}
if (ParseTwoCharToken(state, "GA") && ParseEncoding(state)) { if (ParseTwoCharToken(state, "GA") && ParseEncoding(state)) {
return true; return true;
......
...@@ -612,6 +612,26 @@ TEST(Demangle, StringLiterals) { ...@@ -612,6 +612,26 @@ TEST(Demangle, StringLiterals) {
EXPECT_STREQ("f<>()", tmp); EXPECT_STREQ("f<>()", tmp);
} }
TEST(Demangle, GlobalInitializers) {
char tmp[80];
// old form without suffix
EXPECT_TRUE(Demangle("_ZGR1v", tmp, sizeof(tmp)));
EXPECT_STREQ("reference temporary for v", tmp);
// modern form for the whole initializer
EXPECT_TRUE(Demangle("_ZGR1v_", tmp, sizeof(tmp)));
EXPECT_STREQ("reference temporary for v", tmp);
// next subobject in depth-first preorder traversal
EXPECT_TRUE(Demangle("_ZGR1v0_", tmp, sizeof(tmp)));
EXPECT_STREQ("reference temporary for v", tmp);
// subobject with a larger seq-id
EXPECT_TRUE(Demangle("_ZGR1v1Z_", tmp, sizeof(tmp)));
EXPECT_STREQ("reference temporary for v", tmp);
}
// Test the GNU abi_tag extension. // Test the GNU abi_tag extension.
TEST(Demangle, AbiTags) { TEST(Demangle, AbiTags) {
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