Skip to content

Commit bfb1f9a

Browse files
committed
[Mangler] Refactor the mangling of OperatorKind into a helper function. NFC.
1 parent f90f271 commit bfb1f9a

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/Basic/Remangle.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ static bool isNonAscii(StringRef str) {
7070
return false;
7171
}
7272

73+
static char mangleOperatorKind(OperatorKind operatorKind) {
74+
switch (operatorKind) {
75+
case OperatorKind::NotOperator: unreachable("invalid");
76+
case OperatorKind::Infix: return 'i';
77+
case OperatorKind::Prefix: return 'p';
78+
case OperatorKind::Postfix: return 'P';
79+
}
80+
unreachable("invalid");
81+
}
82+
7383
static void mangleIdentifier(StringRef ident, OperatorKind operatorKind,
7484
bool usePunycode, DemanglerPrinter &out) {
7585
std::string punycodeBuf;
@@ -99,15 +109,7 @@ static void mangleIdentifier(StringRef ident, OperatorKind operatorKind,
99109
// operator-fixity ::= 'i' // infix
100110
// where the count is the number of characters in the operator,
101111
// and where the individual operator characters are translated.
102-
out << 'o' << [=] {
103-
switch (operatorKind) {
104-
case OperatorKind::NotOperator: unreachable("invalid");
105-
case OperatorKind::Infix: return 'i';
106-
case OperatorKind::Prefix: return 'p';
107-
case OperatorKind::Postfix: return 'P';
108-
}
109-
unreachable("invalid");
110-
}();
112+
out << 'o' << mangleOperatorKind(operatorKind);
111113

112114
// Mangle ASCII operators directly.
113115
out << ident.size();

0 commit comments

Comments
 (0)