@@ -123,16 +123,15 @@ ArrayRef<FormatToken *> FormatTokenLexer::lex() {
123123 if (Style.isJavaScript ()) {
124124 tryParseJSRegexLiteral ();
125125 handleTemplateStrings ();
126- }
127- if (Style.isTextProto ())
126+ } else if (Style.isTextProto ()) {
128127 tryParsePythonComment ();
128+ }
129129 tryMergePreviousTokens ();
130130 if (Style.isCSharp ()) {
131131 // This needs to come after tokens have been merged so that C#
132132 // string literals are correctly identified.
133133 handleCSharpVerbatimAndInterpolatedStrings ();
134- }
135- if (Style.isTableGen ()) {
134+ } else if (Style.isTableGen ()) {
136135 handleTableGenMultilineString ();
137136 handleTableGenNumericLikeIdentifier ();
138137 }
@@ -190,23 +189,23 @@ void FormatTokenLexer::tryMergePreviousTokens() {
190189 }
191190 if (tryMergeNullishCoalescingEqual ())
192191 return ;
193- }
194-
195- if (Style.isCSharp ()) {
196- static const tok::TokenKind CSharpNullConditionalLSquare[] = {
197- tok::question, tok::l_square};
198192
199- if (tryMergeCSharpKeywordVariables ())
200- return ;
201- if (tryMergeCSharpStringLiteral ())
202- return ;
203- if (tryTransformCSharpForEach ())
204- return ;
205- if (tryMergeTokens (CSharpNullConditionalLSquare,
206- TT_CSharpNullConditionalLSquare)) {
207- // Treat like a regular "[" operator.
208- Tokens.back ()->Tok .setKind (tok::l_square);
209- return ;
193+ if (Style.isCSharp ()) {
194+ static const tok::TokenKind CSharpNullConditionalLSquare[] = {
195+ tok::question, tok::l_square};
196+
197+ if (tryMergeCSharpKeywordVariables ())
198+ return ;
199+ if (tryMergeCSharpStringLiteral ())
200+ return ;
201+ if (tryTransformCSharpForEach ())
202+ return ;
203+ if (tryMergeTokens (CSharpNullConditionalLSquare,
204+ TT_CSharpNullConditionalLSquare)) {
205+ // Treat like a regular "[" operator.
206+ Tokens.back ()->Tok .setKind (tok::l_square);
207+ return ;
208+ }
210209 }
211210 }
212211
@@ -246,16 +245,12 @@ void FormatTokenLexer::tryMergePreviousTokens() {
246245 }
247246 if (tryMergeJSPrivateIdentifier ())
248247 return ;
249- }
250-
251- if (Style.isJava ()) {
248+ } else if (Style.isJava ()) {
252249 static const tok::TokenKind JavaRightLogicalShiftAssign[] = {
253250 tok::greater, tok::greater, tok::greaterequal};
254251 if (tryMergeTokens (JavaRightLogicalShiftAssign, TT_BinaryOperator))
255252 return ;
256- }
257-
258- if (Style.isVerilog ()) {
253+ } else if (Style.isVerilog ()) {
259254 // Merge the number following a base like `'h?a0`.
260255 if (Tokens.size () >= 3 && Tokens.end ()[-3 ]->is (TT_VerilogNumberBase) &&
261256 Tokens.end ()[-2 ]->is (tok::numeric_constant) &&
@@ -327,8 +322,7 @@ void FormatTokenLexer::tryMergePreviousTokens() {
327322 Tokens.back ()->ForcedPrecedence = prec::Comma;
328323 return ;
329324 }
330- }
331- if (Style.isTableGen ()) {
325+ } else if (Style.isTableGen ()) {
332326 // TableGen's Multi line string starts with [{
333327 if (tryMergeTokens ({tok::l_square, tok::l_brace},
334328 TT_TableGenMultiLineString)) {
@@ -843,10 +837,7 @@ void FormatTokenLexer::handleCSharpVerbatimAndInterpolatedStrings() {
843837
844838 const char *StrBegin = Lex->getBufferLocation () - TokenText.size ();
845839 const char *Offset = StrBegin;
846- if (Verbatim && Interpolated)
847- Offset += 3 ;
848- else
849- Offset += 2 ;
840+ Offset += Verbatim && Interpolated ? 3 : 2 ;
850841
851842 const auto End = Lex->getBuffer ().end ();
852843 Offset = lexCSharpString (Offset, End, Verbatim, Interpolated);
@@ -1377,13 +1368,9 @@ FormatToken *FormatTokenLexer::getNextToken() {
13771368 } else if (Style.isTableGen () && !Keywords.isTableGenKeyword (*FormatTok)) {
13781369 FormatTok->Tok .setKind (tok::identifier);
13791370 }
1380- } else if (FormatTok->is (tok::greatergreater)) {
1381- FormatTok->Tok .setKind (tok::greater);
1382- FormatTok->TokenText = FormatTok->TokenText .substr (0 , 1 );
1383- ++Column;
1384- StateStack.push (LexerState::TOKEN_STASHED);
1385- } else if (FormatTok->is (tok::lessless)) {
1386- FormatTok->Tok .setKind (tok::less);
1371+ } else if (const bool Greater = FormatTok->is (tok::greatergreater);
1372+ Greater || FormatTok->is (tok::lessless)) {
1373+ FormatTok->Tok .setKind (Greater ? tok::greater : tok::less);
13871374 FormatTok->TokenText = FormatTok->TokenText .substr (0 , 1 );
13881375 ++Column;
13891376 StateStack.push (LexerState::TOKEN_STASHED);
0 commit comments