diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -575,7 +575,7 @@ if (!Changes[j].IsInsideToken) LineLengthAfter += Changes[j].TokenLength; } - unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter; + int ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter; // If we are restricted by the maximum column width, end the sequence. if (ChangeMinColumn > MaxColumn || ChangeMaxColumn < MinColumn || diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -16847,9 +16847,11 @@ "double b();", Alignment); unsigned OldColumnLimit = Alignment.ColumnLimit; - // We need to set ColumnLimit to zero, in order to stress nested alignments, - // otherwise the function parameters will be re-flowed onto a single line. - Alignment.ColumnLimit = 0; + // We need to set ColumnLimit to a small number, in order to stress + // nested alignments, otherwise the function parameters will be + // re-flowed onto a single line. It also needs to be wide enough so + // that things still get aligned. + Alignment.ColumnLimit = 20; EXPECT_EQ("int a(int x,\n" " float y);\n" "double b(int x,\n"