Improve handling of trailing block comments.
We can now (even in non-bin-packing modes) format:
someFunction(1, /* comment 1 */
2, /* comment 2 */
3, /* comment 3 */
aaa);
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174309 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 0676df6..0cfd990 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -662,17 +662,15 @@
if (Current.FormatTok.MustBreakBefore) {
Current.MustBreakBefore = true;
+ } else if (Current.Type == TT_LineComment) {
+ Current.MustBreakBefore = Current.FormatTok.NewlinesBefore > 0;
+ } else if ((Current.Parent->is(tok::comment) &&
+ Current.FormatTok.NewlinesBefore > 0) ||
+ (Current.is(tok::string_literal) &&
+ Current.Parent->is(tok::string_literal))) {
+ Current.MustBreakBefore = true;
} else {
- if (Current.Type == TT_LineComment) {
- Current.MustBreakBefore = Current.FormatTok.NewlinesBefore > 0;
- } else if ((Current.Parent->is(tok::comment) &&
- Current.FormatTok.NewlinesBefore > 0) ||
- (Current.is(tok::string_literal) &&
- Current.Parent->is(tok::string_literal))) {
- Current.MustBreakBefore = true;
- } else {
- Current.MustBreakBefore = false;
- }
+ Current.MustBreakBefore = false;
}
Current.CanBreakBefore = Current.MustBreakBefore || canBreakBefore(Current);
if (Current.MustBreakBefore)