r285674 - clang-format: Fix bug in function reference qualifier detection.
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 31 23:23:19 PDT 2016
Author: djasper
Date: Tue Nov 1 01:23:19 2016
New Revision: 285674
URL: http://llvm.org/viewvc/llvm-project?rev=285674&view=rev
Log:
clang-format: Fix bug in function reference qualifier detection.
Before:
template <typename T>
void F(T) &&
= delete;
After:
template <typename T>
void F(T) && = delete;
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=285674&r1=285673&r2=285674&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Nov 1 01:23:19 2016
@@ -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;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=285674&r1=285673&r2=285674&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Nov 1 01:23:19 2016
@@ -5637,6 +5637,9 @@ TEST_F(FormatTest, UnderstandsFunctionRe
verifyFormat("SomeType MemberFunction(const Deleted &) && final {}");
verifyFormat("SomeType MemberFunction(const Deleted &) && override {}");
verifyFormat("SomeType MemberFunction(const Deleted &) const &;");
+ verifyFormat("template <typename T>\n"
+ "void F(T) && = delete;",
+ getGoogleStyle());
FormatStyle AlignLeft = getLLVMStyle();
AlignLeft.PointerAlignment = FormatStyle::PAS_Left;
@@ -5789,7 +5792,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStar
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);");
More information about the cfe-commits
mailing list