40#include "llvm/ADT/SmallVector.h"
134 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
145 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
152Parser::ParseExpressionWithLeadingExtension(
SourceLocation ExtLoc) {
158 LHS = ParseCastExpression(AnyCastExpr);
161 if (!LHS.isInvalid())
165 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
170 if (Tok.
is(tok::code_completion)) {
177 if (Tok.
is(tok::kw_throw))
178 return ParseThrowExpression();
179 if (Tok.
is(tok::kw_co_yield))
180 return ParseCoyieldExpression();
182 ExprResult LHS = ParseCastExpression(AnyCastExpr,
189 if (Tok.
is(tok::code_completion)) {
211Parser::ParseAssignmentExprWithObjCMessageExprStart(
SourceLocation LBracLoc,
214 Expr *ReceiverExpr) {
216 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
217 ReceiverType, ReceiverExpr);
218 R = ParsePostfixExpressionSuffix(R);
226 "Call this function only if your ExpressionEvaluationContext is "
227 "already ConstantEvaluated");
228 ExprResult LHS(ParseCastExpression(AnyCastExpr,
false, isTypeCast));
248 Actions.
ExprEvalContexts.back().InConditionallyConstantEvaluateContext =
true;
269 ExprResult LHS(ParseCastExpression(AnyCastExpr));
291 bool NotPrimaryExpression =
false;
292 auto ParsePrimary = [&] () {
293 ExprResult E = ParseCastExpression(PrimaryExprOnly,
297 &NotPrimaryExpression);
301 E = ParsePostfixExpressionSuffix(
E);
308 ? diag::note_unparenthesized_non_primary_expr_in_requires_clause
309 : diag::err_unparenthesized_non_primary_expr_in_requires_clause)
317 if (NotPrimaryExpression ||
324 Tok.
isOneOf(tok::period, tok::plusplus, tok::minusminus) ||
325 (Tok.
is(tok::l_square) && !
NextToken().is(tok::l_square))) {
326 E = RecoverFromNonPrimary(
E,
false);
329 NotPrimaryExpression =
false;
331 bool PossibleNonPrimary;
332 bool IsConstraintExpr =
334 IsTrailingRequiresClause);
335 if (!IsConstraintExpr || PossibleNonPrimary) {
340 if (PossibleNonPrimary)
341 E = RecoverFromNonPrimary(
E, !IsConstraintExpr);
350 while (Tok.
is(tok::ampamp)) {
358 tok::ampamp, LHS.
get(), RHS.
get());
384 while (Tok.
is(tok::pipepipe)) {
393 tok::pipepipe, LHS.
get(), RHS.
get());
404bool Parser::isNotExpressionStart() {
406 if (K == tok::l_brace || K == tok::r_brace ||
407 K == tok::kw_for || K == tok::kw_while ||
408 K == tok::kw_if || K == tok::kw_else ||
409 K == tok::kw_goto || K == tok::kw_try)
412 return isKnownToBeDeclarationSpecifier();
415bool Parser::isFoldOperator(
prec::Level Level)
const {
429 GreaterThanIsOperator,
433 auto SavedType = PreferredType;
436 PreferredType = SavedType;
440 if (NextTokPrec < MinPrec)
447 if (OpToken.
is(tok::caretcaret)) {
448 return ExprError(
Diag(Tok, diag::err_opencl_logical_exclusive_or));
453 if (OpToken.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
454 tok::greatergreatergreater) &&
455 checkPotentialAngleBracketDelimiter(OpToken))
463 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
471 if (isFoldOperator(NextTokPrec) && Tok.
is(tok::ellipsis)) {
485 Tok.
isOneOf(tok::colon, tok::r_square) &&
498 TernaryMiddle = ParseBraceInitializer();
499 if (!TernaryMiddle.isInvalid()) {
500 Diag(BraceLoc, diag::err_init_list_bin_op)
505 }
else if (Tok.
isNot(tok::colon)) {
517 TernaryMiddle =
nullptr;
518 Diag(Tok, diag::ext_gnu_conditional_expr);
521 if (TernaryMiddle.isInvalid()) {
524 TernaryMiddle =
nullptr;
533 const char *FIText =
": ";
537 bool IsInvalid =
false;
538 const char *SourcePtr =
540 if (!IsInvalid && *SourcePtr ==
' ') {
543 if (!IsInvalid && *SourcePtr ==
' ') {
550 Diag(Tok, diag::err_expected)
552 Diag(OpToken, diag::note_matching) << tok::question;
570 bool RHSIsInitList =
false;
572 RHS = ParseBraceInitializer();
573 RHSIsInitList =
true;
577 RHS = ParseCastExpression(AnyCastExpr);
583 if (TernaryMiddle.isUsable())
600 if (ThisPrec < NextTokPrec ||
601 (ThisPrec == NextTokPrec && isRightAssoc)) {
603 Diag(Tok, diag::err_init_list_bin_op)
612 RHS = ParseRHSOfBinaryExpression(RHS,
613 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
614 RHSIsInitList =
false;
620 if (TernaryMiddle.isUsable())
631 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
633 }
else if (ColonLoc.
isValid()) {
634 Diag(ColonLoc, diag::err_init_list_bin_op)
639 Diag(OpToken, diag::err_init_list_bin_op)
649 if (TernaryMiddle.isInvalid()) {
653 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
655 diag::warn_cxx11_right_shift_in_template_arg,
665 {LHS.get(), RHS.get()});
673 std::vector<clang::Expr *> Args;
675 if (TernaryMiddle.get())
676 Args = {LHS.
get(), TernaryMiddle.get(), RHS.
get()};
678 Args = {LHS.
get(), RHS.
get()};
706ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
707 bool isAddressOfOperand,
708 TypeCastState isTypeCast,
709 bool isVectorLiteral,
710 bool *NotPrimaryExpression) {
712 ExprResult Res = ParseCastExpression(ParseKind,
717 NotPrimaryExpression);
719 Diag(Tok, diag::err_expected_expression);
726 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
727 : NextToken(Next), AllowNonTypes(AllowNonTypes) {
728 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
731 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
736 if (isa<TypeDecl>(ND))
737 return WantTypeSpecifiers;
742 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
745 for (
auto *
C : candidate) {
747 if (isa<ValueDecl>(ND) && !isa<FunctionDecl>(ND))
753 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
754 return std::make_unique<CastExpressionIdValidator>(*
this);
765 if (RevertibleTypeTraits.empty()) {
766#define RTT_JOIN(X, Y) X##Y
767#define REVERTIBLE_TYPE_TRAIT(Name) \
768 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
828#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
829 REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
830#include "clang/Basic/TransformTypeTraits.def"
831#undef REVERTIBLE_TYPE_TRAIT
834 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known =
835 RevertibleTypeTraits.find(II);
836 if (Known != RevertibleTypeTraits.end()) {
838 *
Kind = Known->second;
844ExprResult Parser::ParseBuiltinPtrauthTypeDiscriminator() {
848 if (
T.expectAndConsume())
860 Loc, UETT_PtrAuthTypeDiscriminator,
1047ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
1048 bool isAddressOfOperand,
1050 TypeCastState isTypeCast,
1051 bool isVectorLiteral,
1052 bool *NotPrimaryExpression) {
1055 auto SavedType = PreferredType;
1056 NotCastExpr =
false;
1061 bool AllowSuffix =
true;
1073 switch (SavedKind) {
1074 case tok::l_paren: {
1077 ParenParseOption ParenExprType;
1078 switch (ParseKind) {
1079 case CastParseKind::UnaryExprOnly:
1082 case CastParseKind::AnyCastExpr:
1083 ParenExprType = ParenParseOption::CastExpr;
1085 case CastParseKind::PrimaryExprOnly:
1086 ParenExprType = FoldExpr;
1091 Res = ParseParenExpression(ParenExprType,
false,
1092 isTypeCast ==
IsTypeCast, CastTy, RParenLoc);
1097 if (isVectorLiteral)
1100 switch (ParenExprType) {
1101 case SimpleExpr:
break;
1103 case CompoundLiteral:
1121 case tok::numeric_constant:
1122 case tok::binary_data:
1132 Res = ParseCXXBoolLiteral();
1135 case tok::kw___objc_yes:
1136 case tok::kw___objc_no:
1137 Res = ParseObjCBoolLiteral();
1140 case tok::kw_nullptr:
1142 Diag(Tok, diag::warn_cxx98_compat_nullptr);
1145 : diag::ext_c_nullptr) << Tok.
getName();
1150 case tok::annot_primary_expr:
1151 case tok::annot_overload_set:
1152 Res = getExprAnnotation(Tok);
1155 ConsumeAnnotationToken();
1157 checkPotentialAngleBracket(Res);
1160 case tok::annot_non_type:
1161 case tok::annot_non_type_dependent:
1162 case tok::annot_non_type_undeclared: {
1165 Res = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
1167 "should not perform typo correction on annotation token");
1171 case tok::annot_embed: {
1172 injectEmbedTokens();
1173 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1174 isVectorLiteral, NotPrimaryExpression);
1177 case tok::kw___super:
1178 case tok::kw_decltype:
1182 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
1183 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1184 isVectorLiteral, NotPrimaryExpression);
1186 case tok::identifier:
1197 if (Next.is(tok::ellipsis) && Tok.
is(tok::identifier) &&
1198 GetLookAheadToken(2).is(tok::l_square)) {
1203 Tok.
is(tok::annot_pack_indexing_type))
1204 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1205 isVectorLiteral, NotPrimaryExpression);
1211 else if (Next.is(tok::l_paren) && Tok.
is(tok::identifier) &&
1215 if (isRevertibleTypeTrait(II, &Kind)) {
1217 return ParseCastExpression(ParseKind, isAddressOfOperand,
1218 NotCastExpr, isTypeCast,
1219 isVectorLiteral, NotPrimaryExpression);
1223 else if ((!ColonIsSacred && Next.is(tok::colon)) ||
1224 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
1229 if (!Tok.
is(tok::identifier))
1230 return ParseCastExpression(ParseKind, isAddressOfOperand,
1231 NotCastExpr, isTypeCast,
1233 NotPrimaryExpression);
1246 (&II == Ident_super &&
getCurScope()->isInObjcMethodScope()))) {
1249 if (Tok.
is(tok::code_completion) && &II != Ident_super) {
1252 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
1256 if (Tok.
isNot(tok::identifier) &&
1258 Diag(Tok, diag::err_expected_property_name);
1273 if (
getLangOpts().
ObjC && &II == Ident_super && !InMessageExpression &&
1275 ((Tok.
is(tok::identifier) &&
1277 Tok.
is(tok::code_completion))) {
1278 Res = ParseObjCMessageExpressionBody(
SourceLocation(), ILoc,
nullptr,
1289 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
1290 Tok.
is(tok::code_completion))) {
1292 if (Tok.
is(tok::code_completion) ||
1293 Next.is(tok::colon) || Next.is(tok::r_square))
1295 if (Typ.get()->isObjCObjectOrInterfaceType()) {
1298 DS.SetRangeStart(ILoc);
1299 DS.SetRangeEnd(ILoc);
1300 const char *PrevSpec =
nullptr;
1302 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
1319 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1320 isAddressOfOperand =
false;
1329 CastExpressionIdValidator Validator(
1333 Validator.IsAddressOfOperand = isAddressOfOperand;
1334 if (Tok.
isOneOf(tok::periodstar, tok::arrowstar)) {
1335 Validator.WantExpressionKeywords =
false;
1336 Validator.WantRemainingKeywords =
false;
1338 Validator.WantRemainingKeywords = Tok.
isNot(tok::r_paren);
1340 Name.setIdentifier(&II, ILoc);
1342 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
1343 isAddressOfOperand, &Validator,
1345 Tok.
is(tok::r_paren) ?
nullptr : &Replacement);
1347 UnconsumeToken(Replacement);
1348 return ParseCastExpression(ParseKind, isAddressOfOperand,
1349 NotCastExpr, isTypeCast,
1351 NotPrimaryExpression);
1353 Res = tryParseCXXPackIndexingExpression(Res);
1355 checkPotentialAngleBracket(Res);
1358 case tok::char_constant:
1359 case tok::wide_char_constant:
1360 case tok::utf8_char_constant:
1361 case tok::utf16_char_constant:
1362 case tok::utf32_char_constant:
1366 case tok::kw___func__:
1367 case tok::kw___FUNCTION__:
1368 case tok::kw___FUNCDNAME__:
1369 case tok::kw___FUNCSIG__:
1370 case tok::kw_L__FUNCTION__:
1371 case tok::kw_L__FUNCSIG__:
1372 case tok::kw___PRETTY_FUNCTION__:
1384 case tok::string_literal:
1385 case tok::wide_string_literal:
1386 case tok::utf8_string_literal:
1387 case tok::utf16_string_literal:
1388 case tok::utf32_string_literal:
1391 case tok::kw__Generic:
1392 Res = ParseGenericSelectionExpression();
1394 case tok::kw___builtin_available:
1395 Res = ParseAvailabilityCheckExpr(Tok.
getLocation());
1397 case tok::kw___builtin_va_arg:
1398 case tok::kw___builtin_offsetof:
1399 case tok::kw___builtin_choose_expr:
1400 case tok::kw___builtin_astype:
1401 case tok::kw___builtin_convertvector:
1402 case tok::kw___builtin_COLUMN:
1403 case tok::kw___builtin_FILE:
1404 case tok::kw___builtin_FILE_NAME:
1405 case tok::kw___builtin_FUNCTION:
1406 case tok::kw___builtin_FUNCSIG:
1407 case tok::kw___builtin_LINE:
1408 case tok::kw___builtin_source_location:
1409 if (NotPrimaryExpression)
1410 *NotPrimaryExpression =
true;
1412 return ParseBuiltinPrimaryExpression();
1413 case tok::kw___null:
1418 case tok::minusminus: {
1419 if (NotPrimaryExpression)
1420 *NotPrimaryExpression =
true;
1425 Token SavedTok = Tok;
1434 UnaryExprOnly : AnyCastExpr,
1441 UnconsumeToken(SavedTok);
1455 if (NotPrimaryExpression)
1456 *NotPrimaryExpression =
true;
1461 Res = ParseCastExpression(AnyCastExpr,
true);
1477 case tok::kw___real:
1478 case tok::kw___imag: {
1479 if (NotPrimaryExpression)
1480 *NotPrimaryExpression =
true;
1483 Res = ParseCastExpression(AnyCastExpr);
1487 isAddressOfOperand);
1494 case tok::kw_co_await: {
1495 if (NotPrimaryExpression)
1496 *NotPrimaryExpression =
true;
1498 Res = ParseCastExpression(AnyCastExpr);
1504 case tok::kw___extension__:{
1506 if (NotPrimaryExpression)
1507 *NotPrimaryExpression =
true;
1510 Res = ParseCastExpression(AnyCastExpr);
1515 case tok::kw__Alignof:
1516 diagnoseUseOfC11Keyword(Tok);
1518 case tok::kw_alignof:
1519 case tok::kw___alignof:
1521 case tok::kw_sizeof:
1525 case tok::kw___datasizeof:
1526 case tok::kw_vec_step:
1528 case tok::kw___builtin_omp_required_simd_align:
1529 case tok::kw___builtin_vectorelements:
1530 if (NotPrimaryExpression)
1531 *NotPrimaryExpression =
true;
1532 AllowSuffix =
false;
1533 Res = ParseUnaryExprOrTypeTraitExpression();
1536 if (NotPrimaryExpression)
1537 *NotPrimaryExpression =
true;
1539 if (Tok.
isNot(tok::identifier))
1540 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1543 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1545 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1550 AllowSuffix =
false;
1553 case tok::kw_const_cast:
1554 case tok::kw_dynamic_cast:
1555 case tok::kw_reinterpret_cast:
1556 case tok::kw_static_cast:
1557 case tok::kw_addrspace_cast:
1558 if (NotPrimaryExpression)
1559 *NotPrimaryExpression =
true;
1560 Res = ParseCXXCasts();
1562 case tok::kw___builtin_bit_cast:
1563 if (NotPrimaryExpression)
1564 *NotPrimaryExpression =
true;
1565 Res = ParseBuiltinBitCast();
1567 case tok::kw_typeid:
1568 if (NotPrimaryExpression)
1569 *NotPrimaryExpression =
true;
1570 Res = ParseCXXTypeid();
1572 case tok::kw___uuidof:
1573 if (NotPrimaryExpression)
1574 *NotPrimaryExpression =
true;
1575 Res = ParseCXXUuidof();
1578 Res = ParseCXXThis();
1580 case tok::kw___builtin_sycl_unique_stable_name:
1581 Res = ParseSYCLUniqueStableNameExpression();
1584 case tok::annot_typename:
1585 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1593 const char *PrevSpec =
nullptr;
1596 PrevSpec, DiagID,
Type,
1605 ConsumeAnnotationToken();
1612 case tok::annot_decltype:
1613 case tok::annot_pack_indexing_type:
1615 case tok::kw_wchar_t:
1616 case tok::kw_char8_t:
1617 case tok::kw_char16_t:
1618 case tok::kw_char32_t:
1623 case tok::kw___int64:
1624 case tok::kw___int128:
1625 case tok::kw__ExtInt:
1626 case tok::kw__BitInt:
1627 case tok::kw_signed:
1628 case tok::kw_unsigned:
1631 case tok::kw_double:
1632 case tok::kw___bf16:
1633 case tok::kw__Float16:
1634 case tok::kw___float128:
1635 case tok::kw___ibm128:
1638 case tok::kw_typename:
1639 case tok::kw_typeof:
1640 case tok::kw___vector:
1641 case tok::kw__Accum:
1642 case tok::kw__Fract:
1644#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1645#include "clang/Basic/OpenCLImageTypes.def"
1648 Diag(Tok, diag::err_expected_expression);
1653 if (NotPrimaryExpression)
1654 *NotPrimaryExpression =
true;
1656 if (SavedKind == tok::kw_typename) {
1673 ParseCXXSimpleTypeSpecifier(DS);
1674 if (Tok.
isNot(tok::l_paren) &&
1676 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1677 << DS.getSourceRange());
1679 if (Tok.
is(tok::l_brace))
1680 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1682 Res = ParseCXXTypeConstructExpression(DS);
1686 case tok::annot_cxxscope: {
1691 if (!Tok.
is(tok::annot_cxxscope))
1692 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1693 isTypeCast, isVectorLiteral,
1694 NotPrimaryExpression);
1697 if (Next.is(tok::annot_template_id)) {
1704 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1708 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1709 isTypeCast, isVectorLiteral,
1710 NotPrimaryExpression);
1715 Res = ParseCXXIdExpression(isAddressOfOperand);
1719 case tok::annot_template_id: {
1727 return ParseCastExpression(ParseKind, isAddressOfOperand,
1728 NotCastExpr, isTypeCast, isVectorLiteral,
1729 NotPrimaryExpression);
1736 case tok::kw_operator:
1737 Res = ParseCXXIdExpression(isAddressOfOperand);
1740 case tok::coloncolon: {
1745 if (!Tok.
is(tok::coloncolon))
1746 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1747 isVectorLiteral, NotPrimaryExpression);
1752 if (Tok.
is(tok::kw_new)) {
1753 if (NotPrimaryExpression)
1754 *NotPrimaryExpression =
true;
1755 Res = ParseCXXNewExpression(
true, CCLoc);
1756 AllowSuffix =
false;
1759 if (Tok.
is(tok::kw_delete)) {
1760 if (NotPrimaryExpression)
1761 *NotPrimaryExpression =
true;
1762 Res = ParseCXXDeleteExpression(
true, CCLoc);
1763 AllowSuffix =
false;
1768 Diag(CCLoc, diag::err_expected_expression);
1773 if (NotPrimaryExpression)
1774 *NotPrimaryExpression =
true;
1775 Res = ParseCXXNewExpression(
false, Tok.
getLocation());
1776 AllowSuffix =
false;
1779 case tok::kw_delete:
1780 if (NotPrimaryExpression)
1781 *NotPrimaryExpression =
true;
1782 Res = ParseCXXDeleteExpression(
false, Tok.
getLocation());
1783 AllowSuffix =
false;
1786 case tok::kw_requires:
1787 Res = ParseRequiresExpression();
1788 AllowSuffix =
false;
1791 case tok::kw_noexcept: {
1792 if (NotPrimaryExpression)
1793 *NotPrimaryExpression =
true;
1794 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1798 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1811 T.getCloseLocation());
1812 AllowSuffix =
false;
1816#define TYPE_TRAIT(N,Spelling,K) \
1817 case tok::kw_##Spelling:
1818#include "clang/Basic/TokenKinds.def"
1819 Res = ParseTypeTrait();
1822 case tok::kw___array_rank:
1823 case tok::kw___array_extent:
1824 if (NotPrimaryExpression)
1825 *NotPrimaryExpression =
true;
1826 Res = ParseArrayTypeTrait();
1829 case tok::kw___builtin_ptrauth_type_discriminator:
1830 return ParseBuiltinPtrauthTypeDiscriminator();
1832 case tok::kw___is_lvalue_expr:
1833 case tok::kw___is_rvalue_expr:
1834 if (NotPrimaryExpression)
1835 *NotPrimaryExpression =
true;
1836 Res = ParseExpressionTrait();
1840 if (NotPrimaryExpression)
1841 *NotPrimaryExpression =
true;
1843 return ParseObjCAtExpression(AtLoc);
1846 Res = ParseBlockLiteralExpression();
1848 case tok::code_completion: {
1854#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
1855#include "clang/Basic/TransformTypeTraits.def"
1860 Diag(Tok, diag::ext_keyword_as_ident)
1862 goto ParseIdentifier;
1864 goto ExpectedExpression;
1873 Res = TryParseLambdaExpression();
1877 if (NotPrimaryExpression)
1878 *NotPrimaryExpression =
true;
1879 Res = ParseObjCMessageExpression();
1883 Res = ParseLambdaExpression();
1887 Res = ParseObjCMessageExpression();
1901 if (ParseKind == PrimaryExprOnly)
1916 case tok::minusminus:
1934 Diag(Tok.
getLocation(), diag::err_postfix_after_unary_requires_parens)
1942 PreferredType = SavedType;
1943 Res = ParsePostfixExpressionSuffix(Res);
1945 !
getActions().getOpenCLOptions().isAvailableOption(
1947 if (
Expr *PostfixExpr = Res.
get()) {
1948 QualType Ty = PostfixExpr->getType();
1950 Diag(PostfixExpr->getExprLoc(),
1951 diag::err_opencl_taking_function_address_parser);
1981Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1985 auto SavedType = PreferredType;
1988 PreferredType = SavedType;
1990 case tok::code_completion:
1991 if (InMessageExpression)
1999 case tok::identifier:
2006 nullptr, LHS.
get());
2014 case tok::l_square: {
2022 isSimpleObjCMessageExpression())
2027 if (CheckProhibitedCXX11Attribute()) {
2033 Loc =
T.getOpenLocation();
2036 ExprVector ArgExprs;
2037 bool HasError =
false;
2044 if ((!
getLangOpts().OpenMP && !AllowOpenACCArraySections) ||
2045 Tok.
isNot(tok::colon)) {
2049 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2050 Idx = ParseBraceInitializer();
2059 ArgExprs.push_back(Idx.
get());
2061 }
else if (Tok.
isNot(tok::r_square)) {
2062 if (ParseExpressionList(ArgExprs)) {
2073 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {
2075 if (Tok.
is(tok::colon)) {
2078 if (Tok.
isNot(tok::r_square))
2081 }
else if (ArgExprs.size() <= 1 &&
getLangOpts().OpenMP) {
2083 if (Tok.
is(tok::colon)) {
2086 if (Tok.
isNot(tok::r_square) &&
2094 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||
2095 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
2096 Tok.
is(tok::colon)) {
2099 if (Tok.
isNot(tok::r_square)) {
2108 if (!LHS.
isInvalid() && !HasError && !Length.isInvalid() &&
2115 if (AllowOpenACCArraySections) {
2117 "Stride/second colon not allowed for OpenACC");
2119 LHS.
get(),
Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
2120 ColonLocFirst, Length.get(), RLoc);
2123 LHS.
get(),
Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
2124 ColonLocFirst, ColonLocSecond, Length.get(), Stride.
get(),
2141 case tok::lesslessless: {
2146 Expr *ExecConfig =
nullptr;
2150 if (OpKind == tok::lesslessless) {
2151 ExprVector ExecConfigExprs;
2154 if (ParseSimpleExpressionList(ExecConfigExprs)) {
2165 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
2166 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
2172 if (ExpectAndConsume(tok::l_paren))
2175 Loc = PrevTokLocation;
2180 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);
2184 ExecConfig = ECResult.
get();
2188 Loc = PT.getOpenLocation();
2191 ExprVector ArgExprs;
2192 auto RunSignatureHelp = [&]() ->
QualType {
2195 LHS.
get(), ArgExprs, PT.getOpenLocation());
2196 CalledSignatureHelp =
true;
2197 return PreferredType;
2199 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
2200 if (Tok.
isNot(tok::r_paren)) {
2201 if (ParseExpressionList(ArgExprs, [&] {
2202 PreferredType.enterFunctionArgument(Tok.
getLocation(),
2214 for (
auto &
E : ArgExprs)
2223 }
else if (Tok.
isNot(tok::r_paren)) {
2224 bool HadDelayedTypo =
false;
2226 HadDelayedTypo =
true;
2227 for (
auto &
E : ArgExprs)
2229 HadDelayedTypo =
true;
2244 ArgExprs.insert(ArgExprs.begin(), Fn);
2262 bool MayBePseudoDestructor =
false;
2265 PreferredType.enterMemAccess(Actions, Tok.
getLocation(), OrigLHS);
2269 const Type* BaseType =
Base->getType().getTypePtrOrNull();
2270 if (BaseType && Tok.
is(tok::l_paren) &&
2273 Diag(OpLoc, diag::err_function_is_not_record)
2274 << OpKind <<
Base->getSourceRange()
2276 return ParsePostfixExpressionSuffix(
Base);
2281 MayBePseudoDestructor);
2286 if (Tok.
is(tok::code_completion)) {
2292 ParseOptionalCXXScopeSpecifier(
2294 false, &MayBePseudoDestructor);
2296 ObjectType =
nullptr;
2299 if (Tok.
is(tok::code_completion)) {
2301 OpKind == tok::arrow ? tok::period : tok::arrow;
2308 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
2309 MayBePseudoDestructor);
2313 Expr *CorrectedBase = CorrectedLHS.get();
2315 CorrectedBase =
Base;
2321 Base && ExprStatementTokLoc ==
Base->getBeginLoc(),
2327 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
2328 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
2343 Tok.
is(tok::kw_class)) {
2353 Name.setIdentifier(
Id,
Loc);
2360 false, &TemplateKWLoc, Name)) {
2367 OpKind, SS, TemplateKWLoc, Name,
2368 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
2371 if (Tok.
is(tok::less))
2372 checkPotentialAngleBracket(LHS);
2373 }
else if (OrigLHS && Name.isValid()) {
2376 Name.getEndLoc(), {OrigLHS});
2381 case tok::minusminus:
2429Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
2434 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,
2435 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,
2436 tok::kw__Alignof, tok::kw_vec_step,
2437 tok::kw___builtin_omp_required_simd_align,
2438 tok::kw___builtin_vectorelements) &&
2439 "Not a typeof/sizeof/alignof/vec_step expression!");
2444 if (Tok.
isNot(tok::l_paren)) {
2447 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2448 tok::kw_alignof, tok::kw__Alignof)) {
2449 if (isTypeIdUnambiguously()) {
2451 ParseSpecifierQualifierList(DS);
2454 ParseDeclarator(DeclaratorInfo);
2460 diag::err_expected_parentheses_around_typename)
2463 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
2473 if (OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
2480 Operand = ParseCastExpression(UnaryExprOnly);
2486 ParenParseOption ExprType =
CastExpr;
2489 Operand = ParseParenExpression(ExprType,
true,
2490 false, CastTy, RParenLoc);
2501 !OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {
2518ExprResult Parser::ParseSYCLUniqueStableNameExpression() {
2519 assert(Tok.
is(tok::kw___builtin_sycl_unique_stable_name) &&
2520 "Not __builtin_sycl_unique_stable_name");
2526 if (
T.expectAndConsume(diag::err_expected_lparen_after,
2527 "__builtin_sycl_unique_stable_name"))
2537 if (
T.consumeClose())
2541 OpLoc,
T.getOpenLocation(),
T.getCloseLocation(), Ty.
get());
2558ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
2559 assert(Tok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2560 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
2561 tok::kw___builtin_omp_required_simd_align,
2562 tok::kw___builtin_vectorelements) &&
2563 "Not a sizeof/alignof/vec_step expression!");
2568 if (Tok.
is(tok::ellipsis) && OpTok.
is(tok::kw_sizeof)) {
2573 if (Tok.
is(tok::l_paren)) {
2576 LParenLoc =
T.getOpenLocation();
2577 if (Tok.
is(tok::identifier)) {
2581 RParenLoc =
T.getCloseLocation();
2585 Diag(Tok, diag::err_expected_parameter_pack);
2588 }
else if (Tok.
is(tok::identifier)) {
2593 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2598 Diag(Tok, diag::err_sizeof_parameter_pack);
2615 OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2616 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2618 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.
getName();
2634 case tok::kw_alignof:
2635 case tok::kw__Alignof:
2636 ExprKind = UETT_AlignOf;
2638 case tok::kw___alignof:
2639 ExprKind = UETT_PreferredAlignOf;
2641 case tok::kw_vec_step:
2642 ExprKind = UETT_VecStep;
2644 case tok::kw___builtin_omp_required_simd_align:
2645 ExprKind = UETT_OpenMPRequiredSimdAlign;
2647 case tok::kw___datasizeof:
2648 ExprKind = UETT_DataSizeOf;
2650 case tok::kw___builtin_vectorelements:
2651 ExprKind = UETT_VectorElements;
2664 if (OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2700ExprResult Parser::ParseBuiltinPrimaryExpression() {
2708 if (Tok.
isNot(tok::l_paren))
2709 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2718 default: llvm_unreachable(
"Not a builtin primary expression!");
2719 case tok::kw___builtin_va_arg: {
2722 if (ExpectAndConsume(tok::comma)) {
2729 if (Tok.
isNot(tok::r_paren)) {
2730 Diag(Tok, diag::err_expected) << tok::r_paren;
2740 case tok::kw___builtin_offsetof: {
2746 if (MacroName ==
"offsetof")
2759 if (ExpectAndConsume(tok::comma)) {
2765 if (Tok.
isNot(tok::identifier)) {
2766 Diag(Tok, diag::err_expected) << tok::identifier;
2775 Comps.back().isBrackets =
false;
2777 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2781 if (Tok.
is(tok::period)) {
2784 Comps.back().isBrackets =
false;
2787 if (Tok.
isNot(tok::identifier)) {
2788 Diag(Tok, diag::err_expected) << tok::identifier;
2794 }
else if (Tok.
is(tok::l_square)) {
2795 if (CheckProhibitedCXX11Attribute())
2800 Comps.back().isBrackets =
true;
2803 Comps.back().LocStart = ST.getOpenLocation();
2809 Comps.back().U.E = Res.
get();
2812 Comps.back().LocEnd = ST.getCloseLocation();
2814 if (Tok.
isNot(tok::r_paren)) {
2823 PT.getCloseLocation());
2830 case tok::kw___builtin_choose_expr: {
2832 if (Cond.isInvalid()) {
2836 if (ExpectAndConsume(tok::comma)) {
2842 if (Expr1.isInvalid()) {
2846 if (ExpectAndConsume(tok::comma)) {
2852 if (Expr2.isInvalid()) {
2856 if (Tok.
isNot(tok::r_paren)) {
2857 Diag(Tok, diag::err_expected) << tok::r_paren;
2861 Expr2.get(), ConsumeParen());
2864 case tok::kw___builtin_astype: {
2867 if (
Expr.isInvalid()) {
2872 if (ExpectAndConsume(tok::comma)) {
2883 if (Tok.
isNot(tok::r_paren)) {
2884 Diag(Tok, diag::err_expected) << tok::r_paren;
2893 case tok::kw___builtin_convertvector: {
2896 if (
Expr.isInvalid()) {
2901 if (ExpectAndConsume(tok::comma)) {
2912 if (Tok.
isNot(tok::r_paren)) {
2913 Diag(Tok, diag::err_expected) << tok::r_paren;
2922 case tok::kw___builtin_COLUMN:
2923 case tok::kw___builtin_FILE:
2924 case tok::kw___builtin_FILE_NAME:
2925 case tok::kw___builtin_FUNCTION:
2926 case tok::kw___builtin_FUNCSIG:
2927 case tok::kw___builtin_LINE:
2928 case tok::kw___builtin_source_location: {
2930 if (Tok.
isNot(tok::r_paren)) {
2931 Diag(Tok, diag::err_expected) << tok::r_paren;
2937 case tok::kw___builtin_FILE:
2939 case tok::kw___builtin_FILE_NAME:
2941 case tok::kw___builtin_FUNCTION:
2943 case tok::kw___builtin_FUNCSIG:
2945 case tok::kw___builtin_LINE:
2947 case tok::kw___builtin_COLUMN:
2949 case tok::kw___builtin_source_location:
2952 llvm_unreachable(
"invalid keyword");
2965 return ParsePostfixExpressionSuffix(Res.
get());
2968bool Parser::tryParseOpenMPArrayShapingCastPart() {
2969 assert(Tok.
is(tok::l_square) &&
"Expected open bracket");
2970 bool ErrorFound =
true;
2971 TentativeParsingAction TPA(*
this);
2973 if (Tok.
isNot(tok::l_square))
2978 while (!
SkipUntil(tok::r_square, tok::annot_pragma_openmp_end,
2981 if (Tok.
isNot(tok::r_square))
2986 if (Tok.
is(tok::r_paren)) {
2990 }
while (Tok.
isNot(tok::annot_pragma_openmp_end));
3023Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
3026 assert(Tok.
is(tok::l_paren) &&
"Not a paren expr!");
3029 if (
T.consumeOpen())
3033 PreferredType.enterParenExpr(Tok.
getLocation(), OpenLoc);
3036 bool isAmbiguousTypeId;
3039 if (Tok.
is(tok::code_completion)) {
3043 ExprType >= CompoundLiteral);
3050 tok::kw___bridge_transfer,
3051 tok::kw___bridge_retained,
3052 tok::kw___bridge_retain));
3053 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
3055 StringRef BridgeCastName = Tok.
getName();
3058 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
3068 Diag(Tok, OpenLoc.
isMacroID() ? diag::ext_gnu_statement_expr_macro
3069 : diag::ext_gnu_statement_expr);
3071 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
3080 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
3083 "statement expr not in code context");
3093 if (!
Stmt.isInvalid()) {
3100 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
3106 if (tokenKind == tok::kw___bridge)
3108 else if (tokenKind == tok::kw___bridge_transfer)
3110 else if (tokenKind == tok::kw___bridge_retained)
3115 assert(tokenKind == tok::kw___bridge_retain);
3118 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
3120 "__bridge_retained");
3125 ColonProtection.restore();
3126 RParenLoc =
T.getCloseLocation();
3129 ExprResult SubExpr = ParseCastExpression(AnyCastExpr);
3135 BridgeKeywordLoc, Ty.
get(),
3136 RParenLoc, SubExpr.
get());
3137 }
else if (ExprType >= CompoundLiteral &&
3138 isTypeIdInParens(isAmbiguousTypeId)) {
3147 if (isAmbiguousTypeId && !stopIfCastExpr) {
3148 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy,
T,
3150 RParenLoc =
T.getCloseLocation();
3156 ParseSpecifierQualifierList(DS);
3159 ParseDeclarator(DeclaratorInfo);
3164 if (!DeclaratorInfo.isInvalidType() && Tok.
is(tok::identifier) &&
3178 ColonProtection.restore();
3179 RParenLoc =
T.getCloseLocation();
3180 if (Tok.
is(tok::l_brace)) {
3181 ExprType = CompoundLiteral;
3187 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
3190 if (Tok.
is(tok::l_paren)) {
3211 Result = ParseCastExpression(AnyCastExpr,
3216 if (!
Result.isInvalid()) {
3218 DeclaratorInfo, CastTy,
3219 RParenLoc,
Result.get());
3223 if (!
Result.isInvalid()) {
3235 if (DeclaratorInfo.isInvalidType())
3240 if (stopIfCastExpr) {
3254 GetLookAheadToken(1).isNot(tok::period)) {
3263 Result = ParseCastExpression(AnyCastExpr,
3266 if (!
Result.isInvalid()) {
3268 DeclaratorInfo, CastTy,
3269 RParenLoc,
Result.get());
3274 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
3277 }
else if (ExprType >= FoldExpr && Tok.
is(tok::ellipsis) &&
3279 ExprType = FoldExpr;
3281 }
else if (isTypeCast) {
3284 ExprVector ArgExprs;
3286 if (!ParseSimpleExpressionList(ArgExprs)) {
3289 if (ExprType >= FoldExpr && ArgExprs.size() == 1 &&
3291 ExprType = FoldExpr;
3292 return ParseFoldExpression(ArgExprs[0],
T);
3295 ExprType = SimpleExpr;
3299 }
else if (
getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&
3300 ExprType ==
CastExpr && Tok.
is(tok::l_square) &&
3301 tryParseOpenMPArrayShapingCastPart()) {
3302 bool ErrorFound =
false;
3312 while (!
SkipUntil(tok::r_square, tok::r_paren,
3317 OMPDimensions.push_back(NumElements.
get());
3318 OMPBracketsRanges.push_back(TS.getRange());
3319 }
while (Tok.
isNot(tok::r_paren));
3322 RParenLoc =
T.getCloseLocation();
3326 }
else if (!
Result.isInvalid()) {
3328 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);
3341 if (ExprType >= FoldExpr && isFoldOperator(Tok.
getKind()) &&
3343 ExprType = FoldExpr;
3344 return ParseFoldExpression(
Result,
T);
3346 ExprType = SimpleExpr;
3349 if (!
Result.isInvalid() && Tok.
is(tok::r_paren))
3355 if (
Result.isInvalid()) {
3361 RParenLoc =
T.getCloseLocation();
3374Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
3377 assert(Tok.
is(tok::l_brace) &&
"Not a compound literal!");
3379 Diag(LParenLoc, diag::ext_c99_compound_literal);
3382 if (!
Result.isInvalid() && Ty)
3408 "Not a string-literal-like token!");
3416 StringToks.push_back(Tok);
3421 assert(!AllowUserDefinedLiteral &&
"UDL are always evaluated");
3450ExprResult Parser::ParseGenericSelectionExpression() {
3451 assert(Tok.
is(tok::kw__Generic) &&
"_Generic keyword expected");
3453 diagnoseUseOfC11Keyword(Tok);
3457 if (
T.expectAndConsume())
3464 if (isTypeIdForGenericSelection()) {
3470 const auto *LIT = cast<LocInfoType>(ControllingType.
get().get());
3473 : diag::ext_c2y_generic_with_type_arg);
3487 if (ExpectAndConsume(tok::comma)) {
3497 if (Tok.
is(tok::kw_default)) {
3501 Diag(Tok, diag::err_duplicate_default_assoc);
3502 Diag(DefaultLoc, diag::note_previous_default_assoc);
3517 Types.push_back(Ty);
3519 if (ExpectAndConsume(tok::colon)) {
3528 if (ER.isInvalid()) {
3532 Exprs.push_back(ER.get());
3536 if (
T.getCloseLocation().isInvalid())
3539 void *ExprOrTy = ControllingExpr.
isUsable()
3540 ? ControllingExpr.
get()
3541 : ControllingType.
get().getAsOpaquePtr();
3544 KeyLoc, DefaultLoc,
T.getCloseLocation(), ControllingExpr.
isUsable(),
3545 ExprOrTy, Types, Exprs);
3567 assert(isFoldOperator(Kind) &&
"missing fold-operator");
3571 assert(Tok.
is(tok::ellipsis) &&
"not a fold-expression");
3575 if (Tok.
isNot(tok::r_paren)) {
3576 if (!isFoldOperator(Tok.
getKind()))
3579 if (Kind != tok::unknown && Tok.
getKind() != Kind)
3593 ? diag::warn_cxx14_compat_fold_expression
3594 : diag::ext_fold_expression);
3598 Kind, EllipsisLoc, RHS.
get(),
3599 T.getCloseLocation());
3602void Parser::injectEmbedTokens() {
3606 Data->BinaryData.size() * 2 - 1),
3607 Data->BinaryData.size() * 2 - 1);
3609 for (
auto &Byte :
Data->BinaryData) {
3610 Toks[I].startToken();
3611 Toks[I].setKind(tok::binary_data);
3613 Toks[I].setLength(1);
3614 Toks[I].setLiteralData(&Byte);
3615 if (I != ((
Data->BinaryData.size() - 1) * 2)) {
3616 Toks[I + 1].startToken();
3617 Toks[I + 1].setKind(tok::comma);
3622 PP.EnterTokenStream(std::move(Toks),
true,
3650 llvm::function_ref<
void()> ExpressionStarts,
3651 bool FailImmediatelyOnInvalidExpr,
3652 bool EarlyTypoCorrection) {
3653 bool SawError =
false;
3655 if (ExpressionStarts)
3660 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3661 Expr = ParseBraceInitializer();
3665 if (EarlyTypoCorrection)
3668 if (Tok.
is(tok::ellipsis))
3670 else if (Tok.
is(tok::code_completion)) {
3680 if (
Expr.isInvalid()) {
3682 if (FailImmediatelyOnInvalidExpr)
3686 Exprs.push_back(
Expr.get());
3689 if (Tok.
isNot(tok::comma))
3694 checkPotentialAngleBracketDelimiter(Comma);
3699 for (
auto &
E : Exprs) {
3718 if (
Expr.isInvalid())
3721 Exprs.push_back(
Expr.get());
3731 checkPotentialAngleBracketDelimiter(Comma);
3742 if (Tok.
is(tok::code_completion)) {
3751 ParseSpecifierQualifierList(DS);
3757 ParseDeclarator(DeclaratorInfo);
3759 MaybeParseGNUAttributes(DeclaratorInfo);
3775ExprResult Parser::ParseBlockLiteralExpression() {
3776 assert(Tok.
is(tok::caret) &&
"block literal starts with ^");
3780 "block literal parsing");
3803 if (Tok.
is(tok::l_paren)) {
3804 ParseParenDeclarator(ParamInfo);
3809 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
3810 ParamInfo.SetRangeEnd(Tmp);
3811 if (ParamInfo.isInvalidType()) {
3819 MaybeParseGNUAttributes(ParamInfo);
3823 }
else if (!Tok.
is(tok::l_brace)) {
3824 ParseBlockId(CaretLoc);
3828 ParamInfo.AddTypeInfo(
3846 CaretLoc, CaretLoc, ParamInfo),
3849 MaybeParseGNUAttributes(ParamInfo);
3857 if (!Tok.
is(tok::l_brace)) {
3859 Diag(Tok, diag::err_expected_expression);
3866 if (!
Stmt.isInvalid())
3886 llvm::SmallSet<StringRef, 4> Platforms;
3887 bool HasOtherPlatformSpec =
false;
3889 for (
const auto &Spec : AvailSpecs) {
3890 if (Spec.isOtherPlatformSpec()) {
3891 if (HasOtherPlatformSpec) {
3892 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3896 HasOtherPlatformSpec =
true;
3900 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3905 StringRef Platform = Spec.getPlatform();
3906 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3907 << Spec.getEndLoc() << Platform;
3912 if (!HasOtherPlatformSpec) {
3913 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3914 P.Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3927std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() {
3928 if (Tok.
is(tok::star)) {
3932 if (Tok.
is(tok::code_completion)) {
3935 return std::nullopt;
3937 if (Tok.
isNot(tok::identifier)) {
3938 Diag(Tok, diag::err_avail_query_expected_platform_name);
3939 return std::nullopt;
3944 VersionTuple Version = ParseVersionTuple(VersionRange);
3946 if (Version.empty())
3947 return std::nullopt;
3949 StringRef GivenPlatform = PlatformIdentifier->
Ident->
getName();
3950 StringRef Platform =
3951 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3953 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||
3954 (GivenPlatform.contains(
"xros") || GivenPlatform.contains(
"xrOS"))) {
3956 diag::err_avail_query_unrecognized_platform_name)
3958 return std::nullopt;
3967 assert(Tok.
is(tok::kw___builtin_available) ||
3974 if (
Parens.expectAndConsume())
3978 bool HasError =
false;
3980 std::optional<AvailabilitySpec> Spec = ParseAvailabilitySpec();
3984 AvailSpecs.push_back(*Spec);
3997 if (
Parens.consumeClose())
4001 AvailSpecs, BeginLoc,
Parens.getCloseLocation());
Defines the clang::ASTContext interface.
static Decl::Kind getKind(const Decl *D)
Defines the clang::Expr interface and subclasses for C++ expressions.
static bool CheckAvailabilitySpecList(Parser &P, ArrayRef< AvailabilitySpec > AvailSpecs)
Validate availability spec list, emitting diagnostics if necessary.
#define REVERTIBLE_TYPE_TRAIT(Name)
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
This file declares semantic analysis for CUDA constructs.
This file declares facilities that support code completion.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenACC constructs and clauses.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis for SYCL constructs.
const clang::PrintingPolicy & getPrintingPolicy() const
One specifier in an @available expression.
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
CompoundStmt - This represents a group of statements like { stmt stmt }.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
Captures information about "declaration specifiers".
Information about one declarator, including the parsed type information and the identifier.
RAII object that enters a new expression evaluation context.
This represents one expression.
bool containsErrors() const
Whether this expression contains subexpressions which had errors, e.g.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
One of these records is kept for each identifier that is lexed.
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
StringRef getName() const
Return the actual identifier string.
Represents the declaration of a label.
static StringRef getImmediateMacroNameForDiagnostics(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
This represents a decl that may have a name.
void * getAsOpaquePtr() const
static const ParsedAttributesView & none()
Parser - This implements a parser for the C family of languages.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
Sema & getActions() const
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
ExprResult ParseCaseExpression(SourceLocation CaseLoc)
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
ExprResult ParseConstantExpression()
ExprResult ParseConditionalExpression()
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
ExprResult ParseArrayBoundExpression()
ExprResult ParseConstraintLogicalAndExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-and-expression.
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtSemi
Stop skipping at semicolon.
bool TryAnnotateTypeOrScopeToken(ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
TypeCastState
TypeCastState - State whether an expression is or may be a type cast.
ExprResult ParseUnevaluatedStringLiteralExpression()
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
void enterSubscript(Sema &S, SourceLocation Tok, Expr *LHS)
void enterUnary(Sema &S, SourceLocation Tok, tok::TokenKind OpKind, SourceLocation OpLoc)
void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op)
QualType get(SourceLocation Tok) const
Get the expected type associated with this location, if any.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
SourceManager & getSourceManager() const
llvm::BumpPtrAllocator & getPreprocessorAllocator()
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
bool isAtStartOfMacroExpansion(SourceLocation loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the first token of the macro expansion.
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
If a crash happens while one of these objects are live, the message is printed out along with the spe...
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
@ BlockScope
This is a scope that corresponds to a block/closure object.
@ CompoundStmtScope
This is a compound statement scope.
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ DeclScope
This is a scope that can contain a declaration.
ExprResult ActOnExecConfigExpr(Scope *S, SourceLocation LLLLoc, MultiExprArg ExecConfig, SourceLocation GGGLoc)
@ PCC_Type
Code completion occurs where only a type is permitted.
void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)
Perform code-completion in an expression context when we know what type we're looking for.
QualType ProduceCallSignatureHelp(Expr *Fn, ArrayRef< Expr * > Args, SourceLocation OpenParLoc)
Determines the preferred type of the current function argument, by examining the signatures of all po...
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, const IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
void CodeCompleteAvailabilityPlatformName()
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement, QualType PreferredType)
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS, QualType PreferredType)
ExprResult ActOnObjCBridgedCast(Scope *S, SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, ParsedType Type, SourceLocation RParenLoc, Expr *SubExpr)
ExprResult ActOnClassPropertyRefExpr(const IdentifierInfo &receiverName, const IdentifierInfo &propertyName, SourceLocation receiverNameLoc, SourceLocation propertyNameLoc)
ExprResult ActOnObjCBoolLiteral(SourceLocation AtLoc, SourceLocation ValueLoc, bool Value)
ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)
ExprResult ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, Expr *Length, SourceLocation RBLoc)
Checks and creates an Array Section used in an OpenACC construct/clause.
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLocFirst, SourceLocation ColonLocSecond, Expr *Length, Expr *Stride, SourceLocation RBLoc)
ExprResult ActOnOMPArrayShapingExpr(Expr *Base, SourceLocation LParenLoc, SourceLocation RParenLoc, ArrayRef< Expr * > Dims, ArrayRef< SourceRange > Brackets)
ExprResult ActOnUniqueStableNameExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, ParsedType ParsedTy)
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
Unary Operators. 'Tok' is the token for the operator.
ExprResult ActOnConstantExpression(ExprResult Res)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
void ActOnStartStmtExpr()
void ActOnStmtExprError()
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc)
ActOnCXXNullPtrLiteral - Parse 'nullptr'.
bool CheckConstraintExpression(const Expr *CE, Token NextToken=Token(), bool *PossibleNonPrimary=nullptr, bool IsTrailingRequiresClause=false)
Check whether the given expression is a valid constraint expression.
ASTContext & getASTContext() const
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
SourceRange getExprRange(Expr *E) const
SemaCodeCompletion & CodeCompletion()
ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)
ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Member, Decl *ObjCImpDecl)
The main callback when the parser finds something like expression .
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, bool PredicateIsExpr, void *ControllingExprOrType, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr * > ArgExprs)
ControllingExprOrType is either an opaque pointer coming out of a ParsedType or an Expr *.
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
ExprResult ActOnSourceLocExpr(SourceLocIdentKind Kind, SourceLocation BuiltinLoc, SourceLocation RPLoc)
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
TypeResult ActOnTypeName(Declarator &D)
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e....
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
Binary Operators. 'Tok' is the token for the operator.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
Parse a __builtin_astype expression.
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
ExprResult ActOnSizeofParameterPackExpr(Scope *S, SourceLocation OpLoc, IdentifierInfo &Name, SourceLocation NameLoc, SourceLocation RParenLoc)
Called when an expression computing the size of a parameter pack is parsed.
ExprResult ActOnStmtExpr(Scope *S, SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
ExprResult ActOnCXXFoldExpr(Scope *S, SourceLocation LParenLoc, Expr *LHS, tok::TokenKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc)
Handle a C++1z fold-expression: ( expr op ... op expr ).
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
ExprResult CreateRecoveryExpr(SourceLocation Begin, SourceLocation End, ArrayRef< Expr * > SubExprs, QualType T=QualType())
Attempts to produce a RecoveryExpr after some AST node cannot be created.
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, MultiExprArg ArgExprs, SourceLocation RLoc)
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)
ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
ActOnConvertVectorExpr - create a new convert-vector expression from the provided arguments.
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
ExprResult ActOnNameClassifiedAsOverloadSet(Scope *S, Expr *OverloadSet)
Act on the result of classifying a name as an overload set.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
const char * getName() const
void setKind(tok::TokenKind K)
SourceLocation getAnnotationEndLoc() const
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
void * getAnnotationValue() const
tok::TokenKind getKind() const
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
bool isSimpleTypeSpecifier(const LangOptions &LangOpts) const
Determine whether the token kind starts a simple-type-specifier.
SourceLocation getLastLoc() const
Base wrapper for a particular "section" of type source info.
The base class of the type hierarchy.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
bool isFunctionType() const
bool isVectorType() const
Simple class containing the result of Sema::CorrectTypo.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
Represents a C++ unqualified-id that has been parsed.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
bool tokenIsLikeStringLiteral(const Token &Tok, const LangOptions &LO)
Return true if the token is a string literal, or a function local predefined macro,...
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
@ Result
The result type of a method or function.
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
@ OBC_Bridge
Bridging via __bridge, which does nothing but reinterpret the bits.
@ OBC_BridgeTransfer
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC.
@ OBC_BridgeRetained
Bridging via __bridge_retain, which makes an ARC object available as a +1 C pointer.
ActionResult< Expr * > ExprResult
prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, bool CPlusPlus11)
Return the precedence of the specified binary operator token.
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
const FunctionProtoType * T
@ Parens
New-expression has a C++98 paren-delimited initializer.
@ EST_None
no exception specification
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
Helper class to shuttle information about #embed directives from the preprocessor to the parser throu...
Wraps an identifier and optional source location for the identifier.
Information about a template-id annotation token.
TemplateNameKind Kind
The kind of template that Template refers to.