Author: djasper Date: Wed Jan 23 06:58:14 2013 New Revision: 173259 URL: http://llvm.org/viewvc/llvm-project?rev=173259&view=rev Log: Fix the formatting of pointer/reference types in range-based for loops.
Before: for (int & a : Values) {} After: for (int &a : Values) {} 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=173259&r1=173258&r2=173259&view=diff ============================================================================== --- cfe/trunk/lib/Format/Format.cpp (original) +++ cfe/trunk/lib/Format/Format.cpp Wed Jan 23 06:58:14 2013 @@ -1262,7 +1262,8 @@ } } if (Current.is(tok::kw_return) || Current.is(tok::kw_throw) || - (Current.is(tok::l_paren) && !Line.MustBeDeclaration)) + (Current.is(tok::l_paren) && !Line.MustBeDeclaration && + (Current.Parent == NULL || Current.Parent->isNot(tok::kw_for)))) IsExpression = true; if (Current.Type == TT_Unknown) { Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=173259&r1=173258&r2=173259&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 23 06:58:14 2013 @@ -1356,6 +1356,10 @@ verifyIndependentOfContext("if (*b[i])"); verifyIndependentOfContext("if (int *a = (&b))"); verifyIndependentOfContext("while (int *a = &b)"); + verifyFormat("void f() {\n" + " for (const int &v : Values) {\n" + " }\n" + "}"); verifyIndependentOfContext("A = new SomeType *[Length]();"); verifyGoogleFormat("A = new SomeType* [Length]();"); _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits