clang-format: Fix bug in function ref qualifier identification.

.. and simplify it.

Before:
  void A::f()&& {}
  void f() && {}

After:
  void A::f() && {}
  void f() && {}

llvm-svn: 272124
This commit is contained in:
Daniel Jasper 2016-06-08 08:23:46 +00:00
parent c4ae8537cf
commit 2b4d6eae39
2 changed files with 2 additions and 4 deletions

View File

@ -1989,10 +1989,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
if (Left.is(tok::l_square) && Right.is(tok::amp))
return false;
if (Right.is(TT_PointerOrReference))
return (Left.is(tok::r_paren) && Left.MatchingParen &&
(Left.MatchingParen->is(TT_OverloadedOperatorLParen) ||
(Left.MatchingParen->Previous &&
Left.MatchingParen->Previous->is(TT_FunctionDeclarationName)))) ||
return (Left.is(tok::r_paren) && Line.MightBeFunctionDecl) ||
(Left.Tok.isLiteral() ||
(!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
(Style.PointerAlignment != FormatStyle::PAS_Left ||

View File

@ -5629,6 +5629,7 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
FormatStyle AlignLeft = getLLVMStyle();
AlignLeft.PointerAlignment = FormatStyle::PAS_Left;
verifyFormat("void A::b() && {}", AlignLeft);
verifyFormat("Deleted& operator=(const Deleted&) & = default;", AlignLeft);
verifyFormat("SomeType MemberFunction(const Deleted&) & = delete;",
AlignLeft);