[cfe-commits] r173257 - in /cfe/trunk: lib/Format/Format.cpp unittests/Format/FormatTest.cpp
Daniel Jasper
djasper at google.com
Wed Jan 23 04:27:43 PST 2013
Author: djasper
Date: Wed Jan 23 06:27:43 2013
New Revision: 173257
URL: http://llvm.org/viewvc/llvm-project?rev=173257&view=rev
Log:
Removing the penalty for breaking after "=".
Having seen more cases, this actually was not a good thing to do in the
first place. We can still improve on what we do now, but breaking after
the "=" is good in many cases.
Before:
aaaaaaaaaaaaa = aa->aaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa));
After:
aaaaaaaaaaaaa =
aa->aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa));
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=173257&r1=173256&r2=173257&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Wed Jan 23 06:27:43 2013
@@ -702,11 +702,6 @@
return prec::Assignment;
prec::Level Level = getPrecedence(Left);
- // Breaking after an assignment leads to a bad result as the two sides of
- // the assignment are visually very close together.
- if (Level == prec::Assignment)
- return 50;
-
if (Level != prec::Unknown)
return Level;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=173257&r1=173256&r2=173257&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 23 06:27:43 2013
@@ -1030,15 +1030,15 @@
" ccccccccccccccccccccccccc) {\n}");
}
-TEST_F(FormatTest, PrefersNotToBreakAfterAssignments) {
+TEST_F(FormatTest, BreaksAfterAssignments) {
verifyFormat(
- "unsigned Cost = TTI.getMemoryOpCost(I->getOpcode(), VectorTy,\n"
- " SI->getAlignment(),\n"
- " SI->getPointerAddressSpaceee());\n");
- verifyFormat(
- "CharSourceRange LineRange = CharSourceRange::getTokenRange(\n"
- " Line.Tokens.front().Tok.getLocation(),\n"
- " Line.Tokens.back().Tok.getLocation());");
+ "unsigned Cost =\n"
+ " TTI.getMemoryOpCost(I->getOpcode(), VectorTy, SI->getAlignment(),\n"
+ " SI->getPointerAddressSpaceee());\n");
+ verifyFormat(
+ "CharSourceRange LineRange =\n"
+ " CharSourceRange::getTokenRange(Line.Tokens.front().Tok.getLoc(),\n"
+ " Line.Tokens.back().Tok.getLoc());");
}
TEST_F(FormatTest, AlignsAfterAssignments) {
@@ -1055,9 +1055,9 @@
"int Result = (aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n"
" aaaaaaaaaaaaaaaaaaaaaaaaa);");
verifyFormat(
- "double LooooooooooooooooooooooooongResult = aaaaaaaaaaaaaaaaaaaaaaaa +\n"
- " aaaaaaaaaaaaaaaaaaaaaaaa +\n"
- " aaaaaaaaaaaaaaaaaaaaaaaa;");
+ "double LooooooooooooooooooooooooongResult =\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaa +\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaa;");
}
TEST_F(FormatTest, AlignsAfterReturn) {
@@ -1133,9 +1133,8 @@
"}");
verifyFormat(
- // FIXME: Does an expression like this ever make sense? If yes, fix.
- "if (int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 100000000 +\n"
- " 10000000) {\n}");
+ "if (int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
+ " 100000000 + 10000000) {\n}");
}
TEST_F(FormatTest, WrapsAtFunctionCallsIfNecessary) {
More information about the cfe-commits
mailing list