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 @@ -609,7 +609,8 @@ ++CommasBeforeMatch; } else if (Changes[i].indentAndNestingLevel() > IndentAndNestingLevel) { // Call AlignTokens recursively, skipping over this scope block. - unsigned StoppedAt = AlignTokens(Style, Matches, Changes, i, ACS); + unsigned StoppedAt = + AlignTokens(Style, Matches, Changes, i, ACS, RightJustify); i = StoppedAt - 1; continue; } 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 @@ -17693,6 +17693,20 @@ "dvsdsv <<= 5;\n" "int dsvvdvsdvvv = 123;", Alignment); + verifyFormat("int xxx = 5;\n" + "xxx = 5;\n" + "{\n" + " int yyy = 6;\n" + " yyy = 6;\n" + "}", + Alignment); + verifyFormat("int xxx = 5;\n" + "xxx += 5;\n" + "{\n" + " int yyy = 6;\n" + " yyy += 6;\n" + "}", + Alignment); // Test that `<=` is not treated as a compound assignment. verifyFormat("aa &= 5;\n" "b <= 10;\n"