Lines Matching refs:Tok
27 void Parser::MaybeSkipAttributes(tok::ObjCKeywordKind Kind) {
29 if (Tok.is(tok::kw___attribute)) {
30 if (Kind == tok::objc_interface || Kind == tok::objc_protocol)
31 Diag(Tok, diag::err_objc_postfix_attribute_hint)
32 << (Kind == tok::objc_protocol);
34 Diag(Tok, diag::err_objc_postfix_attribute);
50 if (Tok.is(tok::code_completion)) {
57 switch (Tok.getObjCKeywordID()) {
58 case tok::objc_class:
60 case tok::objc_interface: {
65 case tok::objc_protocol: {
69 case tok::objc_implementation:
71 case tok::objc_end:
73 case tok::objc_compatibility_alias:
76 case tok::objc_synthesize:
79 case tok::objc_dynamic:
82 case tok::objc_import:
86 SkipUntil(tok::semi);
90 SkipUntil(tok::semi);
134 MaybeSkipAttributes(tok::objc_class);
135 if (Tok.isNot(tok::identifier)) {
136 Diag(Tok, diag::err_expected) << tok::identifier;
137 SkipUntil(tok::semi);
140 ClassNames.push_back(Tok.getIdentifierInfo());
141 ClassLocs.push_back(Tok.getLocation());
146 if (Tok.is(tok::less))
149 if (!TryConsumeToken(tok::comma))
154 if (ExpectAndConsume(tok::semi, diag::err_expected_after, "@class"))
213 assert(Tok.isObjCAtKeyword(tok::objc_interface) &&
219 if (Tok.is(tok::code_completion)) {
225 MaybeSkipAttributes(tok::objc_interface);
227 if (Tok.isNot(tok::identifier)) {
228 Diag(Tok, diag::err_expected)
229 << tok::identifier; // missing class or category name.
234 IdentifierInfo *nameId = Tok.getIdentifierInfo();
244 if (Tok.is(tok::less))
248 if (Tok.is(tok::l_paren) &&
251 BalancedDelimiterTracker T(*this, tok::l_paren);
256 if (Tok.is(tok::code_completion)) {
263 if (Tok.is(tok::identifier)) {
264 categoryId = Tok.getIdentifierInfo();
268 Diag(Tok, diag::err_expected)
269 << tok::identifier; // missing category name.
286 if (Tok.is(tok::less) &&
302 if (Tok.is(tok::l_brace))
303 ParseObjCClassInstanceVariables(CategoryType, tok::objc_private, AtLoc);
305 ParseObjCInterfaceDeclList(tok::objc_not_keyword, CategoryType);
317 if (Tok.is(tok::colon)) { // a super class is specified.
321 if (Tok.is(tok::code_completion)) {
327 if (Tok.isNot(tok::identifier)) {
328 Diag(Tok, diag::err_expected)
329 << tok::identifier; // missing super class name.
332 superClassId = Tok.getIdentifierInfo();
336 if (Tok.is(tok::less)) {
362 } else if (protocols.empty() && Tok.is(tok::less) &&
369 if (Tok.isNot(tok::less))
383 if (Tok.is(tok::l_brace))
384 ParseObjCClassInstanceVariables(ClsType, tok::objc_protected, AtLoc);
386 ParseObjCInterfaceDeclList(tok::objc_interface, ClsType);
450 assert(Tok.is(tok::less) && "Not at the beginning of a type parameter list");
485 if (Tok.is(tok::kw___covariant) || Tok.is(tok::kw___contravariant)) {
486 variance = Tok.is(tok::kw___covariant)
501 if (!Tok.is(tok::identifier)) {
503 if (Tok.is(tok::code_completion)) {
514 Diag(Tok, diag::err_objc_expected_type_parameter);
519 IdentifierInfo *paramName = Tok.getIdentifierInfo();
525 if (TryConsumeToken(tok::colon, colonLoc)) {
558 } while (TryConsumeToken(tok::comma));
562 SkipUntil(tok::greater, tok::at, StopBeforeMatch);
563 if (Tok.is(tok::greater))
569 SkipUntil({tok::greater, tok::greaterequal, tok::at, tok::minus,
570 tok::minus, tok::plus, tok::colon, tok::l_paren, tok::l_brace,
571 tok::comma, tok::semi },
573 if (Tok.is(tok::greater))
582 if (Tok.isNot(tok::colon) && Tok.isNot(tok::l_paren)) {
633 void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey,
637 tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword;
643 if (Tok.isOneOf(tok::minus, tok::plus)) {
651 SkipUntil(tok::at, StopAtSemi | StopBeforeMatch);
652 if (Tok.is(tok::semi))
657 if (Tok.is(tok::l_paren)) {
658 Diag(Tok, diag::err_expected_minus_or_plus);
659 ParseObjCMethodDecl(Tok.getLocation(),
660 tok::minus,
665 if (Tok.is(tok::semi)) {
675 if (Tok.is(tok::code_completion)) {
683 if (Tok.isNot(tok::at)) {
687 if (Tok.is(tok::r_brace))
696 if (Tok.is(tok::code_completion)) {
701 tok::ObjCKeywordKind DirectiveKind = Tok.getObjCKeywordID();
703 if (DirectiveKind == tok::objc_end) { // @end -> terminate list
705 AtEnd.setEnd(Tok.getLocation());
707 } else if (DirectiveKind == tok::objc_not_keyword) {
708 Diag(Tok, diag::err_objc_unknown_at);
709 SkipUntil(tok::semi);
724 SkipUntil(tok::r_brace, tok::at, StopAtSemi);
727 case tok::objc_implementation:
728 case tok::objc_interface:
736 case tok::objc_required:
737 case tok::objc_optional:
740 if (contextKey != tok::objc_protocol)
746 case tok::objc_property:
753 if (Tok.is(tok::l_paren)) {
754 LParenLoc = Tok.getLocation();
802 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
809 if (Tok.is(tok::code_completion)) {
812 } else if (Tok.isObjCAtKeyword(tok::objc_end)) {
815 Diag(Tok, diag::err_objc_missing_end)
816 << FixItHint::CreateInsertion(Tok.getLocation(), "\n@end\n");
819 AtEnd.setBegin(Tok.getLocation());
820 AtEnd.setEnd(Tok.getLocation());
871 assert(Tok.getKind() == tok::l_paren);
872 BalancedDelimiterTracker T(*this, tok::l_paren);
876 if (Tok.is(tok::code_completion)) {
880 const IdentifierInfo *II = Tok.getIdentifierInfo();
917 if (ExpectAndConsume(tok::equal, DiagID)) {
918 SkipUntil(tok::r_paren, StopAtSemi);
922 if (Tok.is(tok::code_completion)) {
934 Diag(Tok, diag::err_objc_expected_selector_for_getter_setter)
936 SkipUntil(tok::r_paren, StopAtSemi);
944 if (ExpectAndConsume(tok::colon,
946 SkipUntil(tok::r_paren, StopAtSemi);
957 Tok.getLocation());
959 DS.setNullability(Tok.getLocation(), NullabilityKind::NonNull);
964 Tok.getLocation());
966 DS.setNullability(Tok.getLocation(), NullabilityKind::Nullable);
971 Tok.getLocation());
973 DS.setNullability(Tok.getLocation(), NullabilityKind::Unspecified);
978 Tok.getLocation());
980 DS.setNullability(Tok.getLocation(), NullabilityKind::Unspecified);
986 SkipUntil(tok::r_paren, StopAtSemi);
990 if (Tok.isNot(tok::comma))
1009 Decl *Parser::ParseObjCMethodPrototype(tok::ObjCKeywordKind MethodImplKind,
1011 assert(Tok.isOneOf(tok::minus, tok::plus) && "expected +/-");
1013 tok::TokenKind methodType = Tok.getKind();
1032 switch (Tok.getKind()) {
1035 case tok::ampamp:
1036 case tok::ampequal:
1037 case tok::amp:
1038 case tok::pipe:
1039 case tok::tilde:
1040 case tok::exclaim:
1041 case tok::exclaimequal:
1042 case tok::pipepipe:
1043 case tok::pipeequal:
1044 case tok::caret:
1045 case tok::caretequal: {
1046 std::string ThisTok(PP.getSpelling(Tok));
1049 Tok.setKind(tok::identifier);
1056 case tok::identifier:
1057 case tok::kw_asm:
1058 case tok::kw_auto:
1059 case tok::kw_bool:
1060 case tok::kw_break:
1061 case tok::kw_case:
1062 case tok::kw_catch:
1063 case tok::kw_char:
1064 case tok::kw_class:
1065 case tok::kw_const:
1066 case tok::kw_const_cast:
1067 case tok::kw_continue:
1068 case tok::kw_default:
1069 case tok::kw_delete:
1070 case tok::kw_do:
1071 case tok::kw_double:
1072 case tok::kw_dynamic_cast:
1073 case tok::kw_else:
1074 case tok::kw_enum:
1075 case tok::kw_explicit:
1076 case tok::kw_export:
1077 case tok::kw_extern:
1078 case tok::kw_false:
1079 case tok::kw_float:
1080 case tok::kw_for:
1081 case tok::kw_friend:
1082 case tok::kw_goto:
1083 case tok::kw_if:
1084 case tok::kw_inline:
1085 case tok::kw_int:
1086 case tok::kw_long:
1087 case tok::kw_mutable:
1088 case tok::kw_namespace:
1089 case tok::kw_new:
1090 case tok::kw_operator:
1091 case tok::kw_private:
1092 case tok::kw_protected:
1093 case tok::kw_public:
1094 case tok::kw_register:
1095 case tok::kw_reinterpret_cast:
1096 case tok::kw_restrict:
1097 case tok::kw_return:
1098 case tok::kw_short:
1099 case tok::kw_signed:
1100 case tok::kw_sizeof:
1101 case tok::kw_static:
1102 case tok::kw_static_cast:
1103 case tok::kw_struct:
1104 case tok::kw_switch:
1105 case tok::kw_template:
1106 case tok::kw_this:
1107 case tok::kw_throw:
1108 case tok::kw_true:
1109 case tok::kw_try:
1110 case tok::kw_typedef:
1111 case tok::kw_typeid:
1112 case tok::kw_typename:
1113 case tok::kw_typeof:
1114 case tok::kw_union:
1115 case tok::kw_unsigned:
1116 case tok::kw_using:
1117 case tok::kw_virtual:
1118 case tok::kw_void:
1119 case tok::kw_volatile:
1120 case tok::kw_wchar_t:
1121 case tok::kw_while:
1122 case tok::kw__Bool:
1123 case tok::kw__Complex:
1124 case tok::kw___alignof:
1125 case tok::kw___auto_type:
1126 IdentifierInfo *II = Tok.getIdentifierInfo();
1138 return (getLangOpts().ObjC2 && Tok.is(tok::identifier) &&
1139 Tok.getIdentifierInfo() == ObjCTypeQuals[objc_in]);
1167 if (Tok.is(tok::code_completion)) {
1173 if (Tok.isNot(tok::identifier))
1176 const IdentifierInfo *II = Tok.getIdentifierInfo();
1179 NextToken().is(tok::less) ||
1180 NextToken().is(tok::coloncolon))
1213 DS.setNullability(Tok.getLocation(), Nullability);
1271 assert(Tok.is(tok::l_paren) && "expected (");
1273 BalancedDelimiterTracker T(*this, tok::l_paren);
1276 SourceLocation TypeStartLoc = Tok.getLocation();
1291 declSpec.SetRangeEnd(Tok.getLocation());
1316 if (Tok.is(tok::r_paren))
1318 else if (Tok.getLocation() == TypeStartLoc) {
1320 Diag(Tok, diag::err_expected_type);
1321 SkipUntil(tok::r_paren, StopAtSemi);
1359 tok::TokenKind mType,
1360 tok::ObjCKeywordKind MethodImplKind,
1364 if (Tok.is(tok::code_completion)) {
1365 Actions.CodeCompleteObjCMethodDecl(getCurScope(), mType == tok::minus,
1374 if (Tok.is(tok::l_paren))
1383 if (Tok.is(tok::code_completion)) {
1384 tok::minus,
1395 if (!SelIdent && Tok.isNot(tok::colon)) { // missing selector name.
1396 Diag(Tok, diag::err_expected_selector_for_method)
1397 << SourceRange(mLoc, Tok.getLocation());
1399 SkipUntil(tok::at, StopAtSemi | StopBeforeMatch);
1404 if (Tok.isNot(tok::colon)) {
1411 = Actions.ActOnMethodDeclaration(getCurScope(), mLoc, Tok.getLocation(),
1433 if (ExpectAndConsume(tok::colon))
1437 if (Tok.is(tok::l_paren)) // Parse the argument type if present.
1451 if (Tok.is(tok::code_completion)) {
1454 mType == tok::minus,
1461 if (Tok.isNot(tok::identifier)) {
1462 Diag(Tok, diag::err_expected)
1463 << tok::identifier; // missing argument name.
1467 ArgInfo.Name = Tok.getIdentifierInfo();
1468 ArgInfo.NameLoc = Tok.getLocation();
1479 if (Tok.is(tok::code_completion)) {
1481 mType == tok::minus,
1490 if (!SelIdent && Tok.isNot(tok::colon))
1493 SourceLocation ColonLoc = Tok.getLocation();
1506 while (Tok.is(tok::comma)) {
1508 if (Tok.is(tok::ellipsis)) {
1514 Diag(Tok, diag::warn_cstyle_param);
1541 = Actions.ActOnMethodDeclaration(getCurScope(), mLoc, Tok.getLocation(),
1561 assert(Tok.is(tok::less) && "expected <");
1568 if (Tok.is(tok::code_completion)) {
1575 if (Tok.isNot(tok::identifier)) {
1576 Diag(Tok, diag::err_expected) << tok::identifier;
1577 SkipUntil(tok::greater, StopAtSemi);
1580 ProtocolIdents.push_back(std::make_pair(Tok.getIdentifierInfo(),
1581 Tok.getLocation()));
1582 ProtocolLocs.push_back(Tok.getLocation());
1585 if (!TryConsumeToken(tok::comma))
1601 assert(Tok.is(tok::less) && "Protocol qualifiers start with '<'");
1639 assert(Tok.is(tok::less) && "Not at the start of type args or protocols");
1652 if (Tok.is(tok::identifier) &&
1653 (NextToken().is(tok::comma) ||
1654 NextToken().is(tok::greater) ||
1655 NextToken().is(tok::greatergreater))) {
1656 identifiers.push_back(Tok.getIdentifierInfo());
1661 if (Tok.is(tok::code_completion)) {
1682 } while (TryConsumeToken(tok::comma));
1742 TryConsumeToken(tok::ellipsis, ellipsisLoc);
1752 } while (TryConsumeToken(tok::comma));
1779 assert(Tok.is(tok::less));
1796 if ((consumeLastToken && Tok.is(tok::less)) ||
1797 (!consumeLastToken && NextToken().is(tok::less))) {
1807 Diag(Tok, diag::err_objc_type_args_after_protocols)
1809 SkipUntil(tok::greater, tok::greatergreater, skipFlags);
1825 assert(Tok.is(tok::less));
1844 endLoc = Tok.getLocation();
1897 tok::ObjCKeywordKind visibility,
1899 assert(Tok.is(tok::l_brace) && "expected {");
1905 BalancedDelimiterTracker T(*this, tok::l_brace);
1908 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
1912 if (Tok.is(tok::semi)) {
1918 if (TryConsumeToken(tok::at)) { // parse objc-visibility-spec
1919 if (Tok.is(tok::code_completion)) {
1924 switch (Tok.getObjCKeywordID()) {
1925 case tok::objc_private:
1926 case tok::objc_public:
1927 case tok::objc_protected:
1928 case tok::objc_package:
1929 visibility = Tok.getObjCKeywordID();
1933 case tok::objc_end:
1934 Diag(Tok, diag::err_objc_unexpected_atend);
1935 Tok.setLocation(Tok.getLocation().getLocWithOffset(-1));
1936 Tok.setKind(tok::at);
1937 Tok.setLength(1);
1938 PP.EnterToken(Tok);
1944 Diag(Tok, diag::err_objc_illegal_visibility_spec);
1949 if (Tok.is(tok::code_completion)) {
1972 if (Tok.is(tok::semi)) {
1975 Diag(Tok, diag::err_expected_semi_decl_list);
1977 SkipUntil(tok::r_brace, StopAtSemi | StopBeforeMatch);
2004 assert(Tok.isObjCAtKeyword(tok::objc_protocol) &&
2008 if (Tok.is(tok::code_completion)) {
2014 MaybeSkipAttributes(tok::objc_protocol);
2016 if (Tok.isNot(tok::identifier)) {
2017 Diag(Tok, diag::err_expected) << tok::identifier; // missing protocol name.
2021 IdentifierInfo *protocolName = Tok.getIdentifierInfo();
2024 if (TryConsumeToken(tok::semi)) { // forward declaration of one protocol.
2032 if (Tok.is(tok::comma)) { // list of forward declarations.
2039 if (Tok.isNot(tok::identifier)) {
2040 Diag(Tok, diag::err_expected) << tok::identifier;
2041 SkipUntil(tok::semi);
2044 ProtocolRefs.push_back(IdentifierLocPair(Tok.getIdentifierInfo(),
2045 Tok.getLocation()));
2048 if (Tok.isNot(tok::comma))
2052 if (ExpectAndConsume(tok::semi, diag::err_expected_after, "@protocol"))
2064 if (Tok.is(tok::less) &&
2077 ParseObjCInterfaceDeclList(tok::objc_protocol, ProtoType);
2093 assert(Tok.isObjCAtKeyword(tok::objc_implementation) &&
2099 if (Tok.is(tok::code_completion)) {
2105 MaybeSkipAttributes(tok::objc_implementation);
2107 if (Tok.isNot(tok::identifier)) {
2108 Diag(Tok, diag::err_expected)
2109 << tok::identifier; // missing class or category name.
2113 IdentifierInfo *nameId = Tok.getIdentifierInfo();
2119 if (Tok.is(tok::less)) {
2122 SourceLocation diagLoc = Tok.getLocation();
2134 if (Tok.is(tok::l_paren)) {
2140 if (Tok.is(tok::code_completion)) {
2146 if (Tok.is(tok::identifier)) {
2147 categoryId = Tok.getIdentifierInfo();
2150 Diag(Tok, diag::err_expected)
2151 << tok::identifier; // missing category name.
2154 if (Tok.isNot(tok::r_paren)) {
2155 Diag(Tok, diag::err_expected) << tok::r_paren;
2156 SkipUntil(tok::r_paren); // don't stop at ';'
2160 if (Tok.is(tok::less)) { // we have illegal '<' try to recover
2161 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2179 if (TryConsumeToken(tok::colon)) {
2181 if (Tok.isNot(tok::identifier)) {
2182 Diag(Tok, diag::err_expected)
2183 << tok::identifier; // missing super class name.
2186 superClassId = Tok.getIdentifierInfo();
2193 if (Tok.is(tok::l_brace)) // we have ivars
2194 ParseObjCClassInstanceVariables(ObjCImpDecl, tok::objc_private, AtLoc);
2195 else if (Tok.is(tok::less)) { // we have illegal '<' try to recover
2196 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2230 assert(Tok.isObjCAtKeyword(tok::objc_end) &&
2243 finish(P.Tok.getLocation());
2245 P.Diag(P.Tok, diag::err_objc_missing_end)
2246 << FixItHint::CreateInsertion(P.Tok.getLocation(), "\n@end\n");
2283 assert(Tok.isObjCAtKeyword(tok::objc_compatibility_alias) &&
2286 if (Tok.isNot(tok::identifier)) {
2287 Diag(Tok, diag::err_expected) << tok::identifier;
2290 IdentifierInfo *aliasId = Tok.getIdentifierInfo();
2292 if (Tok.isNot(tok::identifier)) {
2293 Diag(Tok, diag::err_expected) << tok::identifier;
2296 IdentifierInfo *classId = Tok.getIdentifierInfo();
2298 ExpectAndConsume(tok::semi, diag::err_expected_after, "@compatibility_alias");
2315 assert(Tok.isObjCAtKeyword(tok::objc_synthesize) &&
2320 if (Tok.is(tok::code_completion)) {
2326 if (Tok.isNot(tok::identifier)) {
2327 Diag(Tok, diag::err_synthesized_property_name);
2328 SkipUntil(tok::semi);
2333 IdentifierInfo *propertyId = Tok.getIdentifierInfo();
2336 if (TryConsumeToken(tok::equal)) {
2338 if (Tok.is(tok::code_completion)) {
2344 if (Tok.isNot(tok::identifier)) {
2345 Diag(Tok, diag::err_expected) << tok::identifier;
2348 propertyIvar = Tok.getIdentifierInfo();
2353 if (Tok.isNot(tok::comma))
2357 ExpectAndConsume(tok::semi, diag::err_expected_after, "@synthesize");
2369 assert(Tok.isObjCAtKeyword(tok::objc_dynamic) &&
2373 if (Tok.is(tok::code_completion)) {
2379 if (Tok.isNot(tok::identifier)) {
2380 Diag(Tok, diag::err_expected) << tok::identifier;
2381 SkipUntil(tok::semi);
2385 IdentifierInfo *propertyId = Tok.getIdentifierInfo();
2390 if (Tok.isNot(tok::comma))
2394 ExpectAndConsume(tok::semi, diag::err_expected_after, "@dynamic");
2404 if (Tok.isNot(tok::semi)) {
2407 SkipUntil(tok::semi);
2412 ExpectAndConsume(tok::semi, diag::err_expected_after, "@throw");
2422 if (Tok.isNot(tok::l_paren)) {
2423 Diag(Tok, diag::err_expected_lparen_after) << "@synchronized";
2431 if (Tok.is(tok::r_paren)) {
2435 Diag(Tok, diag::err_expected) << tok::r_paren;
2438 SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch);
2442 if (Tok.isNot(tok::l_brace)) {
2444 Diag(Tok, diag::err_expected) << tok::l_brace;
2463 body = Actions.ActOnNullStmt(Tok.getLocation());
2483 if (Tok.isNot(tok::l_brace)) {
2484 Diag(Tok, diag::err_expected) << tok::l_brace;
2493 TryBody = Actions.ActOnNullStmt(Tok.getLocation());
2495 while (Tok.is(tok::at)) {
2500 if (!AfterAt.isObjCAtKeyword(tok::objc_catch) &&
2501 !AfterAt.isObjCAtKeyword(tok::objc_finally))
2505 if (Tok.isObjCAtKeyword(tok::objc_catch)) {
2508 if (Tok.is(tok::l_paren)) {
2511 if (Tok.isNot(tok::ellipsis)) {
2525 if (Tok.is(tok::r_paren))
2528 SkipUntil(tok::r_paren, StopAtSemi);
2531 if (Tok.is(tok::l_brace))
2534 Diag(Tok, diag::err_expected) << tok::l_brace;
2536 CatchBody = Actions.ActOnNullStmt(Tok.getLocation());
2552 assert(Tok.isObjCAtKeyword(tok::objc_finally) && "Lookahead confused?");
2557 if (Tok.is(tok::l_brace))
2560 Diag(Tok, diag::err_expected) << tok::l_brace;
2562 FinallyBody = Actions.ActOnNullStmt(Tok.getLocation());
2585 if (Tok.isNot(tok::l_brace)) {
2586 Diag(Tok, diag::err_expected) << tok::l_brace;
2597 AutoreleasePoolBody = Actions.ActOnNullStmt(Tok.getLocation());
2609 Toks.push_back(Tok);
2610 if (Tok.is(tok::kw_try)) {
2612 if (Tok.is(tok::colon)) {
2613 Toks.push_back(Tok);
2615 while (Tok.isNot(tok::l_brace)) {
2616 ConsumeAndStoreUntil(tok::l_paren, Toks, /*StopAtSemi=*/false);
2617 ConsumeAndStoreUntil(tok::r_paren, Toks, /*StopAtSemi=*/false);
2620 Toks.push_back(Tok); // also store '{'
2622 else if (Tok.is(tok::colon)) {
2625 while (Tok.isNot(tok::l_brace)) {
2626 ConsumeAndStoreUntil(tok::l_paren, Toks, /*StopAtSemi=*/false);
2627 ConsumeAndStoreUntil(tok::r_paren, Toks, /*StopAtSemi=*/false);
2629 Toks.push_back(Tok); // also store '{'
2633 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
2634 while (Tok.is(tok::kw_catch)) {
2635 ConsumeAndStoreUntil(tok::l_brace, Toks, /*StopAtSemi=*/false);
2636 ConsumeAndStoreUntil(tok::r_brace, Toks, /*StopAtSemi=*/false);
2645 PrettyDeclStackTraceEntry CrashInfo(Actions, MDecl, Tok.getLocation(),
2649 if (Tok.is(tok::semi)) {
2651 Diag(Tok, diag::warn_semicolon_before_method_body)
2652 << FixItHint::CreateRemoval(Tok.getLocation());
2658 if (Tok.isNot(tok::l_brace)) {
2659 Diag(Tok, diag::err_expected_method_body);
2662 SkipUntil(tok::l_brace, StopAtSemi | StopBeforeMatch);
2665 if (Tok.isNot(tok::l_brace))
2671 SkipUntil(tok::r_brace);
2685 if (Tok.is(tok::code_completion)) {
2691 if (Tok.isObjCAtKeyword(tok::objc_try))
2694 if (Tok.isObjCAtKeyword(tok::objc_throw))
2697 if (Tok.isObjCAtKeyword(tok::objc_synchronized))
2700 if (Tok.isObjCAtKeyword(tok::objc_autoreleasepool))
2703 if (Tok.isObjCAtKeyword(tok::objc_import) &&
2705 SkipUntil(tok::semi);
2706 return Actions.ActOnNullStmt(Tok.getLocation());
2714 SkipUntil(tok::semi);
2724 switch (Tok.getKind()) {
2725 case tok::code_completion:
2730 case tok::minus:
2731 case tok::plus: {
2732 tok::TokenKind Kind = Tok.getKind();
2735 if (!Tok.is(tok::numeric_constant)) {
2738 case tok::minus: Symbol = "-"; break;
2739 case tok::plus: Symbol = "+"; break;
2742 Diag(Tok, diag::err_nsnumber_nonliteral_unary)
2747 ExprResult Lit(Actions.ActOnNumericConstant(Tok));
2761 case tok::string_literal: // primary-expression: string-literal
2762 case tok::wide_string_literal:
2765 case tok::char_constant:
2768 case tok::numeric_constant:
2771 case tok::kw_true: // Objective-C++, etc.
2772 case tok::kw___objc_yes: // c/c++/objc/objc++ __objc_yes
2774 case tok::kw_false: // Objective-C++, etc.
2775 case tok::kw___objc_no: // c/c++/objc/objc++ __objc_no
2778 case tok::l_square:
2782 case tok::l_brace:
2786 case tok::l_paren:
2791 if (Tok.getIdentifierInfo() == nullptr)
2794 switch (Tok.getIdentifierInfo()->getObjCKeywordID()) {
2795 case tok::objc_encode:
2797 case tok::objc_protocol:
2799 case tok::objc_selector:
2803 if (GetLookAheadToken(1).is(tok::l_brace)) {
2804 char ch = Tok.getIdentifierInfo()->getNameStart()[0];
2811 SourceLocation kwLoc = Tok.getLocation();
2847 if (Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw_typename,
2848 tok::annot_cxxscope))
2851 if (!Actions.isSimpleTypeSpecifier(Tok.getKind())) {
2873 if (Tok.is(tok::l_paren)) {
2918 assert(Tok.is(tok::l_square) && getLangOpts().ObjC1 &&
2920 return GetLookAheadToken(1).is(tok::identifier) &&
2921 GetLookAheadToken(2).is(tok::identifier);
2925 if (!getLangOpts().ObjC1 || !NextToken().is(tok::identifier) ||
2932 if (Tok.is(tok::annot_typename))
2933 Type = getTypeAnnotation(Tok);
2934 else if (Tok.is(tok::identifier))
2935 Type = Actions.getTypeName(*Tok.getIdentifierInfo(), Tok.getLocation(),
2942 if (AfterNext.isOneOf(tok::colon, tok::r_square)) {
2943 if (Tok.is(tok::identifier))
2946 return Tok.is(tok::annot_typename);
2963 assert(Tok.is(tok::l_square) && "'[' expected");
2966 if (Tok.is(tok::code_completion)) {
2981 if (Tok.is(tok::identifier) && Tok.getIdentifierInfo() == Ident_super &&
2982 NextToken().isNot(tok::period) && getCurScope()->isInObjcMethodScope())
2990 SkipUntil(tok::r_square, StopAtSemi);
3004 if (Tok.is(tok::identifier)) {
3005 IdentifierInfo *Name = Tok.getIdentifierInfo();
3006 SourceLocation NameLoc = Tok.getLocation();
3010 NextToken().is(tok::period),
3018 SkipUntil(tok::r_square, StopAtSemi);
3025 if (Tok.is(tok::less)) {
3032 SkipUntil(tok::r_square, StopAtSemi);
3051 SkipUntil(tok::r_square, StopAtSemi);
3104 if (Tok.is(tok::code_completion)) {
3126 if (Tok.is(tok::colon)) {
3132 if (ExpectAndConsume(tok::colon)) {
3136 SkipUntil(tok::r_square, StopAtSemi);
3142 if (Tok.is(tok::code_completion)) {
3161 if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) {
3162 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3172 SkipUntil(tok::r_square, StopAtSemi);
3180 if (Tok.is(tok::code_completion)) {
3199 if (!selIdent && Tok.isNot(tok::colon))
3204 while (Tok.is(tok::comma)) {
3208 if (Tok.is(tok::colon))
3211 if (Tok.is(tok::colon)) {
3218 SkipUntil(tok::r_square, StopAtSemi);
3226 Diag(Tok, diag::err_expected) << tok::identifier; // missing selector name.
3231 SkipUntil(tok::r_square, StopAtSemi);
3235 if (Tok.isNot(tok::r_square)) {
3236 Diag(Tok, diag::err_expected)
3237 << (Tok.is(tok::identifier) ? tok::colon : tok::r_square);
3241 SkipUntil(tok::r_square, StopAtSemi);
3276 while (Tok.is(tok::at)) {
3281 return ExprError(Diag(Tok, diag::err_objc_concat_string));
3309 ExprResult Lit(Actions.ActOnCharacterConstant(Tok));
3323 ExprResult Lit(Actions.ActOnNumericConstant(Tok));
3336 if (Tok.isNot(tok::l_paren))
3337 return ExprError(Diag(Tok, diag::err_expected_lparen_after) << "@");
3339 BalancedDelimiterTracker T(*this, tok::l_paren);
3360 while (Tok.isNot(tok::r_square)) {
3367 SkipUntil(tok::r_square, StopAtSemi);
3372 if (Tok.is(tok::ellipsis))
3379 if (Tok.is(tok::comma))
3381 else if (Tok.isNot(tok::r_square))
3382 return ExprError(Diag(Tok, diag::err_expected_either) << tok::r_square
3383 << tok::comma);
3393 while (Tok.isNot(tok::r_brace)) {
3403 SkipUntil(tok::r_brace, StopAtSemi);
3408 if (ExpectAndConsume(tok::colon)) {
3409 SkipUntil(tok::r_brace, StopAtSemi);
3418 SkipUntil(tok::r_brace, StopAtSemi);
3425 TryConsumeToken(tok::ellipsis, EllipsisLoc);
3434 if (!TryConsumeToken(tok::comma) && Tok.isNot(tok::r_brace))
3435 return ExprError(Diag(Tok, diag::err_expected_either) << tok::r_brace
3436 << tok::comma);
3449 assert(Tok.isObjCAtKeyword(tok::objc_encode) && "Not an @encode expression!");
3453 if (Tok.isNot(tok::l_paren))
3454 return ExprError(Diag(Tok, diag::err_expected_lparen_after) << "@encode");
3456 BalancedDelimiterTracker T(*this, tok::l_paren);
3476 if (Tok.isNot(tok::l_paren))
3477 return ExprError(Diag(Tok, diag::err_expected_lparen_after) << "@protocol");
3479 BalancedDelimiterTracker T(*this, tok::l_paren);
3482 if (Tok.isNot(tok::identifier))
3483 return ExprError(Diag(Tok, diag::err_expected) << tok::identifier);
3485 IdentifierInfo *protocolId = Tok.getIdentifierInfo();
3500 if (Tok.isNot(tok::l_paren))
3501 return ExprError(Diag(Tok, diag::err_expected_lparen_after) << "@selector");
3506 BalancedDelimiterTracker T(*this, tok::l_paren);
3508 bool HasOptionalParen = Tok.is(tok::l_paren);
3512 if (Tok.is(tok::code_completion)) {
3520 Tok.isNot(tok::colon) && Tok.isNot(tok::coloncolon))
3521 return ExprError(Diag(Tok, diag::err_expected) << tok::identifier);
3526 if (Tok.isNot(tok::r_paren)) {
3528 if (TryConsumeToken(tok::coloncolon)) { // Handle :: in C++.
3531 } else if (ExpectAndConsume(tok::colon)) // Otherwise expect ':'.
3535 if (Tok.is(tok::r_paren))
3538 if (Tok.is(tok::code_completion)) {
3548 if (!SelIdent && Tok.isNot(tok::colon) && Tok.isNot(tok::coloncolon))
3552 if (HasOptionalParen && Tok.is(tok::r_paren))
3572 SourceLocation OrigLoc = Tok.getLocation();
3577 LM.Toks.push_back(Tok);
3583 assert(Tok.isOneOf(tok::l_brace, tok::kw_try, tok::colon) &&
3597 if (Tok.is(tok::kw_try))
3600 if (Tok.is(tok::colon))
3605 if (Tok.getLocation() != OrigLoc) {
3611 if (PP.getSourceManager().isBeforeInTranslationUnit(Tok.getLocation(),
3613 while (Tok.getLocation() != OrigLoc && Tok.isNot(tok::eof))