diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1871,7 +1871,7 @@ 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, '}'); } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -25388,6 +25388,12 @@ "} while (0);", Style); + Style.RemoveBracesLLVM = true; + verifyFormat("if (a) //\n" + " return b;", + Style); + Style.RemoveBracesLLVM = false; + Style.ColumnLimit = 15; verifyFormat("#define A \\\n"