[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

Galen Elias via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 6 09:56:08 PDT 2023


galenelias marked an inline comment as done.
galenelias added a comment.

In D151761#4394758 <https://reviews.llvm.org/D151761#4394758>, @MyDeveloperDay wrote:

> did you consider a case where the case falls through? (i.e. no return)
>
>   "case log::info :    return \"info\";\n"
>   "case log::warning :\n"
>   "default :           return \"default\";\n"

That's a great point.  I didn't really consider this, and currently this particular case won't align the case statements if they have an empty case block, however if you had some tokens (e.g. `// fallthrough`) it would.  It's not immediately clear to me what the expectation would be.  I guess to align as if there was an invisible trailing token, but it's a bit awkward if the cases missing a body are the 'long' cases that push out the alignment.  Also, I don't think it's possible to use `AlignTokens` and get this behavior, as there is no token on those lines to align, so it's not straightforward to handle.  I guess I'll be curious to see if there is feedback or cases where this behavior is desired, and if so, I can look into adding that functionality later.  Since right now it would involve a completely custom AlignTokens clone, my preference would be to just leave this as not supported.


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

https://reviews.llvm.org/D151761



More information about the cfe-commits mailing list