diff options
Diffstat (limited to 'clang/lib/Format/UnwrappedLineFormatter.cpp')
-rw-r--r-- | clang/lib/Format/UnwrappedLineFormatter.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index fb1e8dd6842..672a911d8d6 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -403,6 +403,7 @@ UnwrappedLineFormatter::format(const SmallVectorImpl<AnnotatedLine *> &Lines, bool FixIndentation = FixBadIndentation && (LevelIndent != FirstTok->OriginalColumn); + bool ShouldFormat = TheLine.Affected || FixIndentation; if (TheLine.First->is(tok::eof)) { if (PreviousLine && PreviousLine->Affected && !DryRun) { // Remove the file's trailing whitespace. @@ -411,8 +412,7 @@ UnwrappedLineFormatter::format(const SmallVectorImpl<AnnotatedLine *> &Lines, /*IndentLevel=*/0, /*Spaces=*/0, /*TargetColumn=*/0); } - } else if (TheLine.Type != LT_Invalid && - (TheLine.Affected || FixIndentation)) { + } else if (TheLine.Type != LT_Invalid && ShouldFormat) { if (FirstTok->WhitespaceRange.isValid()) { if (!DryRun) formatFirstToken(*TheLine.First, PreviousLine, TheLine.Level, Indent, @@ -476,6 +476,8 @@ UnwrappedLineFormatter::format(const SmallVectorImpl<AnnotatedLine *> &Lines, } } } + if (TheLine.Type == LT_Invalid && ShouldFormat && IncompleteFormat) + *IncompleteFormat = true; if (!DryRun) markFinalized(TheLine.First); PreviousLine = *I; |