From: Daniel Jasper Date: Mon, 13 Jun 2016 07:49:09 +0000 (+0000) Subject: clang-format: Fix incorrect cast detection. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9538b3ee581105c70839e9a87baf0a9099366b67;p=clang clang-format: Fix incorrect cast detection. 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 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 13bda71127..1f1a32a2b2 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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; } diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index d27da34d34..7e3b4ce357 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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) {