[PATCH] D99840: [clang-format] Correctly attach enum braces with ShortEnums disabled

Luna Kirkby via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 29 15:43:56 PDT 2021


lunasorcery added a comment.

Looking at this again I think the change is flawed. The `InitialToken` is taken *after* the enum token, and additionally the invocation of `ShouldBreakBeforeBrace` is falling through to the `return false;` case every time. As such the call to `addUnwrappedLine()` is _always_ skipped. This removes the newline for both the Attach and Break styles - but the Break style is then fixed up by some code in `TokenAnnotator.cpp` that I don't fully understand, which adds the newline back in.

So this change _works_, but not quite for the right reasons.

D106349 <https://reviews.llvm.org/D106349> appears to implement this in a slightly more correct manner, taking the `InitialToken` _before_ we've advanced past the enum token, and handling the enum case inside `ShouldBreakBeforeBrace`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99840



More information about the cfe-commits mailing list