Uran198 created this revision.
Uran198 added reviewers: klimek, krasimir, djasper.

Repository:
  rC Clang

https://reviews.llvm.org/D47519

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTest.cpp


Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6156,6 +6156,12 @@
                "operator()() && {}");
   verifyGoogleFormat("template <typename T>\n"
                      "auto x() & -> int {}");
+  verifyGoogleFormat("template <typename T>\n"
+                     "auto x() const& noexcept -> bool {}");
+  verifyGoogleFormat("template <typename T>\n"
+                     "void f() &noexcept {}");
+  verifyGoogleFormat("template <typename T>\n"
+                     "auto operator+() &MACRO {}");
 }
 
 TEST_F(FormatTest, UnderstandsAttributes) {
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1563,7 +1563,7 @@
         (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
       return TT_PointerOrReference;
 
-    if (PrevToken->is(tok::coloncolon))
+    if (PrevToken->isOneOf(tok::coloncolon, tok::kw_const))
       return TT_PointerOrReference;
 
     if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
@@ -1585,7 +1585,9 @@
       FormatToken *TokenBeforeMatchingParen =
           PrevToken->MatchingParen->getPreviousNonComment();
       if (TokenBeforeMatchingParen &&
-          TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+          TokenBeforeMatchingParen->isOneOf(
+              tok::kw_typeof, tok::kw_decltype, TT_FunctionDeclarationName,
+              TT_StartOfName, TT_OverloadedOperator))
         return TT_PointerOrReference;
     }
 


Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6156,6 +6156,12 @@
                "operator()() && {}");
   verifyGoogleFormat("template <typename T>\n"
                      "auto x() & -> int {}");
+  verifyGoogleFormat("template <typename T>\n"
+                     "auto x() const& noexcept -> bool {}");
+  verifyGoogleFormat("template <typename T>\n"
+                     "void f() &noexcept {}");
+  verifyGoogleFormat("template <typename T>\n"
+                     "auto operator+() &MACRO {}");
 }
 
 TEST_F(FormatTest, UnderstandsAttributes) {
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1563,7 +1563,7 @@
         (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
       return TT_PointerOrReference;
 
-    if (PrevToken->is(tok::coloncolon))
+    if (PrevToken->isOneOf(tok::coloncolon, tok::kw_const))
       return TT_PointerOrReference;
 
     if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
@@ -1585,7 +1585,9 @@
       FormatToken *TokenBeforeMatchingParen =
           PrevToken->MatchingParen->getPreviousNonComment();
       if (TokenBeforeMatchingParen &&
-          TokenBeforeMatchingParen->isOneOf(tok::kw_typeof, tok::kw_decltype))
+          TokenBeforeMatchingParen->isOneOf(
+              tok::kw_typeof, tok::kw_decltype, TT_FunctionDeclarationName,
+              TT_StartOfName, TT_OverloadedOperator))
         return TT_PointerOrReference;
     }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D47519: [clang-f... Attila via Phabricator via cfe-commits

Reply via email to