From 28b4d5133c1161868d63644e73ddeb78fc361f48 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 1 Nov 2016 06:23:19 +0000 Subject: [PATCH] clang-format: Fix bug in function reference qualifier detection. Before: template void F(T) && = delete; After: template void F(T) && = delete; llvm-svn: 285674 --- clang/lib/Format/TokenAnnotator.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index d010efa..0b6e71d 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1251,7 +1251,7 @@ private: const FormatToken *NextToken = Tok.getNextNonComment(); if (!NextToken || - NextToken->isOneOf(tok::arrow, Keywords.kw_final, + NextToken->isOneOf(tok::arrow, Keywords.kw_final, tok::equal, Keywords.kw_override) || (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment())) return TT_PointerOrReference; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 6ab4a74..5c70b8c 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5637,6 +5637,9 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) { verifyFormat("SomeType MemberFunction(const Deleted &) && final {}"); verifyFormat("SomeType MemberFunction(const Deleted &) && override {}"); verifyFormat("SomeType MemberFunction(const Deleted &) const &;"); + verifyFormat("template \n" + "void F(T) && = delete;", + getGoogleStyle()); FormatStyle AlignLeft = getLLVMStyle(); AlignLeft.PointerAlignment = FormatStyle::PAS_Left; @@ -5789,7 +5792,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { FormatStyle Left = getLLVMStyle(); Left.PointerAlignment = FormatStyle::PAS_Left; verifyFormat("x = *a(x) = *a(y);", Left); - verifyFormat("for (;; * = b) {\n}", Left); + verifyFormat("for (;; *a = b) {\n}", Left); verifyFormat("return *this += 1;", Left); verifyIndependentOfContext("a = *(x + y);"); -- 2.7.4