Commit 5195c35d by Chris Mihelich Committed by Copybara-Service

Demangle template parameter object names, TA <template-arg>.

PiperOrigin-RevId: 641893938
Change-Id: I8a21e322c9cf1d5dab7477af5367aad134fbf2ab
parent 2f61aed1
...@@ -1176,6 +1176,7 @@ static bool ParseConversionOperatorType(State *state) { ...@@ -1176,6 +1176,7 @@ static bool ParseConversionOperatorType(State *state) {
// ::= GR <(object) name> [<seq-id>] _ // ::= GR <(object) name> [<seq-id>] _
// ::= T <call-offset> <(base) encoding> // ::= T <call-offset> <(base) encoding>
// ::= GTt <encoding> # transaction-safe entry point // ::= GTt <encoding> # transaction-safe entry point
// ::= TA <template-arg> # nontype template parameter object
// G++ extensions: // G++ extensions:
// ::= TC <type> <(offset) number> _ <(base) type> // ::= TC <type> <(offset) number> _ <(base) type>
// ::= TF <type> // ::= TF <type>
...@@ -1190,6 +1191,8 @@ static bool ParseConversionOperatorType(State *state) { ...@@ -1190,6 +1191,8 @@ static bool ParseConversionOperatorType(State *state) {
// thread_local feature. For these see: // thread_local feature. For these see:
// //
// https://maskray.me/blog/2021-02-14-all-about-thread-local-storage // https://maskray.me/blog/2021-02-14-all-about-thread-local-storage
//
// For TA see https://github.com/itanium-cxx-abi/cxx-abi/issues/63.
static bool ParseSpecialName(State *state) { static bool ParseSpecialName(State *state) {
ComplexityGuard guard(state); ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false; if (guard.IsTooComplex()) return false;
...@@ -1280,6 +1283,18 @@ static bool ParseSpecialName(State *state) { ...@@ -1280,6 +1283,18 @@ static bool ParseSpecialName(State *state) {
return true; return true;
} }
state->parse_state = copy; state->parse_state = copy;
if (ParseTwoCharToken(state, "TA")) {
bool append = state->parse_state.append;
DisableAppend(state);
if (ParseTemplateArg(state)) {
RestoreAppend(state, append);
MaybeAppend(state, "template parameter object");
return true;
}
}
state->parse_state = copy;
return false; return false;
} }
......
...@@ -943,6 +943,29 @@ TEST(Demangle, TransactionSafeFunctionType) { ...@@ -943,6 +943,29 @@ TEST(Demangle, TransactionSafeFunctionType) {
EXPECT_STREQ("f()", tmp); EXPECT_STREQ("f()", tmp);
} }
TEST(Demangle, TemplateParameterObject) {
char tmp[80];
// Source:
//
// struct S { int x, y; };
// template <S s, const S* p = &s> void f() {}
// template void f<S{1, 2}>();
//
// LLVM demangling:
//
// void f<S{1, 2}, &template parameter object for S{1, 2}>()
EXPECT_TRUE(Demangle("_Z1fIXtl1SLi1ELi2EEEXadL_ZTAXtlS0_Li1ELi2EEEEEEvv",
tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
// The name of the object standing alone.
//
// LLVM demangling: template parameter object for S{1, 2}
EXPECT_TRUE(Demangle("_ZTAXtl1SLi1ELi2EEE", tmp, sizeof(tmp)));
EXPECT_STREQ("template parameter object", tmp);
}
TEST(Demangle, EnableIfAttributeOnGlobalFunction) { TEST(Demangle, EnableIfAttributeOnGlobalFunction) {
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