[all-commits] [llvm/llvm-project] 4ef646: [clang-format]: Fix formatting of if statements wi...
Gedare Bloom via All-commits
all-commits at lists.llvm.org
Mon Jan 22 19:01:29 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4ef646eab3023b52ce8ee529d16605c92caba8ba
https://github.com/llvm/llvm-project/commit/4ef646eab3023b52ce8ee529d16605c92caba8ba
Author: Gedare Bloom <gedare at rtems.org>
Date: 2024-01-22 (Mon, 22 Jan 2024)
Changed paths:
M clang/lib/Format/ContinuationIndenter.cpp
M clang/unittests/Format/FormatTest.cpp
Log Message:
-----------
[clang-format]: Fix formatting of if statements with BlockIndent (#77699)
A bug with BlockIndent prevents line breaks within if (and else if)
clauses.
While fixing this bug, it appears that AlignAfterOpenBracket is not
designed to work with loop and if statements, but AlwaysBreak works on
if clauses. The documentation and tests are not clear on whether or not
this behavior is intended.
This PR preserves the `AlwaysBreak` behavior on `if` clauses without
supporting `BlockIndent` on `if` clauses to avoid regressions while
fixing the bug.
It may be reasonable to create an explicit option for alignment of if
(and loop) clauses intentionally for both `AlwaysBreak` and
`BlockIndent`
Fixes #54663.
Migrated from Differential Revision: https://reviews.llvm.org/D154755
See more discussion there. Addressed last open comment from the rev
about refactoring the complex conditional logic involved with the
`AlignAfterOpenBracket` line break behavior.
More information about the All-commits
mailing list