Lines Matching refs:tok
117 assert(Tok.is(tok::kw___attribute) && "Not a GNU attribute list!");
119 while (Tok.is(tok::kw___attribute)) {
121 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
123 SkipUntil(tok::r_paren, true); // skip until ) or ;
126 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after, "(")) {
127 SkipUntil(tok::r_paren, true); // skip until ) or ;
131 while (Tok.is(tok::identifier) || isDeclarationSpecifier() ||
132 Tok.is(tok::comma)) {
133 if (Tok.is(tok::comma)) {
139 IdentifierInfo *AttrName = Tok.getIdentifierInfo();
142 if (Tok.is(tok::l_paren)) {
155 ConsumeAndStoreUntil(tok::r_paren, LA->Toks, true, false);
159 Eof.setLocation(Tok.getLocation());
170 if (ExpectAndConsume(tok::r_paren, diag::err_expected_rparen))
171 SkipUntil(tok::r_paren, false);
172 SourceLocation Loc = Tok.getLocation();
173 if (ExpectAndConsume(tok::r_paren, diag::err_expected_rparen)) {
174 SkipUntil(tok::r_paren, false);
192 assert(Tok.is(tok::l_paren) && "Attribute arg list not starting with '('");
221 switch (Tok.getKind()) {
222 case tok::kw_char:
223 case tok::kw_wchar_t:
224 case tok::kw_char16_t:
225 case tok::kw_char32_t:
226 case tok::kw_bool:
227 case tok::kw_short:
228 case tok::kw_int:
229 case tok::kw_long:
230 case tok::kw___int64:
231 case tok::kw___int128:
232 case tok::kw_signed:
233 case tok::kw_unsigned:
234 case tok::kw_float:
235 case tok::kw_double:
236 case tok::kw_void:
237 case tok::kw_typeof:
244 case tok::identifier:
250 ParmName = Tok.getIdentifierInfo();
263 (ParmLoc.isValid() ? Tok.is(tok::comma) : Tok.isNot(tok::r_paren))) {
272 SkipUntil(tok::r_paren);
276 if (Tok.isNot(tok::comma))
281 else if (Tok.is(tok::less) && AttrName->isStr("iboutletcollection")) {
282 if (!ExpectAndConsume(tok::less, diag::err_expected_less_after, "<",
283 tok::greater)) {
284 while (Tok.is(tok::identifier)) {
286 if (Tok.is(tok::greater))
288 if (Tok.is(tok::comma)) {
293 if (Tok.isNot(tok::greater))
294 Diag(Tok, diag::err_iboutletcollection_with_protocol);
295 SkipUntil(tok::r_paren, false, true); // skip until ')'
301 if (Tok.is(tok::identifier))
308 SourceLocation RParen = Tok.getLocation();
309 if (!ExpectAndConsume(tok::r_paren, diag::err_expected_rparen) &&
321 Diag(Tok, diag::err_iboutletcollection_builtintype);
332 BalancedDelimiterTracker T(*this, tok::l_paren);
334 AttrName->getNameStart(), tok::r_paren))
388 if (Tok.getKind() == tok::l_paren)
404 BalancedDelimiterTracker T(*this, tok::l_paren);
406 Ident->getNameStart(), tok::r_paren))
420 BalancedDelimiterTracker T(*this, tok::l_paren);
433 assert(Tok.is(tok::kw___declspec) && "Not a declspec!");
436 BalancedDelimiterTracker T(*this, tok::l_paren);
438 tok::r_paren))
443 while (Tok.getKind() != tok::r_paren) {
446 bool IsString = Tok.getKind() == tok::string_literal ? true : false;
447 if (!IsString && Tok.getKind() != tok::identifier &&
448 Tok.getKind() != tok::kw_restrict) {
449 Diag(Tok, diag::err_ms_declspec_type);
459 StringRef Str = PP.getSpelling(Tok
467 AttrName = Tok.getIdentifierInfo();
488 while (Tok.is(tok::kw___fastcall) || Tok.is(tok::kw___stdcall) ||
489 Tok.is(tok::kw___thiscall) || Tok.is(tok::kw___cdecl) ||
490 Tok.is(tok::kw___ptr64) || Tok.is(tok::kw___w64) ||
491 Tok.is(tok::kw___ptr32) || Tok.is(tok::kw___unaligned)) {
492 IdentifierInfo *AttrName = Tok.getIdentifierInfo();
501 while (Tok.is(tok::kw___pascal)) {
502 IdentifierInfo *AttrName = Tok.getIdentifierInfo();
511 while (Tok.is(tok::kw___kernel)) {
512 IdentifierInfo *AttrName = Tok.getIdentifierInfo();
522 SourceLocation Loc = Tok.getLocation();
523 switch(Tok.getKind()) {
525 case tok::kw___private:
526 case tok::kw_private:
532 case tok::kw___global:
538 case tok::kw___local:
544 case tok::kw___constant:
550 case tok::kw___read_only:
556 case tok::kw___write_only:
562 case tok::kw___read_write:
578 Range = Tok.getLocation();
580 if (!Tok.is(tok::numeric_constant)) {
581 Diag(Tok, diag::err_expected_version);
582 SkipUntil(tok::comma, tok::r_paren, true, true, true);
591 Buffer.resize(Tok.getLength()+1);
596 unsigned ActualLength = PP.getSpelling(Tok, ThisTokBegin, &Invalid);
609 Diag(Tok, diag::err_expected_version);
610 SkipUntil(tok::comma, tok::r_paren, true, true, true);
619 Diag(Tok, diag::err_zero_version);
627 Diag(Tok, diag::err_expected_version);
628 SkipUntil(tok::comma, tok::r_paren, true, true, true);
645 Diag(Tok, diag::err_zero_version);
654 Diag(Tok, diag::err_expected_version);
655 SkipUntil(tok::comma, tok::r_paren, true, true, true);
668 Diag(Tok, diag::err_expected_version);
669 SkipUntil(tok::comma, tok::r_paren, true, true, true);
707 BalancedDelimiterTracker T(*this, tok::l_paren);
709 Diag(Tok, diag::err_expected_lparen);
714 if (Tok.isNot(tok::identifier)) {
715 Diag(Tok, diag::err_availability_expected_platform);
716 SkipUntil(tok::r_paren);
719 Platform = Tok.getIdentifierInfo();
723 if (ExpectAndConsume(tok::comma, diag::err_expected_comma, "", tok::r_paren))
739 if (Tok.isNot(tok::identifier)) {
740 Diag(Tok, diag::err_availability_expected_change);
741 SkipUntil(tok::r_paren);
744 IdentifierInfo *Keyword = Tok.getIdentifierInfo();
754 if (Tok.isNot(tok::comma))
761 if (Tok.isNot(tok::equal)) {
762 Diag(Tok, diag::err_expected_equal_after)
764 SkipUntil(tok::r_paren);
770 Diag(Tok, diag::err_expected_string_literal)
772 SkipUntil(tok::r_paren);
783 SkipUntil(tok::r_paren);
813 if (Tok.isNot(tok::comma))
927 SourceLocation OrigLoc = Tok.getLocation();
931 LA.Toks.push_back(Tok);
939 Diag(Tok, diag::warn_attribute_on_function_definition)
986 Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();
993 if (Tok.getLocation() != OrigLoc) {
998 if (PP.getSourceManager().isBeforeInTranslationUnit(Tok.getLocation(),
1000 while (Tok.getLocation() != OrigLoc && Tok.isNot(tok::eof))
1046 assert(Tok.is(tok::l_paren) && "Attribute arg list not starting with '('");
1048 BalancedDelimiterTracker T(*this, tok::l_paren);
1055 while (Tok.isNot(tok::r_paren)) {
1065 if (Tok.isNot(tok::comma))
1082 assert(Tok.is(tok::l_paren) && "Attribute arg list not starting with '('");
1084 BalancedDelimiterTracker T(*this, tok::l_paren);
1087 if (Tok.isNot(tok::identifier)) {
1088 Diag(Tok, diag::err_expected_ident);
1092 IdentifierInfo *ArgumentKind = Tok.getIdentifierInfo();
1095 if (Tok.isNot(tok::comma)) {
1096 Diag(Tok, diag::err_expected_comma);
1111 while (Tok.is(tok::comma)) {
1113 if (Tok.isNot(tok::identifier)) {
1114 Diag(Tok, diag::err_expected_ident);
1118 IdentifierInfo *Flag = Tok.getIdentifierInfo();
1124 Diag(Tok, diag::err_type_safety_unknown_flag) << Flag;
1151 assert(Tok.is(tok::l_square) && NextToken().is(tok::l_square));
1159 Diag(Tok.getLocation(), diag::err_l_square_l_square_not_attribute);
1166 SkipUntil(tok::r_square, /*StopAtSemi*/ false);
1167 assert(Tok.is(tok::r_square) && "isCXX11AttributeSpecifier lied");
1182 assert((Tok.is(tok::l_square) && NextToken().is(tok::l_square)) ||
1183 Tok.is(tok::kw_alignas));
1186 SourceLocation Loc = Tok.getLocation();
1239 switch (Tok.getKind()) {
1240 case tok::kw_template:
1241 case tok::kw_export:
1245 case tok::kw_inline:
1247 if (getLangOpts().CPlusPlus && NextToken().is(tok::kw_namespace)) {
1255 case tok::kw_namespace:
1259 case tok::kw_using:
1263 case tok::kw_static_assert:
1264 case tok::kw__Static_assert:
1307 if (Tok.is(tok::semi)) {
1309 DeclEnd = Tok.getLocation();
1324 switch (Tok.getKind()) {
1325 case tok::annot_cxxscope:
1326 case tok::annot_template_id:
1327 case tok::caret:
1328 case tok::code_completion:
1329 case tok::coloncolon:
1330 case tok::ellipsis:
1331 case tok::kw___attribute:
1332 case tok::kw_operator:
1333 case tok::l_paren:
1334 case tok::star:
1337 case tok::amp:
1338 case tok::ampamp:
1341 case tok::l_square: // Might be an attribute on an unnamed bit-field.
1343 NextToken().is(tok::l_square);
1345 case tok::colon: // Might be a typo for '::' or an unnamed bit-field.
1348 case tok::identifier:
1350 case tok::code_completion:
1351 case tok::coloncolon:
1352 case tok::comma:
1353 case tok::equal:
1354 case tok::equalequal: // Might be a typo for '='.
1355 case tok::kw_alignas:
1356 case tok::kw_asm:
1357 case tok::kw___attribute:
1358 case tok::l_brace:
1359 case tok::l_paren:
1360 case tok::l_square:
1361 case tok::less:
1362 case tok::r_brace:
1363 case tok::r_paren:
1364 case tok::r_square:
1365 case tok::semi:
1368 case tok::colon:
1375 case tok::identifier: // Possible virt-specifier.
1389 /// than SkipUntil(tok::r_brace) would, but will never stop later.
1392 switch (Tok.getKind()) {
1393 case tok::l_brace:
1397 SkipUntil(tok::r_brace, /*StopAtSemi*/false);
1398 if (Tok.is(tok::comma) || Tok.is(tok::l_brace) || Toktok::kw_try)) {
1402 if (Tok.is(tok::semi))
1406 case tok::l_square:
1408 SkipUntil(tok::r_square, /*StopAtSemi*/false);
1411 case tok::l_paren:
1413 SkipUntil(tok::r_paren, /*StopAtSemi*/false);
1416 case tok::r_brace:
1419 case tok::semi:
1423 case tok::kw_inline:
1427 if (Tok.isAtStartOfLine() && NextToken().is(tok::kw_namespace) &&
1432 case tok::kw_namespace:
1436 if (Tok.isAtStartOfLine() &&
1441 case tok::at:
1443 if (NextToken().isObjCAtKeyword(tok::objc_end) &&
1448 case tok::minus:
1449 case tok::plus:
1451 if (Tok.isAtStartOfLine() && ParsingInObjCContainer)
1455 case tok::eof:
1500 Diag(Tok, diag::err_function_declared_typedef);
1518 Diag(Tok, diag::err_expected_fn_body);
1519 SkipUntil(tok::semi);
1530 if (FRI && Tok.is(tok::colon)) {
1532 if (Tok.is(tok::l_brace))
1555 while (Tok.is(tok::comma)) {
1558 if (Tok.isAtStartOfLine() && ExpectSemi && !MightBeDeclarator(Context)) {
1591 *DeclEnd = Tok.getLocation();
1601 SkipUntil(tok::r_brace, true, true);
1602 if (Tok.is(tok::semi))
1616 if (Tok.is(tok::kw_asm)) {
1620 SkipUntil(tok::semi, true, true);
1685 SkipUntil(tok::semi, true, true);
1701 if (Tok.is(tok::kw_delete)) {
1707 } else if (Tok.is(tok::kw_default)) {
1719 if (Tok.is(tok::code_completion)) {
1734 SkipUntil(tok::comma, true, true);
1740 } else if (Tok.is(tok::l_paren)) {
1742 BalancedDelimiterTracker T(*this, tok::l_paren);
1755 SkipUntil(tok::r_paren);
1779 } else if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace) &&
1782 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1828 Diag(Tok, diag::err_expected_type);
1832 Diag(Tok, diag::err_typename_requires_specqual);
1883 return T.is(tok::l_square) || T.is(tok::l_paren) || T.is(tok::r_paren) ||
1884 T.is(tok::semi) || T.is(tok::comma) || T.is(tok::equal) ||
1885 T.is(tok::kw_asm) || T.is(tok::l_brace) || T.is(tok::colon);
1902 assert(Tok.is(tok::identifier) && "should have identifier");
1904 SourceLocation Loc = Tok.getLocation();
1949 tok::TokenKind TagKind = tok::unknown;
1951 switch (Actions.isTagName(*Tok.getIdentifierInfo(), getCurScope())) {
1954 TagName="enum" ; FixitTagName = "enum " ; TagKind=tok::kw_enum ;break;
1956 TagName="union" ; FixitTagName = "union " ;TagKind=tok::kw_union ;break;
1958 TagName="struct"; FixitTagName = "struct ";TagKind=tok::kw_struct;break;
1961 TagKind=tok::kw___interface;break;
1963 TagName="class" ; FixitTagName = "class " ;TagKind=tok::kw_class ;break;
1967 IdentifierInfo *TokenName = Tok.getIdentifierInfo();
1973 << FixItHint::CreateInsertion(Tok.getLocation(), FixitTagName);
1983 if (TagKind == tok::kw_enum)
1999 case tok::comma:
2000 case tok::equal:
2001 case tok::kw_asm:
2002 case tok::l_brace:
2003 case tok::l_square:
2004 case tok::semi:
2009 case tok::l_paren: {
2039 IdentifierInfo *II = Tok.getIdentifierInfo();
2049 DS.SetRangeEnd(Tok.getLocation());
2053 } else if (II != Tok.getIdentifierInfo()) {
2055 Tok.setKind(II->getTokenID());
2065 Diag(Loc, diag::err_unknown_typename) << Tok.getIdentifierInfo() << R;
2070 DS.SetRangeEnd(Tok.getLocation());
2108 SourceLocation TypeLoc = Tok.getLocation();
2110 SourceRange TypeRange(Start, Tok.getLocation());
2116 if (getLangOpts().CPlusPlus11 && Tok.is(tok::ellipsis))
2132 assert((Tok.is(tok::kw_alignas) || Tok.is(tok::kw__Alignas)) &&
2135 IdentifierInfo *KWName = Tok.getIdentifierInfo();
2138 BalancedDelimiterTracker T(*this, tok::l_paren);
2145 SkipUntil(tok::r_paren);
2191 DS.SetRangeStart(Tok.getLocation());
2192 DS.SetRangeEnd(Tok.getLocation());
2203 SourceLocation Loc = Tok.getLocation();
2205 switch (Tok.getKind()) {
2224 case tok::l_square:
2225 case tok::kw_alignas:
2240 case tok::code_completion: {
2273 case tok::coloncolon: // ::foo::bar
2280 if (Tok.is(tok::coloncolon)) // ::new or ::delete
2284 case tok::annot_cxxscope: {
2289 Actions.RestoreNestedNameSpecifierAnnotation(Tok.getAnnotationValue(),
2290 Tok.getAnnotationRange(),
2295 if (Next.is(tok::annot_template_id) &&
2342 assert(Tok.is(tok::annot_template_id) &&
2348 if (Next.is(tok::annot_typename)) {
2351 if (Tok.getAnnotationValue()) {
2352 ParsedType T = getTypeAnnotation(Tok);
2354 Tok.getAnnotationEndLoc(),
2361 DS.SetRangeEnd(Tok.getAnnotationEndLoc());
2365 if (Next.isNot(tok::identifier))
2418 DS.SetRangeEnd(Tok.getLocation());
2424 case tok::annot_typename: {
2425 if (Tok.getAnnotationValue()) {
2426 ParsedType T = getTypeAnnotation(Tok);
2435 DS.SetRangeEnd(Tok.getAnnotationEndLoc());
2441 if (Tok.is(tok::less) && getLangOpts().ObjC1)
2447 case tok::kw___is_signed:
2458 Tok.getIdentifierInfo()->RevertTokenIDToIdentifier();
2459 Tok.setKind(tok::identifier);
2466 case tok::kw_decltype:
2467 case tok::identifier: {
2476 if (!Tok.is(tok::identifier))
2496 Actions.getTypeName(*Tok.getIdentifierInfo(),
2497 Tok.getLocation(), getCurScope());
2516 Actions.isCurrentClassName(*Tok.getIdentifierInfo(), getCurScope()) &&
2525 DS.SetRangeEnd(Tok.getLocation());
2531 if (Tok.is(tok::less) && getLangOpts().ObjC1)
2540 case tok::annot_template_id: {
2541 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
2563 case tok::kw___attribute:
2568 case tok::kw___declspec:
2573 case tok::kw___forceinline: {
2575 IdentifierInfo *AttrName = Tok.getIdentifierInfo();
2576 SourceLocation AttrNameLoc = Tok.getLocation();
2584 case tok::kw___ptr64:
2585 case tok::kw___ptr32:
2586 case tok::kw___w64:
2587 case tok::kw___cdecl:
2588 case tok::kw___stdcall:
2589 case tok::kw___fastcall:
2590 case tok::kw___thiscall:
2591 case tok::kw___unaligned:
2596 case tok::kw___pascal:
2601 case tok::kw___kernel:
2606 case tok::kw_typedef:
2610 case tok::kw_extern:
2612 Diag(Tok, diag::ext_thread_before) << "extern";
2616 case tok::kw___private_extern__:
2620 case tok::kw_static:
2622 Diag(Tok, diag::ext_thread_before) << "static";
2626 case tok::kw_auto:
2632 Diag(Tok, diag::ext_auto_storage_class)
2641 case tok::kw_register:
2645 case tok::kw_mutable:
2649 case tok::kw___thread:
2654 case tok::kw_inline:
2657 case tok::kw_virtual:
2660 case tok::kw_explicit:
2663 case tok::kw__Noreturn:
2670 case tok::kw__Alignas:
2672 Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
2677 case tok::kw_friend:
2688 case tok::kw___module_private__:
2693 case tok::kw_constexpr:
2698 case tok::kw_short:
2702 case tok::kw_long:
2710 case tok::kw___int64:
2714 case tok::kw_signed:
2718 case tok::kw_unsigned:
2722 case tok::kw__Complex:
2726 case tok::kw__Imaginary:
2730 case tok::kw_void:
2734 case tok::kw_char:
2738 case tok::kw_int:
2742 case tok::kw___int128:
2746 case tok::kw_half:
2750 case tok::kw_float:
2754 case tok::kw_double:
2758 case tok::kw_wchar_t:
2762 case tok::kw_char16_t:
2766 case tok::kw_char32_t:
2770 case tok::kw_bool:
2771 case tok::kw__Bool:
2772 if (Tok.is(tok::kw_bool) &&
2778 Tok.setKind(tok::identifier);
2785 case tok::kw__Decimal32:
2789 case tok::kw__Decimal64:
2793 case tok::kw__Decimal128:
2797 case tok::kw___vector:
2800 case tok::kw___pixel:
2803 case tok::kw_image1d_t:
2807 case tok::kw_image1d_array_t:
2811 case tok::kw_image1d_buffer_t:
2815 case tok::kw_image2d_t:
2819 case tok::kw_image2d_array_t:
2823 case tok::kw_image3d_t:
2827 case tok::kw_sampler_t:
2831 case tok::kw_event_t:
2835 case tok::kw___unknown_anytype:
2841 case tok::kw_class:
2842 case tok::kw_struct:
2843 case tok::kw___interface:
2844 case tok::kw_union: {
2845 tok::TokenKind Kind = Tok.getKind();
2865 case tok::kw_enum:
2871 case tok::kw_const:
2875 case tok::kw_volatile:
2879 case tok::kw_restrict:
2885 case tok::kw_typename:
2890 if (!Tok.is(tok::kw_typename))
2895 case tok::kw_typeof:
2899 case tok::annot_decltype:
2903 case tok::kw___underlying_type:
2907 case tok::kw__Atomic:
2912 case tok::kw_private:
2915 case tok::kw___private:
2916 case tok::kw___global:
2917 case tok::kw___local:
2918 case tok::kw___constant:
2919 case tok::kw___read_only:
2920 case tok::kw___write_only:
2921 case tok::kw___read_write:
2925 case tok::less:
2947 Diag(Tok, DiagID)
2948 << PrevSpec << FixItHint::CreateRemoval(Tok.getLocation());
2950 Diag(Tok, DiagID) << PrevSpec;
2953 DS.SetRangeEnd(Tok.getLocation());
2981 if (Tok.is(tok::kw___extension__)) {
2993 if (Tok.is(tok::semi)) {
3013 if (Tok.isNot(tok::colon)) {
3019 if (Tok.is(tok::colon)) {
3023 SkipUntil(tok::semi, true, true);
3036 if (Tok.isNot(tok::comma))
3061 BalancedDelimiterTracker T(*this, tok::l_brace);
3070 if (Tok.is(tok::r_brace) && !getLangOpts().CPlusPlus) {
3071 Diag(Tok, diag::ext_empty_struct_union) << (TagType == TST_union);
3072 Diag(Tok, diag::warn_empty_struct_union_compat) << (TagType == TST_union);
3078 while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) {
3082 if (Tok.is(tok::semi)) {
3087 if (!Tok.is(tok::at)) {
3112 if (!Tok.isObjCAtKeyword(tok::objc_defs)) {
3113 Diag(Tok, diag::err_unexpected_at);
3114 SkipUntil(tok::semi, true);
3118 ExpectAndConsume(tok::l_paren, diag::err_expected_lparen);
3119 if (!Tok.is(tok::identifier)) {
3120 Diag(Tok, diag::err_expected_ident);
3121 SkipUntil(tok::semi, true);
3125 Actions.ActOnDefs(getCurScope(), TagDecl, Tok.getLocation(),
3126 Tok.getIdentifierInfo(), Fields);
3129 ExpectAndConsume(tok::r_paren, diag::err_expected_rparen);
3132 if (Tok.is(tok::semi)) {
3134 } else if (Tok.is(tok::r_brace)) {
3135 ExpectAndConsume(tok::semi, diag::ext_expected_semi_decl_list);
3138 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
3140 SkipUntil(tok::r_brace, true, true);
3142 if (Tok.is(tok::semi)) ConsumeToken();
3195 if (Tok.is(tok::code_completion)) {
3207 while (Tok.is(tok::kw___declspec))
3215 (Tok.is(tok::kw_class) || Tok.is(tok::kw_struct))) {
3216 Diag(Tok, diag::warn_cxx98_compat_scoped_enum);
3217 IsScopedUsingClassTag = Tok.is(tok::kw_class);
3227 while (Tok.is(tok::kw___declspec))
3259 if (SS.isSet() && Tok.isNot(tok::identifier)) {
3260 Diag(Tok, diag::err_expected_ident);
3261 if (Tok.isNot(tok::l_brace)) {
3264 SkipUntil(tok::comma, true);
3271 if (Tok.isNot(tok::identifier) && Tok.isNot(tok::l_brace) &&
3272 !(AllowFixedUnderlyingType && Tok.is(tok::colon))) {
3273 Diag(Tok, diag::err_expected_ident_lbrace);
3276 SkipUntil(tok::comma, true);
3283 if (Tok.is(tok::identifier)) {
3284 Name = Tok.getIdentifierInfo();
3291 Diag(Tok, diag::err_scoped_enum_missing_identifier);
3305 if (AllowFixedUnderlyingType && Tok.is(tok::colon)) {
3327 GetLookAheadToken(2).getKind() == tok::semi) {
3389 } else if (Tok.is(tok::l_brace)) {
3391 Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
3394 SkipUntil(tok::r_brace);
3400 (Tok.is(tok::semi) ||
3401 (Tok.isAtStartOfLine() &&
3404 if (Tok.isNot(tok::semi)) {
3406 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_tagdecl,
3408 PP.EnterToken(Tok);
3409 Tok.setKind(tok::semi);
3426 Diag(Tok, diag::err_enum_template);
3427 SkipUntil(tok::comma, true);
3447 Diag(Tok, diag::err_enumerator_unnamed_no_def);
3450 SkipUntil(tok::comma, true);
3469 Diag(Tok, diag::err_expected_type_name_after_typename);
3492 if (Tok.is(tok::l_brace) && TUK != Sema::TUK_Reference) {
3494 SkipUntil(tok::r_brace);
3501 if (Tok.is(tok::l_brace) && TUK != Sema::TUK_Reference)
3525 BalancedDelimiterTracker T(*this, tok::l_brace);
3529 if (Tok.is(tok::r_brace) && !getLangOpts().CPlusPlus)
3530 Diag(Tok, diag::error_empty_enum);
3537 while (Tok.is(tok::identifier)) {
3538 IdentifierInfo *Ident = Tok.getIdentifierInfo();
3551 if (Tok.is(tok::equal)) {
3555 SkipUntil(tok::comma, tok::r_brace, true, true);
3569 if (Tok.is(tok::identifier)) {
3577 if (Tok.isNot(tok::comma))
3581 if (Tok.isNot(tok::identifier)) {
3613 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_tagdecl, "enum");
3617 PP.EnterToken(Tok);
3618 Tok.setKind(tok::semi);
3625 switch (Tok.getKind()) {
3629 case tok::kw_private:
3633 case tok::kw_const:
3634 case tok::kw_volatile:
3635 case tok::kw_restrict:
3636 case tok::kw___private:
3637 case tok::kw___local:
3638 case tok::kw___global:
3639 case tok::kw___constant:
3640 case tok::kw___read_only:
3641 case tok::kw___read_write:
3642 case tok::kw___write_only:
3650 bool Parser::isKnownToBeTypeSpecifier(const Token &Tok) const {
3651 switch (Tok.getKind()) {
3654 case tok::kw_short:
3655 case tok::kw_long:
3656 case tok::kw___int64:
3657 case tok::kw___int128:
3658 case tok::kw_signed:
3659 case tok::kw_unsigned:
3660 case tok::kw__Complex:
3661 case tok::kw__Imaginary:
3662 case tok::kw_void:
3663 case tok::kw_char:
3664 case tok::kw_wchar_t:
3665 case tok::kw_char16_t:
3666 case tok::kw_char32_t:
3667 case tok::kw_int:
3668 case tok::kw_half:
3669 case tok::kw_float:
3670 case tok::kw_double:
3671 case tok::kw_bool:
3672 case tok::kw__Bool:
3673 case tok::kw__Decimal32:
3674 case tok::kw__Decimal64:
3675 case tok::kw__Decimal128:
3676 case tok::kw___vector:
3679 case tok::kw_image1d_t:
3680 case tok::kw_image1d_array_t:
3681 case tok::kw_image1d_buffer_t:
3682 case tok::kw_image2d_t:
3683 case tok::kw_image2d_array_t:
3684 case tok::kw_image3d_t:
3685 case tok::kw_sampler_t:
3686 case tok::kw_event_t:
3689 case tok::kw_class:
3690 case tok::kw_struct:
3691 case tok::kw___interface:
3692 case tok::kw_union:
3694 case tok::kw_enum:
3697 case tok::annot_typename:
3705 switch (Tok.getKind()) {
3708 case tok::identifier: // foo::bar
3712 case tok::kw_typename: // typename T::type
3717 if (Tok.is(tok::identifier))
3721 case tok::coloncolon: // ::foo::bar
3722 if (NextToken().is(tok::kw_new) || // ::new
3723 NextToken().is(tok::kw_delete)) // ::delete
3731 case tok::kw___attribute:
3733 case tok::kw_typeof:
3736 case tok::kw_short:
3737 case tok::kw_long:
3738 case tok::kw___int64:
3739 case tok::kw___int128:
3740 case tok::kw_signed:
3741 case tok::kw_unsigned:
3742 case tok::kw__Complex:
3743 case tok::kw__Imaginary:
3744 case tok::kw_void:
3745 case tok::kw_char:
3746 case tok::kw_wchar_t:
3747 case tok::kw_char16_t:
3748 case tok::kw_char32_t:
3749 case tok::kw_int:
3750 case tok::kw_half:
3751 case tok::kw_float:
3752 case tok::kw_double:
3753 case tok::kw_bool:
3754 case tok::kw__Bool:
3755 case tok::kw__Decimal32:
3756 case tok::kw__Decimal64:
3757 case tok::kw__Decimal128:
3758 case tok::kw___vector:
3761 case tok::kw_image1d_t:
3762 case tok::kw_image1d_array_t:
3763 case tok::kw_image1d_buffer_t:
3764 case tok::kw_image2d_t:
3765 case tok::kw_image2d_array_t:
3766 case tok::kw_image3d_t:
3767 case tok::kw_sampler_t:
3768 case tok::kw_event_t:
3771 case tok::kw_class:
3772 case tok::kw_struct:
3773 case tok::kw___interface:
3774 case tok::kw_union:
3776 case tok::kw_enum:
3779 case tok::kw_const:
3780 case tok::kw_volatile:
3781 case tok::kw_restrict:
3784 case tok::kw___unknown_anytype:
3787 case tok::annot_typename:
3791 case tok::less:
3794 case tok::kw___cdecl:
3795 case tok::kw___stdcall:
3796 case tok::kw___fastcall:
3797 case tok::kw___thiscall:
3798 case tok::kw___w64:
3799 case tok::kw___ptr64:
3800 case tok::kw___ptr32:
3801 case tok::kw___pascal:
3802 case tok::kw___unaligned:
3804 case tok::kw___private:
3805 case tok::kw___local:
3806 case tok::kw___global:
3807 case tok::kw___constant:
3808 case tok::kw___read_only:
3809 case tok::kw___read_write:
3810 case tok::kw___write_only:
3814 case tok::kw_private:
3818 case tok::kw__Atomic:
3829 switch (Tok.getKind()) {
3832 case tok::kw_private:
3835 case tok::identifier: // foo::bar
3837 if (getLangOpts().ObjC1 && NextToken().is(tok::period))
3842 case tok::kw_decltype: // decltype(T())::type
3843 case tok::kw_typename: // typename T::type
3848 if (Tok.is(tok::identifier))
3862 case tok::coloncolon: // ::foo::bar
3863 if (NextToken().is(tok::kw_new) || // ::new
3864 NextToken().is(tok::kw_delete)) // ::delete
3874 case tok::kw_typedef:
3875 case tok::kw_extern:
3876 case tok::kw___private_extern__:
3877 case tok::kw_static:
3878 case tok::kw_auto:
3879 case tok::kw_register:
3880 case tok::kw___thread:
3883 case tok::kw___module_private__:
3886 case tok::kw___unknown_anytype:
3889 case tok::kw_short:
3890 case tok::kw_long:
3891 case tok::kw___int64:
3892 case tok::kw___int128:
3893 case tok::kw_signed:
3894 case tok::kw_unsigned:
3895 case tok::kw__Complex:
3896 case tok::kw__Imaginary:
3897 case tok::kw_void:
3898 case tok::kw_char:
3899 case tok::kw_wchar_t:
3900 case tok::kw_char16_t:
3901 case tok::kw_char32_t:
3903 case tok::kw_int:
3904 case tok::kw_half:
3905 case tok::kw_float:
3906 case tok::kw_double:
3907 case tok::kw_bool:
3908 case tok::kw__Bool:
3909 case tok::kw__Decimal32:
3910 case tok::kw__Decimal64:
3911 case tok::kw__Decimal128:
3912 case tok::kw___vector:
3915 case tok::kw_image1d_t:
3916 case tok::kw_image1d_array_t:
3917 case tok::kw_image1d_buffer_t:
3918 case tok::kw_image2d_t:
3919 case tok::kw_image2d_array_t:
3920 case tok::kw_image3d_t:
3921 case tok::kw_sampler_t:
3922 case tok::kw_event_t:
3925 case tok::kw_class:
3926 case tok::kw_struct:
3927 case tok::kw_union:
3928 case tok::kw___interface:
3930 case tok::kw_enum:
3933 case tok::kw_const:
3934 case tok::kw_volatile:
3935 case tok::kw_restrict:
3938 case tok::kw_inline:
3939 case tok::kw_virtual:
3940 case tok::kw_explicit:
3941 case tok::kw__Noreturn:
3944 case tok::kw__Alignas:
3947 case tok::kw_friend:
3950 case tok::kw__Static_assert:
3953 case tok::kw_typeof:
3956 case tok::kw___attribute:
3959 case tok::annot_decltype:
3960 case tok::kw_constexpr:
3963 case tok::kw__Atomic:
3967 case tok::less:
3971 case tok::annot_typename:
3975 case tok::kw___declspec:
3976 case tok::kw___cdecl:
3977 case tok::kw___stdcall:
3978 case tok::kw___fastcall:
3979 case tok::kw___thiscall:
3980 case tok::kw___w64:
3981 case tok::kw___ptr64:
3982 case tok::kw___ptr32:
3983 case tok::kw___forceinline:
3984 case tok::kw___pascal:
3985 case tok::kw___unaligned:
3987 case tok::kw___private:
3988 case tok::kw___local:
3989 case tok::kw___global:
3990 case tok::kw___constant:
3991 case tok::kw___read_only:
3992 case tok::kw___read_write:
3993 case tok::kw___write_only:
4011 if (Tok.is(tok::identifier) || Tok.is(tok::annot_template_id)) {
4021 if (Tok.isNot(tok::l_paren)) {
4029 if (Tok.is(tok::r_paren) ||
4030 (Tok.is(tok::ellipsis) && NextToken().is(tok::r_paren))) {
4050 else if (Tok.is(tok::identifier) ||
4051 (Tok.is(tok::annot_cxxscope) && NextToken().is(tok::identifier))) {
4056 if (Tok.is(tok::annot_cxxscope))
4063 switch (Tok.getKind()) {
4064 case tok::l_paren:
4066 case tok::l_square:
4069 case tok::coloncolon:
4072 case tok::r_paren:
4116 SourceLocation Loc = Tok.getLocation();
4118 switch (Tok.getKind()) {
4119 case tok::code_completion:
4123 case tok::kw_const:
4127 case tok::kw_volatile:
4131 case tok::kw_restrict:
4137 case tok::kw_private:
4140 case tok::kw___private:
4141 case tok::kw___global:
4142 case tok::kw___local:
4143 case tok::kw___constant:
4144 case tok::kw___read_only:
4145 case tok::kw___write_only:
4146 case tok::kw___read_write:
4150 case tok::kw___w64:
4151 case tok::kw___ptr64:
4152 case tok::kw___ptr32:
4153 case tok::kw___cdecl:
4154 case tok::kw___stdcall:
4155 case tok::kw___fastcall:
4156 case tok::kw___thiscall:
4157 case tok::kw___unaligned:
4163 case tok::kw___pascal:
4169 case tok::kw___attribute:
4188 Diag(Tok, DiagID) << PrevSpec;
4203 static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang) {
4204 if (Kind == tok::star || Kind == tok::caret)
4211 return Kind == tok::amp || Kind == tok::ampamp;
4248 (Tok.is(tok::coloncolon) || Tok.is(tok::identifier) ||
4249 Tok.is(tok::annot_cxxscope))) {
4256 if (Tok.isNot(tok::star)) {
4287 tok::TokenKind Kind = Tok.getKind();
4300 if (Kind == tok::star || Kind == tok::caret) {
4310 if (Kind == tok::star)
4330 if (Kind == tok::ampamp)
4373 Kind == tok::amp),
4459 if (Tok.is(tok::ellipsis) && D.getCXXScopeSpec().isEmpty() &&
4462 NextToken().is(tok::r_paren) &&
4466 if (isPtrOperatorToken(Tok.getKind(), getLangOpts())) {
4480 if (Tok.is(tok::identifier) || Tok.is(tok::kw_operator) ||
4481 Tok.is(tok::annot_template_id) || Tok.is(tok::tilde)) {
4505 D.SetIdentifier(0, Tok.getLocation());
4515 } else if (Tok.is(tok::identifier) && D.mayHaveIdentifier()) {
4517 "There's a C++-specific check for tok::identifier above");
4518 assert(Tok.getIdentifierInfo() && "Not an identifier?");
4519 D.SetIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
4524 if (Tok.is(tok::l_paren)) {
4545 D.SetIdentifier(0, Tok.getLocation());
4553 if (Tok.getKind() == tok::annot_pragma_parser_crash)
4556 Diag(Tok, diag::err_expected_member_name_or_semi)
4559 if (Tok.is(tok::period) || Tok.is(tok::arrow))
4560 Diag(Tok, diag::err_invalid_operator_on_type) << Tok.is(tok::arrow);
4562 Diag(Tok, diag::err_expected_unqualified_id) << getLangOpts().CPlusPlus;
4564 Diag(Tok, diag::err_expected_ident_lparen);
4565 D.SetIdentifier(0, Tok.getLocation());
4578 if (Tok.is(tok::l_paren)) {
4600 BalancedDelimiterTracker T(*this, tok::l_paren);
4604 } else if (Tok.is(tok::l_square)) {
4626 BalancedDelimiterTracker T(*this, tok::l_paren);
4643 if (Tok.is(tok::kw___attribute)) {
4655 if (Tok.is(tok::kw___pascal))
4668 } else if (Tok.is(tok::r_paren) || // 'int()' is a function.
4669 (getLangOpts().CPlusPlus && Tok.is(tok::ellipsis) &&
4670 NextToken().is(tok::r_paren)) || // C++ int(...)
4710 D.SetIdentifier(0, Tok.getLocation());
4784 Diag(Tok, diag::err_argument_required_after_attribute);
4793 if (Tok.isNot(tok::r_paren))
4796 Diag(Tok, diag::err_argument_required_after_attribute);
4820 if (Tok.is(tok::amp) || Tok.is(tok::ampamp)) {
4821 Diag(Tok, getLangOpts().CPlusPlus11 ?
4825 RefQualifierIsLValueRef = Tok.is(tok::amp);
4865 if (getLangOpts().CPlusPlus11 && Tok.is(tok::arrow)) {
4866 Diag(Tok, diag::warn_cxx98_compat_trailing_return_type);
4869 LocalEndLoc = Tok.getLocation();
4908 && Tok.is(tok::identifier)
4912 && (TryAnnotateTypeOrScopeToken() || !Tok.is(tok::annot_typename))
4925 && (NextToken().is(tok::comma) || NextToken().is(tok::r_paren));
4945 Diag(Tok, diag::ext_ident_list_in_param);
4952 if (Tok.isNot(tok::identifier)) {
4953 Diag(Tok, diag::err_expected_ident);
4954 SkipUntil(tok::r_paren, /*StopAtSemi=*/true, /*DontConsume=*/true);
4960 IdentifierInfo *ParmII = Tok.getIdentifierInfo();
4963 if (Actions.getTypeName(*ParmII, Tok.getLocation(), getCurScope()))
4964 Diag(Tok, diag::err_unexpected_typedef_ident) << ParmII;
4968 Diag(Tok, diag::err_param_redefinition) << ParmII;
4972 Tok.getLocation(),
4980 if (Tok.isNot(tok::comma))
5024 if (Tok.is(tok::ellipsis)) {
5041 SourceLocation DSStart = Tok.getLocation();
5085 if (Tok.is(tok::equal)) {
5086 SourceLocation EqualLoc = Tok.getLocation();
5096 if (!ConsumeAndStoreUntil(tok::comma, tok::r_paren, *DefArgToks,
5107 DefArgEnd.setKind(tok::cxx_defaultarg_end);
5108 DefArgEnd.setLocation(Tok.getLocation());
5124 if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace)) {
5125 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
5131 SkipUntil(tok::comma, tok::r_paren, true, true);
5146 if (Tok.isNot(tok::comma)) {
5147 if (Tok.is(tok::ellipsis)) {
5178 BalancedDelimiterTracker T(*this, tok::l_square);
5183 if (Tok.getKind() == tok::r_square) {
5195 } else if (Tok.getKind() == tok::numeric_constant &&
5196 GetLookAheadToken(1).is(tok::r_square)) {
5198 ExprResult ExprRes(Actions.ActOnNumericConstant(Tok, getCurScope()));
5216 if (Tok.is(tok::kw_static))
5226 if (!StaticLoc.isValid() && Tok.is(tok::kw_static))
5237 if (Tok.is(tok::star) && GetLookAheadToken(1).is(tok::r_square)) {
5245 } else if (Tok.isNot(tok::r_square)) {
5266 SkipUntil(tok::r_square);
5290 assert(Tok.is(tok::kw_typeof) && "Not a typeof specifier");
5291 Token OpTok = Tok;
5294 const bool hasParens = Tok.is(tok::l_paren);
5309 DS.SetRangeEnd(Tok.getLocation());
5353 assert(Tok.is(tok::kw__Atomic) && "Not an atomic specifier");
5356 BalancedDelimiterTracker T(*this, tok::l_paren);
5358 SkipUntil(tok::r_paren);
5364 SkipUntil(tok::r_paren);
5391 case tok::kw_short:
5392 case tok::kw_long:
5393 case tok::kw_signed:
5394 case tok::kw_unsigned:
5395 case tok::kw_void:
5396 case tok::kw_char:
5397 case tok::kw_int:
5398 case tok::kw_float:
5399 case tok::kw_double:
5400 case tok::kw_bool:
5401 case tok::kw___pixel:
5402 Tok.setKind(tok::kw___vector);
5404 case tok::identifier:
5406 Tok.setKind(tok::kw___vector);
5416 if (Tok.getIdentifierInfo() == Ident_vector) {
5419 case tok::kw_short:
5420 case tok::kw_long:
5421 case tok::kw_signed:
5422 case tok::kw_unsigned:
5423 case tok::kw_void:
5424 case tok
5425 case tok::kw_int:
5426 case tok::kw_float:
5427 case tok::kw_double:
5428 case tok::kw_bool:
5429 case tok::kw___pixel:
5432 case tok::identifier:
5441 } else if ((Tok.getIdentifierInfo() == Ident_pixel) &&