[PATCH] D158945: [clang-format] Handle Template Arguments with AlignConsecutiveXX

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 26 15:49:42 PDT 2023


HazardyKnusperkeks created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, owenpan, MyDeveloperDay.
HazardyKnusperkeks requested review of this revision.

This fixes https://github.com/llvm/llvm-project/issues/64928.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158945

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
@@ -18726,6 +18726,13 @@
                "                    {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) {
Index: clang/lib/Format/WhitespaceManager.cpp
===================================================================
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -425,6 +425,10 @@
           return true;
         }
 
+        // Continued template parameter.
+        if (Changes[ScopeStart - 1].Tok->is(TT_TemplateOpener))
+          return true;
+
         return false;
       };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158945.553768.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230826/f07f0ed1/attachment.bin>


More information about the cfe-commits mailing list