Skip to content

Commit a40c1ee

Browse files
committed
[Mangler] refactor the code that translates OperatorFixity in mangleIdentifier. NFC.
1 parent 8f30faa commit a40c1ee

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

lib/AST/Mangle.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,23 @@ namespace {
5858
}
5959
};
6060
}
61-
61+
62+
// Translates operator fixity to demangler operators.
63+
static Demangle::OperatorKind TranslateOperator(OperatorFixity fixity) {
64+
switch (fixity) {
65+
case OperatorFixity::NotOperator:return Demangle::OperatorKind::NotOperator;
66+
case OperatorFixity::Prefix: return Demangle::OperatorKind::Prefix;
67+
case OperatorFixity::Postfix: return Demangle::OperatorKind::Postfix;
68+
case OperatorFixity::Infix: return Demangle::OperatorKind::Infix;
69+
}
70+
llvm_unreachable("invalid operator fixity");
71+
}
72+
6273
/// Mangle a StringRef as an identifier into a buffer.
6374
void Mangler::mangleIdentifier(StringRef str, OperatorFixity fixity,
6475
bool isOperator) {
65-
auto operatorKind = [=]() -> Demangle::OperatorKind {
66-
if (!isOperator) return Demangle::OperatorKind::NotOperator;
67-
switch (fixity) {
68-
case OperatorFixity::NotOperator:return Demangle::OperatorKind::NotOperator;
69-
case OperatorFixity::Prefix: return Demangle::OperatorKind::Prefix;
70-
case OperatorFixity::Postfix: return Demangle::OperatorKind::Postfix;
71-
case OperatorFixity::Infix: return Demangle::OperatorKind::Infix;
72-
}
73-
llvm_unreachable("invalid operator fixity");
74-
}();
76+
auto operatorKind = isOperator ? TranslateOperator(fixity) :
77+
Demangle::OperatorKind::NotOperator;
7578

7679
std::string buf;
7780
Demangle::mangleIdentifier(str.data(), str.size(), operatorKind, buf,

0 commit comments

Comments
 (0)