]> granicus.if.org Git - clang/commitdiff
clang-format: Fix incorrect cast detection.
authorDaniel Jasper <djasper@google.com>
Mon, 13 Jun 2016 07:49:09 +0000 (07:49 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 13 Jun 2016 07:49:09 +0000 (07:49 +0000)
Before:
  auto s = sizeof...(Ts)-1;

After:
  auto s = sizeof...(Ts) - 1;

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

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

index 13bda71127ffc56caf509033fee58d0e32ec42f0..1f1a32a2b2cc90dac3026b8a80cf16c5778d7e12 100644 (file)
@@ -1140,7 +1140,7 @@ private:
 
     FormatToken *LeftOfParens = Tok.MatchingParen->getPreviousNonComment();
     if (LeftOfParens) {
-      // If there is an opening parenthesis left of the current parentheses,
+      // If there is a closing parenthesis left of the current parentheses,
       // look past it as these might be chained casts.
       if (LeftOfParens->is(tok::r_paren)) {
         if (!LeftOfParens->MatchingParen ||
@@ -1159,7 +1159,7 @@ private:
       // Certain other tokens right before the parentheses are also signals that
       // this cannot be a cast.
       if (LeftOfParens->isOneOf(tok::at, tok::r_square, TT_OverloadedOperator,
-                                TT_TemplateCloser))
+                                TT_TemplateCloser, tok::ellipsis))
         return false;
     }
 
index d27da34d3406e61c081db3b9c599e5a054f1d790..7e3b4ce3571712f3b6e057bdd5ce51f34dc1bbfb 100644 (file)
@@ -5494,6 +5494,7 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
 
 TEST_F(FormatTest, UnderstandsBinaryOperators) {
   verifyFormat("COMPARE(a, ==, b);");
+  verifyFormat("auto s = sizeof...(Ts) - 1;");
 }
 
 TEST_F(FormatTest, UnderstandsPointersToMembers) {