Fixes a crash introduced in
D123737 where LastNonComment would be null.
Reviewed By: curdeius
Differential Revision: https://reviews.llvm.org/
D124036
// TODO: Use IndentTracker to avoid loop?
// Find the last line with lower level.
auto J = I - 1;
- for (; J != AnnotatedLines.begin(); --J)
- if (!(*J)->InPPDirective && (*J)->Level < TheLine->Level)
- break;
+ if (!TheLine->InPPDirective) {
+ for (; J != AnnotatedLines.begin(); --J) {
+ if (!(*J)->InPPDirective && (*J)->Level < TheLine->Level)
+ break;
+ }
+ }
+
if ((*J)->Level >= TheLine->Level)
return false;
" return 1; \\\n"
" return 2;",
ShortMergedIf);
+
+ verifyFormat("//\n"
+ "#define a \\\n"
+ " if \\\n"
+ " 0",
+ getChromiumStyle(FormatStyle::LK_Cpp));
}
TEST_F(FormatTest, FormatStarDependingOnContext) {