clang-format: Don't merge lines with comments.
Before:
int f() { // comment return 42; }
After:
int f() { // comment
return 42;
}
This fixes llvm.org/PR21769.
llvm-svn: 223609
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index cf8e5d3..ebd1290 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -665,6 +665,9 @@
}
if (I[1]->First->is(TT_FunctionLBrace) &&
Style.BreakBeforeBraces != FormatStyle::BS_Attach) {
+ if (I[1]->Last->is(TT_LineComment))
+ return 0;
+
// Check for Limit <= 2 to account for the " {".
if (Limit <= 2 || (Style.ColumnLimit == 0 && containsMustBreak(TheLine)))
return 0;