<div dir="ltr"><div class="gmail_default" style><br></div><div class="gmail_extra"><div class="gmail_quote">On Tue, Jan 15, 2013 at 11:30 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 class="im"><p dir="ltr"><br>
On Jan 15, 2013 11:21 PM, "Daniel Jasper" <<a href="mailto:djasper@google.com" target="_blank" class="cremed">djasper@google.com</a>> wrote:<br>
><br>
> Author: djasper<br>
> Date: Wed Jan 16 01:19:28 2013<br>
> New Revision: 172601<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=172601&view=rev" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project?rev=172601&view=rev</a><br>
> Log:<br>
> Never merge < and ::, as it produces different tokens.</p>
</div><p dir="ltr">Shouldn't this be std-specific, since this works in C++11? Speaking of which - what does clang-format do with the >> in nested template types?</p></blockquote><div style>Agreed on both fronts -- this needs to be conditioned on the standard version, and >> in nested templates should be handled similarly....</div>
<div style><br></div><div style>That said, the problem is more tricky than it might seem -- we also need to support compilers which are missing support for this feature (most versions of GCC) and warnings which programmers use to notify them of this deviation between C++11 and C++98...</div>
<div style><br></div><div style>I think essentially there are 4 buckets:</div><div style><br></div><div style>C++98 features which need formatting (export maybe)</div><div style>C++11 features which need formatting (range-based for loops)<br>
</div><div style>C++98 compatibility formatting concerns (<:: and >> in templates)</div><div style>C++11 compatibility formatting concerns (I can't think of any, but they maybe exist)</div><div style><br></div>
<div style>It seems like we should always support formatting all of the features, but allow selection of the compatibility target....</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">
<p dir="ltr">><br>
> Before: vector<::Type> t;<br>
> After:  vector< ::Type> t;<br>
><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=172601&r1=172600&r2=172601&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172601&r1=172600&r2=172601&view=diff</a><br>


> ==============================================================================<br>
> --- cfe/trunk/lib/Format/Format.cpp (original)<br>
> +++ cfe/trunk/lib/Format/Format.cpp Wed Jan 16 01:19:28 2013<br>
> @@ -1176,6 +1176,10 @@<br>
>           Right.is(tok::l_paren) || Right.is(tok::l_brace) ||<br>
>           Right.is(tok::kw_true) || Right.is(tok::kw_false)))<br>
>        return false;<br>
> +    if (Left.is(tok::coloncolon))<br>
> +      return false;<br>
> +    if (Right.is(tok::coloncolon))<br>
> +      return Left.isNot(tok::identifier) && Left.isNot(tok::greater);<br>
>      if (Left.is(tok::less) || Right.is(tok::greater) || Right.is(tok::less))<br>
>        return false;<br>
>      if (Right.is(tok::amp) || Right.is(tok::star))<br>
> @@ -1191,10 +1195,6 @@<br>
>        return false;<br>
>      if (Right.is(tok::l_square) && Right.Type != TT_ObjCMethodExpr)<br>
>        return false;<br>
> -    if (Left.is(tok::coloncolon) ||<br>
> -        (Right.is(tok::coloncolon) &&<br>
> -         (Left.is(tok::identifier) || Left.is(tok::greater))))<br>
> -      return false;<br>
>      if (Left.is(tok::period) || Right.is(tok::period))<br>
>        return false;<br>
>      if (Left.is(tok::colon))<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=172601&r1=172600&r2=172601&view=diff" target="_blank" class="cremed">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172601&r1=172600&r2=172601&view=diff</a><br>


> ==============================================================================<br>
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 16 01:19:28 2013<br>
> @@ -131,6 +131,10 @@<br>
>    verifyFormat("Method(f1(f2, (f3())));");<br>
>  }<br>
><br>
> +TEST_F(FormatTest, ImportantSpaces) {<br>
> +  verifyFormat("vector< ::Type> v;");<br>
> +}<br>
> +<br>
>  //===----------------------------------------------------------------------===//<br>
>  // Tests for control statements.<br>
>  //===----------------------------------------------------------------------===//<br>
><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank" 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>
</p>
</div></div><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>
<br></blockquote></div><br></div></div>