[PATCH] D126052: [clang-format] Handle "complex" conditionals in RemoveBracesLLVM

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 20 02:25:26 PDT 2022


owenpan created this revision.
owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Do not remove braces if the conditional of if/for/while might not fit on a single line even after the opening brace is removed.

Examples:

  // ColumnLimit: 20
  // 45678901234567890
  if (a) { /* Remove. */
    foo();
  }
  if (-b >= c) { // Keep.
    bar();
  }

This is the last feature/exception of `RemoveBracesLLVM`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126052

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D126052.430918.patch
Type: text/x-patch
Size: 9595 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220520/c00ed5e8/attachment.bin>


More information about the cfe-commits mailing list