<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 24, 2015 at 5:46 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank" class="cremed">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Mon, Aug 24, 2015 at 7:28 AM, Daniel Jasper via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="cremed">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: djasper<br>
Date: Mon Aug 24 09:28:08 2015<br>
New Revision: 245843<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=245843&view=rev" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=245843&view=rev</a><br>
Log:<br>
clang-format: Make formatting of member function reference qualifiers<br>
more consistent.<br>
<br>
Before:<br>
SomeType MemberFunction(const Deleted &)&&;<br>
SomeType MemberFunction(const Deleted &) && { ... }<br>
<br>
After:<br>
SomeType MemberFunction(const Deleted &)&&;<br>
SomeType MemberFunction(const Deleted &)&& { ... }<br></blockquote></span><div><br>I don't think that's the way most people write them - at least I tend to write them with a space after the ')'? (for both rvalue and lvalue ref) same way I would with 'const'.<br><br>Any sense of how this is usually done (across LLVM or other codebases)?<br></div></div></div></div></blockquote><div><br></div><div>You are probably right. But making this consistent is a good step either way ;-). I'll follow up with another commit ..</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
cfe/trunk/lib/Format/FormatToken.h<br>
cfe/trunk/lib/Format/TokenAnnotator.cpp<br>
cfe/trunk/unittests/Format/FormatTest.cpp<br>
<br>
Modified: cfe/trunk/lib/Format/FormatToken.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=245843&r1=245842&r2=245843&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=245843&r1=245842&r2=245843&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Format/FormatToken.h (original)<br>
+++ cfe/trunk/lib/Format/FormatToken.h Mon Aug 24 09:28:08 2015<br>
@@ -525,6 +525,8 @@ private:<br>
/// properly supported by Clang's lexer.<br>
struct AdditionalKeywords {<br>
AdditionalKeywords(IdentifierTable &IdentTable) {<br>
+ kw_final = &IdentTable.get("final");<br>
+ kw_override = &IdentTable.get("override");<br>
kw_in = &IdentTable.get("in");<br>
kw_CF_ENUM = &IdentTable.get("CF_ENUM");<br>
kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS");<br>
@@ -538,7 +540,6 @@ struct AdditionalKeywords {<br>
<br>
kw_abstract = &IdentTable.get("abstract");<br>
kw_extends = &IdentTable.get("extends");<br>
- kw_final = &IdentTable.get("final");<br>
kw_implements = &IdentTable.get("implements");<br>
kw_instanceof = &IdentTable.get("instanceof");<br>
kw_interface = &IdentTable.get("interface");<br>
@@ -562,6 +563,8 @@ struct AdditionalKeywords {<br>
}<br>
<br>
// Context sensitive keywords.<br>
+ IdentifierInfo *kw_final;<br>
+ IdentifierInfo *kw_override;<br>
IdentifierInfo *kw_in;<br>
IdentifierInfo *kw_CF_ENUM;<br>
IdentifierInfo *kw_CF_OPTIONS;<br>
@@ -578,7 +581,6 @@ struct AdditionalKeywords {<br>
// Java keywords.<br>
IdentifierInfo *kw_abstract;<br>
IdentifierInfo *kw_extends;<br>
- IdentifierInfo *kw_final;<br>
IdentifierInfo *kw_implements;<br>
IdentifierInfo *kw_instanceof;<br>
IdentifierInfo *kw_interface;<br>
<br>
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=245843&r1=245842&r2=245843&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=245843&r1=245842&r2=245843&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)<br>
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Aug 24 09:28:08 2015<br>
@@ -1139,9 +1139,11 @@ private:<br>
return TT_UnaryOperator;<br>
<br>
const FormatToken *NextToken = Tok.getNextNonComment();<br>
- if (!NextToken || NextToken->is(tok::arrow) ||<br>
+ if (!NextToken ||<br>
+ NextToken->isOneOf(tok::arrow, Keywords.kw_final,<br>
+ Keywords.kw_override) ||<br>
(NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))<br>
- return TT_Unknown;<br>
+ return TT_PointerOrReference;<br>
<br>
if (PrevToken->is(tok::coloncolon))<br>
return TT_PointerOrReference;<br>
@@ -1855,7 +1857,9 @@ bool TokenAnnotator::spaceRequiredBetwee<br>
!Line.IsMultiVariableDeclStmt)))<br>
return true;<br>
if (Left.is(TT_PointerOrReference))<br>
- return Right.Tok.isLiteral() || Right.is(TT_BlockComment) ||<br>
+ return Right.Tok.isLiteral() ||<br>
+ Right.isOneOf(TT_BlockComment, Keywords.kw_final,<br>
+ Keywords.kw_override) ||<br>
(Right.is(tok::l_brace) && Right.BlockKind == BK_Block) ||<br>
(!Right.isOneOf(TT_PointerOrReference, TT_ArraySubscriptLSquare,<br>
tok::l_paren) &&<br>
<br>
Modified: cfe/trunk/unittests/Format/FormatTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=245843&r1=245842&r2=245843&view=diff" rel="noreferrer" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=245843&r1=245842&r2=245843&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Aug 24 09:28:08 2015<br>
@@ -5326,6 +5326,9 @@ TEST_F(FormatTest, UnderstandsFunctionRe<br>
verifyFormat("Deleted &operator=(const Deleted &)&&;");<br>
verifyFormat("SomeType MemberFunction(const Deleted &)&;");<br>
verifyFormat("SomeType MemberFunction(const Deleted &)&&;");<br>
+ verifyFormat("SomeType MemberFunction(const Deleted &)&& {}");<br>
+ verifyFormat("SomeType MemberFunction(const Deleted &)&& final {}");<br>
+ verifyFormat("SomeType MemberFunction(const Deleted &)&& override {}");<br>
<br>
verifyGoogleFormat("Deleted& operator=(const Deleted&)& = default;");<br>
verifyGoogleFormat("SomeType MemberFunction(const Deleted&)& = delete;");<br>
@@ -5583,11 +5586,11 @@ TEST_F(FormatTest, UnderstandsUsesOfStar<br>
<br>
// Member function reference qualifiers aren't binary operators.<br>
verifyFormat("string // break\n"<br>
- "operator()() & {}");<br>
+ "operator()()& {}");<br>
verifyFormat("string // break\n"<br>
- "operator()() && {}");<br>
+ "operator()()&& {}");<br>
verifyGoogleFormat("template <typename T>\n"<br>
- "auto x() & -> int {}");<br>
+ "auto x()& -> int {}");<br>
}<br>
<br>
TEST_F(FormatTest, UnderstandsAttributes) {<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="cremed">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="cremed">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>