diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-12 16:51:23 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-12 16:51:23 +0000 |
commit | 9ece2bb8499251f3e7cdf65e7a65b38aaeead0d8 (patch) | |
tree | 7821b4b26a4fa23c0b05ba556a78cdb04723fd3d /lib/Format/Format.cpp | |
parent | 95e8e468af284afb11ec1f994d0b5076fc7423d9 (diff) |
Fix bug in the adjustment to existing lines.
Before (if only the second line was reformatted):
void f() {}
void g() {}
After:
void f() {}
void g() {}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174978 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
-rw-r--r-- | lib/Format/Format.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 347e31470d..f29308e509 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -957,12 +957,15 @@ public: TheLine.Last->FormatTok.Tok.getLocation()) + Lex.MeasureTokenLength(TheLine.Last->FormatTok.Tok.getLocation(), SourceMgr, Lex.getLangOpts()) - 1; - unsigned Indent = SourceMgr.getSpellingColumnNumber( - TheLine.First.FormatTok.Tok.getLocation()) - 1; - unsigned LevelIndent = Indent; - if (static_cast<int>(LevelIndent) - Offset >= 0) - LevelIndent -= Offset; - IndentForLevel[TheLine.Level] = LevelIndent; + if (TheLine.First.FormatTok.NewlinesBefore > 0 || + TheLine.First.FormatTok.IsFirst) { + unsigned Indent = SourceMgr.getSpellingColumnNumber( + TheLine.First.FormatTok.Tok.getLocation()) - 1; + unsigned LevelIndent = Indent; + if (static_cast<int>(LevelIndent) - Offset >= 0) + LevelIndent -= Offset; + IndentForLevel[TheLine.Level] = LevelIndent; + } } } return Whitespaces.generateReplacements(); |