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