summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineFormatter.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2015-05-07 12:26:30 +0000
committerManuel Klimek <klimek@google.com>2015-05-07 12:26:30 +0000
commitec5c3db7acb04ee96fd8b49153e5458d8f21c38a (patch)
treefffc70bc12d7e8140795ab783822a4a2190b8405 /clang/lib/Format/UnwrappedLineFormatter.cpp
parent82cdd651232cf5f1440854c95eb9d6f66821e367 (diff)
downloadbcm5719-llvm-ec5c3db7acb04ee96fd8b49153e5458d8f21c38a.tar.gz
bcm5719-llvm-ec5c3db7acb04ee96fd8b49153e5458d8f21c38a.zip
Implements a way to retrieve information about whether some lines were not formatted due to syntax errors.
llvm-svn: 236722
Diffstat (limited to 'clang/lib/Format/UnwrappedLineFormatter.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineFormatter.cpp6
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;
OpenPOWER on IntegriCloud