1 //===--- 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_LIB_FORMAT_FORMATTOKEN_H 17 #define LLVM_CLANG_LIB_FORMAT_FORMATTOKEN_H 18 19 #include "clang/Basic/IdentifierTable.h" 20 #include "clang/Basic/OperatorPrecedence.h" 21 #include "clang/Format/Format.h" 22 #include "clang/Lex/Lexer.h" 23 #include <memory> 24 25 namespace clang { 26 namespace format { 27 28 #define LIST_TOKEN_TYPES \ 29 TYPE(ArrayInitializerLSquare) \ 30 TYPE(ArraySubscriptLSquare) \ 31 TYPE(AttributeParen) \ 32 TYPE(BinaryOperator) \ 33 TYPE(BitFieldColon) \ 34 TYPE(BlockComment) \ 35 TYPE(CastRParen) \ 36 TYPE(ConditionalExpr) \ 37 TYPE(ConflictAlternative) \ 38 TYPE(ConflictEnd) \ 39 TYPE(ConflictStart) \ 40 TYPE(CtorInitializerColon) \ 41 TYPE(CtorInitializerComma) \ 42 TYPE(DesignatedInitializerPeriod) \ 43 TYPE(DictLiteral) \ 44 TYPE(ForEachMacro) \ 45 TYPE(FunctionAnnotationRParen) \ 46 TYPE(FunctionDeclarationName) \ 47 TYPE(FunctionLBrace) \ 48 TYPE(FunctionTypeLParen) \ 49 TYPE(ImplicitStringLiteral) \ 50 TYPE(InheritanceColon) \ 51 TYPE(InlineASMBrace) \ 52 TYPE(InlineASMColon) \ 53 TYPE(JavaAnnotation) \ 54 TYPE(JsComputedPropertyName) \ 55 TYPE(JsFatArrow) \ 56 TYPE(JsTypeColon) \ 57 TYPE(JsTypeOperator) \ 58 TYPE(JsTypeOptionalQuestion) \ 59 TYPE(LambdaArrow) \ 60 TYPE(LambdaLSquare) \ 61 TYPE(LeadingJavaAnnotation) \ 62 TYPE(LineComment) \ 63 TYPE(MacroBlockBegin) \ 64 TYPE(MacroBlockEnd) \ 65 TYPE(ObjCBlockLBrace) \ 66 TYPE(ObjCBlockLParen) \ 67 TYPE(ObjCDecl) \ 68 TYPE(ObjCForIn) \ 69 TYPE(ObjCMethodExpr) \ 70 TYPE(ObjCMethodSpecifier) \ 71 TYPE(ObjCProperty) \ 72 TYPE(ObjCStringLiteral) \ 73 TYPE(OverloadedOperator) \ 74 TYPE(OverloadedOperatorLParen) \ 75 TYPE(PointerOrReference) \ 76 TYPE(PureVirtualSpecifier) \ 77 TYPE(RangeBasedForLoopColon) \ 78 TYPE(RegexLiteral) \ 79 TYPE(SelectorName) \ 80 TYPE(StartOfName) \ 81 TYPE(TemplateCloser) \ 82 TYPE(TemplateOpener) \ 83 TYPE(TemplateString) \ 84 TYPE(TrailingAnnotation) \ 85 TYPE(TrailingReturnArrow) \ 86 TYPE(TrailingUnaryOperator) \ 87 TYPE(UnaryOperator) \ 88 TYPE(Unknown) 89 90 enum TokenType { 91 #define TYPE(X) TT_##X, 92 LIST_TOKEN_TYPES 93 #undef TYPE 94 NUM_TOKEN_TYPES 95 }; 96 97 /// \brief Determines the name of a token type. 98 const char *getTokenTypeName(TokenType Type); 99 100 // Represents what type of block a set of braces open. 101 enum BraceBlockKind { BK_Unknown, BK_Block, BK_BracedInit }; 102 103 // The packing kind of a function's parameters. 104 enum ParameterPackingKind { PPK_BinPacked, PPK_OnePerLine, PPK_Inconclusive }; 105 106 enum FormatDecision { FD_Unformatted, FD_Continue, FD_Break }; 107 108 class TokenRole; 109 class AnnotatedLine; 110 111 /// \brief A wrapper around a \c Token storing information about the 112 /// whitespace characters preceding it. 113 struct FormatToken { 114 FormatToken() {} 115 116 /// \brief The \c Token. 117 Token Tok; 118 119 /// \brief The number of newlines immediately before the \c Token. 120 /// 121 /// This can be used to determine what the user wrote in the original code 122 /// and thereby e.g. leave an empty line between two function definitions. 123 unsigned NewlinesBefore = 0; 124 125 /// \brief Whether there is at least one unescaped newline before the \c 126 /// Token. 127 bool HasUnescapedNewline = false; 128 129 /// \brief The range of the whitespace immediately preceding the \c Token. 130 SourceRange WhitespaceRange; 131 132 /// \brief The offset just past the last '\n' in this token's leading 133 /// whitespace (relative to \c WhiteSpaceStart). 0 if there is no '\n'. 134 unsigned LastNewlineOffset = 0; 135 136 /// \brief The width of the non-whitespace parts of the token (or its first 137 /// line for multi-line tokens) in columns. 138 /// We need this to correctly measure number of columns a token spans. 139 unsigned ColumnWidth = 0; 140 141 /// \brief Contains the width in columns of the last line of a multi-line 142 /// token. 143 unsigned LastLineColumnWidth = 0; 144 145 /// \brief Whether the token text contains newlines (escaped or not). 146 bool IsMultiline = false; 147 148 /// \brief Indicates that this is the first token of the file. 149 bool IsFirst = false; 150 151 /// \brief Whether there must be a line break before this token. 152 /// 153 /// This happens for example when a preprocessor directive ended directly 154 /// before the token. 155 bool MustBreakBefore = false; 156 157 /// \brief The raw text of the token. 158 /// 159 /// Contains the raw token text without leading whitespace and without leading 160 /// escaped newlines. 161 StringRef TokenText; 162 163 /// \brief Set to \c true if this token is an unterminated literal. 164 bool IsUnterminatedLiteral = 0; 165 166 /// \brief Contains the kind of block if this token is a brace. 167 BraceBlockKind BlockKind = BK_Unknown; 168 169 TokenType Type = TT_Unknown; 170 171 /// \brief The number of spaces that should be inserted before this token. 172 unsigned SpacesRequiredBefore = 0; 173 174 /// \brief \c true if it is allowed to break before this token. 175 bool CanBreakBefore = false; 176 177 /// \brief \c true if this is the ">" of "template<..>". 178 bool ClosesTemplateDeclaration = false; 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 = 0; 186 187 /// \brief Number of parameters that are nested blocks, 188 /// if this is "(", "[" or "<". 189 unsigned BlockParameterCount = 0; 190 191 /// \brief If this is a bracket ("<", "(", "[" or "{"), contains the kind of 192 /// the surrounding bracket. 193 tok::TokenKind ParentBracket = tok::unknown; 194 195 /// \brief A token can have a special role that can carry extra information 196 /// about the token's formatting. 197 std::unique_ptr<TokenRole> Role; 198 199 /// \brief If this is an opening parenthesis, how are the parameters packed? 200 ParameterPackingKind PackingKind = PPK_Inconclusive; 201 202 /// \brief The total length of the unwrapped line up to and including this 203 /// token. 204 unsigned TotalLength = 0; 205 206 /// \brief The original 0-based column of this token, including expanded tabs. 207 /// The configured TabWidth is used as tab width. 208 unsigned OriginalColumn = 0; 209 210 /// \brief The length of following tokens until the next natural split point, 211 /// or the next token that can be broken. 212 unsigned UnbreakableTailLength = 0; 213 214 // FIXME: Come up with a 'cleaner' concept. 215 /// \brief The binding strength of a token. This is a combined value of 216 /// operator precedence, parenthesis nesting, etc. 217 unsigned BindingStrength = 0; 218 219 /// \brief The nesting level of this token, i.e. the number of surrounding (), 220 /// [], {} or <>. 221 unsigned NestingLevel = 0; 222 223 /// \brief The indent level of this token. Copied from the surrounding line. 224 unsigned IndentLevel = 0; 225 226 /// \brief Penalty for inserting a line break before this token. 227 unsigned SplitPenalty = 0; 228 229 /// \brief If this is the first ObjC selector name in an ObjC method 230 /// definition or call, this contains the length of the longest name. 231 /// 232 /// This being set to 0 means that the selectors should not be colon-aligned, 233 /// e.g. because several of them are block-type. 234 unsigned LongestObjCSelectorName = 0; 235 236 /// \brief Stores the number of required fake parentheses and the 237 /// corresponding operator precedence. 238 /// 239 /// If multiple fake parentheses start at a token, this vector stores them in 240 /// reverse order, i.e. inner fake parenthesis first. 241 SmallVector<prec::Level, 4> FakeLParens; 242 /// \brief Insert this many fake ) after this token for correct indentation. 243 unsigned FakeRParens = 0; 244 245 /// \brief \c true if this token starts a binary expression, i.e. has at least 246 /// one fake l_paren with a precedence greater than prec::Unknown. 247 bool StartsBinaryExpression = false; 248 /// \brief \c true if this token ends a binary expression. 249 bool EndsBinaryExpression = false; 250 251 /// \brief Is this is an operator (or "."/"->") in a sequence of operators 252 /// with the same precedence, contains the 0-based operator index. 253 unsigned OperatorIndex = 0; 254 255 /// \brief If this is an operator (or "."/"->") in a sequence of operators 256 /// with the same precedence, points to the next operator. 257 FormatToken *NextOperator = nullptr; 258 259 /// \brief Is this token part of a \c DeclStmt defining multiple variables? 260 /// 261 /// Only set if \c Type == \c TT_StartOfName. 262 bool PartOfMultiVariableDeclStmt = false; 263 264 /// \brief Does this line comment continue a line comment section? 265 /// 266 /// Only set to true if \c Type == \c TT_LineComment. 267 bool ContinuesLineCommentSection = false; 268 269 /// \brief If this is a bracket, this points to the matching one. 270 FormatToken *MatchingParen = nullptr; 271 272 /// \brief The previous token in the unwrapped line. 273 FormatToken *Previous = nullptr; 274 275 /// \brief The next token in the unwrapped line. 276 FormatToken *Next = nullptr; 277 278 /// \brief If this token starts a block, this contains all the unwrapped lines 279 /// in it. 280 SmallVector<AnnotatedLine *, 1> Children; 281 282 /// \brief Stores the formatting decision for the token once it was made. 283 FormatDecision Decision = FD_Unformatted; 284 285 /// \brief If \c true, this token has been fully formatted (indented and 286 /// potentially re-formatted inside), and we do not allow further formatting 287 /// changes. 288 bool Finalized = false; 289 290 bool is(tok::TokenKind Kind) const { return Tok.is(Kind); } 291 bool is(TokenType TT) const { return Type == TT; } 292 bool is(const IdentifierInfo *II) const { 293 return II && II == Tok.getIdentifierInfo(); 294 } 295 bool is(tok::PPKeywordKind Kind) const { 296 return Tok.getIdentifierInfo() && 297 Tok.getIdentifierInfo()->getPPKeywordID() == Kind; 298 } 299 template <typename A, typename B> bool isOneOf(A K1, B K2) const { 300 return is(K1) || is(K2); 301 } 302 template <typename A, typename B, typename... Ts> 303 bool isOneOf(A K1, B K2, Ts... Ks) const { 304 return is(K1) || isOneOf(K2, Ks...); 305 } 306 template <typename T> bool isNot(T Kind) const { return !is(Kind); } 307 308 /// \c true if this token starts a sequence with the given tokens in order, 309 /// following the ``Next`` pointers, ignoring comments. 310 template <typename A, typename... Ts> 311 bool startsSequence(A K1, Ts... Tokens) const { 312 return startsSequenceInternal(K1, Tokens...); 313 } 314 315 /// \c true if this token ends a sequence with the given tokens in order, 316 /// following the ``Previous`` pointers, ignoring comments. 317 template <typename A, typename... Ts> 318 bool endsSequence(A K1, Ts... Tokens) const { 319 return endsSequenceInternal(K1, Tokens...); 320 } 321 322 bool isStringLiteral() const { return tok::isStringLiteral(Tok.getKind()); } 323 324 bool isObjCAtKeyword(tok::ObjCKeywordKind Kind) const { 325 return Tok.isObjCAtKeyword(Kind); 326 } 327 328 bool isAccessSpecifier(bool ColonRequired = true) const { 329 return isOneOf(tok::kw_public, tok::kw_protected, tok::kw_private) && 330 (!ColonRequired || (Next && Next->is(tok::colon))); 331 } 332 333 /// \brief Determine whether the token is a simple-type-specifier. 334 bool isSimpleTypeSpecifier() const; 335 336 bool isObjCAccessSpecifier() const { 337 return is(tok::at) && Next && (Next->isObjCAtKeyword(tok::objc_public) || 338 Next->isObjCAtKeyword(tok::objc_protected) || 339 Next->isObjCAtKeyword(tok::objc_package) || 340 Next->isObjCAtKeyword(tok::objc_private)); 341 } 342 343 /// \brief Returns whether \p Tok is ([{ or a template opening <. 344 bool opensScope() const { 345 if (is(TT_TemplateString) && TokenText.endswith("${")) 346 return true; 347 return isOneOf(tok::l_paren, tok::l_brace, tok::l_square, 348 TT_TemplateOpener); 349 } 350 /// \brief Returns whether \p Tok is )]} or a template closing >. 351 bool closesScope() const { 352 if (is(TT_TemplateString) && TokenText.startswith("}")) 353 return true; 354 return isOneOf(tok::r_paren, tok::r_brace, tok::r_square, 355 TT_TemplateCloser); 356 } 357 358 /// \brief Returns \c true if this is a "." or "->" accessing a member. 359 bool isMemberAccess() const { 360 return isOneOf(tok::arrow, tok::period, tok::arrowstar) && 361 !isOneOf(TT_DesignatedInitializerPeriod, TT_TrailingReturnArrow, 362 TT_LambdaArrow); 363 } 364 365 bool isUnaryOperator() const { 366 switch (Tok.getKind()) { 367 case tok::plus: 368 case tok::plusplus: 369 case tok::minus: 370 case tok::minusminus: 371 case tok::exclaim: 372 case tok::tilde: 373 case tok::kw_sizeof: 374 case tok::kw_alignof: 375 return true; 376 default: 377 return false; 378 } 379 } 380 381 bool isBinaryOperator() const { 382 // Comma is a binary operator, but does not behave as such wrt. formatting. 383 return getPrecedence() > prec::Comma; 384 } 385 386 bool isTrailingComment() const { 387 return is(tok::comment) && 388 (is(TT_LineComment) || !Next || Next->NewlinesBefore > 0); 389 } 390 391 /// \brief Returns \c true if this is a keyword that can be used 392 /// like a function call (e.g. sizeof, typeid, ...). 393 bool isFunctionLikeKeyword() const { 394 switch (Tok.getKind()) { 395 case tok::kw_throw: 396 case tok::kw_typeid: 397 case tok::kw_return: 398 case tok::kw_sizeof: 399 case tok::kw_alignof: 400 case tok::kw_alignas: 401 case tok::kw_decltype: 402 case tok::kw_noexcept: 403 case tok::kw_static_assert: 404 case tok::kw___attribute: 405 return true; 406 default: 407 return false; 408 } 409 } 410 411 /// \brief Returns \c true if this is a string literal that's like a label, 412 /// e.g. ends with "=" or ":". 413 bool isLabelString() const { 414 if (!is(tok::string_literal)) 415 return false; 416 StringRef Content = TokenText; 417 if (Content.startswith("\"") || Content.startswith("'")) 418 Content = Content.drop_front(1); 419 if (Content.endswith("\"") || Content.endswith("'")) 420 Content = Content.drop_back(1); 421 Content = Content.trim(); 422 return Content.size() > 1 && 423 (Content.back() == ':' || Content.back() == '='); 424 } 425 426 /// \brief Returns actual token start location without leading escaped 427 /// newlines and whitespace. 428 /// 429 /// This can be different to Tok.getLocation(), which includes leading escaped 430 /// newlines. 431 SourceLocation getStartOfNonWhitespace() const { 432 return WhitespaceRange.getEnd(); 433 } 434 435 prec::Level getPrecedence() const { 436 return getBinOpPrecedence(Tok.getKind(), true, true); 437 } 438 439 /// \brief Returns the previous token ignoring comments. 440 FormatToken *getPreviousNonComment() const { 441 FormatToken *Tok = Previous; 442 while (Tok && Tok->is(tok::comment)) 443 Tok = Tok->Previous; 444 return Tok; 445 } 446 447 /// \brief Returns the next token ignoring comments. 448 const FormatToken *getNextNonComment() const { 449 const FormatToken *Tok = Next; 450 while (Tok && Tok->is(tok::comment)) 451 Tok = Tok->Next; 452 return Tok; 453 } 454 455 /// \brief Returns \c true if this tokens starts a block-type list, i.e. a 456 /// list that should be indented with a block indent. 457 bool opensBlockOrBlockTypeList(const FormatStyle &Style) const { 458 return is(TT_ArrayInitializerLSquare) || 459 (is(tok::l_brace) && 460 (BlockKind == BK_Block || is(TT_DictLiteral) || 461 (!Style.Cpp11BracedListStyle && NestingLevel == 0))); 462 } 463 464 /// \brief Same as opensBlockOrBlockTypeList, but for the closing token. 465 bool closesBlockOrBlockTypeList(const FormatStyle &Style) const { 466 return MatchingParen && MatchingParen->opensBlockOrBlockTypeList(Style); 467 } 468 469 private: 470 // Disallow copying. 471 FormatToken(const FormatToken &) = delete; 472 void operator=(const FormatToken &) = delete; 473 474 template <typename A, typename... Ts> 475 bool startsSequenceInternal(A K1, Ts... Tokens) const { 476 if (is(tok::comment) && Next) 477 return Next->startsSequenceInternal(K1, Tokens...); 478 return is(K1) && Next && Next->startsSequenceInternal(Tokens...); 479 } 480 481 template <typename A> 482 bool startsSequenceInternal(A K1) const { 483 if (is(tok::comment) && Next) 484 return Next->startsSequenceInternal(K1); 485 return is(K1); 486 } 487 488 template <typename A, typename... Ts> 489 bool endsSequenceInternal(A K1) const { 490 if (is(tok::comment) && Previous) 491 return Previous->endsSequenceInternal(K1); 492 return is(K1); 493 } 494 495 template <typename A, typename... Ts> 496 bool endsSequenceInternal(A K1, Ts... Tokens) const { 497 if (is(tok::comment) && Previous) 498 return Previous->endsSequenceInternal(K1, Tokens...); 499 return is(K1) && Previous && Previous->endsSequenceInternal(Tokens...); 500 } 501 }; 502 503 class ContinuationIndenter; 504 struct LineState; 505 506 class TokenRole { 507 public: 508 TokenRole(const FormatStyle &Style) : Style(Style) {} 509 virtual ~TokenRole(); 510 511 /// \brief After the \c TokenAnnotator has finished annotating all the tokens, 512 /// this function precomputes required information for formatting. 513 virtual void precomputeFormattingInfos(const FormatToken *Token); 514 515 /// \brief Apply the special formatting that the given role demands. 516 /// 517 /// Assumes that the token having this role is already formatted. 518 /// 519 /// Continues formatting from \p State leaving indentation to \p Indenter and 520 /// returns the total penalty that this formatting incurs. 521 virtual unsigned formatFromToken(LineState &State, 522 ContinuationIndenter *Indenter, 523 bool DryRun) { 524 return 0; 525 } 526 527 /// \brief Same as \c formatFromToken, but assumes that the first token has 528 /// already been set thereby deciding on the first line break. 529 virtual unsigned formatAfterToken(LineState &State, 530 ContinuationIndenter *Indenter, 531 bool DryRun) { 532 return 0; 533 } 534 535 /// \brief Notifies the \c Role that a comma was found. 536 virtual void CommaFound(const FormatToken *Token) {} 537 538 protected: 539 const FormatStyle &Style; 540 }; 541 542 class CommaSeparatedList : public TokenRole { 543 public: 544 CommaSeparatedList(const FormatStyle &Style) 545 : TokenRole(Style), HasNestedBracedList(false) {} 546 547 void precomputeFormattingInfos(const FormatToken *Token) override; 548 549 unsigned formatAfterToken(LineState &State, ContinuationIndenter *Indenter, 550 bool DryRun) override; 551 552 unsigned formatFromToken(LineState &State, ContinuationIndenter *Indenter, 553 bool DryRun) override; 554 555 /// \brief Adds \p Token as the next comma to the \c CommaSeparated list. 556 void CommaFound(const FormatToken *Token) override { 557 Commas.push_back(Token); 558 } 559 560 private: 561 /// \brief A struct that holds information on how to format a given list with 562 /// a specific number of columns. 563 struct ColumnFormat { 564 /// \brief The number of columns to use. 565 unsigned Columns; 566 567 /// \brief The total width in characters. 568 unsigned TotalWidth; 569 570 /// \brief The number of lines required for this format. 571 unsigned LineCount; 572 573 /// \brief The size of each column in characters. 574 SmallVector<unsigned, 8> ColumnSizes; 575 }; 576 577 /// \brief Calculate which \c ColumnFormat fits best into 578 /// \p RemainingCharacters. 579 const ColumnFormat *getColumnFormat(unsigned RemainingCharacters) const; 580 581 /// \brief The ordered \c FormatTokens making up the commas of this list. 582 SmallVector<const FormatToken *, 8> Commas; 583 584 /// \brief The length of each of the list's items in characters including the 585 /// trailing comma. 586 SmallVector<unsigned, 8> ItemLengths; 587 588 /// \brief Precomputed formats that can be used for this list. 589 SmallVector<ColumnFormat, 4> Formats; 590 591 bool HasNestedBracedList; 592 }; 593 594 /// \brief Encapsulates keywords that are context sensitive or for languages not 595 /// properly supported by Clang's lexer. 596 struct AdditionalKeywords { 597 AdditionalKeywords(IdentifierTable &IdentTable) { 598 kw_final = &IdentTable.get("final"); 599 kw_override = &IdentTable.get("override"); 600 kw_in = &IdentTable.get("in"); 601 kw_of = &IdentTable.get("of"); 602 kw_CF_ENUM = &IdentTable.get("CF_ENUM"); 603 kw_CF_OPTIONS = &IdentTable.get("CF_OPTIONS"); 604 kw_NS_ENUM = &IdentTable.get("NS_ENUM"); 605 kw_NS_OPTIONS = &IdentTable.get("NS_OPTIONS"); 606 607 kw_as = &IdentTable.get("as"); 608 kw_async = &IdentTable.get("async"); 609 kw_await = &IdentTable.get("await"); 610 kw_declare = &IdentTable.get("declare"); 611 kw_finally = &IdentTable.get("finally"); 612 kw_from = &IdentTable.get("from"); 613 kw_function = &IdentTable.get("function"); 614 kw_import = &IdentTable.get("import"); 615 kw_is = &IdentTable.get("is"); 616 kw_let = &IdentTable.get("let"); 617 kw_module = &IdentTable.get("module"); 618 kw_type = &IdentTable.get("type"); 619 kw_var = &IdentTable.get("var"); 620 kw_yield = &IdentTable.get("yield"); 621 622 kw_abstract = &IdentTable.get("abstract"); 623 kw_assert = &IdentTable.get("assert"); 624 kw_extends = &IdentTable.get("extends"); 625 kw_implements = &IdentTable.get("implements"); 626 kw_instanceof = &IdentTable.get("instanceof"); 627 kw_interface = &IdentTable.get("interface"); 628 kw_native = &IdentTable.get("native"); 629 kw_package = &IdentTable.get("package"); 630 kw_synchronized = &IdentTable.get("synchronized"); 631 kw_throws = &IdentTable.get("throws"); 632 kw___except = &IdentTable.get("__except"); 633 kw___has_include = &IdentTable.get("__has_include"); 634 kw___has_include_next = &IdentTable.get("__has_include_next"); 635 636 kw_mark = &IdentTable.get("mark"); 637 638 kw_extend = &IdentTable.get("extend"); 639 kw_option = &IdentTable.get("option"); 640 kw_optional = &IdentTable.get("optional"); 641 kw_repeated = &IdentTable.get("repeated"); 642 kw_required = &IdentTable.get("required"); 643 kw_returns = &IdentTable.get("returns"); 644 645 kw_signals = &IdentTable.get("signals"); 646 kw_qsignals = &IdentTable.get("Q_SIGNALS"); 647 kw_slots = &IdentTable.get("slots"); 648 kw_qslots = &IdentTable.get("Q_SLOTS"); 649 } 650 651 // Context sensitive keywords. 652 IdentifierInfo *kw_final; 653 IdentifierInfo *kw_override; 654 IdentifierInfo *kw_in; 655 IdentifierInfo *kw_of; 656 IdentifierInfo *kw_CF_ENUM; 657 IdentifierInfo *kw_CF_OPTIONS; 658 IdentifierInfo *kw_NS_ENUM; 659 IdentifierInfo *kw_NS_OPTIONS; 660 IdentifierInfo *kw___except; 661 IdentifierInfo *kw___has_include; 662 IdentifierInfo *kw___has_include_next; 663 664 // JavaScript keywords. 665 IdentifierInfo *kw_as; 666 IdentifierInfo *kw_async; 667 IdentifierInfo *kw_await; 668 IdentifierInfo *kw_declare; 669 IdentifierInfo *kw_finally; 670 IdentifierInfo *kw_from; 671 IdentifierInfo *kw_function; 672 IdentifierInfo *kw_import; 673 IdentifierInfo *kw_is; 674 IdentifierInfo *kw_let; 675 IdentifierInfo *kw_module; 676 IdentifierInfo *kw_type; 677 IdentifierInfo *kw_var; 678 IdentifierInfo *kw_yield; 679 680 // Java keywords. 681 IdentifierInfo *kw_abstract; 682 IdentifierInfo *kw_assert; 683 IdentifierInfo *kw_extends; 684 IdentifierInfo *kw_implements; 685 IdentifierInfo *kw_instanceof; 686 IdentifierInfo *kw_interface; 687 IdentifierInfo *kw_native; 688 IdentifierInfo *kw_package; 689 IdentifierInfo *kw_synchronized; 690 IdentifierInfo *kw_throws; 691 692 // Pragma keywords. 693 IdentifierInfo *kw_mark; 694 695 // Proto keywords. 696 IdentifierInfo *kw_extend; 697 IdentifierInfo *kw_option; 698 IdentifierInfo *kw_optional; 699 IdentifierInfo *kw_repeated; 700 IdentifierInfo *kw_required; 701 IdentifierInfo *kw_returns; 702 703 // QT keywords. 704 IdentifierInfo *kw_signals; 705 IdentifierInfo *kw_qsignals; 706 IdentifierInfo *kw_slots; 707 IdentifierInfo *kw_qslots; 708 }; 709 710 } // namespace format 711 } // namespace clang 712 713 #endif 714