clang-format: Fix bug in function reference qualifier detection.
authorDaniel Jasper <djasper@google.com>
Tue, 1 Nov 2016 06:23:19 +0000 (06:23 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 1 Nov 2016 06:23:19 +0000 (06:23 +0000)
Before:
  template <typename T>
      void F(T) &&
      = delete;

After:
  template <typename T>
  void F(T) && = delete;

llvm-svn: 285674

clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

index d010efa..0b6e71d 100644 (file)
@@ -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;
index 6ab4a74..5c70b8c 100644 (file)
@@ -5637,6 +5637,9 @@ TEST_F(FormatTest, UnderstandsFunctionRefQualification) {
   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, UnderstandsUsesOfStarAndAmp) {
   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);");