Skip to content

Commit

Permalink
[demangler] Add co_await demangling
Browse files Browse the repository at this point in the history
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
  • Loading branch information
urnathan committed Mar 1, 2022
1 parent 45c969d commit 75db179
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libcxxabi/src/demangle/ItaniumDemangle.h
Expand Up @@ -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
Expand Down Expand Up @@ -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()"},
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions libcxxabi/test/test_demangle.pass.cpp
Expand Up @@ -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]);
Expand Down Expand Up @@ -29950,6 +29952,8 @@ const char* invalid_cases[] =

"_ZN1fIiEEvNTUt_E",
"_ZNDTUt_Ev",

"_ZN1fIXawLi0EEEEvv",
};

const unsigned NI = sizeof(invalid_cases) / sizeof(invalid_cases[0]);
Expand Down
6 changes: 6 additions & 0 deletions llvm/include/llvm/Demangle/ItaniumDemangle.h
Expand Up @@ -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
Expand Down Expand Up @@ -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()"},
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 75db179

Please sign in to comment.