<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><div dir="ltr"><div class="gmail_default" style><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 2, 2013 at 4:52 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank" class="cremed">thakis@chromium.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Wed, Jan 2, 2013 at 7:47 AM, Daniel Jasper <<a href="mailto:djasper@google.com" class="cremed">djasper@google.com</a>> wrote:<br>
> Author: djasper<br>
> Date: Wed Jan 2 09:46:59 2013<br>
> New Revision: 171390<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=171390&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=171390&view=rev</a><br>
> Log:<br>
> Correctly format pointers and references in casts.<br>
<br>
</div>Cool!<br>
<div class="im"><br>
><br>
> This fixes <a href="http://llvm.org/PR14747" target="_blank" class="cremed">llvm.org/PR14747</a>.<br>
><br>
> Before: Type *A = (Type * ) P;<br>
> After: Type *A = (Type *) P;<br>
<br>
</div>Shouldn't this be "(Type*)P" though? At least for google style? (It<br>
feels like that's more common in clang too, but I haven't checked if<br>
that's true.)<br></blockquote><div><br></div><div style>I think you are right. It has been quite a while since I have used this type of cast.. ;-)</div><div style><br></div><div style>It is a separate issue, though. I will address it soon.</div>
<div style><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">
><br>
> Modified:<br>
> cfe/trunk/lib/Format/Format.cpp<br>
> cfe/trunk/unittests/Format/FormatTest.cpp<br>
><br>
> Modified: cfe/trunk/lib/Format/Format.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=171390&r1=171389&r2=171390&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=171390&r1=171389&r2=171390&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/lib/Format/Format.cpp (original)<br>
> +++ cfe/trunk/lib/Format/Format.cpp Wed Jan 2 09:46:59 2013<br>
> @@ -822,19 +822,23 @@<br>
> TokenAnnotation::TokenType determineStarAmpUsage(unsigned Index, bool IsRHS) {<br>
> if (Index == Annotations.size())<br>
> return TokenAnnotation::TT_Unknown;<br>
> + const FormatToken &PrevToken = Line.Tokens[Index - 1];<br>
> + const FormatToken &NextToken = Line.Tokens[Index + 1];<br>
><br>
> - if (Index == 0 || Line.Tokens[Index - 1].Tok.is(tok::l_paren) ||<br>
> - Line.Tokens[Index - 1].Tok.is(tok::comma) ||<br>
> - Line.Tokens[Index - 1].Tok.is(tok::kw_return) ||<br>
> - Line.Tokens[Index - 1].Tok.is(tok::colon) ||<br>
> + if (Index == 0 || <a href="http://PrevToken.Tok.is" target="_blank" class="cremed">PrevToken.Tok.is</a>(tok::l_paren) ||<br>
> + <a href="http://PrevToken.Tok.is" target="_blank" class="cremed">PrevToken.Tok.is</a>(tok::comma) || <a href="http://PrevToken.Tok.is" target="_blank" class="cremed">PrevToken.Tok.is</a>(tok::kw_return) ||<br>
> + <a href="http://PrevToken.Tok.is" target="_blank" class="cremed">PrevToken.Tok.is</a>(tok::colon) ||<br>
> Annotations[Index - 1].Type == TokenAnnotation::TT_BinaryOperator)<br>
> return TokenAnnotation::TT_UnaryOperator;<br>
><br>
> - if (Line.Tokens[Index - 1].Tok.isLiteral() ||<br>
> - Line.Tokens[Index + 1].Tok.isLiteral() ||<br>
> - Line.Tokens[Index + 1].Tok.is(tok::kw_sizeof))<br>
> + if (PrevToken.Tok.isLiteral() || NextToken.Tok.isLiteral() ||<br>
> + <a href="http://NextToken.Tok.is" target="_blank" class="cremed">NextToken.Tok.is</a>(tok::kw_sizeof))<br>
> return TokenAnnotation::TT_BinaryOperator;<br>
><br>
> + if (<a href="http://NextToken.Tok.is" target="_blank" class="cremed">NextToken.Tok.is</a>(tok::comma) || <a href="http://NextToken.Tok.is" target="_blank" class="cremed">NextToken.Tok.is</a>(tok::r_paren) ||<br>
> + <a href="http://NextToken.Tok.is" target="_blank" class="cremed">NextToken.Tok.is</a>(tok::greater))<br>
> + return TokenAnnotation::TT_PointerOrReference;<br>
> +<br>
> // It is very unlikely that we are going to find a pointer or reference type<br>
> // definition on the RHS of an assignment.<br>
> if (IsRHS)<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=171390&r1=171389&r2=171390&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=171390&r1=171389&r2=171390&view=diff</a><br>
> ==============================================================================<br>
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 2 09:46:59 2013<br>
> @@ -699,6 +699,9 @@<br>
> verifyFormat("A<int **> a;");<br>
> verifyFormat("A<int *, int *> a;");<br>
> verifyFormat("A<int **, int **> a;");<br>
> + verifyFormat("Type *A = static_cast<Type *>(P);");<br>
> + verifyFormat("Type *A = (Type *) P;");<br>
> + verifyFormat("Type *A = (vector<Type *, int *>) P;");<br>
><br>
> verifyGoogleFormat("int main(int argc, char** argv) {\n}");<br>
> verifyGoogleFormat("A<int*> a;");<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu" class="cremed">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="cremed">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br></div></div></div>