blob: 29fafb825052d4fa9b1602861e9a566e4f719ac5 [file] [log] [blame]
Alexander Kornienko4b672072013-06-03 16:45:03 +00001//===--- FormatToken.h - Format C++ code ------------------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
11/// \brief This file contains the declaration of the FormatToken, a wrapper
12/// around Token with additional information related to formatting.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_CLANG_FORMAT_FORMAT_TOKEN_H
17#define LLVM_CLANG_FORMAT_FORMAT_TOKEN_H
18
19#include "clang/Basic/OperatorPrecedence.h"
Daniel Jasper8de9ed02013-08-22 15:00:41 +000020#include "clang/Format/Format.h"
Alexander Kornienko4b672072013-06-03 16:45:03 +000021#include "clang/Lex/Lexer.h"
Daniel Jasper8de9ed02013-08-22 15:00:41 +000022#include "llvm/ADT/OwningPtr.h"
Alexander Kornienko4b672072013-06-03 16:45:03 +000023
24namespace clang {
25namespace format {
26
27enum TokenType {
Daniel Jasper1db6c382013-10-22 15:30:28 +000028 TT_ArrayInitializerLSquare,
29 TT_ArraySubscriptLSquare,
Alexander Kornienko4b672072013-06-03 16:45:03 +000030 TT_BinaryOperator,
Alexander Kornienko60d1b042013-10-10 13:36:20 +000031 TT_BitFieldColon,
Alexander Kornienko4b672072013-06-03 16:45:03 +000032 TT_BlockComment,
33 TT_CastRParen,
34 TT_ConditionalExpr,
35 TT_CtorInitializerColon,
Daniel Jaspere33d4af2013-07-26 16:56:36 +000036 TT_CtorInitializerComma,
Alexander Kornienko4b672072013-06-03 16:45:03 +000037 TT_DesignatedInitializerPeriod,
Daniel Jasperb596fb22013-10-24 10:31:50 +000038 TT_DictLiteral,
Alexander Kornienko4b672072013-06-03 16:45:03 +000039 TT_ImplicitStringLiteral,
40 TT_InlineASMColon,
41 TT_InheritanceColon,
Alexander Kornienko3cfa9732013-11-20 16:33:05 +000042 TT_FunctionLBrace,
Alexander Kornienko4b672072013-06-03 16:45:03 +000043 TT_FunctionTypeLParen,
Daniel Jasper9fe0e8d2013-09-05 09:29:45 +000044 TT_LambdaLSquare,
Alexander Kornienko4b672072013-06-03 16:45:03 +000045 TT_LineComment,
Alexander Kornienko4b672072013-06-03 16:45:03 +000046 TT_ObjCBlockLParen,
47 TT_ObjCDecl,
Alexander Kornienko4b672072013-06-03 16:45:03 +000048 TT_ObjCForIn,
49 TT_ObjCMethodExpr,
50 TT_ObjCMethodSpecifier,
51 TT_ObjCProperty,
52 TT_ObjCSelectorName,
53 TT_OverloadedOperator,
54 TT_OverloadedOperatorLParen,
55 TT_PointerOrReference,
56 TT_PureVirtualSpecifier,
57 TT_RangeBasedForLoopColon,
58 TT_StartOfName,
59 TT_TemplateCloser,
60 TT_TemplateOpener,
Daniel Jasper43e6a282013-12-16 15:01:54 +000061 TT_TrailingAnnotation,
Daniel Jasper6cdec7c2013-07-09 14:36:48 +000062 TT_TrailingReturnArrow,
Alexander Kornienko4b672072013-06-03 16:45:03 +000063 TT_TrailingUnaryOperator,
64 TT_UnaryOperator,
65 TT_Unknown
66};
67
Daniel Jasperb1f74a82013-07-09 09:06:29 +000068// Represents what type of block a set of braces open.
69enum BraceBlockKind {
70 BK_Unknown,
71 BK_Block,
72 BK_BracedInit
73};
74
Daniel Jasperb10cbc42013-07-10 14:02:49 +000075// The packing kind of a function's parameters.
76enum ParameterPackingKind {
77 PPK_BinPacked,
78 PPK_OnePerLine,
79 PPK_Inconclusive
80};
81
Manuel Klimek71814b42013-10-11 21:25:45 +000082enum FormatDecision {
83 FD_Unformatted,
84 FD_Continue,
85 FD_Break
86};
87
Daniel Jasper8de9ed02013-08-22 15:00:41 +000088class TokenRole;
Daniel Jasper9fe0e8d2013-09-05 09:29:45 +000089class AnnotatedLine;
Daniel Jasper8de9ed02013-08-22 15:00:41 +000090
Alexander Kornienko4b672072013-06-03 16:45:03 +000091/// \brief A wrapper around a \c Token storing information about the
Alp Tokerf6a24ce2013-12-05 16:25:25 +000092/// whitespace characters preceding it.
Alexander Kornienko4b672072013-06-03 16:45:03 +000093struct FormatToken {
94 FormatToken()
Alexander Kornienko632abb92013-09-02 13:58:14 +000095 : NewlinesBefore(0), HasUnescapedNewline(false), LastNewlineOffset(0),
Alexander Kornienko39856b72013-09-10 09:38:25 +000096 ColumnWidth(0), LastLineColumnWidth(0), IsMultiline(false),
Alexander Kornienko632abb92013-09-02 13:58:14 +000097 IsFirst(false), MustBreakBefore(false), IsUnterminatedLiteral(false),
Alexander Kornienkod7b837e2013-08-29 17:32:57 +000098 BlockKind(BK_Unknown), Type(TT_Unknown), SpacesRequiredBefore(0),
99 CanBreakBefore(false), ClosesTemplateDeclaration(false),
100 ParameterCount(0), PackingKind(PPK_Inconclusive), TotalLength(0),
Daniel Jasper63af7c42013-12-09 14:40:19 +0000101 UnbreakableTailLength(0), BindingStrength(0), NestingLevel(0),
102 SplitPenalty(0), LongestObjCSelectorName(0), FakeRParens(0),
Daniel Jasper562ecd42013-09-06 08:08:14 +0000103 StartsBinaryExpression(false), EndsBinaryExpression(false),
104 LastInChainOfCalls(false), PartOfMultiVariableDeclStmt(false),
Manuel Klimek71814b42013-10-11 21:25:45 +0000105 MatchingParen(NULL), Previous(NULL), Next(NULL),
106 Decision(FD_Unformatted), Finalized(false) {}
Alexander Kornienko4b672072013-06-03 16:45:03 +0000107
108 /// \brief The \c Token.
109 Token Tok;
110
111 /// \brief The number of newlines immediately before the \c Token.
112 ///
113 /// This can be used to determine what the user wrote in the original code
114 /// and thereby e.g. leave an empty line between two function definitions.
115 unsigned NewlinesBefore;
116
117 /// \brief Whether there is at least one unescaped newline before the \c
118 /// Token.
119 bool HasUnescapedNewline;
120
Alp Tokerf6a24ce2013-12-05 16:25:25 +0000121 /// \brief The range of the whitespace immediately preceding the \c Token.
Alexander Kornienko4b672072013-06-03 16:45:03 +0000122 SourceRange WhitespaceRange;
123
124 /// \brief The offset just past the last '\n' in this token's leading
125 /// whitespace (relative to \c WhiteSpaceStart). 0 if there is no '\n'.
126 unsigned LastNewlineOffset;
127
Alexander Kornienko39856b72013-09-10 09:38:25 +0000128 /// \brief The width of the non-whitespace parts of the token (or its first
129 /// line for multi-line tokens) in columns.
Alexander Kornienkoffcc0102013-06-05 14:09:10 +0000130 /// We need this to correctly measure number of columns a token spans.
Alexander Kornienko39856b72013-09-10 09:38:25 +0000131 unsigned ColumnWidth;
Alexander Kornienko4b672072013-06-03 16:45:03 +0000132
Alexander Kornienko39856b72013-09-10 09:38:25 +0000133 /// \brief Contains the width in columns of the last line of a multi-line
Alexander Kornienko632abb92013-09-02 13:58:14 +0000134 /// token.
Alexander Kornienkoebb43ca2013-09-05 14:08:34 +0000135 unsigned LastLineColumnWidth;
Alexander Kornienko632abb92013-09-02 13:58:14 +0000136
Alexander Kornienko39856b72013-09-10 09:38:25 +0000137 /// \brief Whether the token text contains newlines (escaped or not).
138 bool IsMultiline;
Alexander Kornienko632abb92013-09-02 13:58:14 +0000139
Alexander Kornienko4b672072013-06-03 16:45:03 +0000140 /// \brief Indicates that this is the first token.
141 bool IsFirst;
142
143 /// \brief Whether there must be a line break before this token.
144 ///
145 /// This happens for example when a preprocessor directive ended directly
146 /// before the token.
147 bool MustBreakBefore;
148
149 /// \brief Returns actual token start location without leading escaped
150 /// newlines and whitespace.
151 ///
152 /// This can be different to Tok.getLocation(), which includes leading escaped
153 /// newlines.
154 SourceLocation getStartOfNonWhitespace() const {
155 return WhitespaceRange.getEnd();
156 }
157
158 /// \brief The raw text of the token.
159 ///
160 /// Contains the raw token text without leading whitespace and without leading
161 /// escaped newlines.
162 StringRef TokenText;
163
Daniel Jasper8369aa52013-07-16 20:28:33 +0000164 /// \brief Set to \c true if this token is an unterminated literal.
165 bool IsUnterminatedLiteral;
166
Daniel Jasperb1f74a82013-07-09 09:06:29 +0000167 /// \brief Contains the kind of block if this token is a brace.
168 BraceBlockKind BlockKind;
169
Alexander Kornienko4b672072013-06-03 16:45:03 +0000170 TokenType Type;
171
Daniel Jasper8de9ed02013-08-22 15:00:41 +0000172 /// \brief The number of spaces that should be inserted before this token.
Alexander Kornienko4b672072013-06-03 16:45:03 +0000173 unsigned SpacesRequiredBefore;
Daniel Jasper8de9ed02013-08-22 15:00:41 +0000174
175 /// \brief \c true if it is allowed to break before this token.
Alexander Kornienko4b672072013-06-03 16:45:03 +0000176 bool CanBreakBefore;
177
178 bool ClosesTemplateDeclaration;
179
180 /// \brief Number of parameters, if this is "(", "[" or "<".
181 ///
182 /// This is initialized to 1 as we don't need to distinguish functions with
183 /// 0 parameters from functions with 1 parameter. Thus, we can simply count
184 /// the number of commas.
185 unsigned ParameterCount;
186
Daniel Jasper8de9ed02013-08-22 15:00:41 +0000187 /// \brief A token can have a special role that can carry extra information
188 /// about the token's formatting.
189 llvm::OwningPtr<TokenRole> Role;
190
Daniel Jasperb10cbc42013-07-10 14:02:49 +0000191 /// \brief If this is an opening parenthesis, how are the parameters packed?
192 ParameterPackingKind PackingKind;
193
Manuel Klimek31c85922013-08-29 15:21:40 +0000194 /// \brief The total length of the unwrapped line up to and including this
195 /// token.
Alexander Kornienko4b672072013-06-03 16:45:03 +0000196 unsigned TotalLength;
197
Alexander Kornienko39856b72013-09-10 09:38:25 +0000198 /// \brief The original 0-based column of this token, including expanded tabs.
199 /// The configured TabWidth is used as tab width.
Manuel Klimek31c85922013-08-29 15:21:40 +0000200 unsigned OriginalColumn;
201
Alexander Kornienko4b672072013-06-03 16:45:03 +0000202 /// \brief The length of following tokens until the next natural split point,
203 /// or the next token that can be broken.
204 unsigned UnbreakableTailLength;
205
206 // FIXME: Come up with a 'cleaner' concept.
207 /// \brief The binding strength of a token. This is a combined value of
208 /// operator precedence, parenthesis nesting, etc.
209 unsigned BindingStrength;
210
Daniel Jasper63af7c42013-12-09 14:40:19 +0000211 /// \brief The nesting level of this token, i.e. the number of surrounding (),
212 /// [], {} or <>.
213 unsigned NestingLevel;
214
Alexander Kornienko4b672072013-06-03 16:45:03 +0000215 /// \brief Penalty for inserting a line break before this token.
216 unsigned SplitPenalty;
217
218 /// \brief If this is the first ObjC selector name in an ObjC method
219 /// definition or call, this contains the length of the longest name.
Daniel Jasperb88b25f2013-12-23 07:29:06 +0000220 ///
221 /// This being set to 0 means that the selectors should not be colon-aligned,
222 /// e.g. because several of them are block-type.
Alexander Kornienko4b672072013-06-03 16:45:03 +0000223 unsigned LongestObjCSelectorName;
224
225 /// \brief Stores the number of required fake parentheses and the
226 /// corresponding operator precedence.
227 ///
228 /// If multiple fake parentheses start at a token, this vector stores them in
229 /// reverse order, i.e. inner fake parenthesis first.
230 SmallVector<prec::Level, 4> FakeLParens;
231 /// \brief Insert this many fake ) after this token for correct indentation.
232 unsigned FakeRParens;
233
Daniel Jasper562ecd42013-09-06 08:08:14 +0000234 /// \brief \c true if this token starts a binary expression, i.e. has at least
235 /// one fake l_paren with a precedence greater than prec::Unknown.
236 bool StartsBinaryExpression;
237 /// \brief \c true if this token ends a binary expression.
238 bool EndsBinaryExpression;
239
Alexander Kornienko4b672072013-06-03 16:45:03 +0000240 /// \brief Is this the last "." or "->" in a builder-type call?
241 bool LastInChainOfCalls;
242
243 /// \brief Is this token part of a \c DeclStmt defining multiple variables?
244 ///
245 /// Only set if \c Type == \c TT_StartOfName.
246 bool PartOfMultiVariableDeclStmt;
247
248 bool is(tok::TokenKind Kind) const { return Tok.is(Kind); }
249
250 bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const {
251 return is(K1) || is(K2);
252 }
253
254 bool isOneOf(tok::TokenKind K1, tok::TokenKind K2, tok::TokenKind K3) const {
255 return is(K1) || is(K2) || is(K3);
256 }
257
258 bool isOneOf(tok::TokenKind K1, tok::TokenKind K2, tok::TokenKind K3,
259 tok::TokenKind K4, tok::TokenKind K5 = tok::NUM_TOKENS,
260 tok::TokenKind K6 = tok::NUM_TOKENS,
261 tok::TokenKind K7 = tok::NUM_TOKENS,
262 tok::TokenKind K8 = tok::NUM_TOKENS,
263 tok::TokenKind K9 = tok::NUM_TOKENS,
264 tok::TokenKind K10 = tok::NUM_TOKENS,
265 tok::TokenKind K11 = tok::NUM_TOKENS,
266 tok::TokenKind K12 = tok::NUM_TOKENS) const {
267 return is(K1) || is(K2) || is(K3) || is(K4) || is(K5) || is(K6) || is(K7) ||
268 is(K8) || is(K9) || is(K10) || is(K11) || is(K12);
269 }
270
271 bool isNot(tok::TokenKind Kind) const { return Tok.isNot(Kind); }
Daniel Jasper04b6a082013-12-20 06:22:01 +0000272 bool isStringLiteral() const { return tok::isStringLiteral(Tok.getKind()); }
Alexander Kornienko4b672072013-06-03 16:45:03 +0000273
274 bool isObjCAtKeyword(tok::ObjCKeywordKind Kind) const {
275 return Tok.isObjCAtKeyword(Kind);
276 }
277
278 bool isAccessSpecifier(bool ColonRequired = true) const {
279 return isOneOf(tok::kw_public, tok::kw_protected, tok::kw_private) &&
280 (!ColonRequired || (Next && Next->is(tok::colon)));
281 }
282
Daniel Jaspercb51cf42014-01-16 09:11:55 +0000283 /// \brief Determine whether the token is a simple-type-specifier.
284 bool isSimpleTypeSpecifier() const;
285
Alexander Kornienko4b672072013-06-03 16:45:03 +0000286 bool isObjCAccessSpecifier() const {
287 return is(tok::at) && Next && (Next->isObjCAtKeyword(tok::objc_public) ||
288 Next->isObjCAtKeyword(tok::objc_protected) ||
289 Next->isObjCAtKeyword(tok::objc_package) ||
290 Next->isObjCAtKeyword(tok::objc_private));
291 }
292
293 /// \brief Returns whether \p Tok is ([{ or a template opening <.
294 bool opensScope() const {
295 return isOneOf(tok::l_paren, tok::l_brace, tok::l_square) ||
296 Type == TT_TemplateOpener;
Alexander Kornienko4b672072013-06-03 16:45:03 +0000297 }
Nico Weber0f987a62013-06-25 19:25:12 +0000298 /// \brief Returns whether \p Tok is )]} or a template closing >.
Alexander Kornienko4b672072013-06-03 16:45:03 +0000299 bool closesScope() const {
300 return isOneOf(tok::r_paren, tok::r_brace, tok::r_square) ||
301 Type == TT_TemplateCloser;
302 }
303
Daniel Jasper4c6e0052013-08-27 14:24:43 +0000304 /// \brief Returns \c true if this is a "." or "->" accessing a member.
305 bool isMemberAccess() const {
306 return isOneOf(tok::arrow, tok::period) &&
307 Type != TT_DesignatedInitializerPeriod;
308 }
309
Alexander Kornienko4b672072013-06-03 16:45:03 +0000310 bool isUnaryOperator() const {
311 switch (Tok.getKind()) {
312 case tok::plus:
313 case tok::plusplus:
314 case tok::minus:
315 case tok::minusminus:
316 case tok::exclaim:
317 case tok::tilde:
318 case tok::kw_sizeof:
319 case tok::kw_alignof:
320 return true;
321 default:
322 return false;
323 }
324 }
Daniel Jasper4c6e0052013-08-27 14:24:43 +0000325
Alexander Kornienko4b672072013-06-03 16:45:03 +0000326 bool isBinaryOperator() const {
327 // Comma is a binary operator, but does not behave as such wrt. formatting.
328 return getPrecedence() > prec::Comma;
329 }
Daniel Jasper4c6e0052013-08-27 14:24:43 +0000330
Alexander Kornienko4b672072013-06-03 16:45:03 +0000331 bool isTrailingComment() const {
332 return is(tok::comment) && (!Next || Next->NewlinesBefore > 0);
333 }
334
335 prec::Level getPrecedence() const {
336 return getBinOpPrecedence(Tok.getKind(), true, true);
337 }
338
339 /// \brief Returns the previous token ignoring comments.
Alexander Kornienko1efe0a02013-07-04 14:47:51 +0000340 FormatToken *getPreviousNonComment() const {
Alexander Kornienko4b672072013-06-03 16:45:03 +0000341 FormatToken *Tok = Previous;
342 while (Tok != NULL && Tok->is(tok::comment))
343 Tok = Tok->Previous;
344 return Tok;
345 }
346
347 /// \brief Returns the next token ignoring comments.
Alexander Kornienko1efe0a02013-07-04 14:47:51 +0000348 const FormatToken *getNextNonComment() const {
Alexander Kornienko4b672072013-06-03 16:45:03 +0000349 const FormatToken *Tok = Next;
350 while (Tok != NULL && Tok->is(tok::comment))
351 Tok = Tok->Next;
352 return Tok;
353 }
354
Daniel Jasperb8f61682013-10-22 15:45:58 +0000355 /// \brief Returns \c true if this tokens starts a block-type list, i.e. a
356 /// list that should be indented with a block indent.
357 bool opensBlockTypeList(const FormatStyle &Style) const {
358 return Type == TT_ArrayInitializerLSquare ||
359 (is(tok::l_brace) &&
Daniel Jasperb596fb22013-10-24 10:31:50 +0000360 (BlockKind == BK_Block || Type == TT_DictLiteral ||
Daniel Jasperb8f61682013-10-22 15:45:58 +0000361 !Style.Cpp11BracedListStyle));
362 }
363
364 /// \brief Same as opensBlockTypeList, but for the closing token.
Daniel Jasper1db6c382013-10-22 15:30:28 +0000365 bool closesBlockTypeList(const FormatStyle &Style) const {
Daniel Jasperb8f61682013-10-22 15:45:58 +0000366 return MatchingParen && MatchingParen->opensBlockTypeList(Style);
Daniel Jasper1db6c382013-10-22 15:30:28 +0000367 }
368
Alexander Kornienko4b672072013-06-03 16:45:03 +0000369 FormatToken *MatchingParen;
370
371 FormatToken *Previous;
372 FormatToken *Next;
373
Daniel Jasper9fe0e8d2013-09-05 09:29:45 +0000374 SmallVector<AnnotatedLine *, 1> Children;
375
Manuel Klimek71814b42013-10-11 21:25:45 +0000376 /// \brief Stores the formatting decision for the token once it was made.
377 FormatDecision Decision;
378
379 /// \brief If \c true, this token has been fully formatted (indented and
380 /// potentially re-formatted inside), and we do not allow further formatting
381 /// changes.
382 bool Finalized;
383
Alexander Kornienko4b672072013-06-03 16:45:03 +0000384private:
385 // Disallow copying.
Craig Topper411294d2013-07-01 04:07:34 +0000386 FormatToken(const FormatToken &) LLVM_DELETED_FUNCTION;
387 void operator=(const FormatToken &) LLVM_DELETED_FUNCTION;
Alexander Kornienko4b672072013-06-03 16:45:03 +0000388};
389
Daniel Jasper8de9ed02013-08-22 15:00:41 +0000390class ContinuationIndenter;
391struct LineState;
392
393class TokenRole {
394public:
395 TokenRole(const FormatStyle &Style) : Style(Style) {}
396 virtual ~TokenRole();
397
398 /// \brief After the \c TokenAnnotator has finished annotating all the tokens,
399 /// this function precomputes required information for formatting.
400 virtual void precomputeFormattingInfos(const FormatToken *Token);
401
402 /// \brief Apply the special formatting that the given role demands.
403 ///
Daniel Jasper01603472014-01-09 13:42:56 +0000404 /// Assumes that the token having this role is already formatted.
405 ///
Daniel Jasper8de9ed02013-08-22 15:00:41 +0000406 /// Continues formatting from \p State leaving indentation to \p Indenter and
407 /// returns the total penalty that this formatting incurs.
Daniel Jasper01603472014-01-09 13:42:56 +0000408 virtual unsigned formatFromToken(LineState &State,
409 ContinuationIndenter *Indenter,
410 bool DryRun) {
411 return 0;
412 }
413
414 /// \brief Same as \c formatFromToken, but assumes that the first token has
415 /// already been set thereby deciding on the first line break.
416 virtual unsigned formatAfterToken(LineState &State,
417 ContinuationIndenter *Indenter,
418 bool DryRun) {
Daniel Jasper8de9ed02013-08-22 15:00:41 +0000419 return 0;
420 }
421
422 /// \brief Notifies the \c Role that a comma was found.
423 virtual void CommaFound(const FormatToken *Token) {}
424
425protected:
426 const FormatStyle &Style;
427};
428
429class CommaSeparatedList : public TokenRole {
430public:
Daniel Jasper01603472014-01-09 13:42:56 +0000431 CommaSeparatedList(const FormatStyle &Style)
432 : TokenRole(Style), HasNestedBracedList(false) {}
Daniel Jasper8de9ed02013-08-22 15:00:41 +0000433
434 virtual void precomputeFormattingInfos(const FormatToken *Token);
435
Daniel Jasper01603472014-01-09 13:42:56 +0000436 virtual unsigned formatAfterToken(LineState &State,
437 ContinuationIndenter *Indenter,
438 bool DryRun);
439
440 virtual unsigned formatFromToken(LineState &State,
441 ContinuationIndenter *Indenter, bool DryRun);
Daniel Jasper8de9ed02013-08-22 15:00:41 +0000442
443 /// \brief Adds \p Token as the next comma to the \c CommaSeparated list.
444 virtual void CommaFound(const FormatToken *Token) { Commas.push_back(Token); }
445
446private:
447 /// \brief A struct that holds information on how to format a given list with
448 /// a specific number of columns.
449 struct ColumnFormat {
450 /// \brief The number of columns to use.
451 unsigned Columns;
452
453 /// \brief The total width in characters.
454 unsigned TotalWidth;
455
456 /// \brief The number of lines required for this format.
457 unsigned LineCount;
458
459 /// \brief The size of each column in characters.
460 SmallVector<unsigned, 8> ColumnSizes;
461 };
462
463 /// \brief Calculate which \c ColumnFormat fits best into
464 /// \p RemainingCharacters.
465 const ColumnFormat *getColumnFormat(unsigned RemainingCharacters) const;
466
467 /// \brief The ordered \c FormatTokens making up the commas of this list.
468 SmallVector<const FormatToken *, 8> Commas;
469
470 /// \brief The length of each of the list's items in characters including the
471 /// trailing comma.
472 SmallVector<unsigned, 8> ItemLengths;
473
474 /// \brief Precomputed formats that can be used for this list.
475 SmallVector<ColumnFormat, 4> Formats;
Daniel Jasper01603472014-01-09 13:42:56 +0000476
477 bool HasNestedBracedList;
Daniel Jasper8de9ed02013-08-22 15:00:41 +0000478};
479
Alexander Kornienko4b672072013-06-03 16:45:03 +0000480} // namespace format
481} // namespace clang
482
483#endif // LLVM_CLANG_FORMAT_FORMAT_TOKEN_H