Improve formatting of operator<< chains.

Before:
  llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: "
               << aaaaaaaaaaaaaaaa << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;

After:
  llvm::outs() << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
               << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa
               << "aaaaaaaaaaaaaaaa: " << aaaaaaaaaaaaaaaa;

llvm-svn: 186320
This commit is contained in:
Daniel Jasper 2013-07-15 14:12:30 +00:00
parent cacb40c6c7
commit 0d5e44df3c
3 changed files with 5 additions and 2 deletions

View File

@ -127,7 +127,7 @@ namespace format {
void setDefaultPenalties(FormatStyle &Style) {
Style.PenaltyBreakComment = 45;
Style.PenaltyBreakFirstLessLess = 100;
Style.PenaltyBreakFirstLessLess = 180;
Style.PenaltyBreakString = 1000;
Style.PenaltyExcessCharacter = 1000000;
}

View File

@ -1082,7 +1082,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
Content = Content.drop_back(1).drop_front(1).trim();
if (Content.size() > 1 &&
(Content.back() == ':' || Content.back() == '='))
return 20;
return 50;
}
return prec::Shift;
}

View File

@ -2999,6 +2999,9 @@ TEST_F(FormatTest, AlignsPipes) {
" << \" ddd = [\" << pkt.ddd << \"]\\n\"\n"
" << \"}\";");
verifyFormat("llvm::outs() << \"aaaaaaaaaaaaaaaa: \" << aaaaaaaaaaaaaaaa\n"
" << \"aaaaaaaaaaaaaaaa: \" << aaaaaaaaaaaaaaaa\n"
" << \"aaaaaaaaaaaaaaaa: \" << aaaaaaaaaaaaaaaa;");
verifyFormat(
"llvm::outs() << \"aaaaaaaaaaaaaaaaa = \" << aaaaaaaaaaaaaaaaa\n"
" << \"bbbbbbbbbbbbbbbbb = \" << bbbbbbbbbbbbbbbbb\n"