diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index 8563312b45bb..673af51d2daa 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -432,6 +432,7 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End, --Previous) { Changes[Previous + 1].Spaces -= Shift; Changes[Previous].Spaces += Shift; + Changes[Previous].StartOfTokenColumn += Shift; } } } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e4fea9085b57..44da34001f99 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -14161,6 +14161,21 @@ TEST_F(FormatTest, ConfigurableUseOfTab) { "int bbbbbbbb; // x\n", Tab); + FormatStyle TabAlignment = Tab; + TabAlignment.AlignConsecutiveDeclarations.Enabled = true; + TabAlignment.PointerAlignment = FormatStyle::PAS_Left; + verifyFormat("unsigned long long big;\n" + "char*\t\t ptr;", + TabAlignment); + TabAlignment.PointerAlignment = FormatStyle::PAS_Middle; + verifyFormat("unsigned long long big;\n" + "char *\t\t ptr;", + TabAlignment); + TabAlignment.PointerAlignment = FormatStyle::PAS_Right; + verifyFormat("unsigned long long big;\n" + "char\t\t *ptr;", + TabAlignment); + Tab.TabWidth = 4; Tab.IndentWidth = 8; verifyFormat("class TabWidth4Indent8 {\n" @@ -14203,6 +14218,26 @@ TEST_F(FormatTest, ConfigurableUseOfTab) { " \t */", Tab)); + TabAlignment.UseTab = FormatStyle::UT_ForIndentation; + TabAlignment.PointerAlignment = FormatStyle::PAS_Left; + verifyFormat("void f() {\n" + "\tunsigned long long big;\n" + "\tchar* ptr;\n" + "}", + TabAlignment); + TabAlignment.PointerAlignment = FormatStyle::PAS_Middle; + verifyFormat("void f() {\n" + "\tunsigned long long big;\n" + "\tchar * ptr;\n" + "}", + TabAlignment); + TabAlignment.PointerAlignment = FormatStyle::PAS_Right; + verifyFormat("void f() {\n" + "\tunsigned long long big;\n" + "\tchar *ptr;\n" + "}", + TabAlignment); + Tab.UseTab = FormatStyle::UT_ForIndentation; verifyFormat("{\n" "\taaaaaaaaaaaaaaaaaaaaaaaaaaaa();\n"