diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-11-12 17:50:13 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-11-12 17:50:13 +0000 |
commit | 875395f9f88aec48006f39aa02e1226208300230 (patch) | |
tree | 77237d1a30c83d7815cc240a1c9bef81fc5e9c09 /clang/lib/Format/BreakableToken.cpp | |
parent | 3f902b27880014413596402f9d9b927054684be1 (diff) | |
download | bcm5719-llvm-875395f9f88aec48006f39aa02e1226208300230.tar.gz bcm5719-llvm-875395f9f88aec48006f39aa02e1226208300230.zip |
Remove extra whitespace instead of breaking the line in comments when possible.
Summary: Solves the problem described in http://llvm.org/PR17756
Reviewers: klimek
Reviewed By: klimek
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D2131
llvm-svn: 194493
Diffstat (limited to 'clang/lib/Format/BreakableToken.cpp')
-rw-r--r-- | clang/lib/Format/BreakableToken.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp index 97475780f4e..d720ce990b5 100644 --- a/clang/lib/Format/BreakableToken.cpp +++ b/clang/lib/Format/BreakableToken.cpp @@ -215,7 +215,16 @@ void BreakableLineComment::insertBreak(unsigned LineIndex, unsigned TailOffset, WhitespaceManager &Whitespaces) { Whitespaces.replaceWhitespaceInToken( Tok, OriginalPrefix.size() + TailOffset + Split.first, Split.second, - Postfix, Prefix, InPPDirective, 1, IndentLevel, StartColumn); + Postfix, Prefix, InPPDirective, /*Newlines=*/1, IndentLevel, StartColumn); +} + +void BreakableLineComment::replaceWhitespace(unsigned LineIndex, + unsigned TailOffset, Split Split, + WhitespaceManager &Whitespaces) { + Whitespaces.replaceWhitespaceInToken( + Tok, OriginalPrefix.size() + TailOffset + Split.first, Split.second, "", + "", /*InPPDirective=*/false, /*Newlines=*/0, /*IndentLevel=*/0, + /*Spaces=*/1); } void @@ -223,7 +232,9 @@ BreakableLineComment::replaceWhitespaceBefore(unsigned LineIndex, WhitespaceManager &Whitespaces) { if (OriginalPrefix != Prefix) { Whitespaces.replaceWhitespaceInToken(Tok, OriginalPrefix.size(), 0, "", "", - false, 0, /*IndentLevel=*/0, 1); + /*InPPDirective=*/false, + /*Newlines=*/0, /*IndentLevel=*/0, + /*Spaces=*/1); } } @@ -374,6 +385,18 @@ void BreakableBlockComment::insertBreak(unsigned LineIndex, unsigned TailOffset, IndentLevel, IndentAtLineBreak - Decoration.size()); } +void BreakableBlockComment::replaceWhitespace(unsigned LineIndex, + unsigned TailOffset, Split Split, + WhitespaceManager &Whitespaces) { + StringRef Text = Lines[LineIndex].substr(TailOffset); + unsigned BreakOffsetInToken = + Text.data() - Tok.TokenText.data() + Split.first; + unsigned CharsToRemove = Split.second; + Whitespaces.replaceWhitespaceInToken( + Tok, BreakOffsetInToken, CharsToRemove, "", "", /*InPPDirective=*/false, + /*Newlines=*/0, /*IndentLevel=*/0, /*Spaces=*/1); +} + void BreakableBlockComment::replaceWhitespaceBefore(unsigned LineIndex, WhitespaceManager &Whitespaces) { |