6 Commits

Author SHA1 Message Date
Owen Pan
51f1681424
[clang-format] Don't merge a short block for SBS_Never (#88238)
Also fix unit tests.

Fixes #87484.
2024-04-10 19:06:29 -07:00
Manuel Klimek
f8d10d5ac9 [clang-format][NFC] Refactor formatting unit tests.
Pull out common base class for formatting unit tests, removing duplicate
code that accumulated over the years.

Pull out macro expansion test into its own test file.
2023-03-01 12:36:07 +00:00
Owen Pan
5751c439be [clang-format] Improve UnwrappedLineParser::mightFitOnOneLine()
Account for an r_brace that precedes an "else if" statement when
calculating whether the line might fit on one line if the r_brace
is removed.

Fixes #59778.

Differential Revision: https://reviews.llvm.org/D140835
2023-01-05 13:23:23 -08:00
Owen Pan
91b5d508e3 Revert "[clang-format] Link the braces of a block in UnwrappedLineParser"
This reverts commit e33243c950ac40d027ad8facbf7ccf0624604a16 but
keeps the added test case and also adds another test case.

Fixes #59417.

Differential Revision: https://reviews.llvm.org/D139760
2022-12-10 02:31:53 -08:00
Owen Pan
e33243c950 [clang-format] Link the braces of a block in UnwrappedLineParser
This includes TT_MacroBlockBegin and TT_MacroBlockEnd as well.

We can no longer use MatchingParen of FormatToken as an indicator
to mark optional braces. Instead, we directly set Optional of an
l_brace first and reset it later if it turns out that the braces
are not optional.

Also added a test case for deeply nested loops.

Differential Revision: https://reviews.llvm.org/D139257
2022-12-04 12:01:26 -08:00
owenca
30ea3fcc4c [clang-format][NFC] Move BracesRemover tests out of FormatTest.cpp
Differential Revision: https://reviews.llvm.org/D136830
2022-10-28 23:44:41 -07:00