r212041 - clang-format: Support member function reference qualifiers.

Daniel Jasper djasper at google.com
Mon Jun 30 06:54:28 PDT 2014


Author: djasper
Date: Mon Jun 30 08:54:27 2014
New Revision: 212041

URL: http://llvm.org/viewvc/llvm-project?rev=212041&view=rev
Log:
clang-format: Support member function reference qualifiers.

Before:
  string // break
      operator()() &
  {}

After:
  string // break
  operator()() & {}

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=212041&r1=212040&r2=212041&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jun 30 08:54:27 2014
@@ -903,7 +903,7 @@ private:
       return TT_UnaryOperator;
 
     const FormatToken *NextToken = Tok.getNextNonComment();
-    if (!NextToken)
+    if (!NextToken || NextToken->is(tok::l_brace))
       return TT_Unknown;
 
     if (PrevToken->is(tok::coloncolon) ||

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=212041&r1=212040&r2=212041&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jun 30 08:54:27 2014
@@ -4682,6 +4682,11 @@ TEST_F(FormatTest, UnderstandsOverloaded
   verifyFormat("Deleted &operator=(const Deleted &)&& = delete;");
   verifyGoogleFormat("Deleted& operator=(const Deleted&)& = default;");
   verifyGoogleFormat("Deleted& operator=(const Deleted&)&& = delete;");
+
+  verifyFormat("string // break\n"
+               "operator()() & {}");
+  verifyFormat("string // break\n"
+               "operator()() && {}");
 }
 
 TEST_F(FormatTest, UnderstandsNewAndDelete) {





More information about the cfe-commits mailing list