[PATCH] D93938: [clang-format] Fixed AfterEnum handling

Marcus Johnson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 17 19:53:46 PST 2021


MarcusJohnson91 added a comment.

Not trying to take over this patch, because I've got a ton of patches I need to be finishing up myself.

but I think the problematic code is in UnwrappedLineParser.cpp:1900

  if (FormatTok->Tok.getKind() == ClosingBraceKind) {
    if (IsEnum && !Style.AllowShortEnumsOnASingleLine)
      addUnwrappedLine();
    nextToken();
    return !HasError;
  }

I'd change that if statement to

  if (FormatTok->Tok.getKind() == ClosingBraceKind) {
    if (IsEnum && (!Style.AllowShortEnumsOnASingleLine || !BraceWrapping.AfterEnum))
        addUnwrappedLine();
    nextToken();
    return !HasError;
  }

I haven't tried this code at all, just a gut feeling based on my experience fixing the extern block wrapping; hopefully it helps point you in the right direction.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93938/new/

https://reviews.llvm.org/D93938



More information about the cfe-commits mailing list