[PATCH] D47519: [clang-format] Detect amp type as TT_PointerOrReference in function annotations
Attila via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 30 02:03:05 PDT 2018
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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47519.149060.patch
Type: text/x-patch
Size: 1690 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180530/3027933f/attachment.bin>
More information about the cfe-commits
mailing list