File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1808,7 +1808,8 @@ class BracesRemover : public TokenAnalyzer {
18081808 removeBraces (Line->Children , Result);
18091809 if (!Line->Affected )
18101810 continue ;
1811- for (FormatToken *Token = Line->First ; Token; Token = Token->Next ) {
1811+ for (FormatToken *Token = Line->First ; Token && !Token->Finalized ;
1812+ Token = Token->Next ) {
18121813 if (!Token->Optional )
18131814 continue ;
18141815 assert (Token->isOneOf (tok::l_brace, tok::r_brace));
Original file line number Diff line number Diff line change @@ -24805,6 +24805,19 @@ TEST_F(FormatTest, RemoveBraces) {
2480524805 "}",
2480624806 Style);
2480724807
24808+ verifyFormat("// clang-format off\n"
24809+ "// comment\n"
24810+ "while (i > 0) { --i; }\n"
24811+ "// clang-format on\n"
24812+ "while (j < 0)\n"
24813+ " ++j;",
24814+ "// clang-format off\n"
24815+ "// comment\n"
24816+ "while (i > 0) { --i; }\n"
24817+ "// clang-format on\n"
24818+ "while (j < 0) { ++j; }",
24819+ Style);
24820+
2480824821 verifyFormat("if (a)\n"
2480924822 " b; // comment\n"
2481024823 "else if (c)\n"
You can’t perform that action at this time.
0 commit comments