On Tue, Jan 15, 2013 at 11:30 PM, David Blaikie <[email protected]> wrote:
> > On Jan 15, 2013 11:21 PM, "Daniel Jasper" <[email protected]> wrote: > > > > Author: djasper > > Date: Wed Jan 16 01:19:28 2013 > > New Revision: 172601 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=172601&view=rev > > Log: > > Never merge < and ::, as it produces different tokens. > > 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? > Agreed on both fronts -- this needs to be conditioned on the standard version, and >> in nested templates should be handled similarly.... 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... I think essentially there are 4 buckets: C++98 features which need formatting (export maybe) C++11 features which need formatting (range-based for loops) C++98 compatibility formatting concerns (<:: and >> in templates) C++11 compatibility formatting concerns (I can't think of any, but they maybe exist) It seems like we should always support formatting all of the features, but allow selection of the compatibility target.... > > > > Before: vector<::Type> t; > > After: vector< ::Type> t; > > > > Modified: > > cfe/trunk/lib/Format/Format.cpp > > cfe/trunk/unittests/Format/FormatTest.cpp > > > > Modified: cfe/trunk/lib/Format/Format.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172601&r1=172600&r2=172601&view=diff > > > ============================================================================== > > --- cfe/trunk/lib/Format/Format.cpp (original) > > +++ cfe/trunk/lib/Format/Format.cpp Wed Jan 16 01:19:28 2013 > > @@ -1176,6 +1176,10 @@ > > Right.is(tok::l_paren) || Right.is(tok::l_brace) || > > Right.is(tok::kw_true) || Right.is(tok::kw_false))) > > return false; > > + if (Left.is(tok::coloncolon)) > > + return false; > > + if (Right.is(tok::coloncolon)) > > + return Left.isNot(tok::identifier) && Left.isNot(tok::greater); > > if (Left.is(tok::less) || Right.is(tok::greater) || > Right.is(tok::less)) > > return false; > > if (Right.is(tok::amp) || Right.is(tok::star)) > > @@ -1191,10 +1195,6 @@ > > return false; > > if (Right.is(tok::l_square) && Right.Type != TT_ObjCMethodExpr) > > return false; > > - if (Left.is(tok::coloncolon) || > > - (Right.is(tok::coloncolon) && > > - (Left.is(tok::identifier) || Left.is(tok::greater)))) > > - return false; > > if (Left.is(tok::period) || Right.is(tok::period)) > > return false; > > if (Left.is(tok::colon)) > > > > Modified: cfe/trunk/unittests/Format/FormatTest.cpp > > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172601&r1=172600&r2=172601&view=diff > > > ============================================================================== > > --- cfe/trunk/unittests/Format/FormatTest.cpp (original) > > +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 16 01:19:28 2013 > > @@ -131,6 +131,10 @@ > > verifyFormat("Method(f1(f2, (f3())));"); > > } > > > > +TEST_F(FormatTest, ImportantSpaces) { > > + verifyFormat("vector< ::Type> v;"); > > +} > > + > > > > //===----------------------------------------------------------------------===// > > // Tests for control statements. > > > > //===----------------------------------------------------------------------===// > > > > > > _______________________________________________ > > cfe-commits mailing list > > [email protected] > > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
