[all-commits] [llvm/llvm-project] cc77e3: [clang-format] Don't apply severe penalty if no po...

James Grant via All-commits all-commits at lists.llvm.org
Wed Jan 10 19:32:27 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cc77e33271371e6ea29569ba06db9cfd1aac022a
      https://github.com/llvm/llvm-project/commit/cc77e33271371e6ea29569ba06db9cfd1aac022a
  Author: James Grant <42079499+jamesg-nz at users.noreply.github.com>
  Date:   2024-01-10 (Wed, 10 Jan 2024)

  Changed paths:
    M clang/lib/Format/FormatToken.cpp
    M clang/unittests/Format/FormatTest.cpp

  Log Message:
  -----------
  [clang-format] Don't apply severe penalty if no possible column formats (#76675)

If there are possible column formats, but they weren't selected because
they don't fit within remaining characters for the current path then
applying severe penalty to induce column layout by selection of a
different path seems fair.

But if due to style configuration or what the input code is, there are
no possible column formats, different paths aren't going to have column
layouts. Seems wrong to apply the severe penalty to induce column
layouts if there are none available.

It just causes selection of sub-optimal paths, e.g. get bad formatting
when brace initializers are used inside lambda bodies.

Fixes #56350




More information about the All-commits mailing list