Index: clang/lib/Format/UnwrappedLineFormatter.cpp =================================================================== --- clang/lib/Format/UnwrappedLineFormatter.cpp +++ clang/lib/Format/UnwrappedLineFormatter.cpp @@ -643,6 +643,7 @@ unsigned Length = 0; bool EndsWithComment = false; bool InPPDirective = I[0]->InPPDirective; + bool InMacroBody = I[0]->InMacroBody; const unsigned Level = I[0]->Level; for (; NumStmts < 3; ++NumStmts) { if (I + 1 + NumStmts == E) @@ -650,6 +651,8 @@ const AnnotatedLine *Line = I[1 + NumStmts]; if (Line->InPPDirective != InPPDirective) break; + if(Line->InMacroBody != InMacroBody) + break; if (Line->First->isOneOf(tok::kw_case, tok::kw_default, tok::r_brace)) break; if (Line->First->isOneOf(tok::kw_if, tok::kw_for, tok::kw_switch, Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -2999,6 +2999,10 @@ "}", Style); Style.ColumnLimit = 21; + verifyFormat("#define X \\\n" + " case 0: break;\n" + "#include \"f\"", + Style); verifyFormat("switch (a) {\n" "case 1: x = 1; break;\n" "case 2: return;\n"