summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/BreakableToken.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-05-06 07:17:22 +0000
committerDaniel Jasper <djasper@google.com>2015-05-06 07:17:22 +0000
commit6d9b88dd997c3188446c6f63c852676bc0e6e432 (patch)
tree6884dabf90d6bd682d74d2c97f1768ab4ff15553 /clang/lib/Format/BreakableToken.cpp
parent26f165b04e803756b870f59fd5f1ab0cd89d0ae0 (diff)
downloadbcm5719-llvm-6d9b88dd997c3188446c6f63c852676bc0e6e432.tar.gz
bcm5719-llvm-6d9b88dd997c3188446c6f63c852676bc0e6e432.zip
clang-format: Fix bug in multiline comment wrapping.
Splitting: /** * multiline block comment * */ Before: /** * multiline block *comment * */ After: /** * multiline block * comment * */ The reason was that the empty line inside the comment (with just the "*") was confusing the comment breaking logic. llvm-svn: 236573
Diffstat (limited to 'clang/lib/Format/BreakableToken.cpp')
-rw-r--r--clang/lib/Format/BreakableToken.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index c84d9afdd4e..66e935abdf5 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -277,6 +277,8 @@ BreakableBlockComment::BreakableBlockComment(
// If the last line is empty, the closing "*/" will have a star.
if (i + 1 == e && Lines[i].empty())
break;
+ if (!Lines[i].empty() && i + 1 != e && Decoration.startswith(Lines[i]))
+ continue;
while (!Lines[i].startswith(Decoration))
Decoration = Decoration.substr(0, Decoration.size() - 1);
}
@@ -297,14 +299,18 @@ BreakableBlockComment::BreakableBlockComment(
}
continue;
}
+
// The first line already excludes the star.
// For all other lines, adjust the line to exclude the star and
// (optionally) the first whitespace.
- StartOfLineColumn[i] += Decoration.size();
- Lines[i] = Lines[i].substr(Decoration.size());
- LeadingWhitespace[i] += Decoration.size();
- IndentAtLineBreak =
- std::min<int>(IndentAtLineBreak, std::max(0, StartOfLineColumn[i]));
+ unsigned DecorationSize =
+ Decoration.startswith(Lines[i]) ? Lines[i].size() : Decoration.size();
+ StartOfLineColumn[i] += DecorationSize;
+ Lines[i] = Lines[i].substr(DecorationSize);
+ LeadingWhitespace[i] += DecorationSize;
+ if (!Decoration.startswith(Lines[i]))
+ IndentAtLineBreak =
+ std::min<int>(IndentAtLineBreak, std::max(0, StartOfLineColumn[i]));
}
IndentAtLineBreak = std::max<unsigned>(IndentAtLineBreak, Decoration.size());
DEBUG({
OpenPOWER on IntegriCloud