Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
clang-format: Fix bug in function ref qualifier identification.
Browse files Browse the repository at this point in the history
.. and simplify it.

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

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272124 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
djasper committed Jun 8, 2016
1 parent da34009 commit 6ae74ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/Format/TokenAnnotator.cpp
Expand Up @@ -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 ||
Expand Down
1 change: 1 addition & 0 deletions unittests/Format/FormatTest.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 6ae74ba

Please sign in to comment.