summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-09-10 09:38:25 +0000
committerAlexander Kornienko <alexfh@google.com>2013-09-10 09:38:25 +0000
commit39856b71a6e233d9ac8606213c820b17f8f965ea (patch)
treeda171e82ae8eea20bb119afa9b93d204178bf3ae /clang/lib/Format/TokenAnnotator.cpp
parent3767ccf3187e4494e30a7f624d7e8e37eb4527de (diff)
downloadbcm5719-llvm-39856b71a6e233d9ac8606213c820b17f8f965ea.tar.gz
bcm5719-llvm-39856b71a6e233d9ac8606213c820b17f8f965ea.zip
Calculate and store ColumnWidth instead of CodePointCount in FormatTokens.
Summary: This fixes various issues with mixed tabs and spaces handling, e.g. when realigning block comments. Reviewers: klimek, djasper Reviewed By: djasper CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1608 llvm-svn: 190395
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index e3cd2105e63..c0897ca68cb 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -326,10 +326,10 @@ private:
Line.First->Type == TT_ObjCMethodSpecifier) {
Tok->Type = TT_ObjCMethodExpr;
Tok->Previous->Type = TT_ObjCSelectorName;
- if (Tok->Previous->CodePointCount >
+ if (Tok->Previous->ColumnWidth >
Contexts.back().LongestObjCSelectorName) {
Contexts.back().LongestObjCSelectorName =
- Tok->Previous->CodePointCount;
+ Tok->Previous->ColumnWidth;
}
if (Contexts.back().FirstObjCSelectorName == NULL)
Contexts.back().FirstObjCSelectorName = Tok->Previous;
@@ -1022,7 +1022,8 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
}
void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) {
- Line.First->TotalLength = Line.First->CodePointCount;
+ Line.First->TotalLength =
+ Line.First->IsMultiline ? Style.ColumnLimit : Line.First->ColumnWidth;
if (!Line.First->Next)
return;
FormatToken *Current = Line.First->Next;
@@ -1055,11 +1056,11 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) {
Current->CanBreakBefore =
Current->MustBreakBefore || canBreakBefore(Line, *Current);
if (Current->MustBreakBefore || !Current->Children.empty() ||
- (Current->is(tok::string_literal) && Current->isMultiline()))
+ Current->IsMultiline)
Current->TotalLength = Current->Previous->TotalLength + Style.ColumnLimit;
else
Current->TotalLength = Current->Previous->TotalLength +
- Current->CodePointCount +
+ Current->ColumnWidth +
Current->SpacesRequiredBefore;
// FIXME: Only calculate this if CanBreakBefore is true once static
// initializers etc. are sorted out.
@@ -1095,7 +1096,7 @@ void TokenAnnotator::calculateUnbreakableTailLengths(AnnotatedLine &Line) {
UnbreakableTailLength = 0;
} else {
UnbreakableTailLength +=
- Current->CodePointCount + Current->SpacesRequiredBefore;
+ Current->ColumnWidth + Current->SpacesRequiredBefore;
}
Current = Current->Previous;
}
OpenPOWER on IntegriCloud