diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index ddbee15cb159f..a099813c9100b 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -740,7 +740,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState &State, bool DryRun, if (!DryRun) { Whitespaces.replaceWhitespace(Current, /*Newlines=*/0, Spaces, - State.Column + Spaces + PPColumnCorrection); + State.Column + Spaces + PPColumnCorrection, + /*IsAligned=*/false, State.Line->InMacroBody); } // If "BreakBeforeInheritanceComma" mode, don't break within the inheritance diff --git a/clang/lib/Format/WhitespaceManager.h b/clang/lib/Format/WhitespaceManager.h index dc6f60e5deeed..8ac73305871ae 100644 --- a/clang/lib/Format/WhitespaceManager.h +++ b/clang/lib/Format/WhitespaceManager.h @@ -55,7 +55,7 @@ class WhitespaceManager { /// this replacement. It is needed for determining how \p Spaces is turned /// into tabs and spaces for some format styles. void replaceWhitespace(FormatToken &Tok, unsigned Newlines, unsigned Spaces, - unsigned StartOfTokenColumn, bool isAligned = false, + unsigned StartOfTokenColumn, bool IsAligned = false, bool InPPDirective = false); /// Adds information about an unchangeable token's whitespace. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index a0825dc2ad4ef..fa3bea5ae5d75 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -21215,6 +21215,13 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresLeftAlignment) { "});", Style); + Style.AlignEscapedNewlines = FormatStyle::ENAS_DontAlign; + verifyFormat("#define FOO \\\n" + " int foo[][2] = { \\\n" + " {0, 1} \\\n" + " };", + Style); + Style.Cpp11BracedListStyle = false; verifyFormat("struct test demo[] = {\n" " { 56, 23, \"hello\" },\n"