diff options
author | Björn Schäpers <bjoern@hazardy.de> | 2023-08-27 00:45:25 +0200 |
---|---|---|
committer | Björn Schäpers <bjoern@hazardy.de> | 2023-08-29 21:59:44 +0200 |
commit | ca0aa533656ceb806d2744c38766f70c317f1053 (patch) | |
tree | d7b594c55d50f4e9b77a641091ebd91615076658 | |
parent | 8cf814e6bd70f67db9efd903cbf1887404360da8 (diff) | |
download | llvm-ca0aa533656ceb806d2744c38766f70c317f1053.zip llvm-ca0aa533656ceb806d2744c38766f70c317f1053.tar.gz llvm-ca0aa533656ceb806d2744c38766f70c317f1053.tar.bz2 |
[clang-format] Handle Template Arguments with AlignConsecutiveXX
This fixes https://github.com/llvm/llvm-project/issues/64928.
Differential-Revision: https://reviews.llvm.org/D158945
-rw-r--r-- | clang/lib/Format/WhitespaceManager.cpp | 4 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index 04048ae..6951c2a 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -425,6 +425,10 @@ AlignTokenSequence(const FormatStyle &Style, unsigned Start, unsigned End, return true; } + // Continued template parameter. + if (Changes[ScopeStart - 1].Tok->is(TT_TemplateOpener)) + return true; + return false; }; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index c1368c9..0d8bc41 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -18726,6 +18726,13 @@ TEST_F(FormatTest, AlignConsecutiveAssignments) { " {a_longer_name_for_wrap,\n" " a_longer_name_for_wrap}};", Alignment); + + Alignment.ColumnLimit = 60; + verifyFormat("using II = typename TI<T, std::tuple<Types...>>::I;\n" + "using I = std::conditional_t<II::value >= 0,\n" + " std::ic<int, II::value + 1>,\n" + " std::ic<int, -1>>;", + Alignment); } TEST_F(FormatTest, AlignConsecutiveBitFields) { |