summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-01-07 13:08:40 +0000
committerDaniel Jasper <djasper@google.com>2013-01-07 13:08:40 +0000
commit206df734174752324e22254db488d60e5fcbb45c (patch)
tree72bcb77455463405ca560737e2cf8ee95b62fb00 /clang/unittests/Format
parenta055aab50666829affd76f47b273d66fa6bd30a7 (diff)
downloadbcm5719-llvm-206df734174752324e22254db488d60e5fcbb45c.tar.gz
bcm5719-llvm-206df734174752324e22254db488d60e5fcbb45c.zip
Prefer not to break after assignments.
This addresses llvm.org/PR14830. Before: unsigned Cost = TTI.getMemoryOpCost(I->getOpcode(), VectorTy, SI->getAlignment(), SI->getPointerAddressSpace()); CharSourceRange LineRange = CharSourceRange::getTokenRange(TheLine.Tokens.front().Tok.getLocation(), TheLine.Tokens.back().Tok.getLocation()); After: unsigned Cost = TTI.getMemoryOpCost(I->getOpcode(), VectorTy, SI->getAlignment(), SI->getPointerAddressSpace()); CharSourceRange LineRange = CharSourceRange::getTokenRange( TheLine.Tokens.front().Tok.getLocation(), TheLine.Tokens.back().Tok.getLocation()); This required rudimentary changes to static initializer lists, but we are not yet formatting them in a reasonable way. That will be done in a subsequent patch. llvm-svn: 171731
Diffstat (limited to 'clang/unittests/Format')
-rw-r--r--clang/unittests/Format/FormatTest.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index a743d1b2b59..d9ad62031cf 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -384,8 +384,8 @@ TEST_F(FormatTest, StaticInitializers) {
// FIXME: Format like enums if the static initializer does not fit on a line.
verifyFormat(
- "static SomeClass WithALoooooooooooooooooooongName = { 100000000,\n"
- " \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" };");
+ "static SomeClass WithALoooooooooooooooooooongName = {\n"
+ " 100000000, \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\" };");
}
TEST_F(FormatTest, FormatsSmallMacroDefinitionsInSingleLine) {
@@ -641,23 +641,34 @@ TEST_F(FormatTest, BreaksAccordingToOperatorPrecedence) {
" ccccccccccccccccccccccccc) {\n}");
}
+TEST_F(FormatTest, PrefersNotToBreakAfterAssignments) {
+ 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());");
+}
+
TEST_F(FormatTest, AlignsAfterAssignments) {
verifyFormat(
"int Result = aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaa;");
+ " aaaaaaaaaaaaaaaaaaaaaaaaa;");
verifyFormat(
"Result += aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaa;");
+ " aaaaaaaaaaaaaaaaaaaaaaaaa;");
verifyFormat(
"Result >>= aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaa;");
+ " aaaaaaaaaaaaaaaaaaaaaaaaa;");
verifyFormat(
"int Result = (aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaa);");
+ " aaaaaaaaaaaaaaaaaaaaaaaaa);");
verifyFormat(
- "double LooooooooooooooooooooooooongResult =\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaa +\n"
- " aaaaaaaaaaaaaaaaaaaaaaaaa;");
+ "double LooooooooooooooooooooooooongResult = aaaaaaaaaaaaaaaaaaaaaaaa +\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaa +\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaa;");
}
TEST_F(FormatTest, AlignsAfterReturn) {
@@ -713,8 +724,10 @@ TEST_F(FormatTest, UnderstandsEquals) {
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n"
"}");
- verifyFormat("if (int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa =\n"
- " 100000000 + 100000000) {\n}");
+ verifyFormat(
+ "if (int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 100000000 +\n"
+ " 10000000) {\n"
+ "}");
}
TEST_F(FormatTest, WrapsAtFunctionCallsIfNecessary) {
OpenPOWER on IntegriCloud