summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-07-15 14:33:14 +0000
committerDaniel Jasper <djasper@google.com>2013-07-15 14:33:14 +0000
commitfa21c0724cb96f4893cf90050da5715a49b98754 (patch)
treed43bebc57bc32fdb48ff2adbf5be237567c8fef6
parenta928e1d7a1fac1e947f460966f74fcc93620958d (diff)
downloadbcm5719-llvm-fa21c0724cb96f4893cf90050da5715a49b98754.tar.gz
bcm5719-llvm-fa21c0724cb96f4893cf90050da5715a49b98754.zip
Improvement of change r186320.
Fixed a test that by now passed for the wrong reason. Before: llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaa); After: llvm::outs() << "aaaaaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa); Also reformatted Format.cpp with the latest changes (1 formatting fix and 1 layout change of a <<-chain). llvm-svn: 186322
-rw-r--r--clang/lib/Format/Format.cpp12
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp4
-rw-r--r--clang/unittests/Format/FormatTest.cpp7
3 files changed, 13 insertions, 10 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f66d95c9109..79048536891 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -127,7 +127,7 @@ namespace format {
void setDefaultPenalties(FormatStyle &Style) {
Style.PenaltyBreakComment = 45;
- Style.PenaltyBreakFirstLessLess = 180;
+ Style.PenaltyBreakFirstLessLess = 120;
Style.PenaltyBreakString = 1000;
Style.PenaltyExcessCharacter = 1000000;
}
@@ -854,7 +854,7 @@ private:
// If this ends the array subscript expr, reset the corresponding value.
const FormatToken *NextNonComment = Current.getNextNonComment();
if (NextNonComment && NextNonComment->isNot(tok::l_square))
- State.Stack.back().StartOfArraySubscripts = 0;
+ State.Stack.back().StartOfArraySubscripts = 0;
}
// Remove scopes created by fake parenthesis.
@@ -1339,10 +1339,10 @@ public:
: Style(Style), Lex(Lex), SourceMgr(SourceMgr),
Whitespaces(SourceMgr, Style), Ranges(Ranges),
Encoding(encoding::detectEncoding(Lex.getBuffer())) {
- DEBUG(llvm::dbgs()
- << "File encoding: "
- << (Encoding == encoding::Encoding_UTF8 ? "UTF8" : "unknown")
- << "\n");
+ DEBUG(llvm::dbgs() << "File encoding: "
+ << (Encoding == encoding::Encoding_UTF8 ? "UTF8"
+ : "unknown")
+ << "\n");
}
virtual ~Formatter() {}
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index b903597b437..3bed432b19c 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1082,9 +1082,9 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
Content = Content.drop_back(1).drop_front(1).trim();
if (Content.size() > 1 &&
(Content.back() == ':' || Content.back() == '='))
- return 50;
+ return 25;
}
- return prec::Shift;
+ return 1; // Breaking at a << is really cheap.
}
if (Left.Type == TT_ConditionalExpr)
return prec::Conditional;
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 49b51a94e46..01dd38e3c30 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3010,8 +3010,11 @@ TEST_F(FormatTest, AlignsPipes) {
" << \"eeeeeeeeeeeeeeeee = \" << eeeeeeeeeeeeeeeee;");
verifyFormat("llvm::outs() << aaaaaaaaaaaaaaaaaaaaaaaa << \"=\"\n"
" << bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb;");
- verifyFormat("llvm::outs() << \"aaaaaaaaaaaaaaaaaaaaaaaa: \"\n"
- " << aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+ verifyFormat(
+ "void f() {\n"
+ " llvm::outs() << \"aaaaaaaaaaaaaaaaaaaa: \"\n"
+ " << aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa);\n"
+ "}");
// Breaking before the first "<<" is generally not desirable.
verifyFormat(
OpenPOWER on IntegriCloud