summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/ContinuationIndenter.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-08-28 10:03:58 +0000
committerDaniel Jasper <djasper@google.com>2013-08-28 10:03:58 +0000
commit2739af3b9cce00b7bda893162ccb2e7951f7c2e7 (patch)
tree421b10b9954217cb11e8004d616a1658fa7dd74b /clang/lib/Format/ContinuationIndenter.cpp
parent2d999ebb84280a50c2547293cfa44d323d66de1f (diff)
downloadbcm5719-llvm-2739af3b9cce00b7bda893162ccb2e7951f7c2e7.tar.gz
bcm5719-llvm-2739af3b9cce00b7bda893162ccb2e7951f7c2e7.zip
clang-format: Improve token breaking behavior.
Two changes: * Don't add an extra penalty on breaking the same token multiple times. Generally, we should prefer not to break, but once we break, the normal line breaking penalties apply. * Slightly increase the penalty for breaking comments. In general, the author has put some thought into how to break the comment and we should not overwrite this unnecessarily. With a 40-column column limit, formatting aaaaaa("aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa"); Leads to: Before: aaaaaa( "aaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaa"); After: aaaaaa("aaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaa " "aaaaaaaaaaaaaaaa"); llvm-svn: 189466
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 798e4f3aecd..f4ae5cce01b 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -666,8 +666,7 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
assert(NewRemainingTokenColumns < RemainingTokenColumns);
if (!DryRun)
Token->insertBreak(LineIndex, TailOffset, Split, Whitespaces);
- Penalty += Current.is(tok::string_literal) ? Style.PenaltyBreakString
- : Style.PenaltyBreakComment;
+ Penalty += Current.SplitPenalty;
unsigned ColumnsUsed =
Token->getLineLengthAfterSplit(LineIndex, TailOffset, Split.first);
if (ColumnsUsed > getColumnLimit()) {
@@ -691,6 +690,9 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current,
State.Stack[i].BreakBeforeParameter = true;
}
+ Penalty += Current.is(tok::string_literal) ? Style.PenaltyBreakString
+ : Style.PenaltyBreakComment;
+
State.Stack.back().LastSpace = StartColumn;
}
return Penalty;
OpenPOWER on IntegriCloud