diff options
author | Manuel Klimek <klimek@google.com> | 2013-05-28 08:55:01 +0000 |
---|---|---|
committer | Manuel Klimek <klimek@google.com> | 2013-05-28 08:55:01 +0000 |
commit | 281dcbe0266e9bfb625ab1532df9cce99e354c4e (patch) | |
tree | fcafbca0f4e348db33928daa799d4c0de84a6224 /clang/lib/Format/BreakableToken.cpp | |
parent | 3719428c066cbb1e83d08c03431971af110bc1ee (diff) | |
download | bcm5719-llvm-281dcbe0266e9bfb625ab1532df9cce99e354c4e.tar.gz bcm5719-llvm-281dcbe0266e9bfb625ab1532df9cce99e354c4e.zip |
Fixes indentation of empty lines in block comments.
Block comment indentation of empty lines regressed, as we did not
have a test for it.
/* Comment with...
*
* empty line. */
is now formatted correctly again.
llvm-svn: 182757
Diffstat (limited to 'clang/lib/Format/BreakableToken.cpp')
-rw-r--r-- | clang/lib/Format/BreakableToken.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index 1b1827e3f9a..1fd538e25ae 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -321,8 +321,17 @@ BreakableBlockComment::replaceWhitespaceBefore(unsigned LineIndex, if (LineIndex == 0) return; StringRef Prefix = Decoration; - if (LineIndex + 1 == Lines.size() && Lines[LineIndex].empty()) - Prefix = ""; + if (Lines[LineIndex].empty()) { + if (LineIndex + 1 == Lines.size()) { + // If the last line is empty, we don't need a prefix, as the */ will line + // up with the decoration (if it exists). + Prefix = ""; + } else if (!Decoration.empty()) { + // For other empty lines, if we do have a decoration, adapt it to not + // contain a trailing whitespace. + Prefix = Prefix.substr(0, 1); + } + } unsigned WhitespaceOffsetInToken = Lines[LineIndex].data() - Tok.TokenText.data() - |