diff options
author | Daniel Jasper <djasper@google.com> | 2015-11-02 20:02:49 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-11-02 20:02:49 +0000 |
commit | f83834feb15845bb85cefa892efcad7ec3d07e2c (patch) | |
tree | ad726f1b3ccd1db05710bc0998bfeefc242de9cc /clang/lib/Format/UnwrappedLineFormatter.cpp | |
parent | 2297a9142e13f84cc7102ed722922ba21511d7b6 (diff) | |
download | bcm5719-llvm-f83834feb15845bb85cefa892efcad7ec3d07e2c.tar.gz bcm5719-llvm-f83834feb15845bb85cefa892efcad7ec3d07e2c.zip |
clang-format: Simplify and improve stop condition for formatting
unaffected lines with incorrect initial indent.
Starting from:
namespace {
int i; // There shouldn't be indentation here.
int j; // <- call clang-format on this line.
}
Before:
namespace {
int i;
int j;
}
After:
namespace {
int i;
int j;
}
llvm-svn: 251824
Diffstat (limited to 'clang/lib/Format/UnwrappedLineFormatter.cpp')
-rw-r--r-- | clang/lib/Format/UnwrappedLineFormatter.cpp | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index 5b4f5d5b09c..04087e84871 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -815,8 +815,6 @@ UnwrappedLineFormatter::format(const SmallVectorImpl<AnnotatedLine *> &Lines, // The minimum level of consecutive lines that have been formatted. unsigned RangeMinLevel = UINT_MAX; - // The level of the previous line. - unsigned PreviousLineLevel = Lines.front()->Level; for (const AnnotatedLine *Line = Joiner.getNextMergedLine(DryRun, IndentTracker); @@ -830,8 +828,7 @@ UnwrappedLineFormatter::format(const SmallVectorImpl<AnnotatedLine *> &Lines, // remaining file if it currently missing a closing brace. bool ContinueFormatting = TheLine.Level > RangeMinLevel || - (TheLine.Level == RangeMinLevel && PreviousLineLevel <= TheLine.Level); - PreviousLineLevel = TheLine.Level; + (TheLine.Level == RangeMinLevel && !TheLine.startsWith(tok::r_brace)); bool FixIndentation = (FixBadIndentation || ContinueFormatting) && Indent != TheLine.First->OriginalColumn; |