aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/WhitespaceManager.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-05-27 15:23:34 +0000
committerManuel Klimek <klimek@google.com>2013-05-27 15:23:34 +0000
commit9043c74f497bfbb8ee708f5aee6229b2f212bc0b (patch)
tree1f8b6362db892b94e13812ad57ca180dd70d982c /clang/lib/Format/WhitespaceManager.cpp
parent111bb2ef8d117e0a51bdfaaa6fe8c8f407141c08 (diff)
downloadllvm-9043c74f497bfbb8ee708f5aee6229b2f212bc0b.zip
llvm-9043c74f497bfbb8ee708f5aee6229b2f212bc0b.tar.gz
llvm-9043c74f497bfbb8ee708f5aee6229b2f212bc0b.tar.bz2
Major refactoring of BreakableToken.
Unify handling of whitespace when breaking protruding tokens with other whitespace replacements. As a side effect, the BreakableToken structure changed significantly: - have a common base class for single-line breakable tokens, as they are much more similar - revamp handling of multi-line comments; we now calculate the information about lines in multi-line comments similar to normal tokens, and always issue replacements As a result, we were able to get rid of special casing of trailing whitespace deletion for comments in the whitespace manager and the BreakableToken and fixed bugs related to tab handling and escaped newlines. llvm-svn: 182738
Diffstat (limited to 'clang/lib/Format/WhitespaceManager.cpp')
-rw-r--r--clang/lib/Format/WhitespaceManager.cpp19
1 files changed, 0 insertions, 19 deletions
diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp
index f7b65fc..daf6369 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -46,19 +46,6 @@ void WhitespaceManager::replaceWhitespace(const AnnotatedToken &Tok,
true, Tok.FormatTok.WhitespaceRange,
Spaces, StartOfTokenColumn, Newlines, "", "", Tok.FormatTok.Tok.getKind(),
InPPDirective && !Tok.FormatTok.IsFirst));
-
- // Align line comments if they are trailing or if they continue other
- // trailing comments.
- // FIXME: Pull this out and generalize so it works the same way in broken
- // comments and unbroken comments with trailing whitespace.
- if (Tok.isTrailingComment()) {
- SourceLocation TokenEndLoc = Tok.FormatTok.getStartOfNonWhitespace()
- .getLocWithOffset(Tok.FormatTok.TokenLength);
- // Remove the comment's trailing whitespace.
- if (Tok.FormatTok.TrailingWhiteSpaceLength != 0)
- Replaces.insert(tooling::Replacement(
- SourceMgr, TokenEndLoc, Tok.FormatTok.TrailingWhiteSpaceLength, ""));
- }
}
void WhitespaceManager::addUntouchableToken(const FormatToken &Tok,
@@ -86,12 +73,6 @@ void WhitespaceManager::breakToken(const FormatToken &Tok, unsigned Offset,
tok::unknown, InPPDirective && !Tok.IsFirst));
}
-void WhitespaceManager::addReplacement(const SourceLocation &SourceLoc,
- unsigned ReplaceChars, StringRef Text) {
- Replaces.insert(
- tooling::Replacement(SourceMgr, SourceLoc, ReplaceChars, Text));
-}
-
const tooling::Replacements &WhitespaceManager::generateReplacements() {
if (Changes.empty())
return Replaces;