42 #include "llvm/ADT/SmallVector.h"
44 using namespace clang;
136 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
147 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
154 Parser::ParseExpressionWithLeadingExtension(
SourceLocation ExtLoc) {
160 LHS = ParseCastExpression(AnyCastExpr);
163 if (!LHS.isInvalid())
167 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
172 if (Tok.
is(tok::code_completion)) {
179 if (Tok.
is(tok::kw_throw))
180 return ParseThrowExpression();
181 if (Tok.
is(tok::kw_co_yield))
182 return ParseCoyieldExpression();
184 ExprResult LHS = ParseCastExpression(AnyCastExpr,
191 if (Tok.
is(tok::code_completion)) {
213 Parser::ParseAssignmentExprWithObjCMessageExprStart(
SourceLocation LBracLoc,
216 Expr *ReceiverExpr) {
218 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
219 ReceiverType, ReceiverExpr);
220 R = ParsePostfixExpressionSuffix(R);
228 "Call this function only if your ExpressionEvaluationContext is "
229 "already ConstantEvaluated");
230 ExprResult LHS(ParseCastExpression(AnyCastExpr,
false, isTypeCast));
250 Actions.
ExprEvalContexts.back().InConditionallyConstantEvaluateContext =
true;
271 ExprResult LHS(ParseCastExpression(AnyCastExpr));
293 bool NotPrimaryExpression =
false;
294 auto ParsePrimary = [&] () {
295 ExprResult E = ParseCastExpression(PrimaryExprOnly,
299 &NotPrimaryExpression);
302 auto RecoverFromNonPrimary = [&] (
ExprResult E,
bool Note) {
303 E = ParsePostfixExpressionSuffix(
E);
310 ? diag::note_unparenthesized_non_primary_expr_in_requires_clause
311 : diag::err_unparenthesized_non_primary_expr_in_requires_clause)
319 if (NotPrimaryExpression ||
326 Tok.
isOneOf(tok::period, tok::plusplus, tok::minusminus) ||
327 (Tok.
is(tok::l_square) && !
NextToken().is(tok::l_square))) {
328 E = RecoverFromNonPrimary(
E,
false);
331 NotPrimaryExpression =
false;
333 bool PossibleNonPrimary;
334 bool IsConstraintExpr =
336 IsTrailingRequiresClause);
337 if (!IsConstraintExpr || PossibleNonPrimary) {
342 if (PossibleNonPrimary)
343 E = RecoverFromNonPrimary(
E, !IsConstraintExpr);
352 while (Tok.
is(tok::ampamp)) {
360 tok::ampamp, LHS.
get(), RHS.
get());
386 while (Tok.
is(tok::pipepipe)) {
395 tok::pipepipe, LHS.
get(), RHS.
get());
406 bool Parser::isNotExpressionStart() {
408 if (K == tok::l_brace || K == tok::r_brace ||
409 K == tok::kw_for || K == tok::kw_while ||
410 K == tok::kw_if || K == tok::kw_else ||
411 K == tok::kw_goto || K == tok::kw_try)
414 return isKnownToBeDeclarationSpecifier();
431 GreaterThanIsOperator,
435 auto SavedType = PreferredType;
438 PreferredType = SavedType;
442 if (NextTokPrec < MinPrec)
449 if (OpToken.
is(tok::caretcaret)) {
450 return ExprError(
Diag(Tok, diag::err_opencl_logical_exclusive_or));
455 if (OpToken.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
456 tok::greatergreatergreater) &&
457 checkPotentialAngleBracketDelimiter(OpToken))
465 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
473 if (isFoldOperator(NextTokPrec) && Tok.
is(tok::ellipsis)) {
487 Tok.
isOneOf(tok::colon, tok::r_square) &&
500 TernaryMiddle = ParseBraceInitializer();
501 if (!TernaryMiddle.isInvalid()) {
502 Diag(BraceLoc, diag::err_init_list_bin_op)
507 }
else if (Tok.
isNot(tok::colon)) {
519 TernaryMiddle =
nullptr;
520 Diag(Tok, diag::ext_gnu_conditional_expr);
523 if (TernaryMiddle.isInvalid()) {
526 TernaryMiddle =
nullptr;
535 const char *FIText =
": ";
539 bool IsInvalid =
false;
540 const char *SourcePtr =
542 if (!IsInvalid && *SourcePtr ==
' ') {
545 if (!IsInvalid && *SourcePtr ==
' ') {
552 Diag(Tok, diag::err_expected)
554 Diag(OpToken, diag::note_matching) << tok::question;
572 bool RHSIsInitList =
false;
574 RHS = ParseBraceInitializer();
575 RHSIsInitList =
true;
579 RHS = ParseCastExpression(AnyCastExpr);
585 if (TernaryMiddle.isUsable())
602 if (ThisPrec < NextTokPrec ||
603 (ThisPrec == NextTokPrec && isRightAssoc)) {
605 Diag(Tok, diag::err_init_list_bin_op)
614 RHS = ParseRHSOfBinaryExpression(RHS,
615 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
616 RHSIsInitList =
false;
622 if (TernaryMiddle.isUsable())
633 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
635 }
else if (ColonLoc.
isValid()) {
636 Diag(ColonLoc, diag::err_init_list_bin_op)
641 Diag(OpToken, diag::err_init_list_bin_op)
651 if (TernaryMiddle.isInvalid()) {
655 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
657 diag::warn_cxx11_right_shift_in_template_arg,
667 {LHS.get(), RHS.get()});
675 std::vector<clang::Expr *> Args;
677 if (TernaryMiddle.get())
678 Args = {LHS.
get(), TernaryMiddle.get(), RHS.
get()};
680 Args = {LHS.
get(), RHS.
get()};
708 ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
709 bool isAddressOfOperand,
710 TypeCastState isTypeCast,
711 bool isVectorLiteral,
712 bool *NotPrimaryExpression) {
714 ExprResult Res = ParseCastExpression(ParseKind,
719 NotPrimaryExpression);
721 Diag(Tok, diag::err_expected_expression);
728 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
729 : NextToken(Next), AllowNonTypes(AllowNonTypes) {
730 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
733 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
738 if (isa<TypeDecl>(ND))
739 return WantTypeSpecifiers;
744 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
747 for (
auto *C : candidate) {
749 if (isa<ValueDecl>(ND) && !isa<FunctionDecl>(ND))
755 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
756 return std::make_unique<CastExpressionIdValidator>(*
this);
767 if (RevertibleTypeTraits.empty()) {
771 #define RTT_JOIN(X, Y) X##Y
772 #define REVERTIBLE_TYPE_TRAIT(Name) \
773 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
831 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
832 REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
833 #include "clang/Basic/TransformTypeTraits.def"
834 #undef REVERTIBLE_TYPE_TRAIT
837 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known =
838 RevertibleTypeTraits.find(II);
839 if (Known != RevertibleTypeTraits.end()) {
841 *
Kind = Known->second;
847 ExprResult Parser::ParseBuiltinPtrauthTypeDiscriminator() {
851 if (
T.expectAndConsume())
863 Loc, UETT_PtrAuthTypeDiscriminator,
1050 ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
1051 bool isAddressOfOperand,
1053 TypeCastState isTypeCast,
1054 bool isVectorLiteral,
1055 bool *NotPrimaryExpression) {
1058 auto SavedType = PreferredType;
1059 NotCastExpr =
false;
1064 bool AllowSuffix =
true;
1076 switch (SavedKind) {
1077 case tok::l_paren: {
1080 ParenParseOption ParenExprType;
1081 switch (ParseKind) {
1082 case CastParseKind::UnaryExprOnly:
1085 case CastParseKind::AnyCastExpr:
1086 ParenExprType = ParenParseOption::CastExpr;
1088 case CastParseKind::PrimaryExprOnly:
1089 ParenExprType = FoldExpr;
1094 Res = ParseParenExpression(ParenExprType,
false,
1095 isTypeCast ==
IsTypeCast, CastTy, RParenLoc);
1100 if (isVectorLiteral)
1103 switch (ParenExprType) {
1104 case SimpleExpr:
break;
1106 case CompoundLiteral:
1124 case tok::numeric_constant:
1125 case tok::binary_data:
1135 Res = ParseCXXBoolLiteral();
1138 case tok::kw___objc_yes:
1139 case tok::kw___objc_no:
1140 Res = ParseObjCBoolLiteral();
1143 case tok::kw_nullptr:
1145 Diag(Tok, diag::warn_cxx98_compat_nullptr);
1148 : diag::ext_c_nullptr) << Tok.
getName();
1153 case tok::annot_primary_expr:
1154 case tok::annot_overload_set:
1155 Res = getExprAnnotation(Tok);
1158 ConsumeAnnotationToken();
1160 checkPotentialAngleBracket(Res);
1163 case tok::annot_non_type:
1164 case tok::annot_non_type_dependent:
1165 case tok::annot_non_type_undeclared: {
1168 Res = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
1170 "should not perform typo correction on annotation token");
1174 case tok::annot_embed: {
1175 injectEmbedTokens();
1176 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1177 isVectorLiteral, NotPrimaryExpression);
1180 case tok::kw___super:
1181 case tok::kw_decltype:
1185 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
1186 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1187 isVectorLiteral, NotPrimaryExpression);
1189 case tok::identifier:
1200 if (Next.is(tok::ellipsis) && Tok.
is(tok::identifier) &&
1201 GetLookAheadToken(2).is(tok::l_square)) {
1206 Tok.
is(tok::annot_pack_indexing_type))
1207 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1208 isVectorLiteral, NotPrimaryExpression);
1214 else if (Next.is(tok::l_paren) && Tok.
is(tok::identifier) &&
1218 if (isRevertibleTypeTrait(II, &
Kind)) {
1220 return ParseCastExpression(ParseKind, isAddressOfOperand,
1221 NotCastExpr, isTypeCast,
1222 isVectorLiteral, NotPrimaryExpression);
1226 else if ((!ColonIsSacred && Next.is(tok::colon)) ||
1227 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
1232 if (!Tok.
is(tok::identifier))
1233 return ParseCastExpression(ParseKind, isAddressOfOperand,
1234 NotCastExpr, isTypeCast,
1236 NotPrimaryExpression);
1249 (&II == Ident_super &&
getCurScope()->isInObjcMethodScope()))) {
1252 if (Tok.
is(tok::code_completion) && &II != Ident_super) {
1255 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
1259 if (Tok.
isNot(tok::identifier) &&
1261 Diag(Tok, diag::err_expected_property_name);
1276 if (
getLangOpts().ObjC && &II == Ident_super && !InMessageExpression &&
1278 ((Tok.
is(tok::identifier) &&
1280 Tok.
is(tok::code_completion))) {
1281 Res = ParseObjCMessageExpressionBody(
SourceLocation(), ILoc,
nullptr,
1292 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
1293 Tok.
is(tok::code_completion))) {
1295 if (Tok.
is(tok::code_completion) ||
1296 Next.is(tok::colon) || Next.is(tok::r_square))
1298 if (Typ.get()->isObjCObjectOrInterfaceType()) {
1301 DS.SetRangeStart(ILoc);
1302 DS.SetRangeEnd(ILoc);
1303 const char *PrevSpec =
nullptr;
1305 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
1322 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1323 isAddressOfOperand =
false;
1332 CastExpressionIdValidator Validator(
1336 Validator.IsAddressOfOperand = isAddressOfOperand;
1337 if (Tok.
isOneOf(tok::periodstar, tok::arrowstar)) {
1338 Validator.WantExpressionKeywords =
false;
1339 Validator.WantRemainingKeywords =
false;
1341 Validator.WantRemainingKeywords = Tok.
isNot(tok::r_paren);
1343 Name.setIdentifier(&II, ILoc);
1345 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
1346 isAddressOfOperand, &Validator,
1348 Tok.
is(tok::r_paren) ?
nullptr : &Replacement);
1350 UnconsumeToken(Replacement);
1351 return ParseCastExpression(ParseKind, isAddressOfOperand,
1352 NotCastExpr, isTypeCast,
1354 NotPrimaryExpression);
1356 Res = tryParseCXXPackIndexingExpression(Res);
1358 checkPotentialAngleBracket(Res);
1361 case tok::char_constant:
1362 case tok::wide_char_constant:
1363 case tok::utf8_char_constant:
1364 case tok::utf16_char_constant:
1365 case tok::utf32_char_constant:
1369 case tok::kw___func__:
1370 case tok::kw___FUNCTION__:
1371 case tok::kw___FUNCDNAME__:
1372 case tok::kw___FUNCSIG__:
1373 case tok::kw_L__FUNCTION__:
1374 case tok::kw_L__FUNCSIG__:
1375 case tok::kw___PRETTY_FUNCTION__:
1387 case tok::string_literal:
1388 case tok::wide_string_literal:
1389 case tok::utf8_string_literal:
1390 case tok::utf16_string_literal:
1391 case tok::utf32_string_literal:
1394 case tok::kw__Generic:
1395 Res = ParseGenericSelectionExpression();
1397 case tok::kw___builtin_available:
1398 Res = ParseAvailabilityCheckExpr(Tok.
getLocation());
1400 case tok::kw___builtin_va_arg:
1401 case tok::kw___builtin_offsetof:
1402 case tok::kw___builtin_choose_expr:
1403 case tok::kw___builtin_astype:
1404 case tok::kw___builtin_convertvector:
1405 case tok::kw___builtin_COLUMN:
1406 case tok::kw___builtin_FILE:
1407 case tok::kw___builtin_FILE_NAME:
1408 case tok::kw___builtin_FUNCTION:
1409 case tok::kw___builtin_FUNCSIG:
1410 case tok::kw___builtin_LINE:
1411 case tok::kw___builtin_source_location:
1412 if (NotPrimaryExpression)
1413 *NotPrimaryExpression =
true;
1415 return ParseBuiltinPrimaryExpression();
1416 case tok::kw___null:
1421 case tok::minusminus: {
1422 if (NotPrimaryExpression)
1423 *NotPrimaryExpression =
true;
1428 Token SavedTok = Tok;
1437 UnaryExprOnly : AnyCastExpr,
1444 UnconsumeToken(SavedTok);
1458 if (NotPrimaryExpression)
1459 *NotPrimaryExpression =
true;
1464 Res = ParseCastExpression(AnyCastExpr,
true);
1480 case tok::kw___real:
1481 case tok::kw___imag: {
1482 if (NotPrimaryExpression)
1483 *NotPrimaryExpression =
true;
1486 Res = ParseCastExpression(AnyCastExpr);
1490 isAddressOfOperand);
1497 case tok::kw_co_await: {
1498 if (NotPrimaryExpression)
1499 *NotPrimaryExpression =
true;
1501 Res = ParseCastExpression(AnyCastExpr);
1507 case tok::kw___extension__:{
1509 if (NotPrimaryExpression)
1510 *NotPrimaryExpression =
true;
1513 Res = ParseCastExpression(AnyCastExpr);
1518 case tok::kw__Alignof:
1519 diagnoseUseOfC11Keyword(Tok);
1521 case tok::kw_alignof:
1522 case tok::kw___alignof:
1524 case tok::kw_sizeof:
1528 case tok::kw___datasizeof:
1529 case tok::kw_vec_step:
1531 case tok::kw___builtin_omp_required_simd_align:
1532 case tok::kw___builtin_vectorelements:
1533 if (NotPrimaryExpression)
1534 *NotPrimaryExpression =
true;
1535 AllowSuffix =
false;
1536 Res = ParseUnaryExprOrTypeTraitExpression();
1539 if (NotPrimaryExpression)
1540 *NotPrimaryExpression =
true;
1542 if (Tok.
isNot(tok::identifier))
1543 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1546 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1548 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1553 AllowSuffix =
false;
1556 case tok::kw_const_cast:
1557 case tok::kw_dynamic_cast:
1558 case tok::kw_reinterpret_cast:
1559 case tok::kw_static_cast:
1560 case tok::kw_addrspace_cast:
1561 if (NotPrimaryExpression)
1562 *NotPrimaryExpression =
true;
1563 Res = ParseCXXCasts();
1565 case tok::kw___builtin_bit_cast:
1566 if (NotPrimaryExpression)
1567 *NotPrimaryExpression =
true;
1568 Res = ParseBuiltinBitCast();
1570 case tok::kw_typeid:
1571 if (NotPrimaryExpression)
1572 *NotPrimaryExpression =
true;
1573 Res = ParseCXXTypeid();
1575 case tok::kw___uuidof:
1576 if (NotPrimaryExpression)
1577 *NotPrimaryExpression =
true;
1578 Res = ParseCXXUuidof();
1581 Res = ParseCXXThis();
1583 case tok::kw___builtin_sycl_unique_stable_name:
1584 Res = ParseSYCLUniqueStableNameExpression();
1586 case tok::kw___builtin_sycl_unique_stable_id:
1587 Res = ParseSYCLUniqueStableIdExpression();
1590 case tok::annot_typename:
1591 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1599 const char *PrevSpec =
nullptr;
1602 PrevSpec, DiagID,
Type,
1611 ConsumeAnnotationToken();
1618 case tok::annot_decltype:
1619 case tok::annot_pack_indexing_type:
1621 case tok::kw_wchar_t:
1622 case tok::kw_char8_t:
1623 case tok::kw_char16_t:
1624 case tok::kw_char32_t:
1629 case tok::kw___int64:
1630 case tok::kw___int128:
1631 case tok::kw__ExtInt:
1632 case tok::kw__BitInt:
1633 case tok::kw_signed:
1634 case tok::kw_unsigned:
1637 case tok::kw_double:
1638 case tok::kw___bf16:
1639 case tok::kw__Float16:
1640 case tok::kw___float128:
1641 case tok::kw___ibm128:
1644 case tok::kw_typename:
1645 case tok::kw_typeof:
1646 case tok::kw___vector:
1647 case tok::kw__Accum:
1648 case tok::kw__Fract:
1650 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1651 #include "clang/Basic/OpenCLImageTypes.def"
1652 #define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
1653 #include "clang/Basic/HLSLIntangibleTypes.def"
1656 Diag(Tok, diag::err_expected_expression);
1661 if (NotPrimaryExpression)
1662 *NotPrimaryExpression =
true;
1664 if (SavedKind == tok::kw_typename) {
1681 ParseCXXSimpleTypeSpecifier(DS);
1682 if (Tok.
isNot(tok::l_paren) &&
1684 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1685 << DS.getSourceRange());
1687 if (Tok.
is(tok::l_brace))
1688 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1690 Res = ParseCXXTypeConstructExpression(DS);
1694 case tok::annot_cxxscope: {
1699 if (!Tok.
is(tok::annot_cxxscope))
1700 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1701 isTypeCast, isVectorLiteral,
1702 NotPrimaryExpression);
1705 if (Next.is(tok::annot_template_id)) {
1712 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1716 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1717 isTypeCast, isVectorLiteral,
1718 NotPrimaryExpression);
1723 Res = ParseCXXIdExpression(isAddressOfOperand);
1727 case tok::annot_template_id: {
1735 return ParseCastExpression(ParseKind, isAddressOfOperand,
1736 NotCastExpr, isTypeCast, isVectorLiteral,
1737 NotPrimaryExpression);
1744 case tok::kw_operator:
1745 Res = ParseCXXIdExpression(isAddressOfOperand);
1748 case tok::coloncolon: {
1753 if (!Tok.
is(tok::coloncolon))
1754 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1755 isVectorLiteral, NotPrimaryExpression);
1760 if (Tok.
is(tok::kw_new)) {
1761 if (NotPrimaryExpression)
1762 *NotPrimaryExpression =
true;
1763 Res = ParseCXXNewExpression(
true, CCLoc);
1764 AllowSuffix =
false;
1767 if (Tok.
is(tok::kw_delete)) {
1768 if (NotPrimaryExpression)
1769 *NotPrimaryExpression =
true;
1770 Res = ParseCXXDeleteExpression(
true, CCLoc);
1771 AllowSuffix =
false;
1776 Diag(CCLoc, diag::err_expected_expression);
1781 if (NotPrimaryExpression)
1782 *NotPrimaryExpression =
true;
1783 Res = ParseCXXNewExpression(
false, Tok.
getLocation());
1784 AllowSuffix =
false;
1787 case tok::kw_delete:
1788 if (NotPrimaryExpression)
1789 *NotPrimaryExpression =
true;
1790 Res = ParseCXXDeleteExpression(
false, Tok.
getLocation());
1791 AllowSuffix =
false;
1794 case tok::kw_requires:
1795 Res = ParseRequiresExpression();
1796 AllowSuffix =
false;
1799 case tok::kw_noexcept: {
1800 if (NotPrimaryExpression)
1801 *NotPrimaryExpression =
true;
1802 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1806 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1819 T.getCloseLocation());
1820 AllowSuffix =
false;
1824 #define TYPE_TRAIT(N,Spelling,K) \
1825 case tok::kw_##Spelling:
1826 #include "clang/Basic/TokenKinds.def"
1827 Res = ParseTypeTrait();
1830 case tok::kw___builtin_num_fields:
1831 case tok::kw___builtin_num_bases:
1832 Res = ParseSYCLBuiltinNum();
1834 case tok::kw___builtin_field_type:
1835 case tok::kw___builtin_base_type:
1836 Res = ParseSYCLBuiltinType();
1839 case tok::kw___array_rank:
1840 case tok::kw___array_extent:
1841 if (NotPrimaryExpression)
1842 *NotPrimaryExpression =
true;
1843 Res = ParseArrayTypeTrait();
1846 case tok::kw___builtin_ptrauth_type_discriminator:
1847 return ParseBuiltinPtrauthTypeDiscriminator();
1849 case tok::kw___is_lvalue_expr:
1850 case tok::kw___is_rvalue_expr:
1851 if (NotPrimaryExpression)
1852 *NotPrimaryExpression =
true;
1853 Res = ParseExpressionTrait();
1857 if (NotPrimaryExpression)
1858 *NotPrimaryExpression =
true;
1860 return ParseObjCAtExpression(AtLoc);
1863 Res = ParseBlockLiteralExpression();
1865 case tok::code_completion: {
1871 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
1872 #include "clang/Basic/TransformTypeTraits.def"
1877 Diag(Tok, diag::ext_keyword_as_ident)
1879 goto ParseIdentifier;
1881 goto ExpectedExpression;
1890 Res = TryParseLambdaExpression();
1894 if (NotPrimaryExpression)
1895 *NotPrimaryExpression =
true;
1896 Res = ParseObjCMessageExpression();
1900 Res = ParseLambdaExpression();
1904 Res = ParseObjCMessageExpression();
1918 if (ParseKind == PrimaryExprOnly)
1933 case tok::minusminus:
1951 Diag(Tok.
getLocation(), diag::err_postfix_after_unary_requires_parens)
1959 PreferredType = SavedType;
1960 Res = ParsePostfixExpressionSuffix(Res);
1962 !
getActions().getOpenCLOptions().isAvailableOption(
1964 if (
Expr *PostfixExpr = Res.
get()) {
1965 QualType Ty = PostfixExpr->getType();
1967 Diag(PostfixExpr->getExprLoc(),
1968 diag::err_opencl_taking_function_address_parser);
1980 Tok.
isOneOf(tok::kw___builtin_num_fields, tok::kw___builtin_num_bases));
1981 bool IsNumFields = Tok.
is(tok::kw___builtin_num_fields);
1985 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.
getName()))
2005 Tok.
isOneOf(tok::kw___builtin_field_type, tok::kw___builtin_base_type));
2006 bool IsFieldType = Tok.
is(tok::kw___builtin_field_type);
2010 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.
getName()))
2019 if (ExpectAndConsume(tok::comma))
2055 Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
2059 auto SavedType = PreferredType;
2062 PreferredType = SavedType;
2064 case tok::code_completion:
2065 if (InMessageExpression)
2073 case tok::identifier:
2080 nullptr, LHS.
get());
2088 case tok::l_square: {
2096 isSimpleObjCMessageExpression())
2101 if (CheckProhibitedCXX11Attribute()) {
2107 Loc =
T.getOpenLocation();
2110 ExprVector ArgExprs;
2111 bool HasError =
false;
2118 if ((!
getLangOpts().OpenMP && !AllowOpenACCArraySections) ||
2119 Tok.
isNot(tok::colon)) {
2123 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2124 Idx = ParseBraceInitializer();
2133 ArgExprs.push_back(Idx.
get());
2135 }
else if (Tok.
isNot(tok::r_square)) {
2136 if (ParseExpressionList(ArgExprs)) {
2147 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {
2149 if (Tok.
is(tok::colon)) {
2152 if (Tok.
isNot(tok::r_square))
2155 }
else if (ArgExprs.size() <= 1 &&
getLangOpts().OpenMP) {
2157 if (Tok.
is(tok::colon)) {
2160 if (Tok.
isNot(tok::r_square) &&
2168 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||
2169 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
2170 Tok.
is(tok::colon)) {
2173 if (Tok.
isNot(tok::r_square)) {
2182 if (!LHS.
isInvalid() && !HasError && !Length.isInvalid() &&
2189 if (AllowOpenACCArraySections) {
2191 "Stride/second colon not allowed for OpenACC");
2193 LHS.
get(),
Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
2194 ColonLocFirst, Length.get(), RLoc);
2197 LHS.
get(),
Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
2198 ColonLocFirst, ColonLocSecond, Length.get(), Stride.
get(),
2215 case tok::lesslessless: {
2220 Expr *ExecConfig =
nullptr;
2224 if (OpKind == tok::lesslessless) {
2225 ExprVector ExecConfigExprs;
2228 if (ParseSimpleExpressionList(ExecConfigExprs)) {
2239 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
2240 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
2246 if (ExpectAndConsume(tok::l_paren))
2249 Loc = PrevTokLocation;
2254 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);
2258 ExecConfig = ECResult.
get();
2262 Loc = PT.getOpenLocation();
2265 ExprVector ArgExprs;
2266 auto RunSignatureHelp = [&]() ->
QualType {
2269 LHS.
get(), ArgExprs, PT.getOpenLocation());
2270 CalledSignatureHelp =
true;
2271 return PreferredType;
2273 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
2274 if (Tok.
isNot(tok::r_paren)) {
2275 if (ParseExpressionList(ArgExprs, [&] {
2276 PreferredType.enterFunctionArgument(Tok.
getLocation(),
2288 for (
auto &
E : ArgExprs)
2297 }
else if (Tok.
isNot(tok::r_paren)) {
2298 bool HadDelayedTypo =
false;
2300 HadDelayedTypo =
true;
2301 for (
auto &
E : ArgExprs)
2303 HadDelayedTypo =
true;
2318 ArgExprs.insert(ArgExprs.begin(), Fn);
2336 bool MayBePseudoDestructor =
false;
2339 PreferredType.enterMemAccess(Actions, Tok.
getLocation(), OrigLHS);
2343 const Type* BaseType =
Base->getType().getTypePtrOrNull();
2344 if (BaseType && Tok.
is(tok::l_paren) &&
2347 Diag(OpLoc, diag::err_function_is_not_record)
2348 << OpKind <<
Base->getSourceRange()
2350 return ParsePostfixExpressionSuffix(
Base);
2355 MayBePseudoDestructor);
2360 if (Tok.
is(tok::code_completion)) {
2366 ParseOptionalCXXScopeSpecifier(
2368 false, &MayBePseudoDestructor);
2370 ObjectType =
nullptr;
2373 if (Tok.
is(tok::code_completion)) {
2375 OpKind == tok::arrow ? tok::period : tok::arrow;
2382 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
2383 MayBePseudoDestructor);
2387 Expr *CorrectedBase = CorrectedLHS.get();
2389 CorrectedBase =
Base;
2395 Base && ExprStatementTokLoc ==
Base->getBeginLoc(),
2401 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
2402 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
2416 if (
getLangOpts().ObjC && OpKind == tok::period &&
2417 Tok.
is(tok::kw_class)) {
2427 Name.setIdentifier(
Id,
Loc);
2434 false, &TemplateKWLoc, Name)) {
2441 OpKind, SS, TemplateKWLoc, Name,
2442 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
2445 if (Tok.
is(tok::less))
2446 checkPotentialAngleBracket(LHS);
2447 }
else if (OrigLHS && Name.isValid()) {
2450 Name.getEndLoc(), {OrigLHS});
2455 case tok::minusminus:
2503 Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
2508 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,
2509 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,
2510 tok::kw__Alignof, tok::kw_vec_step,
2511 tok::kw___builtin_omp_required_simd_align,
2512 tok::kw___builtin_vectorelements) &&
2513 "Not a typeof/sizeof/alignof/vec_step expression!");
2518 if (Tok.
isNot(tok::l_paren)) {
2521 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2522 tok::kw_alignof, tok::kw__Alignof)) {
2523 if (isTypeIdUnambiguously()) {
2525 ParseSpecifierQualifierList(DS);
2528 ParseDeclarator(DeclaratorInfo);
2534 diag::err_expected_parentheses_around_typename)
2537 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
2547 if (OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
2558 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2559 tok::kw_alignof, tok::kw__Alignof) &&
2560 Tok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2561 tok::kw_alignof, tok::kw__Alignof))
2563 Operand = ParseCastExpression(UnaryExprOnly);
2566 Operand = ParseCastExpression(UnaryExprOnly);
2572 ParenParseOption ExprType =
CastExpr;
2575 Operand = ParseParenExpression(ExprType,
true,
2576 false, CastTy, RParenLoc);
2587 !OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {
2604 ExprResult Parser::ParseSYCLUniqueStableNameExpression() {
2605 assert(Tok.
is(tok::kw___builtin_sycl_unique_stable_name) &&
2606 "Not __builtin_sycl_unique_stable_name");
2612 if (
T.expectAndConsume(diag::err_expected_lparen_after,
2613 "__builtin_sycl_unique_stable_name"))
2623 if (
T.consumeClose())
2627 OpLoc,
T.getOpenLocation(),
T.getCloseLocation(), Ty.
get());
2632 ExprResult Parser::ParseSYCLUniqueStableIdExpression() {
2633 assert(Tok.
is(tok::kw___builtin_sycl_unique_stable_id) &&
2634 "Not __bulitin_sycl_unique_stable_id");
2639 if (
T.expectAndConsume(diag::err_expected_lparen_after,
2640 "__builtin_sycl_unique_stable_id"))
2654 if (
T.consumeClose())
2658 OpLoc,
T.getOpenLocation(),
T.getCloseLocation(), VarExpr.
get());
2675 ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
2676 assert(Tok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2677 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
2678 tok::kw___builtin_omp_required_simd_align,
2679 tok::kw___builtin_vectorelements) &&
2680 "Not a sizeof/alignof/vec_step expression!");
2685 if (Tok.
is(tok::ellipsis) && OpTok.
is(tok::kw_sizeof)) {
2690 if (Tok.
is(tok::l_paren)) {
2693 LParenLoc =
T.getOpenLocation();
2694 if (Tok.
is(tok::identifier)) {
2698 RParenLoc =
T.getCloseLocation();
2702 Diag(Tok, diag::err_expected_parameter_pack);
2705 }
else if (Tok.
is(tok::identifier)) {
2710 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2715 Diag(Tok, diag::err_sizeof_parameter_pack);
2732 OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2733 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2735 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.
getName();
2751 case tok::kw_alignof:
2752 case tok::kw__Alignof:
2753 ExprKind = UETT_AlignOf;
2755 case tok::kw___alignof:
2756 ExprKind = UETT_PreferredAlignOf;
2758 case tok::kw_vec_step:
2759 ExprKind = UETT_VecStep;
2761 case tok::kw___builtin_omp_required_simd_align:
2762 ExprKind = UETT_OpenMPRequiredSimdAlign;
2764 case tok::kw___datasizeof:
2765 ExprKind = UETT_DataSizeOf;
2767 case tok::kw___builtin_vectorelements:
2768 ExprKind = UETT_VectorElements;
2781 if (OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2817 ExprResult Parser::ParseBuiltinPrimaryExpression() {
2825 if (Tok.
isNot(tok::l_paren))
2826 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2835 default: llvm_unreachable(
"Not a builtin primary expression!");
2836 case tok::kw___builtin_va_arg: {
2839 if (ExpectAndConsume(tok::comma)) {
2846 if (Tok.
isNot(tok::r_paren)) {
2847 Diag(Tok, diag::err_expected) << tok::r_paren;
2857 case tok::kw___builtin_offsetof: {
2859 auto OOK = Sema::OffsetOfKind::OOK_Builtin;
2863 if (MacroName ==
"offsetof")
2864 OOK = Sema::OffsetOfKind::OOK_Macro;
2876 if (ExpectAndConsume(tok::comma)) {
2882 if (Tok.
isNot(tok::identifier)) {
2883 Diag(Tok, diag::err_expected) << tok::identifier;
2892 Comps.back().isBrackets =
false;
2894 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2898 if (Tok.
is(tok::period)) {
2901 Comps.back().isBrackets =
false;
2904 if (Tok.
isNot(tok::identifier)) {
2905 Diag(Tok, diag::err_expected) << tok::identifier;
2911 }
else if (Tok.
is(tok::l_square)) {
2912 if (CheckProhibitedCXX11Attribute())
2917 Comps.back().isBrackets =
true;
2920 Comps.back().LocStart = ST.getOpenLocation();
2926 Comps.back().U.E = Res.
get();
2929 Comps.back().LocEnd = ST.getCloseLocation();
2931 if (Tok.
isNot(tok::r_paren)) {
2940 PT.getCloseLocation());
2947 case tok::kw___builtin_choose_expr: {
2949 if (Cond.isInvalid()) {
2953 if (ExpectAndConsume(tok::comma)) {
2959 if (Expr1.isInvalid()) {
2963 if (ExpectAndConsume(tok::comma)) {
2969 if (Expr2.isInvalid()) {
2973 if (Tok.
isNot(tok::r_paren)) {
2974 Diag(Tok, diag::err_expected) << tok::r_paren;
2978 Expr2.get(), ConsumeParen());
2981 case tok::kw___builtin_astype: {
2984 if (
Expr.isInvalid()) {
2989 if (ExpectAndConsume(tok::comma)) {
3000 if (Tok.
isNot(tok::r_paren)) {
3001 Diag(Tok, diag::err_expected) << tok::r_paren;
3010 case tok::kw___builtin_convertvector: {
3013 if (
Expr.isInvalid()) {
3018 if (ExpectAndConsume(tok::comma)) {
3029 if (Tok.
isNot(tok::r_paren)) {
3030 Diag(Tok, diag::err_expected) << tok::r_paren;
3039 case tok::kw___builtin_COLUMN:
3040 case tok::kw___builtin_FILE:
3041 case tok::kw___builtin_FILE_NAME:
3042 case tok::kw___builtin_FUNCTION:
3043 case tok::kw___builtin_FUNCSIG:
3044 case tok::kw___builtin_LINE:
3045 case tok::kw___builtin_source_location: {
3047 if (Tok.
isNot(tok::r_paren)) {
3048 Diag(Tok, diag::err_expected) << tok::r_paren;
3054 case tok::kw___builtin_FILE:
3056 case tok::kw___builtin_FILE_NAME:
3058 case tok::kw___builtin_FUNCTION:
3060 case tok::kw___builtin_FUNCSIG:
3062 case tok::kw___builtin_LINE:
3064 case tok::kw___builtin_COLUMN:
3066 case tok::kw___builtin_source_location:
3069 llvm_unreachable(
"invalid keyword");
3082 return ParsePostfixExpressionSuffix(Res.
get());
3085 bool Parser::tryParseOpenMPArrayShapingCastPart() {
3086 assert(Tok.
is(tok::l_square) &&
"Expected open bracket");
3087 bool ErrorFound =
true;
3088 TentativeParsingAction TPA(*
this);
3090 if (Tok.
isNot(tok::l_square))
3095 while (!
SkipUntil(tok::r_square, tok::annot_pragma_openmp_end,
3098 if (Tok.
isNot(tok::r_square))
3103 if (Tok.
is(tok::r_paren)) {
3107 }
while (Tok.
isNot(tok::annot_pragma_openmp_end));
3140 Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
3143 assert(Tok.
is(tok::l_paren) &&
"Not a paren expr!");
3146 if (
T.consumeOpen())
3150 PreferredType.enterParenExpr(Tok.
getLocation(), OpenLoc);
3153 bool isAmbiguousTypeId;
3156 if (Tok.
is(tok::code_completion)) {
3160 ExprType >= CompoundLiteral);
3167 tok::kw___bridge_transfer,
3168 tok::kw___bridge_retained,
3169 tok::kw___bridge_retain));
3170 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
3172 StringRef BridgeCastName = Tok.
getName();
3175 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
3185 Diag(Tok, OpenLoc.
isMacroID() ? diag::ext_gnu_statement_expr_macro
3186 : diag::ext_gnu_statement_expr);
3188 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
3191 Result =
ExprError(
Diag(OpenLoc, diag::err_stmtexpr_file_scope));
3197 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
3200 "statement expr not in code context");
3210 if (!
Stmt.isInvalid()) {
3217 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
3223 if (tokenKind == tok::kw___bridge)
3225 else if (tokenKind == tok::kw___bridge_transfer)
3227 else if (tokenKind == tok::kw___bridge_retained)
3232 assert(tokenKind == tok::kw___bridge_retain);
3235 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
3237 "__bridge_retained");
3242 ColonProtection.restore();
3243 RParenLoc =
T.getCloseLocation();
3246 ExprResult SubExpr = ParseCastExpression(AnyCastExpr);
3252 BridgeKeywordLoc, Ty.
get(),
3253 RParenLoc, SubExpr.
get());
3254 }
else if (ExprType >= CompoundLiteral &&
3255 isTypeIdInParens(isAmbiguousTypeId)) {
3264 if (isAmbiguousTypeId && !stopIfCastExpr) {
3265 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy,
T,
3267 RParenLoc =
T.getCloseLocation();
3273 ParseSpecifierQualifierList(DS);
3276 ParseDeclarator(DeclaratorInfo);
3281 if (!DeclaratorInfo.isInvalidType() && Tok.
is(tok::identifier) &&
3295 ColonProtection.restore();
3296 RParenLoc =
T.getCloseLocation();
3297 if (Tok.
is(tok::l_brace)) {
3298 ExprType = CompoundLiteral;
3304 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
3307 if (Tok.
is(tok::l_paren)) {
3328 Result = ParseCastExpression(AnyCastExpr,
3333 if (!Result.isInvalid()) {
3335 DeclaratorInfo, CastTy,
3336 RParenLoc, Result.get());
3340 if (!Result.isInvalid()) {
3341 Result = ParsePostfixExpressionSuffix(Result);
3352 if (DeclaratorInfo.isInvalidType())
3357 if (stopIfCastExpr) {
3371 GetLookAheadToken(1).isNot(tok::period)) {
3380 Result = ParseCastExpression(AnyCastExpr,
3383 if (!Result.isInvalid()) {
3385 DeclaratorInfo, CastTy,
3386 RParenLoc, Result.get());
3391 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
3394 }
else if (ExprType >= FoldExpr && Tok.
is(tok::ellipsis) &&
3396 ExprType = FoldExpr;
3398 }
else if (isTypeCast) {
3401 ExprVector ArgExprs;
3403 if (!ParseSimpleExpressionList(ArgExprs)) {
3406 if (ExprType >= FoldExpr && ArgExprs.size() == 1 &&
3408 ExprType = FoldExpr;
3409 return ParseFoldExpression(ArgExprs[0],
T);
3412 ExprType = SimpleExpr;
3416 }
else if (
getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&
3417 ExprType ==
CastExpr && Tok.
is(tok::l_square) &&
3418 tryParseOpenMPArrayShapingCastPart()) {
3419 bool ErrorFound =
false;
3429 while (!
SkipUntil(tok::r_square, tok::r_paren,
3434 OMPDimensions.push_back(NumElements.
get());
3435 OMPBracketsRanges.push_back(TS.getRange());
3436 }
while (Tok.
isNot(tok::r_paren));
3439 RParenLoc =
T.getCloseLocation();
3443 }
else if (!Result.isInvalid()) {
3445 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);
3458 if (ExprType >= FoldExpr && isFoldOperator(Tok.
getKind()) &&
3460 ExprType = FoldExpr;
3461 return ParseFoldExpression(Result,
T);
3463 ExprType = SimpleExpr;
3466 if (!Result.isInvalid() && Tok.
is(tok::r_paren))
3472 if (Result.isInvalid()) {
3478 RParenLoc =
T.getCloseLocation();
3491 Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
3494 assert(Tok.
is(tok::l_brace) &&
"Not a compound literal!");
3496 Diag(LParenLoc, diag::ext_c99_compound_literal);
3499 if (!Result.isInvalid() && Ty)
3525 "Not a string-literal-like token!");
3533 StringToks.push_back(Tok);
3538 assert(!AllowUserDefinedLiteral &&
"UDL are always evaluated");
3567 ExprResult Parser::ParseGenericSelectionExpression() {
3568 assert(Tok.
is(tok::kw__Generic) &&
"_Generic keyword expected");
3570 diagnoseUseOfC11Keyword(Tok);
3574 if (
T.expectAndConsume())
3581 if (isTypeIdForGenericSelection()) {
3587 const auto *LIT = cast<LocInfoType>(ControllingType.
get().get());
3590 : diag::ext_c2y_generic_with_type_arg);
3604 if (ExpectAndConsume(tok::comma)) {
3614 if (Tok.
is(tok::kw_default)) {
3618 Diag(Tok, diag::err_duplicate_default_assoc);
3619 Diag(DefaultLoc, diag::note_previous_default_assoc);
3634 Types.push_back(Ty);
3636 if (ExpectAndConsume(tok::colon)) {
3645 if (ER.isInvalid()) {
3649 Exprs.push_back(ER.get());
3653 if (
T.getCloseLocation().isInvalid())
3656 void *ExprOrTy = ControllingExpr.
isUsable()
3657 ? ControllingExpr.
get()
3658 : ControllingType.
get().getAsOpaquePtr();
3661 KeyLoc, DefaultLoc,
T.getCloseLocation(), ControllingExpr.
isUsable(),
3662 ExprOrTy, Types, Exprs);
3684 assert(isFoldOperator(
Kind) &&
"missing fold-operator");
3688 assert(Tok.
is(tok::ellipsis) &&
"not a fold-expression");
3692 if (Tok.
isNot(tok::r_paren)) {
3693 if (!isFoldOperator(Tok.
getKind()))
3710 ? diag::warn_cxx14_compat_fold_expression
3711 : diag::ext_fold_expression);
3716 T.getCloseLocation());
3719 void Parser::injectEmbedTokens() {
3723 Data->BinaryData.size() * 2 - 1),
3724 Data->BinaryData.size() * 2 - 1);
3726 for (
auto &Byte :
Data->BinaryData) {
3727 Toks[I].startToken();
3728 Toks[I].setKind(tok::binary_data);
3730 Toks[I].setLength(1);
3731 Toks[I].setLiteralData(&Byte);
3732 if (I != ((
Data->BinaryData.size() - 1) * 2)) {
3733 Toks[I + 1].startToken();
3734 Toks[I + 1].setKind(tok::comma);
3739 PP.EnterTokenStream(std::move(Toks),
true,
3767 llvm::function_ref<
void()> ExpressionStarts,
3768 bool FailImmediatelyOnInvalidExpr,
3769 bool EarlyTypoCorrection) {
3770 bool SawError =
false;
3772 if (ExpressionStarts)
3777 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3778 Expr = ParseBraceInitializer();
3782 if (EarlyTypoCorrection)
3785 if (Tok.
is(tok::ellipsis))
3787 else if (Tok.
is(tok::code_completion)) {
3797 if (
Expr.isInvalid()) {
3799 if (FailImmediatelyOnInvalidExpr)
3803 Exprs.push_back(
Expr.get());
3806 if (Tok.
isNot(tok::comma))
3811 checkPotentialAngleBracketDelimiter(Comma);
3816 for (
auto &
E : Exprs) {
3835 if (
Expr.isInvalid())
3838 Exprs.push_back(
Expr.get());
3848 checkPotentialAngleBracketDelimiter(Comma);
3859 if (Tok.
is(tok::code_completion)) {
3868 ParseSpecifierQualifierList(DS);
3874 ParseDeclarator(DeclaratorInfo);
3876 MaybeParseGNUAttributes(DeclaratorInfo);
3892 ExprResult Parser::ParseBlockLiteralExpression() {
3893 assert(Tok.
is(tok::caret) &&
"block literal starts with ^");
3897 "block literal parsing");
3920 if (Tok.
is(tok::l_paren)) {
3921 ParseParenDeclarator(ParamInfo);
3926 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
3927 ParamInfo.SetRangeEnd(Tmp);
3928 if (ParamInfo.isInvalidType()) {
3936 MaybeParseGNUAttributes(ParamInfo);
3940 }
else if (!Tok.
is(tok::l_brace)) {
3941 ParseBlockId(CaretLoc);
3945 ParamInfo.AddTypeInfo(
3963 CaretLoc, CaretLoc, ParamInfo),
3966 MaybeParseGNUAttributes(ParamInfo);
3974 if (!Tok.
is(tok::l_brace)) {
3976 Diag(Tok, diag::err_expected_expression);
3983 if (!
Stmt.isInvalid())
4003 llvm::SmallSet<StringRef, 4> Platforms;
4004 bool HasOtherPlatformSpec =
false;
4006 for (
const auto &Spec : AvailSpecs) {
4007 if (Spec.isOtherPlatformSpec()) {
4008 if (HasOtherPlatformSpec) {
4009 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
4013 HasOtherPlatformSpec =
true;
4017 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
4022 StringRef Platform = Spec.getPlatform();
4023 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
4024 << Spec.getEndLoc() << Platform;
4029 if (!HasOtherPlatformSpec) {
4030 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
4031 P.Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
4044 std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() {
4045 if (Tok.
is(tok::star)) {
4049 if (Tok.
is(tok::code_completion)) {
4052 return std::nullopt;
4054 if (Tok.
isNot(tok::identifier)) {
4055 Diag(Tok, diag::err_avail_query_expected_platform_name);
4056 return std::nullopt;
4061 VersionTuple Version = ParseVersionTuple(VersionRange);
4063 if (Version.empty())
4064 return std::nullopt;
4066 StringRef GivenPlatform = PlatformIdentifier->
Ident->
getName();
4067 StringRef Platform =
4068 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
4070 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||
4071 (GivenPlatform.contains(
"xros") || GivenPlatform.contains(
"xrOS"))) {
4073 diag::err_avail_query_unrecognized_platform_name)
4075 return std::nullopt;
4084 assert(Tok.
is(tok::kw___builtin_available) ||
4091 if (
Parens.expectAndConsume())
4095 bool HasError =
false;
4097 std::optional<AvailabilitySpec> Spec = ParseAvailabilitySpec();
4101 AvailSpecs.push_back(*Spec);
4114 if (
Parens.consumeClose())
4118 AvailSpecs, BeginLoc,
Parens.getCloseLocation());
Defines the clang::ASTContext interface.
enum clang::sema::@1659::IndirectLocalPathEntry::EntryKind Kind
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...
bool isFileContext() const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
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)
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
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.
Scope * getCurScope() const
Sema & getActions() const
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)
const LangOptions & getLangOpts() 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)
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)
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
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.
llvm::BumpPtrAllocator & getPreprocessorAllocator()
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 ActOnSYCLBuiltinFieldTypeExpr(ParsedType PT, Expr *Idx)
Get a value based on the type of the given field number so that callers can wrap it in a decltype() t...
ExprResult ActOnUniqueStableIdExpr(SourceLocation OpLoc, SourceLocation LParen, SourceLocation RParen, Expr *E)
ExprResult ActOnSYCLBuiltinNumBasesExpr(ParsedType PT)
Get the number of base classes within the parsed type.
ExprResult ActOnSYCLBuiltinNumFieldsExpr(ParsedType PT)
Get the number of fields or captures within the parsed type.
ExprResult ActOnSYCLBuiltinBaseTypeExpr(ParsedType PT, Expr *Idx)
Get a value based on the type of the given base number so that callers can wrap it in a decltype() to...
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.
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
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.
ASTContext & getASTContext() const
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...
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
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)
SemaCodeCompletion & CodeCompletion()
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.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void * getAnnotationValue() const
void setKind(tok::TokenKind K)
const char * getName() const
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)) {....
tok::TokenKind getKind() const
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
IdentifierInfo * getIdentifierInfo() const
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.
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.
ActionResult< Stmt * > StmtResult
@ 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.