This is a workaround for #57539.
Fixes #57509.
Differential Revision: https://reviews.llvm.org/D133635
FormatToken *Tok = nullptr;
if (Style.InsertBraces && !Line->InPPDirective && !Line->Tokens.empty() &&
- PreprocessorDirectives.empty()) {
- assert(!Line->Tokens.empty());
+ PreprocessorDirectives.empty() && FormatTok->isNot(tok::semi)) {
Tok = Style.BraceWrapping.AfterControlStatement == FormatStyle::BWACS_Never
? getLastNonComment(*Line)
: Line->Tokens.back().Tok;
"}",
Style);
+ verifyFormat("do {\n"
+ "#if 0\n"
+ " if (a) {\n"
+ "#else\n"
+ " if (b) {\n"
+ "#endif\n"
+ "}\n"
+ "}\n"
+ "while (0)\n"
+ " ;",
+ Style);
+ // TODO: Replace the test above with the one below after #57539 is fixed.
+#if 0
+ verifyFormat("do {\n"
+ "#if 0\n"
+ " if (a) {\n"
+ "#else\n"
+ " if (b) {\n"
+ "#endif\n"
+ " }\n"
+ "} while (0);",
+ Style);
+#endif
+
Style.ColumnLimit = 15;
verifyFormat("#define A \\\n"