Skip to content

Commit

Permalink
[clang-format] Refactor ShouldBreakBeforeBrace to use switch. NFC.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkurdej committed Mar 18, 2022
1 parent f47e7e4 commit c59c2b6
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions clang/lib/Format/UnwrappedLineParser.cpp
Expand Up @@ -897,17 +897,24 @@ static bool isIIFE(const UnwrappedLine &Line,

static bool ShouldBreakBeforeBrace(const FormatStyle &Style,
const FormatToken &InitialToken) {
if (InitialToken.isOneOf(tok::kw_namespace, TT_NamespaceMacro))
tok::TokenKind Kind = InitialToken.Tok.getKind();
if (InitialToken.is(TT_NamespaceMacro))
Kind = tok::kw_namespace;

switch (Kind) {
case tok::kw_namespace:
return Style.BraceWrapping.AfterNamespace;
if (InitialToken.is(tok::kw_class))
case tok::kw_class:
return Style.BraceWrapping.AfterClass;
if (InitialToken.is(tok::kw_union))
case tok::kw_union:
return Style.BraceWrapping.AfterUnion;
if (InitialToken.is(tok::kw_struct))
case tok::kw_struct:
return Style.BraceWrapping.AfterStruct;
if (InitialToken.is(tok::kw_enum))
case tok::kw_enum:
return Style.BraceWrapping.AfterEnum;
return false;
default:
return false;
}
}

void UnwrappedLineParser::parseChildBlock(
Expand Down

0 comments on commit c59c2b6

Please sign in to comment.