diff options
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r-- | clang/lib/Format/Format.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 347e31470d5..f29308e509c 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/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(); |