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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@182757 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/BreakableToken.cpp b/lib/Format/BreakableToken.cpp
index 1b1827e..1fd538e 100644
--- a/lib/Format/BreakableToken.cpp
+++ b/lib/Format/BreakableToken.cpp
@@ -321,8 +321,17 @@
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() -