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

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 8 01:23:47 PDT 2016


Author: djasper
Date: Wed Jun  8 03:23:46 2016
New Revision: 272124

URL: http://llvm.org/viewvc/llvm-project?rev=272124&view=rev
Log:
clang-format: Fix bug in function ref qualifier identification.

.. and simplify it.

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

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

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=272124&r1=272123&r2=272124&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Wed Jun  8 03:23:46 2016
@@ -1989,10 +1989,7 @@ bool TokenAnnotator::spaceRequiredBetwee
   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 ||

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=272124&r1=272123&r2=272124&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jun  8 03:23:46 2016
@@ -5629,6 +5629,7 @@ TEST_F(FormatTest, UnderstandsFunctionRe
 
   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);




More information about the cfe-commits mailing list