[clang-format] Wrap inserted braces only if preceded by comments

Fixes #57805.

Differential Revision: https://reviews.llvm.org/D134233
This commit is contained in:
owenca committed 2022-09-20 12:09:39 -07:00
1 parent 68cc35d52c
commit 6257832bf9
2 files changed
+7 -1

No files matched your search

+1 -1
View File
@@ -1871,7 +1871,7 @@ private:
std::string Brace;
if (Token->BraceCount < 0) {
assert(Token->BraceCount == -1);
Brace = "\n{";
Brace = Token->is(tok::comment) ? "\n{" : "{";
} else {
Brace = '\n' + std::string(Token->BraceCount, '}');
}
+6
View File
@@ -25388,6 +25388,12 @@ TEST_F(FormatTest, InsertBraces) {
"} while (0);",
Style);
Style.RemoveBracesLLVM = true;
verifyFormat("if (a) //\n"
" return b;",
Style);
Style.RemoveBracesLLVM = false;
Style.ColumnLimit = 15;
verifyFormat("#define A \\\n"