Skip to content

Commit c59c2b6

Browse files
committed
[clang-format] Refactor ShouldBreakBeforeBrace to use switch. NFC.
1 parent f47e7e4 commit c59c2b6

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -897,17 +897,24 @@ static bool isIIFE(const UnwrappedLine &Line,
897897

898898
static bool ShouldBreakBeforeBrace(const FormatStyle &Style,
899899
const FormatToken &InitialToken) {
900-
if (InitialToken.isOneOf(tok::kw_namespace, TT_NamespaceMacro))
900+
tok::TokenKind Kind = InitialToken.Tok.getKind();
901+
if (InitialToken.is(TT_NamespaceMacro))
902+
Kind = tok::kw_namespace;
903+
904+
switch (Kind) {
905+
case tok::kw_namespace:
901906
return Style.BraceWrapping.AfterNamespace;
902-
if (InitialToken.is(tok::kw_class))
907+
case tok::kw_class:
903908
return Style.BraceWrapping.AfterClass;
904-
if (InitialToken.is(tok::kw_union))
909+
case tok::kw_union:
905910
return Style.BraceWrapping.AfterUnion;
906-
if (InitialToken.is(tok::kw_struct))
911+
case tok::kw_struct:
907912
return Style.BraceWrapping.AfterStruct;
908-
if (InitialToken.is(tok::kw_enum))
913+
case tok::kw_enum:
909914
return Style.BraceWrapping.AfterEnum;
910-
return false;
915+
default:
916+
return false;
917+
}
911918
}
912919

913920
void UnwrappedLineParser::parseChildBlock(

0 commit comments

Comments
 (0)