[PATCH] D106349: [clang-format] respect AfterEnum for enums

Luna Kirkby via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 31 08:42:16 PDT 2021


lunasorcery added a comment.

Copying over the comment I left on D99840 <https://reviews.llvm.org/D99840> explaining it - my existing change only works because it gets bailed out by further code in TokenAnnotator.cpp.
I think your change still is valuable since it's more correct.

> 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 [D99840 <https://reviews.llvm.org/D99840>] _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.




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

https://reviews.llvm.org/D106349



More information about the cfe-commits mailing list