]> granicus.if.org Git - clang/commitdiff
clang-format: Better support for CUDA's triple brackets.
authorDaniel Jasper <djasper@google.com>
Sat, 5 Nov 2016 17:43:16 +0000 (17:43 +0000)
committerDaniel Jasper <djasper@google.com>
Sat, 5 Nov 2016 17:43:16 +0000 (17:43 +0000)
Before:
  aaaaaaaaaaaaaaa<
      aaaaaaaaaaaaaaaaaaa,
      aaaaaaaaaaaaaa><<<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>>>();

After:
  aaaaaaaaaaaaaaa<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>
      <<<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>>>();

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@286041 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index 0b6e71d3d9a81071cc9e2bc99277efe186aee66c..cba9a03b3e0d400025dfd0796e2a244fd295de90 100644 (file)
@@ -2488,6 +2488,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
     return true;
   if (Right.is(TT_RangeBasedForLoopColon))
     return false;
+  if (Left.is(TT_TemplateCloser) && Right.is(TT_TemplateOpener))
+    return true;
   if (Left.isOneOf(TT_TemplateCloser, TT_UnaryOperator) ||
       Left.is(tok::kw_operator))
     return false;
index 7ba93a7f9e04a0faa6422181fa4ef724ca1e1394..f526d458437904218df28c71b524c793d4d2da9f 100644 (file)
@@ -11391,6 +11391,8 @@ TEST_F(FormatTest, TripleAngleBrackets) {
   EXPECT_EQ("f<param><<<1, 1>>>();", format("f< param > <<< 1, 1 >>> ();"));
   verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
                "aaaaaaaaaaa<<<\n    1, 1>>>();");
+  verifyFormat("aaaaaaaaaaaaaaa<aaaaaaaaa, aaaaaaaaaa, aaaaaaaaaaaaaa>\n"
+               "    <<<aaaaaaaaa, aaaaaaaaaa, aaaaaaaaaaaaaaaaaa>>>();");
 }
 
 TEST_F(FormatTest, MergeLessLessAtEnd) {