From f0c809a19bf4efadcb1efaf76325e14d745020f9 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 28 Oct 2014 18:28:22 +0000 Subject: [PATCH] clang-format: Improve && detection as binary operator. Before: template {}&& ::std::is_array{}>::type> void F(); After: template {} && ::std::is_array{}>::type> void F(); llvm-svn: 220813 --- clang/lib/Format/TokenAnnotator.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 14d164e..f0ffdb6 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index f541cc0..e7c9402 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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);"); -- 2.7.4