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/BreakableToken.h | |
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/BreakableToken.h')
-rw-r--r-- | clang/lib/Format/BreakableToken.h | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/clang/lib/Format/BreakableToken.h b/clang/lib/Format/BreakableToken.h index 90b78ac03a7..65b90152514 100644 --- a/clang/lib/Format/BreakableToken.h +++ b/clang/lib/Format/BreakableToken.h @@ -67,12 +67,14 @@ public: protected: BreakableToken(const FormatToken &Tok, bool InPPDirective, - encoding::Encoding Encoding) - : Tok(Tok), InPPDirective(InPPDirective), Encoding(Encoding) {} + encoding::Encoding Encoding, const FormatStyle &Style) + : Tok(Tok), InPPDirective(InPPDirective), Encoding(Encoding), + Style(Style) {} const FormatToken &Tok; const bool InPPDirective; const encoding::Encoding Encoding; + const FormatStyle &Style; }; /// \brief Base class for single line tokens that can be broken. @@ -88,7 +90,8 @@ public: protected: BreakableSingleLineToken(const FormatToken &Tok, unsigned StartColumn, StringRef Prefix, StringRef Postfix, - bool InPPDirective, encoding::Encoding Encoding); + bool InPPDirective, encoding::Encoding Encoding, + const FormatStyle &Style); // The column in which the token starts. unsigned StartColumn; @@ -107,7 +110,8 @@ public: /// \p StartColumn specifies the column in which the token will start /// after formatting. BreakableStringLiteral(const FormatToken &Tok, unsigned StartColumn, - bool InPPDirective, encoding::Encoding Encoding); + bool InPPDirective, encoding::Encoding Encoding, + const FormatStyle &Style); virtual Split getSplit(unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit) const; @@ -122,7 +126,8 @@ public: /// \p StartColumn specifies the column in which the comment will start /// after formatting. BreakableLineComment(const FormatToken &Token, unsigned StartColumn, - bool InPPDirective, encoding::Encoding Encoding); + bool InPPDirective, encoding::Encoding Encoding, + const FormatStyle &Style); virtual Split getSplit(unsigned LineIndex, unsigned TailOffset, unsigned ColumnLimit) const; @@ -144,10 +149,10 @@ public: /// after formatting, while \p OriginalStartColumn specifies in which /// column the comment started before formatting. /// If the comment starts a line after formatting, set \p FirstInLine to true. - BreakableBlockComment(const FormatStyle &Style, const FormatToken &Token, - unsigned StartColumn, unsigned OriginaStartColumn, - bool FirstInLine, bool InPPDirective, - encoding::Encoding Encoding); + BreakableBlockComment(const FormatToken &Token, unsigned StartColumn, + unsigned OriginaStartColumn, bool FirstInLine, + bool InPPDirective, encoding::Encoding Encoding, + const FormatStyle &Style); virtual unsigned getLineCount() const; virtual unsigned getLineLengthAfterSplit(unsigned LineIndex, @@ -172,8 +177,7 @@ private: // Sets StartOfLineColumn to the intended column in which the text at // Lines[LineIndex] starts (note that the decoration, if present, is not // considered part of the text). - void adjustWhitespace(const FormatStyle &Style, unsigned LineIndex, - int IndentDelta); + void adjustWhitespace(unsigned LineIndex, int IndentDelta); // Returns the column at which the text in line LineIndex starts, when broken // at TailOffset. Note that the decoration (if present) is not considered part |