diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index a96f1680db77..17af2fa5f252 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -227,8 +227,8 @@ unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline, State.NextToken->WhitespaceRange.getEnd()) - SourceMgr.getSpellingColumnNumber( State.NextToken->WhitespaceRange.getBegin()); - State.Column += WhitespaceLength + State.NextToken->ColumnWidth; - State.NextToken = State.NextToken->Next; + State.Column += WhitespaceLength; + moveStateToNextToken(State, DryRun, /*NewLine=*/false); return 0; } @@ -349,7 +349,6 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, Penalty += State.NextToken->SplitPenalty; - // Breaking before the first "<<" is generally not desirable if the LHS is // short. Also always add the penalty if the LHS is split over mutliple lines // to avoid unncessary line breaks that just work around this penalty. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 78aa3ce7c8a4..44e8bf849d38 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2024,6 +2024,10 @@ TEST_F(FormatTest, DoesntRemoveUnknownTokens) { verifyFormat("#define A ''qqq"); verifyFormat("#define A `qqq"); verifyFormat("f(\"aaaa, bbbb, \"\\\"ccccc\\\"\");"); + EXPECT_EQ("const char *c = STRINGIFY(\n" + "\\na : b);", + format("const char * c = STRINGIFY(\n" + "\\na : b);")); } TEST_F(FormatTest, IndentsPPDirectiveInReducedSpace) {