[PATCH] D127260: [clang-format] Remove braces of else blocks that embody an if block

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 7 23:45:00 PDT 2022


curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!



================
Comment at: clang/unittests/Format/FormatTest.cpp:25570-25575
+               "  else {\n"
+               "    if (d) {\n"
+               "      e;\n"
+               "      f;\n"
+               "    }\n"
+               "  }\n"
----------------
owenpan wrote:
> curdeius wrote:
> > Why isn't this block changed like this?
> > I might be missing something...
> It would cause a dangling `else` error because the last `else` would be paired with the inner merged `else if`.
True. There are indeed no braces in the outer if.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127260



More information about the cfe-commits mailing list