From: Daniel Jasper Date: Tue, 28 Oct 2014 18:28:22 +0000 (+0000) Subject: clang-format: Improve && detection as binary operator. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=48f193c024213355859806d7ea1c1556587f38c9;p=clang clang-format: Improve && detection as binary operator. Before: template {}&& ::std::is_array{}>::type> void F(); After: template {} && ::std::is_array{}>::type> void F(); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220813 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 14d164e2ae..f0ffdb6d0b 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -982,7 +982,7 @@ private: if (PrevToken->Tok.isLiteral() || PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true, - tok::kw_false) || + tok::kw_false, tok::r_brace) || NextToken->Tok.isLiteral() || NextToken->isOneOf(tok::kw_true, tok::kw_false) || NextToken->isUnaryOperator() || diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index f541cc0903..e7c9402837 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5034,7 +5034,14 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { "template ::value &&\n" " (sizeof(T) > 1 || sizeof(T) < 8)>::type>\n" - "void F();", getLLVMStyleWithColumns(76)); + "void F();", + getLLVMStyleWithColumns(76)); + verifyFormat( + "template {} && ::std::is_array{}>::type>\n" + "void F();", + getGoogleStyleWithColumns(68)); verifyIndependentOfContext("MACRO(int *i);"); verifyIndependentOfContext("MACRO(auto *a);");