Implement more accurate penalty & trade-offs while breaking protruding tokens.
For each line that we break in a protruding token, compute whether the
penalty of breaking is actually larger than the penalty of the excess
characters. Only break if that is the case.
llvm-svn: 318515
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index 67d75fd..d2064ac 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -605,9 +605,9 @@
}
}
-bool BreakableBlockComment::introducesBreakBefore(unsigned LineIndex) const {
+bool BreakableBlockComment::introducesBreakBeforeToken() const {
// A break is introduced when we want delimiters on newline.
- return LineIndex == 0 && DelimitersOnNewline &&
+ return DelimitersOnNewline &&
Lines[0].substr(1).find_first_not_of(Blanks) != StringRef::npos;
}