32 #include "llvm/ADT/SmallString.h"
33 #include "llvm/ADT/SmallVector.h"
34 using namespace clang;
122 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
133 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
140 Parser::ParseExpressionWithLeadingExtension(
SourceLocation ExtLoc) {
146 LHS = ParseCastExpression(
false);
149 if (!LHS.isInvalid())
153 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
158 if (Tok.
is(tok::code_completion)) {
164 if (Tok.
is(tok::kw_throw))
165 return ParseThrowExpression();
166 if (Tok.
is(tok::kw_co_yield))
167 return ParseCoyieldExpression();
185 Parser::ParseAssignmentExprWithObjCMessageExprStart(
SourceLocation LBracLoc,
188 Expr *ReceiverExpr) {
190 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
191 ReceiverType, ReceiverExpr);
192 R = ParsePostfixExpressionSuffix(R);
205 ExprResult LHS(ParseCastExpression(
false,
false, isTypeCast));
228 bool Parser::isNotExpressionStart() {
230 if (K == tok::l_brace || K == tok::r_brace ||
231 K == tok::kw_for || K == tok::kw_while ||
232 K == tok::kw_if || K == tok::kw_else ||
233 K == tok::kw_goto || K == tok::kw_try)
236 return isKnownToBeDeclarationSpecifier();
251 GreaterThanIsOperator,
259 if (NextTokPrec < MinPrec)
266 if (OpToken.
is(tok::caretcaret)) {
267 return ExprError(
Diag(Tok, diag::err_opencl_logical_exclusive_or));
274 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
293 if (Tok.
isNot(tok::colon)) {
302 if (TernaryMiddle.isInvalid()) {
305 TernaryMiddle =
nullptr;
310 TernaryMiddle =
nullptr;
311 Diag(Tok, diag::ext_gnu_conditional_expr);
320 const char *FIText =
": ";
324 bool IsInvalid =
false;
325 const char *SourcePtr =
327 if (!IsInvalid && *SourcePtr ==
' ') {
330 if (!IsInvalid && *SourcePtr ==
' ') {
337 Diag(Tok, diag::err_expected)
339 Diag(OpToken, diag::note_matching) << tok::question;
363 bool RHSIsInitList =
false;
365 RHS = ParseBraceInitializer();
366 RHSIsInitList =
true;
370 RHS = ParseCastExpression(
false);
376 if (TernaryMiddle.isUsable())
393 if (ThisPrec < NextTokPrec ||
394 (ThisPrec == NextTokPrec && isRightAssoc)) {
396 Diag(Tok, diag::err_init_list_bin_op)
405 RHS = ParseRHSOfBinaryExpression(RHS,
406 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
407 RHSIsInitList =
false;
413 if (TernaryMiddle.isUsable())
424 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
427 Diag(OpToken, diag::err_init_list_bin_op)
437 if (TernaryMiddle.isInvalid()) {
441 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
443 diag::warn_cxx11_right_shift_in_template_arg,
452 LHS.
get(), TernaryMiddle.get(),
475 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
476 bool isAddressOfOperand,
477 TypeCastState isTypeCast) {
479 ExprResult Res = ParseCastExpression(isUnaryExpression,
484 Diag(Tok, diag::err_expected_expression);
491 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
492 : NextToken(Next), AllowNonTypes(AllowNonTypes) {
493 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
496 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
501 if (isa<TypeDecl>(ND))
502 return WantTypeSpecifiers;
507 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
510 for (
auto *C : candidate) {
512 if (isa<ValueDecl>(ND) && !isa<FunctionDecl>(ND))
695 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
696 bool isAddressOfOperand,
698 TypeCastState isTypeCast) {
718 ParenParseOption ParenExprType =
719 (isUnaryExpression && !
getLangOpts().CPlusPlus) ? CompoundLiteral
723 Res = ParseParenExpression(ParenExprType,
false,
726 switch (ParenExprType) {
727 case SimpleExpr:
break;
729 case CompoundLiteral:
743 case tok::numeric_constant:
753 return ParseCXXBoolLiteral();
755 case tok::kw___objc_yes:
756 case tok::kw___objc_no:
757 return ParseObjCBoolLiteral();
759 case tok::kw_nullptr:
760 Diag(Tok, diag::warn_cxx98_compat_nullptr);
763 case tok::annot_primary_expr:
764 assert(Res.
get() ==
nullptr &&
"Stray primary-expression annotation?");
765 Res = getExprAnnotation(Tok);
769 case tok::kw___super:
770 case tok::kw_decltype:
774 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
775 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
777 case tok::identifier: {
790 if (Next.
is(tok::l_paren) &&
791 Tok.
is(tok::identifier) &&
795 if (RevertibleTypeTraits.empty()) {
796 #define RTT_JOIN(X,Y) X##Y
797 #define REVERTIBLE_TYPE_TRAIT(Name) \
798 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] \
799 = RTT_JOIN(tok::kw_,Name)
851 #undef REVERTIBLE_TYPE_TRAIT
859 = RevertibleTypeTraits.find(II);
860 if (Known != RevertibleTypeTraits.end()) {
862 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
863 NotCastExpr, isTypeCast);
867 if ((!ColonIsSacred && Next.
is(tok::colon)) ||
868 Next.
isOneOf(tok::coloncolon, tok::less, tok::l_paren,
873 if (!Tok.
is(tok::identifier))
874 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
891 if (Tok.
isNot(tok::identifier) &&
893 Diag(Tok, diag::err_expected_property_name);
908 if (
getLangOpts().ObjC1 && &II == Ident_super && !InMessageExpression &&
910 ((Tok.
is(tok::identifier) &&
912 Tok.
is(tok::code_completion))) {
913 Res = ParseObjCMessageExpressionBody(
SourceLocation(), ILoc,
nullptr,
924 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
925 Tok.
is(tok::code_completion))) {
927 if (Tok.
is(tok::code_completion) ||
928 Next.
is(tok::colon) || Next.
is(tok::r_square))
930 if (Typ.get()->isObjCObjectOrInterfaceType()) {
933 DS.SetRangeStart(ILoc);
934 DS.SetRangeEnd(ILoc);
935 const char *PrevSpec =
nullptr;
937 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
954 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
955 isAddressOfOperand =
false;
964 auto Validator = llvm::make_unique<CastExpressionIdValidator>(
966 Validator->IsAddressOfOperand = isAddressOfOperand;
967 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
968 Validator->WantExpressionKeywords =
false;
969 Validator->WantRemainingKeywords =
false;
971 Validator->WantRemainingKeywords = Tok.isNot(tok::r_paren);
975 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren),
976 isAddressOfOperand, std::move(Validator),
979 if (!Res.isInvalid() && !Res.get()) {
980 UnconsumeToken(Replacement);
981 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
982 NotCastExpr, isTypeCast);
986 case tok::char_constant:
987 case tok::wide_char_constant:
988 case tok::utf8_char_constant:
989 case tok::utf16_char_constant:
990 case tok::utf32_char_constant:
994 case tok::kw___func__:
995 case tok::kw___FUNCTION__:
996 case tok::kw___FUNCDNAME__:
997 case tok::kw___FUNCSIG__:
998 case tok::kw_L__FUNCTION__:
999 case tok::kw___PRETTY_FUNCTION__:
1003 case tok::string_literal:
1004 case tok::wide_string_literal:
1005 case tok::utf8_string_literal:
1006 case tok::utf16_string_literal:
1007 case tok::utf32_string_literal:
1008 Res = ParseStringLiteralExpression(
true);
1010 case tok::kw__Generic:
1011 Res = ParseGenericSelectionExpression();
1013 case tok::kw___builtin_available:
1014 return ParseAvailabilityCheckExpr(Tok.getLocation());
1015 case tok::kw___builtin_va_arg:
1016 case tok::kw___builtin_offsetof:
1017 case tok::kw___builtin_choose_expr:
1018 case tok::kw___builtin_astype:
1019 case tok::kw___builtin_convertvector:
1020 return ParseBuiltinPrimaryExpression();
1021 case tok::kw___null:
1025 case tok::minusminus: {
1030 Token SavedTok = Tok;
1041 assert(Res.isInvalid());
1042 UnconsumeToken(SavedTok);
1045 if (!Res.isInvalid())
1047 SavedKind, Res.get());
1053 Res = ParseCastExpression(
false,
true);
1054 if (!Res.isInvalid())
1064 case tok::kw___real:
1065 case tok::kw___imag: {
1067 Res = ParseCastExpression(
false);
1068 if (!Res.isInvalid())
1073 case tok::kw_co_await: {
1075 Res = ParseCastExpression(
false);
1076 if (!Res.isInvalid())
1081 case tok::kw___extension__:{
1085 Res = ParseCastExpression(
false);
1086 if (!Res.isInvalid())
1090 case tok::kw__Alignof:
1092 Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
1094 case tok::kw_alignof:
1095 case tok::kw___alignof:
1097 case tok::kw_sizeof:
1099 case tok::kw_vec_step:
1101 case tok::kw___builtin_omp_required_simd_align:
1102 return ParseUnaryExprOrTypeTraitExpression();
1105 if (Tok.isNot(tok::identifier))
1106 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1109 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1111 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1118 case tok::kw_const_cast:
1119 case tok::kw_dynamic_cast:
1120 case tok::kw_reinterpret_cast:
1121 case tok::kw_static_cast:
1122 Res = ParseCXXCasts();
1124 case tok::kw_typeid:
1125 Res = ParseCXXTypeid();
1127 case tok::kw___uuidof:
1128 Res = ParseCXXUuidof();
1131 Res = ParseCXXThis();
1134 case tok::annot_typename:
1135 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1140 DS.SetRangeStart(Tok.getLocation());
1141 DS.SetRangeEnd(Tok.getLastLoc());
1143 const char *PrevSpec =
nullptr;
1145 DS.SetTypeSpecType(
TST_typename, Tok.getAnnotationEndLoc(),
1146 PrevSpec, DiagID, Type,
1161 case tok::annot_decltype:
1163 case tok::kw_wchar_t:
1164 case tok::kw_char16_t:
1165 case tok::kw_char32_t:
1170 case tok::kw___int64:
1171 case tok::kw___int128:
1172 case tok::kw_signed:
1173 case tok::kw_unsigned:
1176 case tok::kw_double:
1177 case tok::kw___float128:
1179 case tok::kw_typename:
1180 case tok::kw_typeof:
1181 case tok::kw___vector:
1182 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1183 #include "clang/Basic/OpenCLImageTypes.def"
1186 Diag(Tok, diag::err_expected_expression);
1190 if (SavedKind == tok::kw_typename) {
1207 ParseCXXSimpleTypeSpecifier(DS);
1208 if (Tok.isNot(tok::l_paren) &&
1209 (!
getLangOpts().CPlusPlus11 || Tok.isNot(tok::l_brace)))
1210 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1211 << DS.getSourceRange());
1213 if (Tok.is(tok::l_brace))
1214 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1216 Res = ParseCXXTypeConstructExpression(DS);
1220 case tok::annot_cxxscope: {
1225 if (!Tok.is(tok::annot_cxxscope))
1226 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1227 NotCastExpr, isTypeCast);
1230 if (Next.
is(tok::annot_template_id)) {
1237 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1239 AnnotateTemplateIdTokenAsType();
1240 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1241 NotCastExpr, isTypeCast);
1246 Res = ParseCXXIdExpression(isAddressOfOperand);
1250 case tok::annot_template_id: {
1256 AnnotateTemplateIdTokenAsType();
1257 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1258 NotCastExpr, isTypeCast);
1264 case tok::kw_operator:
1265 Res = ParseCXXIdExpression(isAddressOfOperand);
1268 case tok::coloncolon: {
1273 if (!Tok.is(tok::coloncolon))
1274 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
1279 if (Tok.is(tok::kw_new))
1280 return ParseCXXNewExpression(
true, CCLoc);
1281 if (Tok.is(tok::kw_delete))
1282 return ParseCXXDeleteExpression(
true, CCLoc);
1285 Diag(CCLoc, diag::err_expected_expression);
1290 return ParseCXXNewExpression(
false, Tok.getLocation());
1292 case tok::kw_delete:
1293 return ParseCXXDeleteExpression(
false, Tok.getLocation());
1295 case tok::kw_noexcept: {
1296 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1300 if (T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1312 Result.
get(), T.getCloseLocation());
1316 #define TYPE_TRAIT(N,Spelling,K) \
1317 case tok::kw_##Spelling:
1318 #include "clang/Basic/TokenKinds.def"
1319 return ParseTypeTrait();
1321 case tok::kw___array_rank:
1322 case tok::kw___array_extent:
1323 return ParseArrayTypeTrait();
1325 case tok::kw___is_lvalue_expr:
1326 case tok::kw___is_rvalue_expr:
1327 return ParseExpressionTrait();
1331 return ParseObjCAtExpression(AtLoc);
1334 Res = ParseBlockLiteralExpression();
1336 case tok::code_completion: {
1349 Res = TryParseLambdaExpression();
1350 if (!Res.isInvalid() && !Res.get())
1351 Res = ParseObjCMessageExpression();
1354 Res = ParseLambdaExpression();
1358 Res = ParseObjCMessageExpression();
1372 Res = ParsePostfixExpressionSuffix(Res);
1374 if (
Expr *PostfixExpr = Res.get()) {
1375 QualType Ty = PostfixExpr->getType();
1377 Diag(PostfixExpr->getExprLoc(),
1378 diag::err_opencl_taking_function_address_parser);
1407 Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1412 switch (Tok.getKind()) {
1413 case tok::code_completion:
1414 if (InMessageExpression)
1421 case tok::identifier:
1425 if (
getLangOpts().ObjC1 && !InMessageExpression &&
1428 nullptr, LHS.
get());
1436 case tok::l_square: {
1443 if (
getLangOpts().ObjC1 && Tok.isAtStartOfLine() &&
1444 isSimpleObjCMessageExpression())
1449 if (CheckProhibitedCXX11Attribute()) {
1456 Loc = T.getOpenLocation();
1460 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1461 Idx = ParseBraceInitializer();
1465 if (!Tok.is(tok::colon)) {
1469 if (Tok.is(tok::colon)) {
1472 if (Tok.isNot(tok::r_square))
1482 Tok.is(tok::r_square)) {
1507 case tok::lesslessless: {
1512 Expr *ExecConfig =
nullptr;
1516 if (OpKind == tok::lesslessless) {
1517 ExprVector ExecConfigExprs;
1518 CommaLocsTy ExecConfigCommaLocs;
1521 if (ParseSimpleExpressionList(ExecConfigExprs, ExecConfigCommaLocs)) {
1532 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1533 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1539 if (ExpectAndConsume(tok::l_paren))
1542 Loc = PrevTokLocation;
1553 ExecConfig = ECResult.
get();
1557 Loc = PT.getOpenLocation();
1560 ExprVector ArgExprs;
1561 CommaLocsTy CommaLocs;
1563 if (Tok.is(tok::code_completion)) {
1569 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1570 if (Tok.isNot(tok::r_paren)) {
1571 if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
1577 for (
auto &
E : ArgExprs)
1586 }
else if (Tok.isNot(tok::r_paren)) {
1587 bool HadDelayedTypo =
false;
1589 HadDelayedTypo =
true;
1590 for (
auto &
E : ArgExprs)
1592 HadDelayedTypo =
true;
1602 assert((ArgExprs.size() == 0 ||
1603 ArgExprs.size()-1 == CommaLocs.size())&&
1604 "Unexpected number of commas!");
1606 ArgExprs, Tok.getLocation(),
1622 bool MayBePseudoDestructor =
false;
1626 if (BaseType && Tok.is(tok::l_paren) &&
1629 Diag(OpLoc, diag::err_function_is_not_record)
1630 << OpKind << Base->getSourceRange()
1632 return ParsePostfixExpressionSuffix(Base);
1636 OpLoc, OpKind, ObjectType,
1637 MayBePseudoDestructor);
1641 ParseOptionalCXXScopeSpecifier(SS, ObjectType,
1643 &MayBePseudoDestructor);
1645 ObjectType =
nullptr;
1648 if (Tok.is(tok::code_completion)) {
1651 OpLoc, OpKind == tok::arrow);
1657 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
1658 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
1672 if (
getLangOpts().ObjC2 && OpKind == tok::period &&
1673 Tok.is(tok::kw_class)) {
1689 ObjectType, TemplateKWLoc, Name)) {
1696 OpKind, SS, TemplateKWLoc,
Name,
1697 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
1702 case tok::minusminus:
1705 Tok.getKind(), LHS.
get());
1737 Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1742 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_sizeof, tok::kw___alignof,
1743 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
1744 tok::kw___builtin_omp_required_simd_align) &&
1745 "Not a typeof/sizeof/alignof/vec_step expression!");
1750 if (Tok.isNot(tok::l_paren)) {
1753 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1754 tok::kw__Alignof)) {
1755 if (isTypeIdUnambiguously()) {
1757 ParseSpecifierQualifierList(DS);
1759 ParseDeclarator(DeclaratorInfo);
1763 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
1779 Operand = ParseCastExpression(
true);
1785 ParenParseOption ExprType =
CastExpr;
1788 Operand = ParseParenExpression(ExprType,
true,
1789 false, CastTy, RParenLoc);
1804 if (!Operand.isInvalid())
1805 Operand = ParsePostfixExpressionSuffix(Operand.get());
1827 ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
1828 assert(Tok.isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1829 tok::kw__Alignof, tok::kw_vec_step,
1830 tok::kw___builtin_omp_required_simd_align) &&
1831 "Not a sizeof/alignof/vec_step expression!");
1836 if (Tok.is(tok::ellipsis) && OpTok.is(tok::kw_sizeof)) {
1841 if (Tok.is(tok::l_paren)) {
1844 LParenLoc = T.getOpenLocation();
1845 if (Tok.is(tok::identifier)) {
1846 Name = Tok.getIdentifierInfo();
1849 RParenLoc = T.getCloseLocation();
1853 Diag(Tok, diag::err_expected_parameter_pack);
1856 }
else if (Tok.is(tok::identifier)) {
1857 Name = Tok.getIdentifierInfo();
1861 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
1866 Diag(Tok, diag::err_sizeof_parameter_pack);
1876 OpTok.getLocation(),
1881 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
1882 Diag(OpTok, diag::warn_cxx98_compat_alignof);
1890 ExprResult Operand = ParseExprAfterUnaryExprOrTypeTrait(OpTok,
1896 if (OpTok.isOneOf(tok::kw_alignof, tok::kw___alignof, tok::kw__Alignof))
1898 else if (OpTok.is(tok::kw_vec_step))
1900 else if (OpTok.is(tok::kw___builtin_omp_required_simd_align))
1910 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
1911 Diag(OpTok, diag::ext_alignof_expr) << OpTok.getIdentifierInfo();
1939 ExprResult Parser::ParseBuiltinPrimaryExpression() {
1947 if (Tok.isNot(tok::l_paren))
1948 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
1957 default: llvm_unreachable(
"Not a builtin primary expression!");
1958 case tok::kw___builtin_va_arg: {
1961 if (ExpectAndConsume(tok::comma)) {
1968 if (Tok.isNot(tok::r_paren)) {
1969 Diag(Tok, diag::err_expected) << tok::r_paren;
1979 case tok::kw___builtin_offsetof: {
1987 if (ExpectAndConsume(tok::comma)) {
1993 if (Tok.isNot(tok::identifier)) {
1994 Diag(Tok, diag::err_expected) << tok::identifier;
2003 Comps.back().isBrackets =
false;
2004 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2005 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2009 if (Tok.is(tok::period)) {
2012 Comps.back().isBrackets =
false;
2015 if (Tok.isNot(tok::identifier)) {
2016 Diag(Tok, diag::err_expected) << tok::identifier;
2020 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2023 }
else if (Tok.is(tok::l_square)) {
2024 if (CheckProhibitedCXX11Attribute())
2029 Comps.back().isBrackets =
true;
2032 Comps.back().LocStart = ST.getOpenLocation();
2038 Comps.back().U.E = Res.
get();
2041 Comps.back().LocEnd = ST.getCloseLocation();
2043 if (Tok.isNot(tok::r_paren)) {
2052 PT.getCloseLocation());
2059 case tok::kw___builtin_choose_expr: {
2061 if (Cond.isInvalid()) {
2065 if (ExpectAndConsume(tok::comma)) {
2071 if (Expr1.isInvalid()) {
2075 if (ExpectAndConsume(tok::comma)) {
2081 if (Expr2.isInvalid()) {
2085 if (Tok.isNot(tok::r_paren)) {
2086 Diag(Tok, diag::err_expected) << tok::r_paren;
2090 Expr2.get(), ConsumeParen());
2093 case tok::kw___builtin_astype: {
2096 if (
Expr.isInvalid()) {
2101 if (ExpectAndConsume(tok::comma)) {
2112 if (Tok.isNot(tok::r_paren)) {
2113 Diag(Tok, diag::err_expected) << tok::r_paren;
2122 case tok::kw___builtin_convertvector: {
2125 if (
Expr.isInvalid()) {
2130 if (ExpectAndConsume(tok::comma)) {
2141 if (Tok.isNot(tok::r_paren)) {
2142 Diag(Tok, diag::err_expected) << tok::r_paren;
2158 return ParsePostfixExpressionSuffix(Res.
get());
2187 Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
2190 assert(Tok.is(tok::l_paren) &&
"Not a paren expr!");
2193 if (T.consumeOpen())
2198 bool isAmbiguousTypeId;
2201 if (Tok.is(tok::code_completion)) {
2211 Tok.isOneOf(tok::kw___bridge,
2212 tok::kw___bridge_transfer,
2213 tok::kw___bridge_retained,
2214 tok::kw___bridge_retain));
2215 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2217 StringRef BridgeCastName = Tok.getName();
2220 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2229 if (ExprType >=
CompoundStmt && Tok.is(tok::l_brace)) {
2230 Diag(Tok, diag::ext_gnu_statement_expr);
2233 Result =
ExprError(
Diag(OpenLoc, diag::err_stmtexpr_file_scope));
2239 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
2242 "statement expr not in code context");
2252 if (!
Stmt.isInvalid()) {
2258 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
2264 if (tokenKind == tok::kw___bridge)
2266 else if (tokenKind == tok::kw___bridge_transfer)
2268 else if (tokenKind == tok::kw___bridge_retained)
2273 assert(tokenKind == tok::kw___bridge_retain);
2276 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2278 "__bridge_retained");
2283 ColonProtection.restore();
2284 RParenLoc = T.getCloseLocation();
2285 ExprResult SubExpr = ParseCastExpression(
false);
2291 BridgeKeywordLoc, Ty.
get(),
2292 RParenLoc, SubExpr.
get());
2293 }
else if (ExprType >= CompoundLiteral &&
2294 isTypeIdInParens(isAmbiguousTypeId)) {
2303 if (isAmbiguousTypeId && !stopIfCastExpr) {
2304 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,
2306 RParenLoc = T.getCloseLocation();
2312 ParseSpecifierQualifierList(DS);
2314 ParseDeclarator(DeclaratorInfo);
2319 if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) &&
2333 ColonProtection.restore();
2334 RParenLoc = T.getCloseLocation();
2335 if (Tok.is(tok::l_brace)) {
2336 ExprType = CompoundLiteral;
2342 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2348 if (DeclaratorInfo.isInvalidType())
2353 if (stopIfCastExpr) {
2364 if (Tok.is(tok::identifier) &&
getLangOpts().ObjC1 &&
2365 Tok.getIdentifierInfo() == Ident_super &&
2367 GetLookAheadToken(1).
isNot(tok::period)) {
2368 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2375 Result = ParseCastExpression(
false,
2380 DeclaratorInfo, CastTy,
2381 RParenLoc, Result.
get());
2386 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2389 }
else if (Tok.is(tok::ellipsis) &&
2392 }
else if (isTypeCast) {
2396 ExprVector ArgExprs;
2397 CommaLocsTy CommaLocs;
2399 if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) {
2404 return ParseFoldExpression(Result, T);
2406 ExprType = SimpleExpr;
2419 ExprType = SimpleExpr;
2422 return ParseFoldExpression(Result, T);
2425 if (!Result.
isInvalid() && Tok.is(tok::r_paren))
2437 RParenLoc = T.getCloseLocation();
2450 Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
2453 assert(Tok.is(tok::l_brace) &&
"Not a compound literal!");
2455 Diag(LParenLoc, diag::ext_c99_compound_literal);
2470 ExprResult Parser::ParseStringLiteralExpression(
bool AllowUserDefinedLiteral) {
2471 assert(isTokenStringLiteral() &&
"Not a string literal!");
2478 StringToks.push_back(Tok);
2479 ConsumeStringToken();
2480 }
while (isTokenStringLiteral());
2501 ExprResult Parser::ParseGenericSelectionExpression() {
2502 assert(Tok.is(tok::kw__Generic) &&
"_Generic keyword expected");
2506 Diag(KeyLoc, diag::ext_c11_generic_selection);
2509 if (T.expectAndConsume())
2525 if (ExpectAndConsume(tok::comma)) {
2535 if (Tok.is(tok::kw_default)) {
2539 Diag(Tok, diag::err_duplicate_default_assoc);
2540 Diag(DefaultLoc, diag::note_previous_default_assoc);
2555 Types.push_back(Ty);
2557 if (ExpectAndConsume(tok::colon)) {
2566 if (ER.isInvalid()) {
2570 Exprs.push_back(ER.get());
2574 if (T.getCloseLocation().isInvalid())
2578 T.getCloseLocation(),
2579 ControllingExpr.
get(),
2601 Kind = Tok.getKind();
2606 assert(Tok.is(tok::ellipsis) &&
"not a fold-expression");
2610 if (Tok.isNot(tok::r_paren)) {
2612 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
2614 if (Kind != tok::unknown && Tok.getKind() !=
Kind)
2615 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
2617 Kind = Tok.getKind();
2628 ? diag::warn_cxx14_compat_fold_expression
2629 : diag::ext_fold_expression);
2660 std::function<
void()> Completer) {
2661 bool SawError =
false;
2663 if (Tok.is(tok::code_completion)) {
2674 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2675 Expr = ParseBraceInitializer();
2679 if (Tok.is(tok::ellipsis))
2685 Exprs.push_back(Expr.
get());
2688 if (Tok.isNot(tok::comma))
2696 for (
auto &
E : Exprs) {
2720 Exprs.push_back(Expr.
get());
2722 if (Tok.isNot(tok::comma))
2737 if (Tok.is(tok::code_completion)) {
2739 return cutOffParsing();
2744 ParseSpecifierQualifierList(DS);
2748 ParseDeclarator(DeclaratorInfo);
2750 MaybeParseGNUAttributes(DeclaratorInfo);
2766 ExprResult Parser::ParseBlockLiteralExpression() {
2767 assert(Tok.is(tok::caret) &&
"block literal starts with ^");
2771 "block literal parsing");
2788 ParamInfo.SetSourceRange(
SourceRange(Tok.getLocation(), Tok.getLocation()));
2792 if (Tok.is(tok::l_paren)) {
2793 ParseParenDeclarator(ParamInfo);
2798 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
2799 ParamInfo.SetRangeEnd(Tmp);
2800 if (ParamInfo.isInvalidType()) {
2808 MaybeParseGNUAttributes(ParamInfo);
2812 }
else if (!Tok.is(tok::l_brace)) {
2813 ParseBlockId(CaretLoc);
2843 MaybeParseGNUAttributes(ParamInfo);
2851 if (!Tok.is(tok::l_brace)) {
2853 Diag(Tok, diag::err_expected_expression);
2860 if (!
Stmt.isInvalid())
2880 llvm::SmallSet<StringRef, 4> Platforms;
2881 bool HasOtherPlatformSpec =
false;
2883 for (
const auto &Spec : AvailSpecs) {
2884 if (Spec.isOtherPlatformSpec()) {
2885 if (HasOtherPlatformSpec) {
2886 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
2890 HasOtherPlatformSpec =
true;
2894 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
2899 StringRef Platform = Spec.getPlatform();
2900 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
2901 << Spec.getEndLoc() << Platform;
2906 if (!HasOtherPlatformSpec) {
2907 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
2908 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
2922 if (Tok.is(tok::star)) {
2926 if (Tok.isNot(tok::identifier)) {
2927 Diag(Tok, diag::err_avail_query_expected_platform_name);
2933 VersionTuple Version = ParseVersionTuple(VersionRange);
2935 if (Version.
empty())
2938 StringRef Platform = PlatformIdentifier->
Ident->
getName();
2940 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty()) {
2942 diag::err_avail_query_unrecognized_platform_name)
2953 assert(Tok.is(tok::kw___builtin_available) ||
2954 Tok.isObjCAtKeyword(tok::objc_available));
2960 if (Parens.expectAndConsume())
2964 bool HasError =
false;
2970 AvailSpecs.push_back(*Spec);
2983 if (Parens.consumeClose())
2987 Parens.getCloseLocation());
SourceManager & getSourceManager() const
SourceLocation getCloseLocation() const
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
no exception specification
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
Represents a version number in the form major[.minor[.subminor[.build]]].
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
const LangOptions & getLangOpts() const
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
Bridging via __bridge, which does nothing but reinterpret the bits.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS)
ActionResult< Expr * > ExprResult
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
static bool CheckAvailabilitySpecList(Parser &P, ArrayRef< AvailabilitySpec > AvailSpecs)
Validate availability spec list, emitting diagnostics if necessary.
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer...
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
bool isAtStartOfMacroExpansion(SourceLocation loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the first token of the macro expansion...
const char * getName() const
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
The base class of the type hierarchy.
This indicates that the scope corresponds to a function, which means that labels are set here...
ExprResult ActOnObjCBridgedCast(Scope *S, SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, ParsedType Type, SourceLocation RParenLoc, Expr *SubExpr)
TemplateNameKind Kind
The kind of template that Template refers to.
Parser - This implements a parser for the C family of languages.
TypeCastState
TypeCastState - State whether an expression is or may be a type cast.
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef< Expr * > Args)
RAII object that enters a new expression evaluation context.
void EnterToken(const Token &Tok)
Enters a token in the token stream to be lexed next.
Information about one declarator, including the parsed type information and the identifier.
#define REVERTIBLE_TYPE_TRAIT(Name)
void ActOnStartStmtExpr()
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
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 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 ...
Information about a template-id annotation token.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
Base wrapper for a particular "section" of type source info.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool TryConsumeToken(tok::TokenKind Expected)
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
One of these records is kept for each identifier that is lexed.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Token - This structure provides full information about a lexed token.
ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc)
ActOnCXXNullPtrLiteral - Parse 'nullptr'.
void setKind(tok::TokenKind K)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
SourceRange getExprRange(Expr *E) const
Code completion occurs where only a type is permitted.
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
This is a scope that corresponds to a block/closure object.
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr * > ArgExprs)
Represents a C++ unqualified-id that has been parsed.
ExprResult ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc, MultiExprArg ExecConfig, SourceLocation GGGLoc)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool IsArrow)
Code completion occurs within an expression.
ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)
If a crash happens while one of these objects are live, the message is printed out along with the spe...
ExprResult ActOnCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS, tok::TokenKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc)
Handle a C++1z fold-expression: ( expr op ... op expr ).
Represents a C++ nested-name-specifier or a global scope specifier.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
tok::TokenKind getKind() const
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC...
void ActOnStmtExprError()
CompoundStmt - This represents a group of statements like { stmt stmt }.
TypeResult ParseTypeName(SourceRange *Range=nullptr, Declarator::TheContext Context=Declarator::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
const Type * getTypePtrOrNull() const
Expr - This represents one expression.
StringRef getName() const
Return the actual identifier string.
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, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
This file defines the classes used to store parsed information about declaration-specifiers and decla...
TypeResult ActOnTypeName(Scope *S, Declarator &D)
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
bool isNot(tok::TokenKind K) const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
static bool isFoldOperator(prec::Level Level)
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Wraps an identifier and optional source location for the identifier.
The result type of a method or function.
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion...
const clang::PrintingPolicy & getPrintingPolicy() const
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
Stop skipping at semicolon.
Encodes a location in the source.
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
const TemplateArgument * iterator
bool isValid() const
Return true if this is a valid SourceLocation object.
ASTContext & getASTContext() const
LabelDecl - Represents the declaration of a label.
Scope * getCurScope() const
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
ExprResult ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, IdentifierInfo &propertyName, SourceLocation receiverNameLoc, SourceLocation propertyNameLoc)
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLoc, Expr *Length, SourceLocation RBLoc)
bool isFileContext() 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)) {...
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, ParsedType ObjectType, SourceLocation &TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
SourceLocation getOpenLocation() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input)
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero)...
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_astype(...)
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
detail::InMemoryDirectory::const_iterator E
bool isSimpleTypeSpecifier(tok::TokenKind Kind) const
Determine whether the token kind starts a simple-type-specifier.
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 ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
Bridging via __bridge_retain, which makes an ARC object available as a +1 C pointer.
The name refers to a template whose specialization produces a type.
ExprResult ActOnConstantExpression(ExprResult Res)
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
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...
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)
bool isFunctionType() const
ActionResult< Stmt * > StmtResult
void * getAsOpaquePtr() const
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
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.
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
This is a scope that can contain a declaration.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
static ParsedType getTypeAnnotation(Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
Captures information about "declaration specifiers".
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS)
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, 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...
bool TryAnnotateTypeOrScopeToken(bool EnteringContext=false, bool NeedType=false)
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
static Decl::Kind getKind(const Decl *D)
prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, bool CPlusPlus11)
Return the precedence of the specified binary operator token.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e.g.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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.
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
This class handles loading and caching of source files into memory.
Code completion occurs in a parenthesized expression, which might also be a type cast.
One specifier in an expression.
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
Stop skipping at specified token, but don't skip the token itself.
IdentifierInfo * getIdentifierInfo() const