[PATCH] D125528: [clang-format] Fix PointerAlignment: Right not working with tab indentation.
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 16 00:42:38 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
curdeius marked an inline comment as done.
Closed by commit rGe20bc892b6fa: [clang-format] Fix PointerAlignment: Right not working with tab indentation. (authored by curdeius).
Changed prior to commit:
https://reviews.llvm.org/D125528?vs=429178&id=429629#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125528/new/
https://reviews.llvm.org/D125528
Files:
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14161,6 +14161,21 @@
"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 @@
" \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"
Index: clang/lib/Format/WhitespaceManager.cpp
===================================================================
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -432,6 +432,7 @@
--Previous) {
Changes[Previous + 1].Spaces -= Shift;
Changes[Previous].Spaces += Shift;
+ Changes[Previous].StartOfTokenColumn += Shift;
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125528.429629.patch
Type: text/x-patch
Size: 2369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220516/6f3111cf/attachment.bin>
More information about the cfe-commits
mailing list