const AnnotatedLine *NextNonCommentLine = nullptr;
for (AnnotatedLine *Line : llvm::reverse(Lines)) {
assert(Line->First);
- bool CommentLine = true;
- for (const FormatToken *Tok = Line->First; Tok; Tok = Tok->Next) {
- if (!Tok->is(tok::comment)) {
- CommentLine = false;
- break;
- }
- }
// If the comment is currently aligned with the line immediately following
// it, that's probably intentional and we should keep it.
- if (NextNonCommentLine && CommentLine &&
+ if (NextNonCommentLine && Line->isComment() &&
NextNonCommentLine->First->NewlinesBefore <= 1 &&
NextNonCommentLine->First->OriginalColumn ==
Line->First->OriginalColumn) {
Kind = IfStmtKind::IfElseIf;
addUnwrappedLine();
} else if (FormatTok->is(tok::kw_if)) {
- FormatToken *Previous = Tokens->getPreviousToken();
- const bool IsPrecededByComment = Previous && Previous->is(tok::comment);
+ const FormatToken *Previous = Tokens->getPreviousToken();
+ assert(Previous);
+ const bool IsPrecededByComment = Previous->is(tok::comment);
if (IsPrecededByComment) {
addUnwrappedLine();
++Line->Level;