[demangler] Add co_await demangling

The demangler doesn't understand 'aw' as an operator name. This adds
the necessary smarts -- you may use this as an operator functionname,
but not as an expression operator.

Reviewed By: ChuanqiXu

Differential Revision: https://reviews.llvm.org/D120143
This commit is contained in:
Nathan Sidwell 2022-02-18 09:51:24 -08:00
parent 45c969defa
commit 75db1795e4
3 changed files with 16 additions and 0 deletions

View File

@ -2568,6 +2568,7 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
Call, // Function call: expr (expr*)
CCast, // C cast: (type)expr
Conditional, // Conditional: expr ? expr : expr
NameOnly, // Overload only, not allowed in expression.
// Below do not have operator names
NamedCast, // Named cast, @<type>(expr)
OfIdOp, // alignof, sizeof, typeid
@ -2877,6 +2878,7 @@ AbstractManglingParser<Derived, Alloc>::parseOperatorEncoding() {
{"ad", OperatorInfo::Prefix, false, "operator&"},
{"an", OperatorInfo::Binary, false, "operator&"},
{"at", OperatorInfo::OfIdOp, /*Type*/ true, "alignof ("},
{"aw", OperatorInfo::NameOnly, false, "operator co_await"},
{"az", OperatorInfo::OfIdOp, /*Type*/ false, "alignof ("},
{"cc", OperatorInfo::NamedCast, false, "const_cast"},
{"cl", OperatorInfo::Call, false, "operator()"},
@ -4573,6 +4575,10 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
return nullptr;
return make<EnclosingExpr>(Sym, Arg, ")");
}
case OperatorInfo::NameOnly: {
// Not valid as an expression operand.
return nullptr;
}
}
DEMANGLE_UNREACHABLE;
}

View File

@ -29865,6 +29865,8 @@ const char* cases[][2] =
{"_ZN2FnIXdlLj4EEXgsdaLj4EEEEvv", "void Fn<delete 4u, ::delete[] 4u>()"},
{"_Z3TPLIiET_S0_", "int TPL<int>(int)"},
{"_ZN1XawEv", "X::operator co_await()"},
};
const unsigned N = sizeof(cases) / sizeof(cases[0]);
@ -29950,6 +29952,8 @@ const char* invalid_cases[] =
"_ZN1fIiEEvNTUt_E",
"_ZNDTUt_Ev",
"_ZN1fIXawLi0EEEEvv",
};
const unsigned NI = sizeof(invalid_cases) / sizeof(invalid_cases[0]);

View File

@ -2568,6 +2568,7 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
Call, // Function call: expr (expr*)
CCast, // C cast: (type)expr
Conditional, // Conditional: expr ? expr : expr
NameOnly, // Overload only, not allowed in expression.
// Below do not have operator names
NamedCast, // Named cast, @<type>(expr)
OfIdOp, // alignof, sizeof, typeid
@ -2877,6 +2878,7 @@ AbstractManglingParser<Derived, Alloc>::parseOperatorEncoding() {
{"ad", OperatorInfo::Prefix, false, "operator&"},
{"an", OperatorInfo::Binary, false, "operator&"},
{"at", OperatorInfo::OfIdOp, /*Type*/ true, "alignof ("},
{"aw", OperatorInfo::NameOnly, false, "operator co_await"},
{"az", OperatorInfo::OfIdOp, /*Type*/ false, "alignof ("},
{"cc", OperatorInfo::NamedCast, false, "const_cast"},
{"cl", OperatorInfo::Call, false, "operator()"},
@ -4573,6 +4575,10 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
return nullptr;
return make<EnclosingExpr>(Sym, Arg, ")");
}
case OperatorInfo::NameOnly: {
// Not valid as an expression operand.
return nullptr;
}
}
DEMANGLE_UNREACHABLE;
}