[clang-format] Wrap inserted braces only if preceded by comments
Fixes #57805. Differential Revision: https://reviews.llvm.org/D134233
This commit is contained in:
@@ -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, '}');
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user