[clang-format] Never remove braces in macro definitions

Fixes #56559.

Differential Revision: https://reviews.llvm.org/D129921
This commit is contained in:
owenca 2022-07-15 23:17:42 -07:00
parent 2b2e858e9c
commit a0458d92e9
2 changed files with 8 additions and 1 deletions

View File

@ -539,7 +539,7 @@ bool UnwrappedLineParser::parseLevel(const FormatToken *OpeningBrace,
break;
case tok::r_brace:
if (OpeningBrace) {
if (!Style.RemoveBracesLLVM ||
if (!Style.RemoveBracesLLVM || Line->InPPDirective ||
!OpeningBrace->isOneOf(TT_ControlStatementLBrace, TT_ElseLBrace)) {
return false;
}

View File

@ -25803,6 +25803,13 @@ TEST_F(FormatTest, RemoveBraces) {
Style.ColumnLimit = 20;
verifyFormat("int i;\n"
"#define FOO(a, b) \\\n"
" while (a) { \\\n"
" b; \\\n"
" }",
Style);
verifyFormat("int ab = [](int i) {\n"
" if (i > 0) {\n"
" i = 12345678 -\n"