42#include "llvm/ADT/SmallVector.h"
136 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
147 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
154Parser::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)) {
213Parser::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);
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());
406bool 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();
417bool Parser::isFoldOperator(
prec::Level Level)
const {
431 GreaterThanIsOperator,
435 auto SavedType = PreferredType;
438 PreferredType = SavedType;
442 if (NextTokPrec < MinPrec)
451 if (OpToken.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
452 tok::greatergreatergreater) &&
453 checkPotentialAngleBracketDelimiter(OpToken))
461 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
469 if (isFoldOperator(NextTokPrec) && Tok.
is(tok::ellipsis)) {
483 Tok.
isOneOf(tok::colon, tok::r_square) &&
496 TernaryMiddle = ParseBraceInitializer();
497 if (!TernaryMiddle.isInvalid()) {
498 Diag(BraceLoc, diag::err_init_list_bin_op)
503 }
else if (Tok.
isNot(tok::colon)) {
515 TernaryMiddle =
nullptr;
516 Diag(Tok, diag::ext_gnu_conditional_expr);
519 if (TernaryMiddle.isInvalid()) {
522 TernaryMiddle =
nullptr;
531 const char *FIText =
": ";
535 bool IsInvalid =
false;
536 const char *SourcePtr =
538 if (!IsInvalid && *SourcePtr ==
' ') {
541 if (!IsInvalid && *SourcePtr ==
' ') {
548 Diag(Tok, diag::err_expected)
550 Diag(OpToken, diag::note_matching) << tok::question;
568 bool RHSIsInitList =
false;
570 RHS = ParseBraceInitializer();
571 RHSIsInitList =
true;
575 RHS = ParseCastExpression(AnyCastExpr);
581 if (TernaryMiddle.isUsable())
598 if (ThisPrec < NextTokPrec ||
599 (ThisPrec == NextTokPrec && isRightAssoc)) {
601 Diag(Tok, diag::err_init_list_bin_op)
610 RHS = ParseRHSOfBinaryExpression(RHS,
611 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
612 RHSIsInitList =
false;
618 if (TernaryMiddle.isUsable())
629 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
631 }
else if (ColonLoc.
isValid()) {
632 Diag(ColonLoc, diag::err_init_list_bin_op)
637 Diag(OpToken, diag::err_init_list_bin_op)
647 if (TernaryMiddle.isInvalid()) {
651 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
653 diag::warn_cxx11_right_shift_in_template_arg,
663 {LHS.get(), RHS.get()});
671 std::vector<clang::Expr *> Args;
673 if (TernaryMiddle.get())
674 Args = {LHS.
get(), TernaryMiddle.get(), RHS.
get()};
676 Args = {LHS.
get(), RHS.
get()};
704ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
705 bool isAddressOfOperand,
706 TypeCastState isTypeCast,
707 bool isVectorLiteral,
708 bool *NotPrimaryExpression) {
710 ExprResult Res = ParseCastExpression(ParseKind,
715 NotPrimaryExpression);
717 Diag(Tok, diag::err_expected_expression);
724 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
725 : NextToken(Next), AllowNonTypes(AllowNonTypes) {
726 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
729 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
734 if (isa<TypeDecl>(ND))
735 return WantTypeSpecifiers;
740 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
743 for (
auto *
C : candidate) {
745 if (isa<ValueDecl>(ND) && !isa<FunctionDecl>(ND))
751 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
752 return std::make_unique<CastExpressionIdValidator>(*
this);
763 if (RevertibleTypeTraits.empty()) {
767#define RTT_JOIN(X, Y) X##Y
768#define REVERTIBLE_TYPE_TRAIT(Name) \
769 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
827#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
828 REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
829#include "clang/Basic/TransformTypeTraits.def"
830#undef REVERTIBLE_TYPE_TRAIT
833 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known =
834 RevertibleTypeTraits.find(II);
835 if (Known != RevertibleTypeTraits.end()) {
837 *
Kind = Known->second;
843ExprResult Parser::ParseBuiltinPtrauthTypeDiscriminator() {
847 if (
T.expectAndConsume())
859 Loc, UETT_PtrAuthTypeDiscriminator,
1046ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
1047 bool isAddressOfOperand,
1049 TypeCastState isTypeCast,
1050 bool isVectorLiteral,
1051 bool *NotPrimaryExpression) {
1054 auto SavedType = PreferredType;
1055 NotCastExpr =
false;
1060 bool AllowSuffix =
true;
1072 switch (SavedKind) {
1073 case tok::l_paren: {
1076 ParenParseOption ParenExprType;
1077 switch (ParseKind) {
1078 case CastParseKind::UnaryExprOnly:
1081 case CastParseKind::AnyCastExpr:
1082 ParenExprType = ParenParseOption::CastExpr;
1084 case CastParseKind::PrimaryExprOnly:
1085 ParenExprType = FoldExpr;
1090 Res = ParseParenExpression(ParenExprType,
false,
1091 isTypeCast ==
IsTypeCast, CastTy, RParenLoc);
1096 if (isVectorLiteral)
1099 switch (ParenExprType) {
1100 case SimpleExpr:
break;
1102 case CompoundLiteral:
1120 case tok::numeric_constant:
1121 case tok::binary_data:
1131 Res = ParseCXXBoolLiteral();
1134 case tok::kw___objc_yes:
1135 case tok::kw___objc_no:
1136 Res = ParseObjCBoolLiteral();
1139 case tok::kw_nullptr:
1141 Diag(Tok, diag::warn_cxx98_compat_nullptr);
1144 : diag::ext_c_nullptr) << Tok.
getName();
1149 case tok::annot_primary_expr:
1150 case tok::annot_overload_set:
1151 Res = getExprAnnotation(Tok);
1154 ConsumeAnnotationToken();
1156 checkPotentialAngleBracket(Res);
1159 case tok::annot_non_type:
1160 case tok::annot_non_type_dependent:
1161 case tok::annot_non_type_undeclared: {
1164 Res = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
1166 "should not perform typo correction on annotation token");
1170 case tok::annot_embed: {
1171 injectEmbedTokens();
1172 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1173 isVectorLiteral, NotPrimaryExpression);
1176 case tok::kw___super:
1177 case tok::kw_decltype:
1181 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
1182 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1183 isVectorLiteral, NotPrimaryExpression);
1185 case tok::identifier:
1196 if (Next.is(tok::ellipsis) && Tok.
is(tok::identifier) &&
1197 GetLookAheadToken(2).is(tok::l_square)) {
1202 Tok.
isOneOf(tok::annot_pack_indexing_type, tok::annot_cxxscope))
1203 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1204 isVectorLiteral, NotPrimaryExpression);
1210 else if (Next.is(tok::l_paren) && Tok.
is(tok::identifier) &&
1214 if (isRevertibleTypeTrait(II, &Kind)) {
1216 return ParseCastExpression(ParseKind, isAddressOfOperand,
1217 NotCastExpr, isTypeCast,
1218 isVectorLiteral, NotPrimaryExpression);
1222 else if ((!ColonIsSacred && Next.is(tok::colon)) ||
1223 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
1228 if (!Tok.
is(tok::identifier))
1229 return ParseCastExpression(ParseKind, isAddressOfOperand,
1230 NotCastExpr, isTypeCast,
1232 NotPrimaryExpression);
1245 (&II == Ident_super &&
getCurScope()->isInObjcMethodScope()))) {
1248 if (Tok.
is(tok::code_completion) && &II != Ident_super) {
1251 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
1255 if (Tok.
isNot(tok::identifier) &&
1257 Diag(Tok, diag::err_expected_property_name);
1272 if (
getLangOpts().
ObjC && &II == Ident_super && !InMessageExpression &&
1274 ((Tok.
is(tok::identifier) &&
1276 Tok.
is(tok::code_completion))) {
1277 Res = ParseObjCMessageExpressionBody(
SourceLocation(), ILoc,
nullptr,
1288 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
1289 Tok.
is(tok::code_completion))) {
1291 if (Tok.
is(tok::code_completion) ||
1292 Next.is(tok::colon) || Next.is(tok::r_square))
1294 if (Typ.get()->isObjCObjectOrInterfaceType()) {
1297 DS.SetRangeStart(ILoc);
1298 DS.SetRangeEnd(ILoc);
1299 const char *PrevSpec =
nullptr;
1301 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
1318 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1319 isAddressOfOperand =
false;
1328 CastExpressionIdValidator Validator(
1332 Validator.IsAddressOfOperand = isAddressOfOperand;
1333 if (Tok.
isOneOf(tok::periodstar, tok::arrowstar)) {
1334 Validator.WantExpressionKeywords =
false;
1335 Validator.WantRemainingKeywords =
false;
1337 Validator.WantRemainingKeywords = Tok.
isNot(tok::r_paren);
1339 Name.setIdentifier(&II, ILoc);
1341 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
1342 isAddressOfOperand, &Validator,
1344 Tok.
is(tok::r_paren) ?
nullptr : &Replacement);
1346 UnconsumeToken(Replacement);
1347 return ParseCastExpression(ParseKind, isAddressOfOperand,
1348 NotCastExpr, isTypeCast,
1350 NotPrimaryExpression);
1352 Res = tryParseCXXPackIndexingExpression(Res);
1354 checkPotentialAngleBracket(Res);
1357 case tok::char_constant:
1358 case tok::wide_char_constant:
1359 case tok::utf8_char_constant:
1360 case tok::utf16_char_constant:
1361 case tok::utf32_char_constant:
1365 case tok::kw___func__:
1366 case tok::kw___FUNCTION__:
1367 case tok::kw___FUNCDNAME__:
1368 case tok::kw___FUNCSIG__:
1369 case tok::kw_L__FUNCTION__:
1370 case tok::kw_L__FUNCSIG__:
1371 case tok::kw___PRETTY_FUNCTION__:
1383 case tok::string_literal:
1384 case tok::wide_string_literal:
1385 case tok::utf8_string_literal:
1386 case tok::utf16_string_literal:
1387 case tok::utf32_string_literal:
1390 case tok::kw__Generic:
1391 Res = ParseGenericSelectionExpression();
1393 case tok::kw___builtin_available:
1394 Res = ParseAvailabilityCheckExpr(Tok.
getLocation());
1396 case tok::kw___builtin_va_arg:
1397 case tok::kw___builtin_offsetof:
1398 case tok::kw___builtin_choose_expr:
1399 case tok::kw___builtin_astype:
1400 case tok::kw___builtin_convertvector:
1401 case tok::kw___builtin_COLUMN:
1402 case tok::kw___builtin_FILE:
1403 case tok::kw___builtin_FILE_NAME:
1404 case tok::kw___builtin_FUNCTION:
1405 case tok::kw___builtin_FUNCSIG:
1406 case tok::kw___builtin_LINE:
1407 case tok::kw___builtin_source_location:
1408 if (NotPrimaryExpression)
1409 *NotPrimaryExpression =
true;
1411 return ParseBuiltinPrimaryExpression();
1412 case tok::kw___null:
1417 case tok::minusminus: {
1418 if (NotPrimaryExpression)
1419 *NotPrimaryExpression =
true;
1424 Token SavedTok = Tok;
1433 UnaryExprOnly : AnyCastExpr,
1440 UnconsumeToken(SavedTok);
1454 if (NotPrimaryExpression)
1455 *NotPrimaryExpression =
true;
1460 Res = ParseCastExpression(AnyCastExpr,
true);
1476 case tok::kw___real:
1477 case tok::kw___imag: {
1478 if (NotPrimaryExpression)
1479 *NotPrimaryExpression =
true;
1482 Res = ParseCastExpression(AnyCastExpr);
1486 isAddressOfOperand);
1493 case tok::kw_co_await: {
1494 if (NotPrimaryExpression)
1495 *NotPrimaryExpression =
true;
1497 Res = ParseCastExpression(AnyCastExpr);
1503 case tok::kw___extension__:{
1505 if (NotPrimaryExpression)
1506 *NotPrimaryExpression =
true;
1509 Res = ParseCastExpression(AnyCastExpr);
1514 case tok::kw__Alignof:
1515 diagnoseUseOfC11Keyword(Tok);
1517 case tok::kw_alignof:
1518 case tok::kw___alignof:
1520 case tok::kw_sizeof:
1524 case tok::kw___datasizeof:
1525 case tok::kw_vec_step:
1527 case tok::kw___builtin_omp_required_simd_align:
1528 case tok::kw___builtin_vectorelements:
1529 if (NotPrimaryExpression)
1530 *NotPrimaryExpression =
true;
1531 AllowSuffix =
false;
1532 Res = ParseUnaryExprOrTypeTraitExpression();
1535 if (NotPrimaryExpression)
1536 *NotPrimaryExpression =
true;
1538 if (Tok.
isNot(tok::identifier))
1539 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1542 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1544 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1549 AllowSuffix =
false;
1552 case tok::kw_const_cast:
1553 case tok::kw_dynamic_cast:
1554 case tok::kw_reinterpret_cast:
1555 case tok::kw_static_cast:
1556 case tok::kw_addrspace_cast:
1557 if (NotPrimaryExpression)
1558 *NotPrimaryExpression =
true;
1559 Res = ParseCXXCasts();
1561 case tok::kw___builtin_bit_cast:
1562 if (NotPrimaryExpression)
1563 *NotPrimaryExpression =
true;
1564 Res = ParseBuiltinBitCast();
1566 case tok::kw_typeid:
1567 if (NotPrimaryExpression)
1568 *NotPrimaryExpression =
true;
1569 Res = ParseCXXTypeid();
1571 case tok::kw___uuidof:
1572 if (NotPrimaryExpression)
1573 *NotPrimaryExpression =
true;
1574 Res = ParseCXXUuidof();
1577 Res = ParseCXXThis();
1579 case tok::kw___builtin_sycl_unique_stable_name:
1580 Res = ParseSYCLUniqueStableNameExpression();
1583 case tok::annot_typename:
1584 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1592 const char *PrevSpec =
nullptr;
1595 PrevSpec, DiagID,
Type,
1604 ConsumeAnnotationToken();
1611 case tok::annot_decltype:
1612 case tok::annot_pack_indexing_type:
1614 case tok::kw_wchar_t:
1615 case tok::kw_char8_t:
1616 case tok::kw_char16_t:
1617 case tok::kw_char32_t:
1622 case tok::kw___int64:
1623 case tok::kw___int128:
1624 case tok::kw__ExtInt:
1625 case tok::kw__BitInt:
1626 case tok::kw_signed:
1627 case tok::kw_unsigned:
1630 case tok::kw_double:
1631 case tok::kw___bf16:
1632 case tok::kw__Float16:
1633 case tok::kw___float128:
1634 case tok::kw___ibm128:
1637 case tok::kw_typename:
1638 case tok::kw_typeof:
1639 case tok::kw___vector:
1640 case tok::kw__Accum:
1641 case tok::kw__Fract:
1643#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1644#include "clang/Basic/OpenCLImageTypes.def"
1645#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
1646#include "clang/Basic/HLSLIntangibleTypes.def"
1649 Diag(Tok, diag::err_expected_expression);
1654 if (NotPrimaryExpression)
1655 *NotPrimaryExpression =
true;
1657 if (SavedKind == tok::kw_typename) {
1674 ParseCXXSimpleTypeSpecifier(DS);
1675 if (Tok.
isNot(tok::l_paren) &&
1677 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1678 << DS.getSourceRange());
1680 if (Tok.
is(tok::l_brace))
1681 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1683 Res = ParseCXXTypeConstructExpression(DS);
1687 case tok::annot_cxxscope: {
1692 if (!Tok.
is(tok::annot_cxxscope))
1693 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1694 isTypeCast, isVectorLiteral,
1695 NotPrimaryExpression);
1698 if (Next.is(tok::annot_template_id)) {
1705 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1709 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1710 isTypeCast, isVectorLiteral,
1711 NotPrimaryExpression);
1716 Res = ParseCXXIdExpression(isAddressOfOperand);
1720 case tok::annot_template_id: {
1728 return ParseCastExpression(ParseKind, isAddressOfOperand,
1729 NotCastExpr, isTypeCast, isVectorLiteral,
1730 NotPrimaryExpression);
1737 case tok::kw_operator:
1738 Res = ParseCXXIdExpression(isAddressOfOperand);
1741 case tok::coloncolon: {
1746 if (!Tok.
is(tok::coloncolon))
1747 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1748 isVectorLiteral, NotPrimaryExpression);
1753 if (Tok.
is(tok::kw_new)) {
1754 if (NotPrimaryExpression)
1755 *NotPrimaryExpression =
true;
1756 Res = ParseCXXNewExpression(
true, CCLoc);
1757 AllowSuffix =
false;
1760 if (Tok.
is(tok::kw_delete)) {
1761 if (NotPrimaryExpression)
1762 *NotPrimaryExpression =
true;
1763 Res = ParseCXXDeleteExpression(
true, CCLoc);
1764 AllowSuffix =
false;
1769 Diag(CCLoc, diag::err_expected_expression);
1774 if (NotPrimaryExpression)
1775 *NotPrimaryExpression =
true;
1776 Res = ParseCXXNewExpression(
false, Tok.
getLocation());
1777 AllowSuffix =
false;
1780 case tok::kw_delete:
1781 if (NotPrimaryExpression)
1782 *NotPrimaryExpression =
true;
1783 Res = ParseCXXDeleteExpression(
false, Tok.
getLocation());
1784 AllowSuffix =
false;
1787 case tok::kw_requires:
1788 Res = ParseRequiresExpression();
1789 AllowSuffix =
false;
1792 case tok::kw_noexcept: {
1793 if (NotPrimaryExpression)
1794 *NotPrimaryExpression =
true;
1795 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1799 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1812 T.getCloseLocation());
1813 AllowSuffix =
false;
1817#define TYPE_TRAIT(N,Spelling,K) \
1818 case tok::kw_##Spelling:
1819#include "clang/Basic/TokenKinds.def"
1820 Res = ParseTypeTrait();
1823 case tok::kw___array_rank:
1824 case tok::kw___array_extent:
1825 if (NotPrimaryExpression)
1826 *NotPrimaryExpression =
true;
1827 Res = ParseArrayTypeTrait();
1830 case tok::kw___builtin_ptrauth_type_discriminator:
1831 return ParseBuiltinPtrauthTypeDiscriminator();
1833 case tok::kw___is_lvalue_expr:
1834 case tok::kw___is_rvalue_expr:
1835 if (NotPrimaryExpression)
1836 *NotPrimaryExpression =
true;
1837 Res = ParseExpressionTrait();
1841 if (NotPrimaryExpression)
1842 *NotPrimaryExpression =
true;
1844 return ParseObjCAtExpression(AtLoc);
1847 Res = ParseBlockLiteralExpression();
1849 case tok::code_completion: {
1855#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
1856#include "clang/Basic/TransformTypeTraits.def"
1861 Diag(Tok, diag::ext_keyword_as_ident)
1863 goto ParseIdentifier;
1865 goto ExpectedExpression;
1874 Res = TryParseLambdaExpression();
1878 if (NotPrimaryExpression)
1879 *NotPrimaryExpression =
true;
1880 Res = ParseObjCMessageExpression();
1884 Res = ParseLambdaExpression();
1888 Res = ParseObjCMessageExpression();
1902 if (ParseKind == PrimaryExprOnly)
1917 case tok::minusminus:
1935 Diag(Tok.
getLocation(), diag::err_postfix_after_unary_requires_parens)
1943 PreferredType = SavedType;
1944 Res = ParsePostfixExpressionSuffix(Res);
1946 !
getActions().getOpenCLOptions().isAvailableOption(
1948 if (
Expr *PostfixExpr = Res.
get()) {
1949 QualType Ty = PostfixExpr->getType();
1951 Diag(PostfixExpr->getExprLoc(),
1952 diag::err_opencl_taking_function_address_parser);
1982Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1986 auto SavedType = PreferredType;
1989 PreferredType = SavedType;
1991 case tok::code_completion:
1992 if (InMessageExpression)
2000 case tok::identifier:
2007 nullptr, LHS.
get());
2015 case tok::l_square: {
2023 isSimpleObjCMessageExpression())
2028 if (CheckProhibitedCXX11Attribute()) {
2034 Loc =
T.getOpenLocation();
2037 ExprVector ArgExprs;
2038 bool HasError =
false;
2045 if ((!
getLangOpts().OpenMP && !AllowOpenACCArraySections) ||
2046 Tok.
isNot(tok::colon)) {
2050 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2051 Idx = ParseBraceInitializer();
2060 ArgExprs.push_back(Idx.
get());
2062 }
else if (Tok.
isNot(tok::r_square)) {
2063 if (ParseExpressionList(ArgExprs)) {
2074 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {
2076 if (Tok.
is(tok::colon)) {
2079 if (Tok.
isNot(tok::r_square))
2082 }
else if (ArgExprs.size() <= 1 &&
getLangOpts().OpenMP) {
2084 if (Tok.
is(tok::colon)) {
2087 if (Tok.
isNot(tok::r_square) &&
2095 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||
2096 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
2097 Tok.
is(tok::colon)) {
2100 if (Tok.
isNot(tok::r_square)) {
2109 if (!LHS.
isInvalid() && !HasError && !Length.isInvalid() &&
2116 if (AllowOpenACCArraySections) {
2118 "Stride/second colon not allowed for OpenACC");
2120 LHS.
get(),
Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
2121 ColonLocFirst, Length.get(), RLoc);
2124 LHS.
get(),
Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
2125 ColonLocFirst, ColonLocSecond, Length.get(), Stride.
get(),
2142 case tok::lesslessless: {
2147 Expr *ExecConfig =
nullptr;
2151 if (OpKind == tok::lesslessless) {
2152 ExprVector ExecConfigExprs;
2155 if (ParseSimpleExpressionList(ExecConfigExprs)) {
2166 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
2167 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
2173 if (ExpectAndConsume(tok::l_paren))
2176 Loc = PrevTokLocation;
2181 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);
2185 ExecConfig = ECResult.
get();
2189 Loc = PT.getOpenLocation();
2192 ExprVector ArgExprs;
2193 auto RunSignatureHelp = [&]() ->
QualType {
2196 LHS.
get(), ArgExprs, PT.getOpenLocation());
2197 CalledSignatureHelp =
true;
2198 return PreferredType;
2200 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
2201 if (Tok.
isNot(tok::r_paren)) {
2202 bool HasTrailingComma =
false;
2203 bool HasError = ParseExpressionList(
2206 PreferredType.enterFunctionArgument(Tok.
getLocation(),
2210 false, &HasTrailingComma);
2212 if (HasError && !HasTrailingComma) {
2222 for (
auto &
E : ArgExprs)
2231 }
else if (Tok.
isNot(tok::r_paren)) {
2232 bool HadDelayedTypo =
false;
2234 HadDelayedTypo =
true;
2235 for (
auto &
E : ArgExprs)
2237 HadDelayedTypo =
true;
2252 ArgExprs.insert(ArgExprs.begin(), Fn);
2270 bool MayBePseudoDestructor =
false;
2273 PreferredType.enterMemAccess(Actions, Tok.
getLocation(), OrigLHS);
2277 const Type* BaseType =
Base->getType().getTypePtrOrNull();
2278 if (BaseType && Tok.
is(tok::l_paren) &&
2281 Diag(OpLoc, diag::err_function_is_not_record)
2282 << OpKind <<
Base->getSourceRange()
2284 return ParsePostfixExpressionSuffix(
Base);
2289 MayBePseudoDestructor);
2294 if (Tok.
is(tok::code_completion)) {
2300 ParseOptionalCXXScopeSpecifier(
2302 false, &MayBePseudoDestructor);
2304 ObjectType =
nullptr;
2307 if (Tok.
is(tok::code_completion)) {
2309 OpKind == tok::arrow ? tok::period : tok::arrow;
2316 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
2317 MayBePseudoDestructor);
2321 Expr *CorrectedBase = CorrectedLHS.get();
2323 CorrectedBase =
Base;
2329 Base && ExprStatementTokLoc ==
Base->getBeginLoc(),
2335 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
2336 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
2351 Tok.
is(tok::kw_class)) {
2361 Name.setIdentifier(
Id,
Loc);
2368 false, &TemplateKWLoc, Name)) {
2375 OpKind, SS, TemplateKWLoc, Name,
2376 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
2379 if (Tok.
is(tok::less))
2380 checkPotentialAngleBracket(LHS);
2381 }
else if (OrigLHS && Name.isValid()) {
2384 Name.getEndLoc(), {OrigLHS});
2389 case tok::minusminus:
2437Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
2442 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,
2443 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,
2444 tok::kw__Alignof, tok::kw_vec_step,
2445 tok::kw___builtin_omp_required_simd_align,
2446 tok::kw___builtin_vectorelements) &&
2447 "Not a typeof/sizeof/alignof/vec_step expression!");
2452 if (Tok.
isNot(tok::l_paren)) {
2455 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2456 tok::kw_alignof, tok::kw__Alignof)) {
2457 if (isTypeIdUnambiguously()) {
2459 ParseSpecifierQualifierList(DS);
2462 ParseDeclarator(DeclaratorInfo);
2468 diag::err_expected_parentheses_around_typename)
2471 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
2481 if (OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
2492 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2493 tok::kw_alignof, tok::kw__Alignof) &&
2494 Tok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2495 tok::kw_alignof, tok::kw__Alignof))
2497 Operand = ParseCastExpression(UnaryExprOnly);
2500 Operand = ParseCastExpression(UnaryExprOnly);
2506 ParenParseOption ExprType =
CastExpr;
2509 Operand = ParseParenExpression(ExprType,
true,
2510 false, CastTy, RParenLoc);
2521 !OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {
2538ExprResult Parser::ParseSYCLUniqueStableNameExpression() {
2539 assert(Tok.
is(tok::kw___builtin_sycl_unique_stable_name) &&
2540 "Not __builtin_sycl_unique_stable_name");
2546 if (
T.expectAndConsume(diag::err_expected_lparen_after,
2547 "__builtin_sycl_unique_stable_name"))
2557 if (
T.consumeClose())
2561 OpLoc,
T.getOpenLocation(),
T.getCloseLocation(), Ty.
get());
2578ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
2579 assert(Tok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2580 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
2581 tok::kw___builtin_omp_required_simd_align,
2582 tok::kw___builtin_vectorelements) &&
2583 "Not a sizeof/alignof/vec_step expression!");
2588 if (Tok.
is(tok::ellipsis) && OpTok.
is(tok::kw_sizeof)) {
2593 if (Tok.
is(tok::l_paren)) {
2596 LParenLoc =
T.getOpenLocation();
2597 if (Tok.
is(tok::identifier)) {
2601 RParenLoc =
T.getCloseLocation();
2605 Diag(Tok, diag::err_expected_parameter_pack);
2608 }
else if (Tok.
is(tok::identifier)) {
2613 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2618 Diag(Tok, diag::err_sizeof_parameter_pack);
2635 OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2636 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2638 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.
getName();
2654 case tok::kw_alignof:
2655 case tok::kw__Alignof:
2656 ExprKind = UETT_AlignOf;
2658 case tok::kw___alignof:
2659 ExprKind = UETT_PreferredAlignOf;
2661 case tok::kw_vec_step:
2662 ExprKind = UETT_VecStep;
2664 case tok::kw___builtin_omp_required_simd_align:
2665 ExprKind = UETT_OpenMPRequiredSimdAlign;
2667 case tok::kw___datasizeof:
2668 ExprKind = UETT_DataSizeOf;
2670 case tok::kw___builtin_vectorelements:
2671 ExprKind = UETT_VectorElements;
2684 if (OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2720ExprResult Parser::ParseBuiltinPrimaryExpression() {
2728 if (Tok.
isNot(tok::l_paren))
2729 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2738 default: llvm_unreachable(
"Not a builtin primary expression!");
2739 case tok::kw___builtin_va_arg: {
2742 if (ExpectAndConsume(tok::comma)) {
2749 if (Tok.
isNot(tok::r_paren)) {
2750 Diag(Tok, diag::err_expected) << tok::r_paren;
2760 case tok::kw___builtin_offsetof: {
2766 if (MacroName ==
"offsetof")
2779 if (ExpectAndConsume(tok::comma)) {
2785 if (Tok.
isNot(tok::identifier)) {
2786 Diag(Tok, diag::err_expected) << tok::identifier;
2795 Comps.back().isBrackets =
false;
2797 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2801 if (Tok.
is(tok::period)) {
2804 Comps.back().isBrackets =
false;
2807 if (Tok.
isNot(tok::identifier)) {
2808 Diag(Tok, diag::err_expected) << tok::identifier;
2814 }
else if (Tok.
is(tok::l_square)) {
2815 if (CheckProhibitedCXX11Attribute())
2820 Comps.back().isBrackets =
true;
2823 Comps.back().LocStart = ST.getOpenLocation();
2829 Comps.back().U.E = Res.
get();
2832 Comps.back().LocEnd = ST.getCloseLocation();
2834 if (Tok.
isNot(tok::r_paren)) {
2843 PT.getCloseLocation());
2850 case tok::kw___builtin_choose_expr: {
2852 if (Cond.isInvalid()) {
2856 if (ExpectAndConsume(tok::comma)) {
2862 if (Expr1.isInvalid()) {
2866 if (ExpectAndConsume(tok::comma)) {
2872 if (Expr2.isInvalid()) {
2876 if (Tok.
isNot(tok::r_paren)) {
2877 Diag(Tok, diag::err_expected) << tok::r_paren;
2881 Expr2.get(), ConsumeParen());
2884 case tok::kw___builtin_astype: {
2887 if (
Expr.isInvalid()) {
2892 if (ExpectAndConsume(tok::comma)) {
2903 if (Tok.
isNot(tok::r_paren)) {
2904 Diag(Tok, diag::err_expected) << tok::r_paren;
2913 case tok::kw___builtin_convertvector: {
2916 if (
Expr.isInvalid()) {
2921 if (ExpectAndConsume(tok::comma)) {
2932 if (Tok.
isNot(tok::r_paren)) {
2933 Diag(Tok, diag::err_expected) << tok::r_paren;
2942 case tok::kw___builtin_COLUMN:
2943 case tok::kw___builtin_FILE:
2944 case tok::kw___builtin_FILE_NAME:
2945 case tok::kw___builtin_FUNCTION:
2946 case tok::kw___builtin_FUNCSIG:
2947 case tok::kw___builtin_LINE:
2948 case tok::kw___builtin_source_location: {
2950 if (Tok.
isNot(tok::r_paren)) {
2951 Diag(Tok, diag::err_expected) << tok::r_paren;
2957 case tok::kw___builtin_FILE:
2959 case tok::kw___builtin_FILE_NAME:
2961 case tok::kw___builtin_FUNCTION:
2963 case tok::kw___builtin_FUNCSIG:
2965 case tok::kw___builtin_LINE:
2967 case tok::kw___builtin_COLUMN:
2969 case tok::kw___builtin_source_location:
2972 llvm_unreachable(
"invalid keyword");
2985 return ParsePostfixExpressionSuffix(Res.
get());
2988bool Parser::tryParseOpenMPArrayShapingCastPart() {
2989 assert(Tok.
is(tok::l_square) &&
"Expected open bracket");
2990 bool ErrorFound =
true;
2991 TentativeParsingAction TPA(*
this);
2993 if (Tok.
isNot(tok::l_square))
2998 while (!
SkipUntil(tok::r_square, tok::annot_pragma_openmp_end,
3001 if (Tok.
isNot(tok::r_square))
3006 if (Tok.
is(tok::r_paren)) {
3010 }
while (Tok.
isNot(tok::annot_pragma_openmp_end));
3043Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
3046 assert(Tok.
is(tok::l_paren) &&
"Not a paren expr!");
3049 if (
T.consumeOpen())
3053 PreferredType.enterParenExpr(Tok.
getLocation(), OpenLoc);
3056 bool isAmbiguousTypeId;
3059 if (Tok.
is(tok::code_completion)) {
3063 ExprType >= CompoundLiteral);
3070 tok::kw___bridge_transfer,
3071 tok::kw___bridge_retained,
3072 tok::kw___bridge_retain));
3073 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
3075 StringRef BridgeCastName = Tok.
getName();
3078 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
3088 Diag(Tok, OpenLoc.
isMacroID() ? diag::ext_gnu_statement_expr_macro
3089 : diag::ext_gnu_statement_expr);
3091 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
3100 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
3103 "statement expr not in code context");
3113 if (!
Stmt.isInvalid()) {
3120 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
3126 if (tokenKind == tok::kw___bridge)
3128 else if (tokenKind == tok::kw___bridge_transfer)
3130 else if (tokenKind == tok::kw___bridge_retained)
3135 assert(tokenKind == tok::kw___bridge_retain);
3138 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
3140 "__bridge_retained");
3145 ColonProtection.restore();
3146 RParenLoc =
T.getCloseLocation();
3149 ExprResult SubExpr = ParseCastExpression(AnyCastExpr);
3155 BridgeKeywordLoc, Ty.
get(),
3156 RParenLoc, SubExpr.
get());
3157 }
else if (ExprType >= CompoundLiteral &&
3158 isTypeIdInParens(isAmbiguousTypeId)) {
3167 if (isAmbiguousTypeId && !stopIfCastExpr) {
3168 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy,
T,
3170 RParenLoc =
T.getCloseLocation();
3176 ParseSpecifierQualifierList(DS);
3179 ParseDeclarator(DeclaratorInfo);
3184 if (!DeclaratorInfo.isInvalidType() && Tok.
is(tok::identifier) &&
3198 ColonProtection.restore();
3199 RParenLoc =
T.getCloseLocation();
3200 if (Tok.
is(tok::l_brace)) {
3201 ExprType = CompoundLiteral;
3207 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
3210 if (Tok.
is(tok::l_paren)) {
3231 Result = ParseCastExpression(AnyCastExpr,
3236 if (!
Result.isInvalid()) {
3238 DeclaratorInfo, CastTy,
3239 RParenLoc,
Result.get());
3243 if (!
Result.isInvalid()) {
3255 if (DeclaratorInfo.isInvalidType())
3260 if (stopIfCastExpr) {
3274 GetLookAheadToken(1).isNot(tok::period)) {
3283 Result = ParseCastExpression(AnyCastExpr,
3286 if (!
Result.isInvalid()) {
3288 DeclaratorInfo, CastTy,
3289 RParenLoc,
Result.get());
3294 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
3297 }
else if (ExprType >= FoldExpr && Tok.
is(tok::ellipsis) &&
3299 ExprType = FoldExpr;
3301 }
else if (isTypeCast) {
3304 ExprVector ArgExprs;
3306 if (!ParseSimpleExpressionList(ArgExprs)) {
3309 if (ExprType >= FoldExpr && ArgExprs.size() == 1 &&
3311 ExprType = FoldExpr;
3312 return ParseFoldExpression(ArgExprs[0],
T);
3315 ExprType = SimpleExpr;
3319 }
else if (
getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&
3320 ExprType ==
CastExpr && Tok.
is(tok::l_square) &&
3321 tryParseOpenMPArrayShapingCastPart()) {
3322 bool ErrorFound =
false;
3332 while (!
SkipUntil(tok::r_square, tok::r_paren,
3337 OMPDimensions.push_back(NumElements.
get());
3338 OMPBracketsRanges.push_back(TS.getRange());
3339 }
while (Tok.
isNot(tok::r_paren));
3342 RParenLoc =
T.getCloseLocation();
3346 }
else if (!
Result.isInvalid()) {
3348 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);
3361 if (ExprType >= FoldExpr && isFoldOperator(Tok.
getKind()) &&
3363 ExprType = FoldExpr;
3364 return ParseFoldExpression(
Result,
T);
3366 ExprType = SimpleExpr;
3369 if (!
Result.isInvalid() && Tok.
is(tok::r_paren))
3375 if (
Result.isInvalid()) {
3381 RParenLoc =
T.getCloseLocation();
3394Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
3397 assert(Tok.
is(tok::l_brace) &&
"Not a compound literal!");
3399 Diag(LParenLoc, diag::ext_c99_compound_literal);
3402 if (!
Result.isInvalid() && Ty)
3428 "Not a string-literal-like token!");
3436 StringToks.push_back(Tok);
3441 assert(!AllowUserDefinedLiteral &&
"UDL are always evaluated");
3470ExprResult Parser::ParseGenericSelectionExpression() {
3471 assert(Tok.
is(tok::kw__Generic) &&
"_Generic keyword expected");
3473 diagnoseUseOfC11Keyword(Tok);
3477 if (
T.expectAndConsume())
3484 if (isTypeIdForGenericSelection()) {
3490 const auto *LIT = cast<LocInfoType>(ControllingType.
get().get());
3493 : diag::ext_c2y_generic_with_type_arg);
3507 if (ExpectAndConsume(tok::comma)) {
3517 if (Tok.
is(tok::kw_default)) {
3521 Diag(Tok, diag::err_duplicate_default_assoc);
3522 Diag(DefaultLoc, diag::note_previous_default_assoc);
3537 Types.push_back(Ty);
3539 if (ExpectAndConsume(tok::colon)) {
3548 if (ER.isInvalid()) {
3552 Exprs.push_back(ER.get());
3556 if (
T.getCloseLocation().isInvalid())
3559 void *ExprOrTy = ControllingExpr.
isUsable()
3560 ? ControllingExpr.
get()
3561 : ControllingType.
get().getAsOpaquePtr();
3564 KeyLoc, DefaultLoc,
T.getCloseLocation(), ControllingExpr.
isUsable(),
3565 ExprOrTy, Types, Exprs);
3587 assert(isFoldOperator(Kind) &&
"missing fold-operator");
3591 assert(Tok.
is(tok::ellipsis) &&
"not a fold-expression");
3595 if (Tok.
isNot(tok::r_paren)) {
3596 if (!isFoldOperator(Tok.
getKind()))
3599 if (Kind != tok::unknown && Tok.
getKind() != Kind)
3613 ? diag::warn_cxx14_compat_fold_expression
3614 : diag::ext_fold_expression);
3618 Kind, EllipsisLoc, RHS.
get(),
3619 T.getCloseLocation());
3622void Parser::injectEmbedTokens() {
3626 Data->BinaryData.size() * 2 - 1),
3627 Data->BinaryData.size() * 2 - 1);
3629 for (
auto &Byte :
Data->BinaryData) {
3630 Toks[I].startToken();
3631 Toks[I].setKind(tok::binary_data);
3633 Toks[I].setLength(1);
3634 Toks[I].setLiteralData(&Byte);
3635 if (I != ((
Data->BinaryData.size() - 1) * 2)) {
3636 Toks[I + 1].startToken();
3637 Toks[I + 1].setKind(tok::comma);
3642 PP.EnterTokenStream(std::move(Toks),
true,
3670 llvm::function_ref<
void()> ExpressionStarts,
3671 bool FailImmediatelyOnInvalidExpr,
3672 bool EarlyTypoCorrection,
3673 bool *HasTrailingComma) {
3674 bool SawError =
false;
3676 if (ExpressionStarts)
3681 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3682 Expr = ParseBraceInitializer();
3686 if (EarlyTypoCorrection)
3689 if (Tok.
is(tok::ellipsis))
3691 else if (Tok.
is(tok::code_completion)) {
3701 if (
Expr.isInvalid()) {
3703 if (FailImmediatelyOnInvalidExpr)
3707 Exprs.push_back(
Expr.get());
3710 if (Tok.
isNot(tok::comma))
3715 checkPotentialAngleBracketDelimiter(Comma);
3717 if (Tok.
is(tok::r_paren)) {
3718 if (HasTrailingComma)
3719 *HasTrailingComma =
true;
3726 for (
auto &
E : Exprs) {
3745 if (
Expr.isInvalid())
3748 Exprs.push_back(
Expr.get());
3758 checkPotentialAngleBracketDelimiter(Comma);
3769 if (Tok.
is(tok::code_completion)) {
3778 ParseSpecifierQualifierList(DS);
3784 ParseDeclarator(DeclaratorInfo);
3786 MaybeParseGNUAttributes(DeclaratorInfo);
3802ExprResult Parser::ParseBlockLiteralExpression() {
3803 assert(Tok.
is(tok::caret) &&
"block literal starts with ^");
3807 "block literal parsing");
3830 if (Tok.
is(tok::l_paren)) {
3831 ParseParenDeclarator(ParamInfo);
3836 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
3837 ParamInfo.SetRangeEnd(Tmp);
3838 if (ParamInfo.isInvalidType()) {
3846 MaybeParseGNUAttributes(ParamInfo);
3850 }
else if (!Tok.
is(tok::l_brace)) {
3851 ParseBlockId(CaretLoc);
3855 ParamInfo.AddTypeInfo(
3873 CaretLoc, ParamInfo),
3876 MaybeParseGNUAttributes(ParamInfo);
3884 if (!Tok.
is(tok::l_brace)) {
3886 Diag(Tok, diag::err_expected_expression);
3893 if (!
Stmt.isInvalid())
3913 llvm::SmallSet<StringRef, 4> Platforms;
3914 bool HasOtherPlatformSpec =
false;
3916 for (
const auto &Spec : AvailSpecs) {
3917 if (Spec.isOtherPlatformSpec()) {
3918 if (HasOtherPlatformSpec) {
3919 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3923 HasOtherPlatformSpec =
true;
3927 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3932 StringRef Platform = Spec.getPlatform();
3933 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3934 << Spec.getEndLoc() << Platform;
3939 if (!HasOtherPlatformSpec) {
3940 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3941 P.Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3954std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() {
3955 if (Tok.
is(tok::star)) {
3959 if (Tok.
is(tok::code_completion)) {
3962 return std::nullopt;
3964 if (Tok.
isNot(tok::identifier)) {
3965 Diag(Tok, diag::err_avail_query_expected_platform_name);
3966 return std::nullopt;
3971 VersionTuple Version = ParseVersionTuple(VersionRange);
3973 if (Version.empty())
3974 return std::nullopt;
3976 StringRef GivenPlatform = PlatformIdentifier->
Ident->
getName();
3977 StringRef Platform =
3978 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3980 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||
3981 (GivenPlatform.contains(
"xros") || GivenPlatform.contains(
"xrOS"))) {
3983 diag::err_avail_query_unrecognized_platform_name)
3985 return std::nullopt;
3994 assert(Tok.
is(tok::kw___builtin_available) ||
4001 if (
Parens.expectAndConsume())
4005 bool HasError =
false;
4007 std::optional<AvailabilitySpec> Spec = ParseAvailabilitySpec();
4011 AvailSpecs.push_back(*Spec);
4024 if (
Parens.consumeClose())
4028 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...
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)
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.