summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-23 12:27:43 +0000
committerDaniel Jasper <djasper@google.com>2013-01-23 12:27:43 +0000
commit43b6548ce0d89c81dcd6f9cab93963daebaf7dba (patch)
treebde6d5497bbf5b23fb1cb27e7100942a524eafb1 /clang
parent5b49f47835e89ffc6dbf8468322febe66ebb6ecf (diff)
downloadbcm5719-llvm-43b6548ce0d89c81dcd6f9cab93963daebaf7dba.tar.gz
bcm5719-llvm-43b6548ce0d89c81dcd6f9cab93963daebaf7dba.zip
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)); llvm-svn: 173257
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/Format.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp25
2 files changed, 12 insertions, 18 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 2d9bd2cc061..c75b8ef834b 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -702,11 +702,6 @@ private:
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;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 3a1cfb261bd..279b61c262b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1030,15 +1030,15 @@ TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
" 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");
+ "unsigned Cost =\n"
+ " TTI.getMemoryOpCost(I->getOpcode(), VectorTy, SI->getAlignment(),\n"
+ " SI->getPointerAddressSpaceee());\n");
verifyFormat(
- "CharSourceRange LineRange = CharSourceRange::getTokenRange(\n"
- " Line.Tokens.front().Tok.getLocation(),\n"
- " Line.Tokens.back().Tok.getLocation());");
+ "CharSourceRange LineRange =\n"
+ " CharSourceRange::getTokenRange(Line.Tokens.front().Tok.getLoc(),\n"
+ " Line.Tokens.back().Tok.getLoc());");
}
TEST_F(FormatTest, AlignsAfterAssignments) {
@@ -1055,9 +1055,9 @@ TEST_F(FormatTest, AlignsAfterAssignments) {
"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 @@ TEST_F(FormatTest, UnderstandsEquals) {
"}");
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) {
OpenPOWER on IntegriCloud