summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/BreakableToken.cpp
diff options
context:
space:
mode:
authorKrasimir Georgiev <krasimir@google.com>2017-08-23 15:58:10 +0000
committerKrasimir Georgiev <krasimir@google.com>2017-08-23 15:58:10 +0000
commit48a9f36876c2ea52c97b74aa7ab7b07c59d64aa6 (patch)
treed2c4197cb4d379b830958cadcf6db64da271043b /clang/lib/Format/BreakableToken.cpp
parent66f6fc0a49231aee5a565822be46863ef6e4ed2d (diff)
downloadbcm5719-llvm-48a9f36876c2ea52c97b74aa7ab7b07c59d64aa6.tar.gz
bcm5719-llvm-48a9f36876c2ea52c97b74aa7ab7b07c59d64aa6.zip
Revert "[clang-format] Emit absolute splits before lines for comments"
This reverts commit r311559, which added a test containing raw string literals in macros, which chokes gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55971 llvm-svn: 311566
Diffstat (limited to 'clang/lib/Format/BreakableToken.cpp')
-rw-r--r--clang/lib/Format/BreakableToken.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index b9e48e63019..20e3e5b1dfd 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -545,18 +545,15 @@ void BreakableBlockComment::insertBreak(unsigned LineIndex, unsigned TailOffset,
}
BreakableToken::Split BreakableBlockComment::getSplitBefore(
- unsigned LineIndex, unsigned PreviousEndColumn, unsigned ColumnLimit,
+ unsigned LineIndex,
+ unsigned PreviousEndColumn,
+ unsigned ColumnLimit,
llvm::Regex &CommentPragmasRegex) const {
if (!mayReflow(LineIndex, CommentPragmasRegex))
return Split(StringRef::npos, 0);
StringRef TrimmedContent = Content[LineIndex].ltrim(Blanks);
- Split Result = getReflowSplit(TrimmedContent, ReflowPrefix, PreviousEndColumn,
- ColumnLimit);
- // Result is relative to TrimmedContent. Adapt it relative to
- // Content[LineIndex].
- if (Result.first != StringRef::npos)
- Result.first += Content[LineIndex].size() - TrimmedContent.size();
- return Result;
+ return getReflowSplit(TrimmedContent, ReflowPrefix, PreviousEndColumn,
+ ColumnLimit);
}
unsigned BreakableBlockComment::getReflownColumn(
@@ -636,12 +633,17 @@ void BreakableBlockComment::replaceWhitespaceBefore(
/*CurrentPrefix=*/ReflowPrefix, InPPDirective, /*Newlines=*/0,
/*Spaces=*/0);
// Check if we need to also insert a break at the whitespace range.
+ // For this we first adapt the reflow split relative to the beginning of the
+ // content.
// Note that we don't need a penalty for this break, since it doesn't change
// the total number of lines.
+ Split BreakSplit = SplitBefore;
+ BreakSplit.first += TrimmedContent.data() - Content[LineIndex].data();
unsigned ReflownColumn =
getReflownColumn(TrimmedContent, LineIndex, PreviousEndColumn);
- if (ReflownColumn > ColumnLimit)
- insertBreak(LineIndex, 0, SplitBefore, Whitespaces);
+ if (ReflownColumn > ColumnLimit) {
+ insertBreak(LineIndex, 0, BreakSplit, Whitespaces);
+ }
return;
}
OpenPOWER on IntegriCloud