From: Daniel Jasper Date: Tue, 1 Nov 2016 06:23:19 +0000 (+0000) Subject: clang-format: Fix bug in function reference qualifier detection. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e54c81e47a71edfea335aaed26d52fed2c957c50;p=clang clang-format: Fix bug in function reference qualifier detection. Before: template void F(T) && = delete; After: template void F(T) && = delete; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285674 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index d010efab3e..0b6e71d3d9 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/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/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 6ab4a74629..5c70b8c12b 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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);");