Lines Matching refs:FormatTok
101 static FormatToken FormatTok; in getFakeEOF() local
103 FormatTok.Tok.startToken(); in getFakeEOF()
104 FormatTok.Tok.setKind(tok::eof); in getFakeEOF()
107 return &FormatTok; in getFakeEOF()
219 FormatTok = nullptr; in reset()
239 pushToken(FormatTok); in parse()
277 switch (FormatTok->Tok.getKind()) { in parseLevel()
316 FormatToken *Tok = FormatTok; in calculateBraceTypes()
394 FormatTok = Tokens->setPosition(StoredPosition); in calculateBraceTypes()
399 assert(FormatTok->Tok.is(tok::l_brace) && "'{' expected"); in parseBlock()
411 if (!FormatTok->Tok.is(tok::r_brace)) { in parseBlock()
418 if (MunchSemi && FormatTok->Tok.is(tok::semi)) in parseBlock()
455 FormatTok->BlockKind = BK_Block; in parseChildBlock()
465 flushComments(isOnNewLine(*FormatTok)); in parseChildBlock()
472 assert(FormatTok->Tok.is(tok::hash) && "'#' expected"); in parsePPDirective()
473 ScopedMacroState MacroState(*Line, Tokens, FormatTok, StructuralError); in parsePPDirective()
476 if (!FormatTok->Tok.getIdentifierInfo()) { in parsePPDirective()
481 switch (FormatTok->Tok.getIdentifierInfo()->getPPKeywordID()) { in parsePPDirective()
555 bool IsLiteralFalse = (FormatTok->Tok.isLiteral() && in parsePPIf()
556 FormatTok->Tok.getLiteralData() != nullptr && in parsePPIf()
557 StringRef(FormatTok->Tok.getLiteralData(), in parsePPIf()
558 FormatTok->Tok.getLength()) == "0") || in parsePPIf()
559 FormatTok->Tok.is(tok::kw_false); in parsePPIf()
579 if (FormatTok->Tok.getKind() != tok::identifier) { in parsePPDefine()
584 if (FormatTok->Tok.getKind() == tok::l_paren && in parsePPDefine()
585 FormatTok->WhitespaceRange.getBegin() == in parsePPDefine()
586 FormatTok->WhitespaceRange.getEnd()) { in parsePPDefine()
637 assert(!FormatTok->Tok.is(tok::l_brace)); in parseStructuralElement()
638 switch (FormatTok->Tok.getKind()) { in parseStructuralElement()
641 if (FormatTok->Tok.is(tok::l_brace)) { in parseStructuralElement()
645 switch (FormatTok->Tok.getObjCKeywordID()) { in parseStructuralElement()
674 if (FormatTok->is(tok::l_brace)) { in parseStructuralElement()
676 while (FormatTok && FormatTok->isNot(tok::eof)) { in parseStructuralElement()
677 if (FormatTok->is(tok::r_brace)) { in parseStructuralElement()
681 FormatTok->Finalized = true; in parseStructuralElement()
691 if (FormatTok->Tok.is(tok::kw_namespace)) { in parseStructuralElement()
731 if (FormatTok->Tok.is(tok::string_literal)) { in parseStructuralElement()
733 if (FormatTok->Tok.is(tok::l_brace)) { in parseStructuralElement()
747 if (FormatTok->IsForEachMacro) { in parseStructuralElement()
752 FormatTok->is(Keywords.kw_import)) { in parseStructuralElement()
756 if (FormatTok->is(Keywords.kw_signals)) { in parseStructuralElement()
766 switch (FormatTok->Tok.getKind()) { in parseStructuralElement()
769 if (FormatTok->Tok.is(tok::l_brace)) in parseStructuralElement()
777 if (FormatTok->isOneOf(Keywords.kw_NS_ENUM, Keywords.kw_NS_OPTIONS, in parseStructuralElement()
791 if (Style.Language == FormatStyle::LK_Java && FormatTok && in parseStructuralElement()
792 FormatTok->is(tok::kw_class)) in parseStructuralElement()
807 if (FormatTok->Tok.isAnyIdentifier() || in parseStructuralElement()
808 FormatTok->isSimpleTypeSpecifier()) in parseStructuralElement()
810 if (FormatTok->is(tok::l_paren)) in parseStructuralElement()
812 if (FormatTok->is(tok::l_brace)) in parseStructuralElement()
823 FormatTok->Type = TT_FunctionLBrace; in parseStructuralElement()
836 StringRef Text = FormatTok->TokenText; in parseStructuralElement()
849 if (FormatTok->Tok.is(tok::colon) && !Line->MustBeDeclaration) { in parseStructuralElement()
855 bool FunctionLike = FormatTok->is(tok::l_paren); in parseStructuralElement()
858 if (FormatTok->NewlinesBefore > 0 && in parseStructuralElement()
860 tokenCanStartNewLine(FormatTok->Tok) && Text == Text.upper()) { in parseStructuralElement()
869 if (FormatTok->Tok.is(tok::l_brace)) { in parseStructuralElement()
897 assert(FormatTok->is(tok::l_square)); in tryToParseLambda()
898 FormatToken &LSquare = *FormatTok; in tryToParseLambda()
902 while (FormatTok->isNot(tok::l_brace)) { in tryToParseLambda()
903 if (FormatTok->isSimpleTypeSpecifier()) { in tryToParseLambda()
907 switch (FormatTok->Tok.getKind()) { in tryToParseLambda()
925 FormatTok->Type = TT_TrailingReturnArrow; in tryToParseLambda()
939 if (FormatTok->is(tok::equal)) { in tryToParseLambdaIntroducer()
941 if (FormatTok->is(tok::r_square)) { in tryToParseLambdaIntroducer()
945 if (FormatTok->isNot(tok::comma)) in tryToParseLambdaIntroducer()
948 } else if (FormatTok->is(tok::amp)) { in tryToParseLambdaIntroducer()
950 if (FormatTok->is(tok::r_square)) { in tryToParseLambdaIntroducer()
954 if (!FormatTok->isOneOf(tok::comma, tok::identifier)) { in tryToParseLambdaIntroducer()
957 if (FormatTok->is(tok::comma)) in tryToParseLambdaIntroducer()
959 } else if (FormatTok->is(tok::r_square)) { in tryToParseLambdaIntroducer()
964 if (FormatTok->is(tok::amp)) in tryToParseLambdaIntroducer()
966 if (!FormatTok->isOneOf(tok::identifier, tok::kw_this)) in tryToParseLambdaIntroducer()
969 if (FormatTok->is(tok::ellipsis)) in tryToParseLambdaIntroducer()
971 if (FormatTok->is(tok::comma)) { in tryToParseLambdaIntroducer()
973 } else if (FormatTok->is(tok::r_square)) { in tryToParseLambdaIntroducer()
987 if (FormatTok->is(tok::identifier)) in tryToParseJSFunction()
990 if (FormatTok->isNot(tok::l_paren)) in tryToParseJSFunction()
993 while (FormatTok->isNot(tok::l_brace)) { in tryToParseJSFunction()
996 if (!FormatTok->isOneOf(tok::identifier, tok::comma, tok::r_paren, in tryToParseJSFunction()
1005 if (FormatTok->BlockKind == BK_Unknown) in tryToParseBracedList()
1007 assert(FormatTok->BlockKind != BK_Unknown); in tryToParseBracedList()
1008 if (FormatTok->BlockKind == BK_Block) in tryToParseBracedList()
1022 FormatTok->is(Keywords.kw_function)) { in parseBracedList()
1026 switch (FormatTok->Tok.getKind()) { in parseBracedList()
1029 if (FormatTok->is(tok::l_brace)) { in parseBracedList()
1039 FormatTok->BlockKind = BK_BracedInit; in parseBracedList()
1047 if (FormatTok->is(tok::l_brace)) in parseBracedList()
1074 assert(FormatTok->Tok.is(tok::l_paren) && "'(' expected."); in parseParens()
1077 switch (FormatTok->Tok.getKind()) { in parseParens()
1080 if (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::l_brace)) in parseParens()
1099 if (FormatTok->Tok.is(tok::l_brace)) in parseParens()
1104 FormatTok->is(Keywords.kw_function)) in parseParens()
1117 assert(FormatTok->Tok.is(tok::l_square) && "'[' expected."); in parseSquare()
1121 switch (FormatTok->Tok.getKind()) { in parseSquare()
1142 if (FormatTok->Tok.is(tok::l_brace)) in parseSquare()
1153 assert(FormatTok->Tok.is(tok::kw_if) && "'if' expected"); in parseIfThenElse()
1155 if (FormatTok->Tok.is(tok::l_paren)) in parseIfThenElse()
1158 if (FormatTok->Tok.is(tok::l_brace)) { in parseIfThenElse()
1173 if (FormatTok->Tok.is(tok::kw_else)) { in parseIfThenElse()
1177 if (FormatTok->Tok.is(tok::l_brace)) { in parseIfThenElse()
1181 } else if (FormatTok->Tok.is(tok::kw_if)) { in parseIfThenElse()
1195 assert(FormatTok->isOneOf(tok::kw_try, tok::kw___try) && "'try' expected"); in parseTryCatch()
1198 if (FormatTok->is(tok::colon)) { in parseTryCatch()
1201 while (FormatTok->is(tok::identifier)) { in parseTryCatch()
1203 if (FormatTok->is(tok::l_paren)) in parseTryCatch()
1207 if (FormatTok->is(tok::comma)) in parseTryCatch()
1212 if (Style.Language == FormatStyle::LK_Java && FormatTok->is(tok::l_paren)) { in parseTryCatch()
1215 if (FormatTok->is(tok::l_brace)) { in parseTryCatch()
1225 } else if (!FormatTok->is(tok::kw_catch)) { in parseTryCatch()
1236 if (FormatTok->is(tok::at)) in parseTryCatch()
1238 if (!(FormatTok->isOneOf(tok::kw_catch, Keywords.kw___except, in parseTryCatch()
1242 FormatTok->is(Keywords.kw_finally)) || in parseTryCatch()
1243 (FormatTok->Tok.isObjCAtKeyword(tok::objc_catch) || in parseTryCatch()
1244 FormatTok->Tok.isObjCAtKeyword(tok::objc_finally)))) in parseTryCatch()
1247 while (FormatTok->isNot(tok::l_brace)) { in parseTryCatch()
1248 if (FormatTok->is(tok::l_paren)) { in parseTryCatch()
1252 if (FormatTok->isOneOf(tok::semi, tok::r_brace, tok::eof)) in parseTryCatch()
1273 assert(FormatTok->Tok.is(tok::kw_namespace) && "'namespace' expected"); in parseNamespace()
1275 const FormatToken &InitialToken = *FormatTok; in parseNamespace()
1277 if (FormatTok->Tok.is(tok::identifier)) in parseNamespace()
1279 if (FormatTok->Tok.is(tok::l_brace)) { in parseNamespace()
1289 if (FormatTok->Tok.is(tok::semi)) in parseNamespace()
1297 assert(FormatTok->is(tok::kw_new) && "'new' expected"); in parseNew()
1305 if (FormatTok->isOneOf(tok::semi, tok::l_brace, tok::r_brace)) in parseNew()
1309 if (FormatTok->is(tok::l_paren)) { in parseNew()
1313 if (FormatTok->is(tok::l_brace)) in parseNew()
1322 assert((FormatTok->Tok.is(tok::kw_for) || FormatTok->Tok.is(tok::kw_while) || in parseForOrWhileLoop()
1323 FormatTok->IsForEachMacro) && in parseForOrWhileLoop()
1326 if (FormatTok->Tok.is(tok::l_paren)) in parseForOrWhileLoop()
1328 if (FormatTok->Tok.is(tok::l_brace)) { in parseForOrWhileLoop()
1341 assert(FormatTok->Tok.is(tok::kw_do) && "'do' expected"); in parseDoWhile()
1343 if (FormatTok->Tok.is(tok::l_brace)) { in parseDoWhile()
1356 if (!FormatTok->Tok.is(tok::kw_while)) { in parseDoWhile()
1370 if (CommentsBeforeNextToken.empty() && FormatTok->Tok.is(tok::l_brace)) { in parseLabel()
1373 if (FormatTok->Tok.is(tok::kw_break)) { in parseLabel()
1389 assert(FormatTok->Tok.is(tok::kw_case) && "'case' expected"); in parseCaseLabel()
1393 } while (!eof() && !FormatTok->Tok.is(tok::colon)); in parseCaseLabel()
1398 assert(FormatTok->Tok.is(tok::kw_switch) && "'switch' expected"); in parseSwitch()
1400 if (FormatTok->Tok.is(tok::l_paren)) in parseSwitch()
1402 if (FormatTok->Tok.is(tok::l_brace)) { in parseSwitch()
1417 if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_qslots)) in parseAccessSpecifier()
1420 if (FormatTok->Tok.is(tok::colon)) in parseAccessSpecifier()
1427 if (FormatTok->Tok.is(tok::kw_enum)) in parseEnum()
1431 if (FormatTok->Tok.is(tok::kw_class) || FormatTok->Tok.is(tok::kw_struct)) in parseEnum()
1433 while (FormatTok->Tok.getIdentifierInfo() || in parseEnum()
1434 FormatTok->isOneOf(tok::colon, tok::coloncolon, tok::less, in parseEnum()
1438 if (FormatTok->is(tok::l_paren)) in parseEnum()
1440 if (FormatTok->is(tok::identifier)) in parseEnum()
1445 if (FormatTok->isNot(tok::l_brace)) in parseEnum()
1447 FormatTok->BlockKind = BK_Block; in parseEnum()
1458 if (FormatTok->is(tok::semi)) in parseEnum()
1486 FormatTok = Tokens->setPosition(StoredPosition); in parseJavaEnumBody()
1501 while (FormatTok) { in parseJavaEnumBody()
1502 if (FormatTok->is(tok::l_brace)) { in parseJavaEnumBody()
1506 } else if (FormatTok->is(tok::l_paren)) { in parseJavaEnumBody()
1508 } else if (FormatTok->is(tok::comma)) { in parseJavaEnumBody()
1511 } else if (FormatTok->is(tok::semi)) { in parseJavaEnumBody()
1515 } else if (FormatTok->is(tok::r_brace)) { in parseJavaEnumBody()
1531 const FormatToken &InitialToken = *FormatTok; in parseRecord()
1533 if (FormatTok->isOneOf(tok::identifier, tok::coloncolon, tok::kw___attribute, in parseRecord()
1537 if (FormatTok->Tok.is(tok::l_paren)) { in parseRecord()
1542 while (FormatTok->is(tok::identifier) || FormatTok->is(tok::coloncolon) || in parseRecord()
1543 FormatTok->is(tok::hashhash) || in parseRecord()
1546 FormatTok->isOneOf(tok::period, tok::comma))) in parseRecord()
1559 if (FormatTok->Tok.is(tok::colon) || FormatTok->Tok.is(tok::less)) { in parseRecord()
1560 while (!eof() && FormatTok->Tok.isNot(tok::l_brace)) { in parseRecord()
1561 if (FormatTok->Tok.is(tok::semi)) in parseRecord()
1567 if (FormatTok->Tok.is(tok::l_brace)) { in parseRecord()
1584 assert(FormatTok->Tok.is(tok::less) && "'<' expected."); in parseObjCProtocolList()
1587 while (!eof() && FormatTok->Tok.isNot(tok::greater)); in parseObjCProtocolList()
1593 if (FormatTok->Tok.isObjCAtKeyword(tok::objc_end)) { in parseObjCUntilAtEnd()
1598 if (FormatTok->is(tok::l_brace)) { in parseObjCUntilAtEnd()
1602 } else if (FormatTok->is(tok::r_brace)) { in parseObjCUntilAtEnd()
1617 if (FormatTok->Tok.is(tok::colon)) { in parseObjCInterfaceOrImplementation()
1620 } else if (FormatTok->Tok.is(tok::l_paren)) in parseObjCInterfaceOrImplementation()
1624 if (FormatTok->Tok.is(tok::less)) in parseObjCInterfaceOrImplementation()
1627 if (FormatTok->Tok.is(tok::l_brace)) { in parseObjCInterfaceOrImplementation()
1645 if (FormatTok->Tok.is(tok::less)) in parseObjCProtocol()
1649 if (FormatTok->Tok.is(tok::semi)) { in parseObjCProtocol()
1659 assert(FormatTok->isOneOf(Keywords.kw_import, tok::kw_export)); in parseJavaScriptEs6ImportExport()
1662 if (FormatTok->isOneOf(tok::kw_const, tok::kw_class, Keywords.kw_function, in parseJavaScriptEs6ImportExport()
1666 if (FormatTok->is(tok::kw_default)) { in parseJavaScriptEs6ImportExport()
1671 if (FormatTok->is(tok::l_brace)) { in parseJavaScriptEs6ImportExport()
1672 FormatTok->BlockKind = BK_Block; in parseJavaScriptEs6ImportExport()
1676 while (!eof() && FormatTok->isNot(tok::semi) && in parseJavaScriptEs6ImportExport()
1677 FormatTok->isNot(tok::l_brace)) { in parseJavaScriptEs6ImportExport()
1725 bool UnwrappedLineParser::eof() const { return FormatTok->Tok.is(tok::eof); } in eof()
1727 bool UnwrappedLineParser::isOnNewLine(const FormatToken &FormatTok) { in isOnNewLine() argument
1728 return (Line->InPPDirective || FormatTok.HasUnescapedNewline) && in isOnNewLine()
1729 FormatTok.NewlinesBefore > 0; in isOnNewLine()
1752 flushComments(isOnNewLine(*FormatTok)); in nextToken()
1753 pushToken(FormatTok); in nextToken()
1760 FormatTok = Tokens->getNextToken(); in readToken()
1761 assert(FormatTok); in readToken()
1762 while (!Line->InPPDirective && FormatTok->Tok.is(tok::hash) && in readToken()
1763 (FormatTok->HasUnescapedNewline || FormatTok->IsFirst)) { in readToken()
1771 flushComments(isOnNewLine(*FormatTok)); in readToken()
1774 while (FormatTok->Type == TT_ConflictStart || in readToken()
1775 FormatTok->Type == TT_ConflictEnd || in readToken()
1776 FormatTok->Type == TT_ConflictAlternative) { in readToken()
1777 if (FormatTok->Type == TT_ConflictStart) { in readToken()
1779 } else if (FormatTok->Type == TT_ConflictAlternative) { in readToken()
1781 } else if (FormatTok->Type == TT_ConflictEnd) { in readToken()
1784 FormatTok = Tokens->getNextToken(); in readToken()
1785 FormatTok->MustBreakBefore = true; in readToken()
1793 if (!FormatTok->Tok.is(tok::comment)) in readToken()
1795 if (isOnNewLine(*FormatTok) || FormatTok->IsFirst) { in readToken()
1799 pushToken(FormatTok); in readToken()
1801 CommentsBeforeNextToken.push_back(FormatTok); in readToken()