Lines Matching refs:FormatTok

99     static FormatToken FormatTok;  in getFakeEOF()  local
101 FormatTok.Tok.startToken(); in getFakeEOF()
102 FormatTok.Tok.setKind(tok::eof); in getFakeEOF()
105 return &FormatTok; in getFakeEOF()
212 FormatTok = nullptr; in reset()
231 pushToken(FormatTok); in parse()
270 tok::TokenKind kind = FormatTok->Tok.getKind(); in parseLevel()
271 if (FormatTok->Type == TT_MacroBlockBegin) { in parseLevel()
273 } else if (FormatTok->Type == TT_MacroBlockEnd) { in parseLevel()
285 if (!FormatTok->is(TT_MacroBlockBegin) && tryToParseBracedList()) in parseLevel()
317 FormatToken *Tok = FormatTok; in calculateBraceTypes()
398 FormatTok = Tokens->setPosition(StoredPosition); in calculateBraceTypes()
403 assert(FormatTok->isOneOf(tok::l_brace, TT_MacroBlockBegin) && in parseBlock()
405 const bool MacroBlock = FormatTok->is(TT_MacroBlockBegin); in parseBlock()
406 FormatTok->BlockKind = BK_Block; in parseBlock()
411 if (MacroBlock && FormatTok->is(tok::l_paren)) in parseBlock()
422 if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd) in parseBlock()
423 : !FormatTok->is(tok::r_brace)) { in parseBlock()
425 FormatTok->BlockKind = BK_Block; in parseBlock()
431 if (MacroBlock && FormatTok->is(tok::l_paren)) in parseBlock()
434 if (MunchSemi && FormatTok->Tok.is(tok::semi)) in parseBlock()
471 FormatTok->BlockKind = BK_Block; in parseChildBlock()
481 flushComments(isOnNewLine(*FormatTok)); in parseChildBlock()
488 assert(FormatTok->Tok.is(tok::hash) && "'#' expected"); in parsePPDirective()
489 ScopedMacroState MacroState(*Line, Tokens, FormatTok); in parsePPDirective()
492 if (!FormatTok->Tok.getIdentifierInfo()) { in parsePPDirective()
497 switch (FormatTok->Tok.getIdentifierInfo()->getPPKeywordID()) { in parsePPDirective()
571 bool IsLiteralFalse = (FormatTok->Tok.isLiteral() && in parsePPIf()
572 FormatTok->Tok.getLiteralData() != nullptr && in parsePPIf()
573 StringRef(FormatTok->Tok.getLiteralData(), in parsePPIf()
574 FormatTok->Tok.getLength()) == "0") || in parsePPIf()
575 FormatTok->Tok.is(tok::kw_false); in parsePPIf()
595 if (FormatTok->Tok.getKind() != tok::identifier) { in parsePPDefine()
600 if (FormatTok->Tok.getKind() == tok::l_paren && in parsePPDefine()
601 FormatTok->WhitespaceRange.getBegin() == in parsePPDefine()
602 FormatTok->WhitespaceRange.getEnd()) { in parsePPDefine()
653 assert(!FormatTok->Tok.is(tok::l_brace)); in parseStructuralElement()
654 switch (FormatTok->Tok.getKind()) { in parseStructuralElement()
657 if (FormatTok->Tok.is(tok::l_brace)) { in parseStructuralElement()
661 switch (FormatTok->Tok.getObjCKeywordID()) { in parseStructuralElement()
681 if (FormatTok->Tok.is(tok::l_brace)) { in parseStructuralElement()
699 if (FormatTok->is(tok::l_brace)) { in parseStructuralElement()
700 FormatTok->Type = TT_InlineASMBrace; in parseStructuralElement()
702 while (FormatTok && FormatTok->isNot(tok::eof)) { in parseStructuralElement()
703 if (FormatTok->is(tok::r_brace)) { in parseStructuralElement()
704 FormatTok->Type = TT_InlineASMBrace; in parseStructuralElement()
709 FormatTok->Finalized = true; in parseStructuralElement()
719 if (FormatTok->Tok.is(tok::kw_namespace)) { in parseStructuralElement()
759 if (FormatTok->Tok.is(tok::string_literal)) { in parseStructuralElement()
761 if (FormatTok->Tok.is(tok::l_brace)) { in parseStructuralElement()
775 if (FormatTok->is(TT_ForEachMacro)) { in parseStructuralElement()
779 if (FormatTok->is(TT_MacroBlockBegin)) { in parseStructuralElement()
785 FormatTok->is(Keywords.kw_import)) { in parseStructuralElement()
789 if (FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals, in parseStructuralElement()
792 if (FormatTok->is(tok::colon)) { in parseStructuralElement()
804 switch (FormatTok->Tok.getKind()) { in parseStructuralElement()
807 if (FormatTok->Tok.is(tok::l_brace)) in parseStructuralElement()
822 if (FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS, in parseStructuralElement()
842 if (Style.Language == FormatStyle::LK_Java && FormatTok && in parseStructuralElement()
843 FormatTok->is(tok::kw_class)) in parseStructuralElement()
845 if (Style.Language == FormatStyle::LK_JavaScript && FormatTok && in parseStructuralElement()
846 FormatTok->Tok.getIdentifierInfo()) in parseStructuralElement()
863 if (FormatTok->isBinaryOperator()) in parseStructuralElement()
868 if (FormatTok->Tok.isAnyIdentifier() || in parseStructuralElement()
869 FormatTok->isSimpleTypeSpecifier()) in parseStructuralElement()
871 if (FormatTok->is(tok::l_paren)) in parseStructuralElement()
873 if (FormatTok->is(tok::l_brace)) in parseStructuralElement()
884 FormatTok->Type = TT_FunctionLBrace; in parseStructuralElement()
897 if (FormatTok->is(TT_MacroBlockEnd)) { in parseStructuralElement()
905 FormatTok->is(Keywords.kw_function) && Line->Tokens.size() > 0) { in parseStructuralElement()
911 FormatTok->is(Keywords.kw_interface)) { in parseStructuralElement()
917 StringRef Text = FormatTok->TokenText; in parseStructuralElement()
923 if (FormatTok->Tok.is(tok::colon) && !Line->MustBeDeclaration) { in parseStructuralElement()
929 bool FunctionLike = FormatTok->is(tok::l_paren); in parseStructuralElement()
935 ? FormatTok->NewlinesBefore > 0 in parseStructuralElement()
939 tokenCanStartNewLine(FormatTok->Tok) && Text == Text.upper()) { in parseStructuralElement()
950 if (FormatTok->is(TT_JsFatArrow)) { in parseStructuralElement()
952 if (FormatTok->is(tok::l_brace)) in parseStructuralElement()
958 if (FormatTok->Tok.is(tok::l_brace)) { in parseStructuralElement()
990 assert(FormatTok->is(tok::l_square)); in tryToParseLambda()
991 FormatToken &LSquare = *FormatTok; in tryToParseLambda()
995 while (FormatTok->isNot(tok::l_brace)) { in tryToParseLambda()
996 if (FormatTok->isSimpleTypeSpecifier()) { in tryToParseLambda()
1000 switch (FormatTok->Tok.getKind()) { in tryToParseLambda()
1019 FormatTok->Type = TT_LambdaArrow; in tryToParseLambda()
1033 if (FormatTok->is(tok::equal)) { in tryToParseLambdaIntroducer()
1035 if (FormatTok->is(tok::r_square)) { in tryToParseLambdaIntroducer()
1039 if (FormatTok->isNot(tok::comma)) in tryToParseLambdaIntroducer()
1042 } else if (FormatTok->is(tok::amp)) { in tryToParseLambdaIntroducer()
1044 if (FormatTok->is(tok::r_square)) { in tryToParseLambdaIntroducer()
1048 if (!FormatTok->isOneOf(tok::comma, tok::identifier)) { in tryToParseLambdaIntroducer()
1051 if (FormatTok->is(tok::comma)) in tryToParseLambdaIntroducer()
1053 } else if (FormatTok->is(tok::r_square)) { in tryToParseLambdaIntroducer()
1058 if (FormatTok->is(tok::amp)) in tryToParseLambdaIntroducer()
1060 if (!FormatTok->isOneOf(tok::identifier, tok::kw_this)) in tryToParseLambdaIntroducer()
1063 if (FormatTok->is(tok::ellipsis)) in tryToParseLambdaIntroducer()
1065 if (FormatTok->is(tok::comma)) { in tryToParseLambdaIntroducer()
1067 } else if (FormatTok->is(tok::r_square)) { in tryToParseLambdaIntroducer()
1081 if (FormatTok->is(tok::identifier)) in tryToParseJSFunction()
1084 if (FormatTok->isNot(tok::l_paren)) in tryToParseJSFunction()
1090 if (FormatTok->is(tok::colon)) { in tryToParseJSFunction()
1096 if (FormatTok->is(tok::l_brace)) in tryToParseJSFunction()
1099 while (FormatTok->isNot(tok::l_brace) && !eof()) in tryToParseJSFunction()
1107 if (FormatTok->BlockKind == BK_Unknown) in tryToParseBracedList()
1109 assert(FormatTok->BlockKind != BK_Unknown); in tryToParseBracedList()
1110 if (FormatTok->BlockKind == BK_Block) in tryToParseBracedList()
1124 if (FormatTok->is(Keywords.kw_function)) { in parseBracedList()
1128 if (FormatTok->is(TT_JsFatArrow)) { in parseBracedList()
1132 if (FormatTok->is(tok::l_brace)) { in parseBracedList()
1138 switch (FormatTok->Tok.getKind()) { in parseBracedList()
1141 if (FormatTok->is(tok::l_brace)) { in parseBracedList()
1151 FormatTok->BlockKind = BK_BracedInit; in parseBracedList()
1159 if (FormatTok->is(tok::l_brace)) in parseBracedList()
1185 assert(FormatTok->Tok.is(tok::l_paren) && "'(' expected."); in parseParens()
1188 switch (FormatTok->Tok.getKind()) { in parseParens()
1191 if (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::l_brace)) in parseParens()
1209 if (FormatTok->Tok.is(tok::l_brace)) in parseParens()
1214 FormatTok->is(Keywords.kw_function)) in parseParens()
1227 assert(FormatTok->Tok.is(tok::l_square) && "'[' expected."); in parseSquare()
1231 switch (FormatTok->Tok.getKind()) { in parseSquare()
1251 if (FormatTok->Tok.is(tok::l_brace)) in parseSquare()
1262 assert(FormatTok->Tok.is(tok::kw_if) && "'if' expected"); in parseIfThenElse()
1264 if (FormatTok->Tok.is(tok::l_paren)) in parseIfThenElse()
1267 if (FormatTok->Tok.is(tok::l_brace)) { in parseIfThenElse()
1280 if (FormatTok->Tok.is(tok::kw_else)) { in parseIfThenElse()
1282 if (FormatTok->Tok.is(tok::l_brace)) { in parseIfThenElse()
1286 } else if (FormatTok->Tok.is(tok::kw_if)) { in parseIfThenElse()
1300 assert(FormatTok->isOneOf(tok::kw_try, tok::kw___try) && "'try' expected"); in parseTryCatch()
1303 if (FormatTok->is(tok::colon)) { in parseTryCatch()
1306 while (FormatTok->is(tok::identifier)) { in parseTryCatch()
1308 if (FormatTok->is(tok::l_paren)) in parseTryCatch()
1310 if (FormatTok->is(tok::comma)) in parseTryCatch()
1315 if (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::l_paren)) { in parseTryCatch()
1318 if (FormatTok->is(tok::l_brace)) { in parseTryCatch()
1326 } else if (!FormatTok->is(tok::kw_catch)) { in parseTryCatch()
1336 if (FormatTok->is(tok::at)) in parseTryCatch()
1338 if (!(FormatTok->isOneOf(tok::kw_catch, Keywords.kw___except, in parseTryCatch()
1342 FormatTok->is(Keywords.kw_finally)) || in parseTryCatch()
1343 (FormatTok->Tok.isObjCAtKeyword(tok::objc_catch) || in parseTryCatch()
1344 FormatTok->Tok.isObjCAtKeyword(tok::objc_finally)))) in parseTryCatch()
1347 while (FormatTok->isNot(tok::l_brace)) { in parseTryCatch()
1348 if (FormatTok->is(tok::l_paren)) { in parseTryCatch()
1352 if (FormatTok->isOneOf(tok::semi, tok::r_brace, tok::eof)) in parseTryCatch()
1369 assert(FormatTok->Tok.is(tok::kw_namespace) && "'namespace' expected"); in parseNamespace()
1371 const FormatToken &InitialToken = *FormatTok; in parseNamespace()
1373 while (FormatTok->isOneOf(tok::identifier, tok::coloncolon)) in parseNamespace()
1375 if (FormatTok->Tok.is(tok::l_brace)) { in parseNamespace()
1385 if (FormatTok->Tok.is(tok::semi)) in parseNamespace()
1393 assert(FormatTok->is(tok::kw_new) && "'new' expected"); in parseNew()
1401 if (FormatTok->isOneOf(tok::semi, tok::l_brace, tok::r_brace)) in parseNew()
1405 if (FormatTok->is(tok::l_paren)) { in parseNew()
1409 if (FormatTok->is(tok::l_brace)) in parseNew()
1418 assert(FormatTok->isOneOf(tok::kw_for, tok::kw_while, TT_ForEachMacro) && in parseForOrWhileLoop()
1421 if (FormatTok->Tok.is(tok::l_paren)) in parseForOrWhileLoop()
1423 if (FormatTok->Tok.is(tok::l_brace)) { in parseForOrWhileLoop()
1436 assert(FormatTok->Tok.is(tok::kw_do) && "'do' expected"); in parseDoWhile()
1438 if (FormatTok->Tok.is(tok::l_brace)) { in parseDoWhile()
1451 if (!FormatTok->Tok.is(tok::kw_while)) { in parseDoWhile()
1465 if (CommentsBeforeNextToken.empty() && FormatTok->Tok.is(tok::l_brace)) { in parseLabel()
1468 if (FormatTok->Tok.is(tok::kw_break)) { in parseLabel()
1475 if (FormatTok->is(tok::semi)) in parseLabel()
1483 assert(FormatTok->Tok.is(tok::kw_case) && "'case' expected"); in parseCaseLabel()
1487 } while (!eof() && !FormatTok->Tok.is(tok::colon)); in parseCaseLabel()
1492 assert(FormatTok->Tok.is(tok::kw_switch) && "'switch' expected"); in parseSwitch()
1494 if (FormatTok->Tok.is(tok::l_paren)) in parseSwitch()
1496 if (FormatTok->Tok.is(tok::l_brace)) { in parseSwitch()
1511 if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_qslots)) in parseAccessSpecifier()
1514 if (FormatTok->Tok.is(tok::colon)) in parseAccessSpecifier()
1521 if (FormatTok->Tok.is(tok::kw_enum)) in parseEnum()
1525 if (FormatTok->Tok.is(tok::kw_class) || FormatTok->Tok.is(tok::kw_struct)) in parseEnum()
1528 while (FormatTok->Tok.getIdentifierInfo() || in parseEnum()
1529 FormatTok->isOneOf(tok::colon, tok::coloncolon, tok::less, in parseEnum()
1533 if (FormatTok->is(tok::l_paren)) in parseEnum()
1535 if (FormatTok->is(tok::identifier)) { in parseEnum()
1540 FormatTok->is(tok::identifier)) in parseEnum()
1546 if (FormatTok->isNot(tok::l_brace)) in parseEnum()
1548 FormatTok->BlockKind = BK_Block; in parseEnum()
1562 if (FormatTok->is(tok::semi)) in parseEnum()
1590 FormatTok = Tokens->setPosition(StoredPosition); in parseJavaEnumBody()
1605 while (FormatTok) { in parseJavaEnumBody()
1606 if (FormatTok->is(tok::l_brace)) { in parseJavaEnumBody()
1610 } else if (FormatTok->is(tok::l_paren)) { in parseJavaEnumBody()
1612 } else if (FormatTok->is(tok::comma)) { in parseJavaEnumBody()
1615 } else if (FormatTok->is(tok::semi)) { in parseJavaEnumBody()
1619 } else if (FormatTok->is(tok::r_brace)) { in parseJavaEnumBody()
1635 const FormatToken &InitialToken = *FormatTok; in parseRecord()
1640 while (FormatTok->isOneOf(tok::identifier, tok::coloncolon, tok::hashhash, in parseRecord()
1645 FormatTok->isOneOf(tok::period, tok::comma))) { in parseRecord()
1647 FormatTok->is(tok::identifier) && in parseRecord()
1648 FormatTok->TokenText != FormatTok->TokenText.upper(); in parseRecord()
1651 if (!IsNonMacroIdentifier && FormatTok->Tok.is(tok::l_paren)) in parseRecord()
1665 if (FormatTok->isOneOf(tok::colon, tok::less)) { in parseRecord()
1667 if (FormatTok->is(tok::l_brace)) { in parseRecord()
1672 if (FormatTok->Tok.is(tok::semi)) in parseRecord()
1677 if (FormatTok->Tok.is(tok::l_brace)) { in parseRecord()
1690 assert(FormatTok->Tok.is(tok::less) && "'<' expected."); in parseObjCProtocolList()
1693 while (!eof() && FormatTok->Tok.isNot(tok::greater)); in parseObjCProtocolList()
1699 if (FormatTok->Tok.isObjCAtKeyword(tok::objc_end)) { in parseObjCUntilAtEnd()
1704 if (FormatTok->is(tok::l_brace)) { in parseObjCUntilAtEnd()
1708 } else if (FormatTok->is(tok::r_brace)) { in parseObjCUntilAtEnd()
1723 if (FormatTok->Tok.is(tok::colon)) { in parseObjCInterfaceOrImplementation()
1726 } else if (FormatTok->Tok.is(tok::l_paren)) in parseObjCInterfaceOrImplementation()
1730 if (FormatTok->Tok.is(tok::less)) in parseObjCInterfaceOrImplementation()
1733 if (FormatTok->Tok.is(tok::l_brace)) { in parseObjCInterfaceOrImplementation()
1750 if (FormatTok->Tok.is(tok::less)) in parseObjCProtocol()
1754 if (FormatTok->Tok.is(tok::semi)) { in parseObjCProtocol()
1764 assert(FormatTok->isOneOf(Keywords.kw_import, tok::kw_export)); in parseJavaScriptEs6ImportExport()
1768 if (FormatTok->is(tok::kw_default)) in parseJavaScriptEs6ImportExport()
1773 if (FormatTok->is(Keywords.kw_function)) { in parseJavaScriptEs6ImportExport()
1778 if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, tok::kw_enum, in parseJavaScriptEs6ImportExport()
1782 if (FormatTok->is(tok::l_brace)) { in parseJavaScriptEs6ImportExport()
1783 FormatTok->BlockKind = BK_Block; in parseJavaScriptEs6ImportExport()
1787 while (!eof() && FormatTok->isNot(tok::semi) && in parseJavaScriptEs6ImportExport()
1788 FormatTok->isNot(tok::l_brace)) { in parseJavaScriptEs6ImportExport()
1833 bool UnwrappedLineParser::eof() const { return FormatTok->Tok.is(tok::eof); } in eof()
1835 bool UnwrappedLineParser::isOnNewLine(const FormatToken &FormatTok) { in isOnNewLine() argument
1836 return (Line->InPPDirective || FormatTok.HasUnescapedNewline) && in isOnNewLine()
1837 FormatTok.NewlinesBefore > 0; in isOnNewLine()
1858 flushComments(isOnNewLine(*FormatTok)); in nextToken()
1859 pushToken(FormatTok); in nextToken()
1866 FormatTok = Tokens->getNextToken(); in readToken()
1867 assert(FormatTok); in readToken()
1868 while (!Line->InPPDirective && FormatTok->Tok.is(tok::hash) && in readToken()
1869 (FormatTok->HasUnescapedNewline || FormatTok->IsFirst)) { in readToken()
1877 flushComments(isOnNewLine(*FormatTok)); in readToken()
1880 while (FormatTok->Type == TT_ConflictStart || in readToken()
1881 FormatTok->Type == TT_ConflictEnd || in readToken()
1882 FormatTok->Type == TT_ConflictAlternative) { in readToken()
1883 if (FormatTok->Type == TT_ConflictStart) { in readToken()
1885 } else if (FormatTok->Type == TT_ConflictAlternative) { in readToken()
1887 } else if (FormatTok->Type == TT_ConflictEnd) { in readToken()
1890 FormatTok = Tokens->getNextToken(); in readToken()
1891 FormatTok->MustBreakBefore = true; in readToken()
1899 if (!FormatTok->Tok.is(tok::comment)) in readToken()
1901 if (isOnNewLine(*FormatTok) || FormatTok->IsFirst) { in readToken()
1905 pushToken(FormatTok); in readToken()
1907 CommentsBeforeNextToken.push_back(FormatTok); in readToken()