diff options
author | Alexander Kornienko <alexfh@google.com> | 2013-09-05 14:08:34 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2013-09-05 14:08:34 +0000 |
commit | ebb43caae250d5d5f3f853392460456a0a58abb1 (patch) | |
tree | 29874d67e67d34dd9d144d1ad8a29c2de1906a8b /clang/lib/Format/ContinuationIndenter.cpp | |
parent | 15832288f4feac7abfbccdbb567a7cd456913ae5 (diff) | |
download | bcm5719-llvm-ebb43caae250d5d5f3f853392460456a0a58abb1.tar.gz bcm5719-llvm-ebb43caae250d5d5f3f853392460456a0a58abb1.zip |
Handle zero-width and double-width characters in string literals and comments.
Summary:
Count column width instead of the number of code points. This also
includes correct handling of tabs inside string literals and comments (with an
exception of multiline string literals/comments, where tabs are present before
the first escaped newline).
Reviewers: djasper, klimek
Reviewed By: klimek
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1601
llvm-svn: 190052
Diffstat (limited to 'clang/lib/Format/ContinuationIndenter.cpp')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index c894a4b29e2..9e84ea770fe 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -623,10 +623,10 @@ ContinuationIndenter::addMultilineStringLiteral(const FormatToken &Current, State.Stack[i].BreakBeforeParameter = true; unsigned ColumnsUsed = - State.Column - Current.CodePointCount + Current.CodePointsInFirstLine; + State.Column - Current.CodePointCount + Current.FirstLineColumnWidth; // We can only affect layout of the first and the last line, so the penalty // for all other lines is constant, and we ignore it. - State.Column = Current.CodePointsInLastLine; + State.Column = Current.LastLineColumnWidth; if (ColumnsUsed > getColumnLimit(State)) return Style.PenaltyExcessCharacter * (ColumnsUsed - getColumnLimit(State)); @@ -659,14 +659,14 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, return 0; Token.reset(new BreakableStringLiteral( - Current, StartColumn, State.Line->InPPDirective, Encoding)); + Current, StartColumn, State.Line->InPPDirective, Encoding, Style)); } else if (Current.Type == TT_BlockComment && Current.isTrailingComment()) { unsigned OriginalStartColumn = SourceMgr.getSpellingColumnNumber(Current.getStartOfNonWhitespace()) - 1; Token.reset(new BreakableBlockComment( - Style, Current, StartColumn, OriginalStartColumn, !Current.Previous, - State.Line->InPPDirective, Encoding)); + Current, StartColumn, OriginalStartColumn, !Current.Previous, + State.Line->InPPDirective, Encoding, Style)); } else if (Current.Type == TT_LineComment && (Current.Previous == NULL || Current.Previous->Type != TT_ImplicitStringLiteral)) { @@ -678,12 +678,12 @@ unsigned ContinuationIndenter::breakProtrudingToken(const FormatToken &Current, // leading whitespace in consecutive lines when changing indentation of // the first line similar to what we do with block comments. if (Current.isMultiline()) { - State.Column = StartColumn + Current.CodePointsInFirstLine; + State.Column = StartColumn + Current.FirstLineColumnWidth; return 0; } - Token.reset(new BreakableLineComment(Current, StartColumn, - State.Line->InPPDirective, Encoding)); + Token.reset(new BreakableLineComment( + Current, StartColumn, State.Line->InPPDirective, Encoding, Style)); } else { return 0; } |