40#include "llvm/ADT/SmallVector.h"
134 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
145 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
152Parser::ParseExpressionWithLeadingExtension(
SourceLocation ExtLoc) {
158 LHS = ParseCastExpression(AnyCastExpr);
161 if (!LHS.isInvalid())
165 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
170 if (Tok.
is(tok::code_completion)) {
177 if (Tok.
is(tok::kw_throw))
178 return ParseThrowExpression();
179 if (Tok.
is(tok::kw_co_yield))
180 return ParseCoyieldExpression();
182 ExprResult LHS = ParseCastExpression(AnyCastExpr,
189 if (Tok.
is(tok::code_completion)) {
211Parser::ParseAssignmentExprWithObjCMessageExprStart(
SourceLocation LBracLoc,
214 Expr *ReceiverExpr) {
216 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
217 ReceiverType, ReceiverExpr);
218 R = ParsePostfixExpressionSuffix(R);
226 "Call this function only if your ExpressionEvaluationContext is "
227 "already ConstantEvaluated");
228 ExprResult LHS(ParseCastExpression(AnyCastExpr,
false, isTypeCast));
248 Actions.
ExprEvalContexts.back().InConditionallyConstantEvaluateContext =
true;
269 ExprResult LHS(ParseCastExpression(AnyCastExpr));
291 bool NotPrimaryExpression =
false;
292 auto ParsePrimary = [&] () {
293 ExprResult E = ParseCastExpression(PrimaryExprOnly,
297 &NotPrimaryExpression);
301 E = ParsePostfixExpressionSuffix(
E);
308 ? diag::note_unparenthesized_non_primary_expr_in_requires_clause
309 : diag::err_unparenthesized_non_primary_expr_in_requires_clause)
317 if (NotPrimaryExpression ||
324 Tok.
isOneOf(tok::period, tok::plusplus, tok::minusminus) ||
325 (Tok.
is(tok::l_square) && !
NextToken().is(tok::l_square))) {
326 E = RecoverFromNonPrimary(
E,
false);
329 NotPrimaryExpression =
false;
331 bool PossibleNonPrimary;
332 bool IsConstraintExpr =
334 IsTrailingRequiresClause);
335 if (!IsConstraintExpr || PossibleNonPrimary) {
340 if (PossibleNonPrimary)
341 E = RecoverFromNonPrimary(
E, !IsConstraintExpr);
350 while (Tok.
is(tok::ampamp)) {
358 tok::ampamp, LHS.
get(), RHS.
get());
384 while (Tok.
is(tok::pipepipe)) {
393 tok::pipepipe, LHS.
get(), RHS.
get());
404bool Parser::isNotExpressionStart() {
406 if (K == tok::l_brace || K == tok::r_brace ||
407 K == tok::kw_for || K == tok::kw_while ||
408 K == tok::kw_if || K == tok::kw_else ||
409 K == tok::kw_goto || K == tok::kw_try)
412 return isKnownToBeDeclarationSpecifier();
415bool Parser::isFoldOperator(
prec::Level Level)
const {
429 GreaterThanIsOperator,
433 auto SavedType = PreferredType;
436 PreferredType = SavedType;
440 if (NextTokPrec < MinPrec)
447 if (OpToken.
is(tok::caretcaret)) {
448 return ExprError(
Diag(Tok, diag::err_opencl_logical_exclusive_or));
453 if (OpToken.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
454 tok::greatergreatergreater) &&
455 checkPotentialAngleBracketDelimiter(OpToken))
463 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
471 if (isFoldOperator(NextTokPrec) && Tok.
is(tok::ellipsis)) {
485 Tok.
isOneOf(tok::colon, tok::r_square) &&
498 TernaryMiddle = ParseBraceInitializer();
499 if (!TernaryMiddle.isInvalid()) {
500 Diag(BraceLoc, diag::err_init_list_bin_op)
505 }
else if (Tok.
isNot(tok::colon)) {
517 TernaryMiddle =
nullptr;
518 Diag(Tok, diag::ext_gnu_conditional_expr);
521 if (TernaryMiddle.isInvalid()) {
524 TernaryMiddle =
nullptr;
533 const char *FIText =
": ";
537 bool IsInvalid =
false;
538 const char *SourcePtr =
540 if (!IsInvalid && *SourcePtr ==
' ') {
543 if (!IsInvalid && *SourcePtr ==
' ') {
550 Diag(Tok, diag::err_expected)
552 Diag(OpToken, diag::note_matching) << tok::question;
570 bool RHSIsInitList =
false;
572 RHS = ParseBraceInitializer();
573 RHSIsInitList =
true;
577 RHS = ParseCastExpression(AnyCastExpr);
583 if (TernaryMiddle.isUsable())
600 if (ThisPrec < NextTokPrec ||
601 (ThisPrec == NextTokPrec && isRightAssoc)) {
603 Diag(Tok, diag::err_init_list_bin_op)
612 RHS = ParseRHSOfBinaryExpression(RHS,
613 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
614 RHSIsInitList =
false;
620 if (TernaryMiddle.isUsable())
631 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
633 }
else if (ColonLoc.
isValid()) {
634 Diag(ColonLoc, diag::err_init_list_bin_op)
639 Diag(OpToken, diag::err_init_list_bin_op)
649 if (TernaryMiddle.isInvalid()) {
653 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
655 diag::warn_cxx11_right_shift_in_template_arg,
665 {LHS.get(), RHS.get()});
673 std::vector<clang::Expr *> Args;
675 if (TernaryMiddle.get())
676 Args = {LHS.
get(), TernaryMiddle.get(), RHS.
get()};
678 Args = {LHS.
get(), RHS.
get()};
706ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
707 bool isAddressOfOperand,
708 TypeCastState isTypeCast,
709 bool isVectorLiteral,
710 bool *NotPrimaryExpression) {
712 ExprResult Res = ParseCastExpression(ParseKind,
717 NotPrimaryExpression);
719 Diag(Tok, diag::err_expected_expression);
726 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
727 : NextToken(Next), AllowNonTypes(AllowNonTypes) {
728 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
731 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
736 if (isa<TypeDecl>(ND))
737 return WantTypeSpecifiers;
742 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
745 for (
auto *
C : candidate) {
747 if (isa<ValueDecl>(ND) && !isa<FunctionDecl>(ND))
753 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
754 return std::make_unique<CastExpressionIdValidator>(*
this);
765 if (RevertibleTypeTraits.empty()) {
769#define RTT_JOIN(X, Y) X##Y
770#define REVERTIBLE_TYPE_TRAIT(Name) \
771 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
829#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
830 REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
831#include "clang/Basic/TransformTypeTraits.def"
832#undef REVERTIBLE_TYPE_TRAIT
835 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known =
836 RevertibleTypeTraits.find(II);
837 if (Known != RevertibleTypeTraits.end()) {
839 *
Kind = Known->second;
845ExprResult Parser::ParseBuiltinPtrauthTypeDiscriminator() {
849 if (
T.expectAndConsume())
861 Loc, UETT_PtrAuthTypeDiscriminator,
1048ExprResult Parser::ParseCastExpression(CastParseKind ParseKind,
1049 bool isAddressOfOperand,
1051 TypeCastState isTypeCast,
1052 bool isVectorLiteral,
1053 bool *NotPrimaryExpression) {
1056 auto SavedType = PreferredType;
1057 NotCastExpr =
false;
1062 bool AllowSuffix =
true;
1074 switch (SavedKind) {
1075 case tok::l_paren: {
1078 ParenParseOption ParenExprType;
1079 switch (ParseKind) {
1080 case CastParseKind::UnaryExprOnly:
1083 case CastParseKind::AnyCastExpr:
1084 ParenExprType = ParenParseOption::CastExpr;
1086 case CastParseKind::PrimaryExprOnly:
1087 ParenExprType = FoldExpr;
1092 Res = ParseParenExpression(ParenExprType,
false,
1093 isTypeCast ==
IsTypeCast, CastTy, RParenLoc);
1098 if (isVectorLiteral)
1101 switch (ParenExprType) {
1102 case SimpleExpr:
break;
1104 case CompoundLiteral:
1122 case tok::numeric_constant:
1123 case tok::binary_data:
1133 Res = ParseCXXBoolLiteral();
1136 case tok::kw___objc_yes:
1137 case tok::kw___objc_no:
1138 Res = ParseObjCBoolLiteral();
1141 case tok::kw_nullptr:
1143 Diag(Tok, diag::warn_cxx98_compat_nullptr);
1146 : diag::ext_c_nullptr) << Tok.
getName();
1151 case tok::annot_primary_expr:
1152 case tok::annot_overload_set:
1153 Res = getExprAnnotation(Tok);
1156 ConsumeAnnotationToken();
1158 checkPotentialAngleBracket(Res);
1161 case tok::annot_non_type:
1162 case tok::annot_non_type_dependent:
1163 case tok::annot_non_type_undeclared: {
1166 Res = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
1168 "should not perform typo correction on annotation token");
1172 case tok::annot_embed: {
1173 injectEmbedTokens();
1174 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1175 isVectorLiteral, NotPrimaryExpression);
1178 case tok::kw___super:
1179 case tok::kw_decltype:
1183 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
1184 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1185 isVectorLiteral, NotPrimaryExpression);
1187 case tok::identifier:
1198 if (Next.is(tok::ellipsis) && Tok.
is(tok::identifier) &&
1199 GetLookAheadToken(2).is(tok::l_square)) {
1204 Tok.
is(tok::annot_pack_indexing_type))
1205 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1206 isVectorLiteral, NotPrimaryExpression);
1212 else if (Next.is(tok::l_paren) && Tok.
is(tok::identifier) &&
1216 if (isRevertibleTypeTrait(II, &Kind)) {
1218 return ParseCastExpression(ParseKind, isAddressOfOperand,
1219 NotCastExpr, isTypeCast,
1220 isVectorLiteral, NotPrimaryExpression);
1224 else if ((!ColonIsSacred && Next.is(tok::colon)) ||
1225 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
1230 if (!Tok.
is(tok::identifier))
1231 return ParseCastExpression(ParseKind, isAddressOfOperand,
1232 NotCastExpr, isTypeCast,
1234 NotPrimaryExpression);
1247 (&II == Ident_super &&
getCurScope()->isInObjcMethodScope()))) {
1250 if (Tok.
is(tok::code_completion) && &II != Ident_super) {
1253 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
1257 if (Tok.
isNot(tok::identifier) &&
1259 Diag(Tok, diag::err_expected_property_name);
1274 if (
getLangOpts().
ObjC && &II == Ident_super && !InMessageExpression &&
1276 ((Tok.
is(tok::identifier) &&
1278 Tok.
is(tok::code_completion))) {
1279 Res = ParseObjCMessageExpressionBody(
SourceLocation(), ILoc,
nullptr,
1290 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
1291 Tok.
is(tok::code_completion))) {
1293 if (Tok.
is(tok::code_completion) ||
1294 Next.is(tok::colon) || Next.is(tok::r_square))
1296 if (Typ.get()->isObjCObjectOrInterfaceType()) {
1299 DS.SetRangeStart(ILoc);
1300 DS.SetRangeEnd(ILoc);
1301 const char *PrevSpec =
nullptr;
1303 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
1320 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1321 isAddressOfOperand =
false;
1330 CastExpressionIdValidator Validator(
1334 Validator.IsAddressOfOperand = isAddressOfOperand;
1335 if (Tok.
isOneOf(tok::periodstar, tok::arrowstar)) {
1336 Validator.WantExpressionKeywords =
false;
1337 Validator.WantRemainingKeywords =
false;
1339 Validator.WantRemainingKeywords = Tok.
isNot(tok::r_paren);
1341 Name.setIdentifier(&II, ILoc);
1343 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
1344 isAddressOfOperand, &Validator,
1346 Tok.
is(tok::r_paren) ?
nullptr : &Replacement);
1348 UnconsumeToken(Replacement);
1349 return ParseCastExpression(ParseKind, isAddressOfOperand,
1350 NotCastExpr, isTypeCast,
1352 NotPrimaryExpression);
1354 Res = tryParseCXXPackIndexingExpression(Res);
1356 checkPotentialAngleBracket(Res);
1359 case tok::char_constant:
1360 case tok::wide_char_constant:
1361 case tok::utf8_char_constant:
1362 case tok::utf16_char_constant:
1363 case tok::utf32_char_constant:
1367 case tok::kw___func__:
1368 case tok::kw___FUNCTION__:
1369 case tok::kw___FUNCDNAME__:
1370 case tok::kw___FUNCSIG__:
1371 case tok::kw_L__FUNCTION__:
1372 case tok::kw_L__FUNCSIG__:
1373 case tok::kw___PRETTY_FUNCTION__:
1385 case tok::string_literal:
1386 case tok::wide_string_literal:
1387 case tok::utf8_string_literal:
1388 case tok::utf16_string_literal:
1389 case tok::utf32_string_literal:
1392 case tok::kw__Generic:
1393 Res = ParseGenericSelectionExpression();
1395 case tok::kw___builtin_available:
1396 Res = ParseAvailabilityCheckExpr(Tok.
getLocation());
1398 case tok::kw___builtin_va_arg:
1399 case tok::kw___builtin_offsetof:
1400 case tok::kw___builtin_choose_expr:
1401 case tok::kw___builtin_astype:
1402 case tok::kw___builtin_convertvector:
1403 case tok::kw___builtin_COLUMN:
1404 case tok::kw___builtin_FILE:
1405 case tok::kw___builtin_FILE_NAME:
1406 case tok::kw___builtin_FUNCTION:
1407 case tok::kw___builtin_FUNCSIG:
1408 case tok::kw___builtin_LINE:
1409 case tok::kw___builtin_source_location:
1410 if (NotPrimaryExpression)
1411 *NotPrimaryExpression =
true;
1413 return ParseBuiltinPrimaryExpression();
1414 case tok::kw___null:
1419 case tok::minusminus: {
1420 if (NotPrimaryExpression)
1421 *NotPrimaryExpression =
true;
1426 Token SavedTok = Tok;
1435 UnaryExprOnly : AnyCastExpr,
1442 UnconsumeToken(SavedTok);
1456 if (NotPrimaryExpression)
1457 *NotPrimaryExpression =
true;
1462 Res = ParseCastExpression(AnyCastExpr,
true);
1478 case tok::kw___real:
1479 case tok::kw___imag: {
1480 if (NotPrimaryExpression)
1481 *NotPrimaryExpression =
true;
1484 Res = ParseCastExpression(AnyCastExpr);
1488 isAddressOfOperand);
1495 case tok::kw_co_await: {
1496 if (NotPrimaryExpression)
1497 *NotPrimaryExpression =
true;
1499 Res = ParseCastExpression(AnyCastExpr);
1505 case tok::kw___extension__:{
1507 if (NotPrimaryExpression)
1508 *NotPrimaryExpression =
true;
1511 Res = ParseCastExpression(AnyCastExpr);
1516 case tok::kw__Alignof:
1517 diagnoseUseOfC11Keyword(Tok);
1519 case tok::kw_alignof:
1520 case tok::kw___alignof:
1522 case tok::kw_sizeof:
1526 case tok::kw___datasizeof:
1527 case tok::kw_vec_step:
1529 case tok::kw___builtin_omp_required_simd_align:
1530 case tok::kw___builtin_vectorelements:
1531 if (NotPrimaryExpression)
1532 *NotPrimaryExpression =
true;
1533 AllowSuffix =
false;
1534 Res = ParseUnaryExprOrTypeTraitExpression();
1537 if (NotPrimaryExpression)
1538 *NotPrimaryExpression =
true;
1540 if (Tok.
isNot(tok::identifier))
1541 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1544 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1546 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1551 AllowSuffix =
false;
1554 case tok::kw_const_cast:
1555 case tok::kw_dynamic_cast:
1556 case tok::kw_reinterpret_cast:
1557 case tok::kw_static_cast:
1558 case tok::kw_addrspace_cast:
1559 if (NotPrimaryExpression)
1560 *NotPrimaryExpression =
true;
1561 Res = ParseCXXCasts();
1563 case tok::kw___builtin_bit_cast:
1564 if (NotPrimaryExpression)
1565 *NotPrimaryExpression =
true;
1566 Res = ParseBuiltinBitCast();
1568 case tok::kw_typeid:
1569 if (NotPrimaryExpression)
1570 *NotPrimaryExpression =
true;
1571 Res = ParseCXXTypeid();
1573 case tok::kw___uuidof:
1574 if (NotPrimaryExpression)
1575 *NotPrimaryExpression =
true;
1576 Res = ParseCXXUuidof();
1579 Res = ParseCXXThis();
1581 case tok::kw___builtin_sycl_unique_stable_name:
1582 Res = ParseSYCLUniqueStableNameExpression();
1585 case tok::annot_typename:
1586 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1594 const char *PrevSpec =
nullptr;
1597 PrevSpec, DiagID,
Type,
1606 ConsumeAnnotationToken();
1613 case tok::annot_decltype:
1614 case tok::annot_pack_indexing_type:
1616 case tok::kw_wchar_t:
1617 case tok::kw_char8_t:
1618 case tok::kw_char16_t:
1619 case tok::kw_char32_t:
1624 case tok::kw___int64:
1625 case tok::kw___int128:
1626 case tok::kw__ExtInt:
1627 case tok::kw__BitInt:
1628 case tok::kw_signed:
1629 case tok::kw_unsigned:
1632 case tok::kw_double:
1633 case tok::kw___bf16:
1634 case tok::kw__Float16:
1635 case tok::kw___float128:
1636 case tok::kw___ibm128:
1639 case tok::kw_typename:
1640 case tok::kw_typeof:
1641 case tok::kw___vector:
1642 case tok::kw__Accum:
1643 case tok::kw__Fract:
1645#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1646#include "clang/Basic/OpenCLImageTypes.def"
1647#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
1648#include "clang/Basic/HLSLIntangibleTypes.def"
1651 Diag(Tok, diag::err_expected_expression);
1656 if (NotPrimaryExpression)
1657 *NotPrimaryExpression =
true;
1659 if (SavedKind == tok::kw_typename) {
1676 ParseCXXSimpleTypeSpecifier(DS);
1677 if (Tok.
isNot(tok::l_paren) &&
1679 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1680 << DS.getSourceRange());
1682 if (Tok.
is(tok::l_brace))
1683 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1685 Res = ParseCXXTypeConstructExpression(DS);
1689 case tok::annot_cxxscope: {
1694 if (!Tok.
is(tok::annot_cxxscope))
1695 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1696 isTypeCast, isVectorLiteral,
1697 NotPrimaryExpression);
1700 if (Next.is(tok::annot_template_id)) {
1707 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1711 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1712 isTypeCast, isVectorLiteral,
1713 NotPrimaryExpression);
1718 Res = ParseCXXIdExpression(isAddressOfOperand);
1722 case tok::annot_template_id: {
1730 return ParseCastExpression(ParseKind, isAddressOfOperand,
1731 NotCastExpr, isTypeCast, isVectorLiteral,
1732 NotPrimaryExpression);
1739 case tok::kw_operator:
1740 Res = ParseCXXIdExpression(isAddressOfOperand);
1743 case tok::coloncolon: {
1748 if (!Tok.
is(tok::coloncolon))
1749 return ParseCastExpression(ParseKind, isAddressOfOperand, isTypeCast,
1750 isVectorLiteral, NotPrimaryExpression);
1755 if (Tok.
is(tok::kw_new)) {
1756 if (NotPrimaryExpression)
1757 *NotPrimaryExpression =
true;
1758 Res = ParseCXXNewExpression(
true, CCLoc);
1759 AllowSuffix =
false;
1762 if (Tok.
is(tok::kw_delete)) {
1763 if (NotPrimaryExpression)
1764 *NotPrimaryExpression =
true;
1765 Res = ParseCXXDeleteExpression(
true, CCLoc);
1766 AllowSuffix =
false;
1771 Diag(CCLoc, diag::err_expected_expression);
1776 if (NotPrimaryExpression)
1777 *NotPrimaryExpression =
true;
1778 Res = ParseCXXNewExpression(
false, Tok.
getLocation());
1779 AllowSuffix =
false;
1782 case tok::kw_delete:
1783 if (NotPrimaryExpression)
1784 *NotPrimaryExpression =
true;
1785 Res = ParseCXXDeleteExpression(
false, Tok.
getLocation());
1786 AllowSuffix =
false;
1789 case tok::kw_requires:
1790 Res = ParseRequiresExpression();
1791 AllowSuffix =
false;
1794 case tok::kw_noexcept: {
1795 if (NotPrimaryExpression)
1796 *NotPrimaryExpression =
true;
1797 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1801 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1814 T.getCloseLocation());
1815 AllowSuffix =
false;
1819#define TYPE_TRAIT(N,Spelling,K) \
1820 case tok::kw_##Spelling:
1821#include "clang/Basic/TokenKinds.def"
1822 Res = ParseTypeTrait();
1825 case tok::kw___array_rank:
1826 case tok::kw___array_extent:
1827 if (NotPrimaryExpression)
1828 *NotPrimaryExpression =
true;
1829 Res = ParseArrayTypeTrait();
1832 case tok::kw___builtin_ptrauth_type_discriminator:
1833 return ParseBuiltinPtrauthTypeDiscriminator();
1835 case tok::kw___is_lvalue_expr:
1836 case tok::kw___is_rvalue_expr:
1837 if (NotPrimaryExpression)
1838 *NotPrimaryExpression =
true;
1839 Res = ParseExpressionTrait();
1843 if (NotPrimaryExpression)
1844 *NotPrimaryExpression =
true;
1846 return ParseObjCAtExpression(AtLoc);
1849 Res = ParseBlockLiteralExpression();
1851 case tok::code_completion: {
1857#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
1858#include "clang/Basic/TransformTypeTraits.def"
1863 Diag(Tok, diag::ext_keyword_as_ident)
1865 goto ParseIdentifier;
1867 goto ExpectedExpression;
1876 Res = TryParseLambdaExpression();
1880 if (NotPrimaryExpression)
1881 *NotPrimaryExpression =
true;
1882 Res = ParseObjCMessageExpression();
1886 Res = ParseLambdaExpression();
1890 Res = ParseObjCMessageExpression();
1904 if (ParseKind == PrimaryExprOnly)
1919 case tok::minusminus:
1937 Diag(Tok.
getLocation(), diag::err_postfix_after_unary_requires_parens)
1945 PreferredType = SavedType;
1946 Res = ParsePostfixExpressionSuffix(Res);
1948 !
getActions().getOpenCLOptions().isAvailableOption(
1950 if (
Expr *PostfixExpr = Res.
get()) {
1951 QualType Ty = PostfixExpr->getType();
1953 Diag(PostfixExpr->getExprLoc(),
1954 diag::err_opencl_taking_function_address_parser);
1984Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1988 auto SavedType = PreferredType;
1991 PreferredType = SavedType;
1993 case tok::code_completion:
1994 if (InMessageExpression)
2002 case tok::identifier:
2009 nullptr, LHS.
get());
2017 case tok::l_square: {
2025 isSimpleObjCMessageExpression())
2030 if (CheckProhibitedCXX11Attribute()) {
2036 Loc =
T.getOpenLocation();
2039 ExprVector ArgExprs;
2040 bool HasError =
false;
2047 if ((!
getLangOpts().OpenMP && !AllowOpenACCArraySections) ||
2048 Tok.
isNot(tok::colon)) {
2052 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2053 Idx = ParseBraceInitializer();
2062 ArgExprs.push_back(Idx.
get());
2064 }
else if (Tok.
isNot(tok::r_square)) {
2065 if (ParseExpressionList(ArgExprs)) {
2076 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {
2078 if (Tok.
is(tok::colon)) {
2081 if (Tok.
isNot(tok::r_square))
2084 }
else if (ArgExprs.size() <= 1 &&
getLangOpts().OpenMP) {
2086 if (Tok.
is(tok::colon)) {
2089 if (Tok.
isNot(tok::r_square) &&
2097 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||
2098 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
2099 Tok.
is(tok::colon)) {
2102 if (Tok.
isNot(tok::r_square)) {
2111 if (!LHS.
isInvalid() && !HasError && !Length.isInvalid() &&
2118 if (AllowOpenACCArraySections) {
2120 "Stride/second colon not allowed for OpenACC");
2122 LHS.
get(),
Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
2123 ColonLocFirst, Length.get(), RLoc);
2126 LHS.
get(),
Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
2127 ColonLocFirst, ColonLocSecond, Length.get(), Stride.
get(),
2144 case tok::lesslessless: {
2149 Expr *ExecConfig =
nullptr;
2153 if (OpKind == tok::lesslessless) {
2154 ExprVector ExecConfigExprs;
2157 if (ParseSimpleExpressionList(ExecConfigExprs)) {
2168 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
2169 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
2175 if (ExpectAndConsume(tok::l_paren))
2178 Loc = PrevTokLocation;
2183 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);
2187 ExecConfig = ECResult.
get();
2191 Loc = PT.getOpenLocation();
2194 ExprVector ArgExprs;
2195 auto RunSignatureHelp = [&]() ->
QualType {
2198 LHS.
get(), ArgExprs, PT.getOpenLocation());
2199 CalledSignatureHelp =
true;
2200 return PreferredType;
2202 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
2203 if (Tok.
isNot(tok::r_paren)) {
2204 if (ParseExpressionList(ArgExprs, [&] {
2205 PreferredType.enterFunctionArgument(Tok.
getLocation(),
2217 for (
auto &
E : ArgExprs)
2226 }
else if (Tok.
isNot(tok::r_paren)) {
2227 bool HadDelayedTypo =
false;
2229 HadDelayedTypo =
true;
2230 for (
auto &
E : ArgExprs)
2232 HadDelayedTypo =
true;
2247 ArgExprs.insert(ArgExprs.begin(), Fn);
2265 bool MayBePseudoDestructor =
false;
2268 PreferredType.enterMemAccess(Actions, Tok.
getLocation(), OrigLHS);
2272 const Type* BaseType =
Base->getType().getTypePtrOrNull();
2273 if (BaseType && Tok.
is(tok::l_paren) &&
2276 Diag(OpLoc, diag::err_function_is_not_record)
2277 << OpKind <<
Base->getSourceRange()
2279 return ParsePostfixExpressionSuffix(
Base);
2284 MayBePseudoDestructor);
2289 if (Tok.
is(tok::code_completion)) {
2295 ParseOptionalCXXScopeSpecifier(
2297 false, &MayBePseudoDestructor);
2299 ObjectType =
nullptr;
2302 if (Tok.
is(tok::code_completion)) {
2304 OpKind == tok::arrow ? tok::period : tok::arrow;
2311 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
2312 MayBePseudoDestructor);
2316 Expr *CorrectedBase = CorrectedLHS.get();
2318 CorrectedBase =
Base;
2324 Base && ExprStatementTokLoc ==
Base->getBeginLoc(),
2330 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
2331 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
2346 Tok.
is(tok::kw_class)) {
2356 Name.setIdentifier(
Id,
Loc);
2363 false, &TemplateKWLoc, Name)) {
2370 OpKind, SS, TemplateKWLoc, Name,
2371 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
2374 if (Tok.
is(tok::less))
2375 checkPotentialAngleBracket(LHS);
2376 }
else if (OrigLHS && Name.isValid()) {
2379 Name.getEndLoc(), {OrigLHS});
2384 case tok::minusminus:
2432Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
2437 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,
2438 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,
2439 tok::kw__Alignof, tok::kw_vec_step,
2440 tok::kw___builtin_omp_required_simd_align,
2441 tok::kw___builtin_vectorelements) &&
2442 "Not a typeof/sizeof/alignof/vec_step expression!");
2447 if (Tok.
isNot(tok::l_paren)) {
2450 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2451 tok::kw_alignof, tok::kw__Alignof)) {
2452 if (isTypeIdUnambiguously()) {
2454 ParseSpecifierQualifierList(DS);
2457 ParseDeclarator(DeclaratorInfo);
2463 diag::err_expected_parentheses_around_typename)
2466 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
2476 if (OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
2487 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2488 tok::kw_alignof, tok::kw__Alignof) &&
2489 Tok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2490 tok::kw_alignof, tok::kw__Alignof))
2492 Operand = ParseCastExpression(UnaryExprOnly);
2495 Operand = ParseCastExpression(UnaryExprOnly);
2501 ParenParseOption ExprType =
CastExpr;
2504 Operand = ParseParenExpression(ExprType,
true,
2505 false, CastTy, RParenLoc);
2516 !OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {
2533ExprResult Parser::ParseSYCLUniqueStableNameExpression() {
2534 assert(Tok.
is(tok::kw___builtin_sycl_unique_stable_name) &&
2535 "Not __builtin_sycl_unique_stable_name");
2541 if (
T.expectAndConsume(diag::err_expected_lparen_after,
2542 "__builtin_sycl_unique_stable_name"))
2552 if (
T.consumeClose())
2556 OpLoc,
T.getOpenLocation(),
T.getCloseLocation(), Ty.
get());
2573ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
2574 assert(Tok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2575 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
2576 tok::kw___builtin_omp_required_simd_align,
2577 tok::kw___builtin_vectorelements) &&
2578 "Not a sizeof/alignof/vec_step expression!");
2583 if (Tok.
is(tok::ellipsis) && OpTok.
is(tok::kw_sizeof)) {
2588 if (Tok.
is(tok::l_paren)) {
2591 LParenLoc =
T.getOpenLocation();
2592 if (Tok.
is(tok::identifier)) {
2596 RParenLoc =
T.getCloseLocation();
2600 Diag(Tok, diag::err_expected_parameter_pack);
2603 }
else if (Tok.
is(tok::identifier)) {
2608 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2613 Diag(Tok, diag::err_sizeof_parameter_pack);
2630 OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2631 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2633 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.
getName();
2649 case tok::kw_alignof:
2650 case tok::kw__Alignof:
2651 ExprKind = UETT_AlignOf;
2653 case tok::kw___alignof:
2654 ExprKind = UETT_PreferredAlignOf;
2656 case tok::kw_vec_step:
2657 ExprKind = UETT_VecStep;
2659 case tok::kw___builtin_omp_required_simd_align:
2660 ExprKind = UETT_OpenMPRequiredSimdAlign;
2662 case tok::kw___datasizeof:
2663 ExprKind = UETT_DataSizeOf;
2665 case tok::kw___builtin_vectorelements:
2666 ExprKind = UETT_VectorElements;
2679 if (OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2715ExprResult Parser::ParseBuiltinPrimaryExpression() {
2723 if (Tok.
isNot(tok::l_paren))
2724 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2733 default: llvm_unreachable(
"Not a builtin primary expression!");
2734 case tok::kw___builtin_va_arg: {
2737 if (ExpectAndConsume(tok::comma)) {
2744 if (Tok.
isNot(tok::r_paren)) {
2745 Diag(Tok, diag::err_expected) << tok::r_paren;
2755 case tok::kw___builtin_offsetof: {
2761 if (MacroName ==
"offsetof")
2774 if (ExpectAndConsume(tok::comma)) {
2780 if (Tok.
isNot(tok::identifier)) {
2781 Diag(Tok, diag::err_expected) << tok::identifier;
2790 Comps.back().isBrackets =
false;
2792 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2796 if (Tok.
is(tok::period)) {
2799 Comps.back().isBrackets =
false;
2802 if (Tok.
isNot(tok::identifier)) {
2803 Diag(Tok, diag::err_expected) << tok::identifier;
2809 }
else if (Tok.
is(tok::l_square)) {
2810 if (CheckProhibitedCXX11Attribute())
2815 Comps.back().isBrackets =
true;
2818 Comps.back().LocStart = ST.getOpenLocation();
2824 Comps.back().U.E = Res.
get();
2827 Comps.back().LocEnd = ST.getCloseLocation();
2829 if (Tok.
isNot(tok::r_paren)) {
2838 PT.getCloseLocation());
2845 case tok::kw___builtin_choose_expr: {
2847 if (Cond.isInvalid()) {
2851 if (ExpectAndConsume(tok::comma)) {
2857 if (Expr1.isInvalid()) {
2861 if (ExpectAndConsume(tok::comma)) {
2867 if (Expr2.isInvalid()) {
2871 if (Tok.
isNot(tok::r_paren)) {
2872 Diag(Tok, diag::err_expected) << tok::r_paren;
2876 Expr2.get(), ConsumeParen());
2879 case tok::kw___builtin_astype: {
2882 if (
Expr.isInvalid()) {
2887 if (ExpectAndConsume(tok::comma)) {
2898 if (Tok.
isNot(tok::r_paren)) {
2899 Diag(Tok, diag::err_expected) << tok::r_paren;
2908 case tok::kw___builtin_convertvector: {
2911 if (
Expr.isInvalid()) {
2916 if (ExpectAndConsume(tok::comma)) {
2927 if (Tok.
isNot(tok::r_paren)) {
2928 Diag(Tok, diag::err_expected) << tok::r_paren;
2937 case tok::kw___builtin_COLUMN:
2938 case tok::kw___builtin_FILE:
2939 case tok::kw___builtin_FILE_NAME:
2940 case tok::kw___builtin_FUNCTION:
2941 case tok::kw___builtin_FUNCSIG:
2942 case tok::kw___builtin_LINE:
2943 case tok::kw___builtin_source_location: {
2945 if (Tok.
isNot(tok::r_paren)) {
2946 Diag(Tok, diag::err_expected) << tok::r_paren;
2952 case tok::kw___builtin_FILE:
2954 case tok::kw___builtin_FILE_NAME:
2956 case tok::kw___builtin_FUNCTION:
2958 case tok::kw___builtin_FUNCSIG:
2960 case tok::kw___builtin_LINE:
2962 case tok::kw___builtin_COLUMN:
2964 case tok::kw___builtin_source_location:
2967 llvm_unreachable(
"invalid keyword");
2980 return ParsePostfixExpressionSuffix(Res.
get());
2983bool Parser::tryParseOpenMPArrayShapingCastPart() {
2984 assert(Tok.
is(tok::l_square) &&
"Expected open bracket");
2985 bool ErrorFound =
true;
2986 TentativeParsingAction TPA(*
this);
2988 if (Tok.
isNot(tok::l_square))
2993 while (!
SkipUntil(tok::r_square, tok::annot_pragma_openmp_end,
2996 if (Tok.
isNot(tok::r_square))
3001 if (Tok.
is(tok::r_paren)) {
3005 }
while (Tok.
isNot(tok::annot_pragma_openmp_end));
3038Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
3041 assert(Tok.
is(tok::l_paren) &&
"Not a paren expr!");
3044 if (
T.consumeOpen())
3048 PreferredType.enterParenExpr(Tok.
getLocation(), OpenLoc);
3051 bool isAmbiguousTypeId;
3054 if (Tok.
is(tok::code_completion)) {
3058 ExprType >= CompoundLiteral);
3065 tok::kw___bridge_transfer,
3066 tok::kw___bridge_retained,
3067 tok::kw___bridge_retain));
3068 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
3070 StringRef BridgeCastName = Tok.
getName();
3073 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
3083 Diag(Tok, OpenLoc.
isMacroID() ? diag::ext_gnu_statement_expr_macro
3084 : diag::ext_gnu_statement_expr);
3086 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
3095 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
3098 "statement expr not in code context");
3108 if (!
Stmt.isInvalid()) {
3115 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
3121 if (tokenKind == tok::kw___bridge)
3123 else if (tokenKind == tok::kw___bridge_transfer)
3125 else if (tokenKind == tok::kw___bridge_retained)
3130 assert(tokenKind == tok::kw___bridge_retain);
3133 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
3135 "__bridge_retained");
3140 ColonProtection.restore();
3141 RParenLoc =
T.getCloseLocation();
3144 ExprResult SubExpr = ParseCastExpression(AnyCastExpr);
3150 BridgeKeywordLoc, Ty.
get(),
3151 RParenLoc, SubExpr.
get());
3152 }
else if (ExprType >= CompoundLiteral &&
3153 isTypeIdInParens(isAmbiguousTypeId)) {
3162 if (isAmbiguousTypeId && !stopIfCastExpr) {
3163 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy,
T,
3165 RParenLoc =
T.getCloseLocation();
3171 ParseSpecifierQualifierList(DS);
3174 ParseDeclarator(DeclaratorInfo);
3179 if (!DeclaratorInfo.isInvalidType() && Tok.
is(tok::identifier) &&
3193 ColonProtection.restore();
3194 RParenLoc =
T.getCloseLocation();
3195 if (Tok.
is(tok::l_brace)) {
3196 ExprType = CompoundLiteral;
3202 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
3205 if (Tok.
is(tok::l_paren)) {
3226 Result = ParseCastExpression(AnyCastExpr,
3231 if (!
Result.isInvalid()) {
3233 DeclaratorInfo, CastTy,
3234 RParenLoc,
Result.get());
3238 if (!
Result.isInvalid()) {
3250 if (DeclaratorInfo.isInvalidType())
3255 if (stopIfCastExpr) {
3269 GetLookAheadToken(1).isNot(tok::period)) {
3278 Result = ParseCastExpression(AnyCastExpr,
3281 if (!
Result.isInvalid()) {
3283 DeclaratorInfo, CastTy,
3284 RParenLoc,
Result.get());
3289 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
3292 }
else if (ExprType >= FoldExpr && Tok.
is(tok::ellipsis) &&
3294 ExprType = FoldExpr;
3296 }
else if (isTypeCast) {
3299 ExprVector ArgExprs;
3301 if (!ParseSimpleExpressionList(ArgExprs)) {
3304 if (ExprType >= FoldExpr && ArgExprs.size() == 1 &&
3306 ExprType = FoldExpr;
3307 return ParseFoldExpression(ArgExprs[0],
T);
3310 ExprType = SimpleExpr;
3314 }
else if (
getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&
3315 ExprType ==
CastExpr && Tok.
is(tok::l_square) &&
3316 tryParseOpenMPArrayShapingCastPart()) {
3317 bool ErrorFound =
false;
3327 while (!
SkipUntil(tok::r_square, tok::r_paren,
3332 OMPDimensions.push_back(NumElements.
get());
3333 OMPBracketsRanges.push_back(TS.getRange());
3334 }
while (Tok.
isNot(tok::r_paren));
3337 RParenLoc =
T.getCloseLocation();
3341 }
else if (!
Result.isInvalid()) {
3343 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);
3356 if (ExprType >= FoldExpr && isFoldOperator(Tok.
getKind()) &&
3358 ExprType = FoldExpr;
3359 return ParseFoldExpression(
Result,
T);
3361 ExprType = SimpleExpr;
3364 if (!
Result.isInvalid() && Tok.
is(tok::r_paren))
3370 if (
Result.isInvalid()) {
3376 RParenLoc =
T.getCloseLocation();
3389Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
3392 assert(Tok.
is(tok::l_brace) &&
"Not a compound literal!");
3394 Diag(LParenLoc, diag::ext_c99_compound_literal);
3397 if (!
Result.isInvalid() && Ty)
3423 "Not a string-literal-like token!");
3431 StringToks.push_back(Tok);
3436 assert(!AllowUserDefinedLiteral &&
"UDL are always evaluated");
3465ExprResult Parser::ParseGenericSelectionExpression() {
3466 assert(Tok.
is(tok::kw__Generic) &&
"_Generic keyword expected");
3468 diagnoseUseOfC11Keyword(Tok);
3472 if (
T.expectAndConsume())
3479 if (isTypeIdForGenericSelection()) {
3485 const auto *LIT = cast<LocInfoType>(ControllingType.
get().get());
3488 : diag::ext_c2y_generic_with_type_arg);
3502 if (ExpectAndConsume(tok::comma)) {
3512 if (Tok.
is(tok::kw_default)) {
3516 Diag(Tok, diag::err_duplicate_default_assoc);
3517 Diag(DefaultLoc, diag::note_previous_default_assoc);
3532 Types.push_back(Ty);
3534 if (ExpectAndConsume(tok::colon)) {
3543 if (ER.isInvalid()) {
3547 Exprs.push_back(ER.get());
3551 if (
T.getCloseLocation().isInvalid())
3554 void *ExprOrTy = ControllingExpr.
isUsable()
3555 ? ControllingExpr.
get()
3556 : ControllingType.
get().getAsOpaquePtr();
3559 KeyLoc, DefaultLoc,
T.getCloseLocation(), ControllingExpr.
isUsable(),
3560 ExprOrTy, Types, Exprs);
3582 assert(isFoldOperator(Kind) &&
"missing fold-operator");
3586 assert(Tok.
is(tok::ellipsis) &&
"not a fold-expression");
3590 if (Tok.
isNot(tok::r_paren)) {
3591 if (!isFoldOperator(Tok.
getKind()))
3594 if (Kind != tok::unknown && Tok.
getKind() != Kind)
3608 ? diag::warn_cxx14_compat_fold_expression
3609 : diag::ext_fold_expression);
3613 Kind, EllipsisLoc, RHS.
get(),
3614 T.getCloseLocation());
3617void Parser::injectEmbedTokens() {
3621 Data->BinaryData.size() * 2 - 1),
3622 Data->BinaryData.size() * 2 - 1);
3624 for (
auto &Byte :
Data->BinaryData) {
3625 Toks[I].startToken();
3626 Toks[I].setKind(tok::binary_data);
3628 Toks[I].setLength(1);
3629 Toks[I].setLiteralData(&Byte);
3630 if (I != ((
Data->BinaryData.size() - 1) * 2)) {
3631 Toks[I + 1].startToken();
3632 Toks[I + 1].setKind(tok::comma);
3637 PP.EnterTokenStream(std::move(Toks),
true,
3665 llvm::function_ref<
void()> ExpressionStarts,
3666 bool FailImmediatelyOnInvalidExpr,
3667 bool EarlyTypoCorrection) {
3668 bool SawError =
false;
3670 if (ExpressionStarts)
3675 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3676 Expr = ParseBraceInitializer();
3680 if (EarlyTypoCorrection)
3683 if (Tok.
is(tok::ellipsis))
3685 else if (Tok.
is(tok::code_completion)) {
3695 if (
Expr.isInvalid()) {
3697 if (FailImmediatelyOnInvalidExpr)
3701 Exprs.push_back(
Expr.get());
3704 if (Tok.
isNot(tok::comma))
3709 checkPotentialAngleBracketDelimiter(Comma);
3714 for (
auto &
E : Exprs) {
3733 if (
Expr.isInvalid())
3736 Exprs.push_back(
Expr.get());
3746 checkPotentialAngleBracketDelimiter(Comma);
3757 if (Tok.
is(tok::code_completion)) {
3766 ParseSpecifierQualifierList(DS);
3772 ParseDeclarator(DeclaratorInfo);
3774 MaybeParseGNUAttributes(DeclaratorInfo);
3790ExprResult Parser::ParseBlockLiteralExpression() {
3791 assert(Tok.
is(tok::caret) &&
"block literal starts with ^");
3795 "block literal parsing");
3818 if (Tok.
is(tok::l_paren)) {
3819 ParseParenDeclarator(ParamInfo);
3824 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
3825 ParamInfo.SetRangeEnd(Tmp);
3826 if (ParamInfo.isInvalidType()) {
3834 MaybeParseGNUAttributes(ParamInfo);
3838 }
else if (!Tok.
is(tok::l_brace)) {
3839 ParseBlockId(CaretLoc);
3843 ParamInfo.AddTypeInfo(
3861 CaretLoc, CaretLoc, ParamInfo),
3864 MaybeParseGNUAttributes(ParamInfo);
3872 if (!Tok.
is(tok::l_brace)) {
3874 Diag(Tok, diag::err_expected_expression);
3881 if (!
Stmt.isInvalid())
3901 llvm::SmallSet<StringRef, 4> Platforms;
3902 bool HasOtherPlatformSpec =
false;
3904 for (
const auto &Spec : AvailSpecs) {
3905 if (Spec.isOtherPlatformSpec()) {
3906 if (HasOtherPlatformSpec) {
3907 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3911 HasOtherPlatformSpec =
true;
3915 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3920 StringRef Platform = Spec.getPlatform();
3921 P.Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3922 << Spec.getEndLoc() << Platform;
3927 if (!HasOtherPlatformSpec) {
3928 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3929 P.Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3942std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() {
3943 if (Tok.
is(tok::star)) {
3947 if (Tok.
is(tok::code_completion)) {
3950 return std::nullopt;
3952 if (Tok.
isNot(tok::identifier)) {
3953 Diag(Tok, diag::err_avail_query_expected_platform_name);
3954 return std::nullopt;
3959 VersionTuple Version = ParseVersionTuple(VersionRange);
3961 if (Version.empty())
3962 return std::nullopt;
3964 StringRef GivenPlatform = PlatformIdentifier->
Ident->
getName();
3965 StringRef Platform =
3966 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3968 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||
3969 (GivenPlatform.contains(
"xros") || GivenPlatform.contains(
"xrOS"))) {
3971 diag::err_avail_query_unrecognized_platform_name)
3973 return std::nullopt;
3982 assert(Tok.
is(tok::kw___builtin_available) ||
3989 if (
Parens.expectAndConsume())
3993 bool HasError =
false;
3995 std::optional<AvailabilitySpec> Spec = ParseAvailabilitySpec();
3999 AvailSpecs.push_back(*Spec);
4012 if (
Parens.consumeClose())
4016 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.