summaryrefslogtreecommitdiffstats
path: root/lib/Format/BreakableToken.cpp
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-03-08 08:55:12 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-03-08 08:55:12 +0000
commit79a6eca386d468058b31e2d4f54b1b736a12f558 (patch)
treec380c1f865659b7351bce30a4ba6735cb679a0d6 /lib/Format/BreakableToken.cpp
parent1c814d10cf1a5085e5b0496c6707b3c44ba86eb5 (diff)
[clang-format] Enable comment reflowing in multiline comments containing pragmas
Summary: This patch enables comment reflowing of lines not matching the comment pragma regex in multiline comments containing comment pragma lines. Previously, these comments were dumped without being reindented to the result. Reviewers: djasper, mprobst Reviewed By: mprobst Subscribers: klimek, mprobst, cfe-commits Differential Revision: https://reviews.llvm.org/D30697 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297261 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/BreakableToken.cpp')
-rw-r--r--lib/Format/BreakableToken.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/Format/BreakableToken.cpp b/lib/Format/BreakableToken.cpp
index 290df1e158..b42e4aee50 100644
--- a/lib/Format/BreakableToken.cpp
+++ b/lib/Format/BreakableToken.cpp
@@ -200,7 +200,8 @@ BreakableStringLiteral::BreakableStringLiteral(
BreakableToken::Split
BreakableStringLiteral::getSplit(unsigned LineIndex, unsigned TailOffset,
- unsigned ColumnLimit) const {
+ unsigned ColumnLimit,
+ llvm::Regex &CommentPragmasRegex) const {
return getStringSplit(Line.substr(TailOffset),
StartColumn + Prefix.size() + Postfix.size(),
ColumnLimit, Style.TabWidth, Encoding);
@@ -231,9 +232,13 @@ BreakableComment::BreakableComment(const FormatToken &Token,
unsigned BreakableComment::getLineCount() const { return Lines.size(); }
-BreakableToken::Split BreakableComment::getSplit(unsigned LineIndex,
- unsigned TailOffset,
- unsigned ColumnLimit) const {
+BreakableToken::Split
+BreakableComment::getSplit(unsigned LineIndex, unsigned TailOffset,
+ unsigned ColumnLimit,
+ llvm::Regex &CommentPragmasRegex) const {
+ // Don't break lines matching the comment pragmas regex.
+ if (CommentPragmasRegex.match(Content[LineIndex]))
+ return Split(StringRef::npos, 0);
return getCommentSplit(Content[LineIndex].substr(TailOffset),
getContentStartColumn(LineIndex, TailOffset),
ColumnLimit, Style.TabWidth, Encoding);