32 #include "llvm/ADT/SmallVector.h"
33 using namespace clang;
121 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
132 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
139 Parser::ParseExpressionWithLeadingExtension(
SourceLocation ExtLoc) {
145 LHS = ParseCastExpression(
false);
148 if (!LHS.isInvalid())
152 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
157 if (Tok.
is(tok::code_completion)) {
163 if (Tok.
is(tok::kw_throw))
164 return ParseThrowExpression();
165 if (Tok.
is(tok::kw_co_yield))
166 return ParseCoyieldExpression();
184 Parser::ParseAssignmentExprWithObjCMessageExprStart(
SourceLocation LBracLoc,
187 Expr *ReceiverExpr) {
189 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
190 ReceiverType, ReceiverExpr);
191 R = ParsePostfixExpressionSuffix(R);
199 "Call this function only if your ExpressionEvaluationContext is "
200 "already ConstantEvaluated");
201 ExprResult LHS(ParseCastExpression(
false,
false, isTypeCast));
234 bool Parser::isNotExpressionStart() {
236 if (K == tok::l_brace || K == tok::r_brace ||
237 K == tok::kw_for || K == tok::kw_while ||
238 K == tok::kw_if || K == tok::kw_else ||
239 K == tok::kw_goto || K == tok::kw_try)
242 return isKnownToBeDeclarationSpecifier();
250 TentativeParsingAction TPA(*
this);
252 if (
SkipUntil(tok::greater, tok::greatergreater, tok::greatergreatergreater,
257 ParseGreaterThanInTemplateList(Greater,
true,
false);
281 GreaterThanIsOperator,
289 if (NextTokPrec < MinPrec)
296 if (OpToken.
is(tok::caretcaret)) {
297 return ExprError(
Diag(Tok, diag::err_opencl_logical_exclusive_or));
304 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
314 (isKnownToBeDeclarationSpecifier() ||
315 Tok.
isOneOf(tok::greater, tok::greatergreater,
316 tok::greatergreatergreater)) &&
317 diagnoseUnknownTemplateId(LHS, OpToken.
getLocation()))
333 if (Tok.
isNot(tok::colon)) {
342 if (TernaryMiddle.isInvalid()) {
345 TernaryMiddle =
nullptr;
350 TernaryMiddle =
nullptr;
351 Diag(Tok, diag::ext_gnu_conditional_expr);
360 const char *FIText =
": ";
364 bool IsInvalid =
false;
365 const char *SourcePtr =
367 if (!IsInvalid && *SourcePtr ==
' ') {
370 if (!IsInvalid && *SourcePtr ==
' ') {
377 Diag(Tok, diag::err_expected)
379 Diag(OpToken, diag::note_matching) << tok::question;
403 bool RHSIsInitList =
false;
405 RHS = ParseBraceInitializer();
406 RHSIsInitList =
true;
410 RHS = ParseCastExpression(
false);
416 if (TernaryMiddle.isUsable())
433 if (ThisPrec < NextTokPrec ||
434 (ThisPrec == NextTokPrec && isRightAssoc)) {
436 Diag(Tok, diag::err_init_list_bin_op)
445 RHS = ParseRHSOfBinaryExpression(RHS,
446 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
447 RHSIsInitList =
false;
453 if (TernaryMiddle.isUsable())
464 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
467 Diag(OpToken, diag::err_init_list_bin_op)
477 if (TernaryMiddle.isInvalid()) {
481 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
483 diag::warn_cxx11_right_shift_in_template_arg,
492 LHS.
get(), TernaryMiddle.get(),
516 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
517 bool isAddressOfOperand,
518 TypeCastState isTypeCast,
519 bool isVectorLiteral) {
521 ExprResult Res = ParseCastExpression(isUnaryExpression,
527 Diag(Tok, diag::err_expected_expression);
534 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
535 : NextToken(Next), AllowNonTypes(AllowNonTypes) {
536 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
539 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
544 if (isa<TypeDecl>(ND))
545 return WantTypeSpecifiers;
550 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
553 for (
auto *C : candidate) {
555 if (isa<ValueDecl>(ND) && !isa<FunctionDecl>(ND))
739 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
740 bool isAddressOfOperand,
742 TypeCastState isTypeCast,
743 bool isVectorLiteral) {
763 ParenParseOption ParenExprType =
764 (isUnaryExpression && !
getLangOpts().CPlusPlus) ? CompoundLiteral
768 Res = ParseParenExpression(ParenExprType,
false,
774 switch (ParenExprType) {
775 case SimpleExpr:
break;
777 case CompoundLiteral:
791 case tok::numeric_constant:
801 return ParseCXXBoolLiteral();
803 case tok::kw___objc_yes:
804 case tok::kw___objc_no:
805 return ParseObjCBoolLiteral();
807 case tok::kw_nullptr:
808 Diag(Tok, diag::warn_cxx98_compat_nullptr);
811 case tok::annot_primary_expr:
812 assert(Res.
get() ==
nullptr &&
"Stray primary-expression annotation?");
813 Res = getExprAnnotation(Tok);
814 ConsumeAnnotationToken();
817 case tok::kw___super:
818 case tok::kw_decltype:
822 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
823 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
825 case tok::identifier: {
838 if (Next.
is(tok::l_paren) &&
839 Tok.
is(tok::identifier) &&
843 if (RevertibleTypeTraits.empty()) {
844 #define RTT_JOIN(X,Y) X##Y
845 #define REVERTIBLE_TYPE_TRAIT(Name) \
846 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] \
847 = RTT_JOIN(tok::kw_,Name)
900 #undef REVERTIBLE_TYPE_TRAIT
907 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known
908 = RevertibleTypeTraits.find(II);
909 if (Known != RevertibleTypeTraits.end()) {
911 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
912 NotCastExpr, isTypeCast);
916 if ((!ColonIsSacred && Next.
is(tok::colon)) ||
917 Next.
isOneOf(tok::coloncolon, tok::less, tok::l_paren,
922 if (!Tok.
is(tok::identifier))
923 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
939 if (Tok.
is(tok::code_completion) && &II != Ident_super) {
941 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
946 if (Tok.
isNot(tok::identifier) &&
948 Diag(Tok, diag::err_expected_property_name);
963 if (
getLangOpts().ObjC1 && &II == Ident_super && !InMessageExpression &&
965 ((Tok.
is(tok::identifier) &&
967 Tok.
is(tok::code_completion))) {
968 Res = ParseObjCMessageExpressionBody(
SourceLocation(), ILoc,
nullptr,
979 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
980 Tok.
is(tok::code_completion))) {
982 if (Tok.
is(tok::code_completion) ||
983 Next.
is(tok::colon) || Next.
is(tok::r_square))
985 if (Typ.get()->isObjCObjectOrInterfaceType()) {
988 DS.SetRangeStart(ILoc);
989 DS.SetRangeEnd(ILoc);
990 const char *PrevSpec =
nullptr;
992 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
1009 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1010 isAddressOfOperand =
false;
1019 auto Validator = llvm::make_unique<CastExpressionIdValidator>(
1021 Validator->IsAddressOfOperand = isAddressOfOperand;
1022 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
1023 Validator->WantExpressionKeywords =
false;
1024 Validator->WantRemainingKeywords =
false;
1026 Validator->WantRemainingKeywords = Tok.isNot(tok::r_paren);
1030 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren),
1031 isAddressOfOperand, std::move(Validator),
1034 if (!Res.isInvalid() && !Res.get()) {
1035 UnconsumeToken(Replacement);
1036 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1037 NotCastExpr, isTypeCast);
1041 case tok::char_constant:
1042 case tok::wide_char_constant:
1043 case tok::utf8_char_constant:
1044 case tok::utf16_char_constant:
1045 case tok::utf32_char_constant:
1049 case tok::kw___func__:
1050 case tok::kw___FUNCTION__:
1051 case tok::kw___FUNCDNAME__:
1052 case tok::kw___FUNCSIG__:
1053 case tok::kw_L__FUNCTION__:
1054 case tok::kw___PRETTY_FUNCTION__:
1058 case tok::string_literal:
1059 case tok::wide_string_literal:
1060 case tok::utf8_string_literal:
1061 case tok::utf16_string_literal:
1062 case tok::utf32_string_literal:
1063 Res = ParseStringLiteralExpression(
true);
1065 case tok::kw__Generic:
1066 Res = ParseGenericSelectionExpression();
1068 case tok::kw___builtin_available:
1069 return ParseAvailabilityCheckExpr(Tok.getLocation());
1070 case tok::kw___builtin_va_arg:
1071 case tok::kw___builtin_offsetof:
1072 case tok::kw___builtin_choose_expr:
1073 case tok::kw___builtin_astype:
1074 case tok::kw___builtin_convertvector:
1075 return ParseBuiltinPrimaryExpression();
1076 case tok::kw___null:
1080 case tok::minusminus: {
1085 Token SavedTok = Tok;
1096 assert(Res.isInvalid());
1097 UnconsumeToken(SavedTok);
1100 if (!Res.isInvalid())
1102 SavedKind, Res.get());
1108 Res = ParseCastExpression(
false,
true);
1109 if (!Res.isInvalid())
1119 case tok::kw___real:
1120 case tok::kw___imag: {
1122 Res = ParseCastExpression(
false);
1123 if (!Res.isInvalid())
1128 case tok::kw_co_await: {
1130 Res = ParseCastExpression(
false);
1131 if (!Res.isInvalid())
1136 case tok::kw___extension__:{
1140 Res = ParseCastExpression(
false);
1141 if (!Res.isInvalid())
1145 case tok::kw__Alignof:
1147 Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
1149 case tok::kw_alignof:
1150 case tok::kw___alignof:
1152 case tok::kw_sizeof:
1154 case tok::kw_vec_step:
1156 case tok::kw___builtin_omp_required_simd_align:
1157 return ParseUnaryExprOrTypeTraitExpression();
1160 if (Tok.isNot(tok::identifier))
1161 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1164 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1166 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1173 case tok::kw_const_cast:
1174 case tok::kw_dynamic_cast:
1175 case tok::kw_reinterpret_cast:
1176 case tok::kw_static_cast:
1177 Res = ParseCXXCasts();
1179 case tok::kw_typeid:
1180 Res = ParseCXXTypeid();
1182 case tok::kw___uuidof:
1183 Res = ParseCXXUuidof();
1186 Res = ParseCXXThis();
1189 case tok::annot_typename:
1190 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1195 DS.SetRangeStart(Tok.getLocation());
1196 DS.SetRangeEnd(Tok.getLastLoc());
1198 const char *PrevSpec =
nullptr;
1200 DS.SetTypeSpecType(
TST_typename, Tok.getAnnotationEndLoc(),
1201 PrevSpec, DiagID, Type,
1209 ConsumeAnnotationToken();
1216 case tok::annot_decltype:
1218 case tok::kw_wchar_t:
1219 case tok::kw_char16_t:
1220 case tok::kw_char32_t:
1225 case tok::kw___int64:
1226 case tok::kw___int128:
1227 case tok::kw_signed:
1228 case tok::kw_unsigned:
1231 case tok::kw_double:
1232 case tok::kw___float128:
1234 case tok::kw_typename:
1235 case tok::kw_typeof:
1236 case tok::kw___vector:
1237 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1238 #include "clang/Basic/OpenCLImageTypes.def"
1241 Diag(Tok, diag::err_expected_expression);
1245 if (SavedKind == tok::kw_typename) {
1262 ParseCXXSimpleTypeSpecifier(DS);
1263 if (Tok.isNot(tok::l_paren) &&
1264 (!
getLangOpts().CPlusPlus11 || Tok.isNot(tok::l_brace)))
1265 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1266 << DS.getSourceRange());
1268 if (Tok.is(tok::l_brace))
1269 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1271 Res = ParseCXXTypeConstructExpression(DS);
1275 case tok::annot_cxxscope: {
1280 if (!Tok.is(tok::annot_cxxscope))
1281 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1282 NotCastExpr, isTypeCast);
1285 if (Next.
is(tok::annot_template_id)) {
1292 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1294 AnnotateTemplateIdTokenAsType();
1295 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1296 NotCastExpr, isTypeCast);
1301 Res = ParseCXXIdExpression(isAddressOfOperand);
1305 case tok::annot_template_id: {
1311 AnnotateTemplateIdTokenAsType();
1312 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1313 NotCastExpr, isTypeCast);
1320 case tok::kw_operator:
1321 Res = ParseCXXIdExpression(isAddressOfOperand);
1324 case tok::coloncolon: {
1329 if (!Tok.is(tok::coloncolon))
1330 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
1335 if (Tok.is(tok::kw_new))
1336 return ParseCXXNewExpression(
true, CCLoc);
1337 if (Tok.is(tok::kw_delete))
1338 return ParseCXXDeleteExpression(
true, CCLoc);
1341 Diag(CCLoc, diag::err_expected_expression);
1346 return ParseCXXNewExpression(
false, Tok.getLocation());
1348 case tok::kw_delete:
1349 return ParseCXXDeleteExpression(
false, Tok.getLocation());
1351 case tok::kw_noexcept: {
1352 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1356 if (T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1369 Result.
get(), T.getCloseLocation());
1373 #define TYPE_TRAIT(N,Spelling,K) \
1374 case tok::kw_##Spelling:
1375 #include "clang/Basic/TokenKinds.def"
1376 return ParseTypeTrait();
1378 case tok::kw___array_rank:
1379 case tok::kw___array_extent:
1380 return ParseArrayTypeTrait();
1382 case tok::kw___is_lvalue_expr:
1383 case tok::kw___is_rvalue_expr:
1384 return ParseExpressionTrait();
1388 return ParseObjCAtExpression(AtLoc);
1391 Res = ParseBlockLiteralExpression();
1393 case tok::code_completion: {
1406 Res = TryParseLambdaExpression();
1407 if (!Res.isInvalid() && !Res.get())
1408 Res = ParseObjCMessageExpression();
1411 Res = ParseLambdaExpression();
1415 Res = ParseObjCMessageExpression();
1429 Res = ParsePostfixExpressionSuffix(Res);
1431 if (
Expr *PostfixExpr = Res.get()) {
1432 QualType Ty = PostfixExpr->getType();
1434 Diag(PostfixExpr->getExprLoc(),
1435 diag::err_opencl_taking_function_address_parser);
1464 Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1469 switch (Tok.getKind()) {
1470 case tok::code_completion:
1471 if (InMessageExpression)
1478 case tok::identifier:
1482 if (
getLangOpts().ObjC1 && !InMessageExpression &&
1485 nullptr, LHS.
get());
1493 case tok::l_square: {
1500 if (
getLangOpts().ObjC1 && Tok.isAtStartOfLine() &&
1501 isSimpleObjCMessageExpression())
1506 if (CheckProhibitedCXX11Attribute()) {
1513 Loc = T.getOpenLocation();
1517 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1518 Idx = ParseBraceInitializer();
1522 if (!Tok.is(tok::colon)) {
1526 if (Tok.is(tok::colon)) {
1529 if (Tok.isNot(tok::r_square))
1539 Tok.is(tok::r_square)) {
1564 case tok::lesslessless: {
1569 Expr *ExecConfig =
nullptr;
1573 if (OpKind == tok::lesslessless) {
1574 ExprVector ExecConfigExprs;
1575 CommaLocsTy ExecConfigCommaLocs;
1578 if (ParseSimpleExpressionList(ExecConfigExprs, ExecConfigCommaLocs)) {
1589 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1590 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1596 if (ExpectAndConsume(tok::l_paren))
1599 Loc = PrevTokLocation;
1610 ExecConfig = ECResult.
get();
1614 Loc = PT.getOpenLocation();
1617 ExprVector ArgExprs;
1618 CommaLocsTy CommaLocs;
1620 if (Tok.is(tok::code_completion)) {
1626 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1627 if (Tok.isNot(tok::r_paren)) {
1628 if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
1634 for (
auto &
E : ArgExprs)
1643 }
else if (Tok.isNot(tok::r_paren)) {
1644 bool HadDelayedTypo =
false;
1646 HadDelayedTypo =
true;
1647 for (
auto &
E : ArgExprs)
1649 HadDelayedTypo =
true;
1659 assert((ArgExprs.size() == 0 ||
1660 ArgExprs.size()-1 == CommaLocs.size())&&
1661 "Unexpected number of commas!");
1663 ArgExprs, Tok.getLocation(),
1679 bool MayBePseudoDestructor =
false;
1683 if (BaseType && Tok.is(tok::l_paren) &&
1686 Diag(OpLoc, diag::err_function_is_not_record)
1689 return ParsePostfixExpressionSuffix(Base);
1693 OpLoc, OpKind, ObjectType,
1694 MayBePseudoDestructor);
1698 ParseOptionalCXXScopeSpecifier(SS, ObjectType,
1700 &MayBePseudoDestructor);
1702 ObjectType =
nullptr;
1705 if (Tok.is(tok::code_completion)) {
1716 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
1717 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
1731 if (
getLangOpts().ObjC2 && OpKind == tok::period &&
1732 Tok.is(tok::kw_class)) {
1749 ObjectType, TemplateKWLoc, Name)) {
1756 OpKind, SS, TemplateKWLoc,
Name,
1757 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
1762 case tok::minusminus:
1765 Tok.getKind(), LHS.
get());
1797 Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1802 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_sizeof, tok::kw___alignof,
1803 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
1804 tok::kw___builtin_omp_required_simd_align) &&
1805 "Not a typeof/sizeof/alignof/vec_step expression!");
1810 if (Tok.isNot(tok::l_paren)) {
1813 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1814 tok::kw__Alignof)) {
1815 if (isTypeIdUnambiguously()) {
1817 ParseSpecifierQualifierList(DS);
1819 ParseDeclarator(DeclaratorInfo);
1823 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
1839 Operand = ParseCastExpression(
true);
1845 ParenParseOption ExprType =
CastExpr;
1848 Operand = ParseParenExpression(ExprType,
true,
1849 false, CastTy, RParenLoc);
1864 if (!Operand.isInvalid())
1865 Operand = ParsePostfixExpressionSuffix(Operand.get());
1887 ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
1888 assert(Tok.isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1889 tok::kw__Alignof, tok::kw_vec_step,
1890 tok::kw___builtin_omp_required_simd_align) &&
1891 "Not a sizeof/alignof/vec_step expression!");
1896 if (Tok.is(tok::ellipsis) && OpTok.is(tok::kw_sizeof)) {
1901 if (Tok.is(tok::l_paren)) {
1904 LParenLoc = T.getOpenLocation();
1905 if (Tok.is(tok::identifier)) {
1906 Name = Tok.getIdentifierInfo();
1909 RParenLoc = T.getCloseLocation();
1913 Diag(Tok, diag::err_expected_parameter_pack);
1916 }
else if (Tok.is(tok::identifier)) {
1917 Name = Tok.getIdentifierInfo();
1921 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
1926 Diag(Tok, diag::err_sizeof_parameter_pack);
1937 OpTok.getLocation(),
1942 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
1943 Diag(OpTok, diag::warn_cxx98_compat_alignof);
1952 ExprResult Operand = ParseExprAfterUnaryExprOrTypeTrait(OpTok,
1958 if (OpTok.isOneOf(tok::kw_alignof, tok::kw___alignof, tok::kw__Alignof))
1960 else if (OpTok.is(tok::kw_vec_step))
1962 else if (OpTok.is(tok::kw___builtin_omp_required_simd_align))
1972 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
1973 Diag(OpTok, diag::ext_alignof_expr) << OpTok.getIdentifierInfo();
2001 ExprResult Parser::ParseBuiltinPrimaryExpression() {
2009 if (Tok.isNot(tok::l_paren))
2010 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2019 default: llvm_unreachable(
"Not a builtin primary expression!");
2020 case tok::kw___builtin_va_arg: {
2023 if (ExpectAndConsume(tok::comma)) {
2030 if (Tok.isNot(tok::r_paren)) {
2031 Diag(Tok, diag::err_expected) << tok::r_paren;
2041 case tok::kw___builtin_offsetof: {
2049 if (ExpectAndConsume(tok::comma)) {
2055 if (Tok.isNot(tok::identifier)) {
2056 Diag(Tok, diag::err_expected) << tok::identifier;
2065 Comps.back().isBrackets =
false;
2066 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2067 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2071 if (Tok.is(tok::period)) {
2074 Comps.back().isBrackets =
false;
2077 if (Tok.isNot(tok::identifier)) {
2078 Diag(Tok, diag::err_expected) << tok::identifier;
2082 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2085 }
else if (Tok.is(tok::l_square)) {
2086 if (CheckProhibitedCXX11Attribute())
2091 Comps.back().isBrackets =
true;
2094 Comps.back().LocStart = ST.getOpenLocation();
2100 Comps.back().U.E = Res.
get();
2103 Comps.back().LocEnd = ST.getCloseLocation();
2105 if (Tok.isNot(tok::r_paren)) {
2114 PT.getCloseLocation());
2121 case tok::kw___builtin_choose_expr: {
2123 if (Cond.isInvalid()) {
2127 if (ExpectAndConsume(tok::comma)) {
2133 if (Expr1.isInvalid()) {
2137 if (ExpectAndConsume(tok::comma)) {
2143 if (Expr2.isInvalid()) {
2147 if (Tok.isNot(tok::r_paren)) {
2148 Diag(Tok, diag::err_expected) << tok::r_paren;
2152 Expr2.get(), ConsumeParen());
2155 case tok::kw___builtin_astype: {
2158 if (
Expr.isInvalid()) {
2163 if (ExpectAndConsume(tok::comma)) {
2174 if (Tok.isNot(tok::r_paren)) {
2175 Diag(Tok, diag::err_expected) << tok::r_paren;
2184 case tok::kw___builtin_convertvector: {
2187 if (
Expr.isInvalid()) {
2192 if (ExpectAndConsume(tok::comma)) {
2203 if (Tok.isNot(tok::r_paren)) {
2204 Diag(Tok, diag::err_expected) << tok::r_paren;
2220 return ParsePostfixExpressionSuffix(Res.
get());
2249 Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
2252 assert(Tok.is(tok::l_paren) &&
"Not a paren expr!");
2255 if (T.consumeOpen())
2260 bool isAmbiguousTypeId;
2263 if (Tok.is(tok::code_completion)) {
2273 Tok.isOneOf(tok::kw___bridge,
2274 tok::kw___bridge_transfer,
2275 tok::kw___bridge_retained,
2276 tok::kw___bridge_retain));
2277 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2279 StringRef BridgeCastName = Tok.getName();
2282 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2291 if (ExprType >=
CompoundStmt && Tok.is(tok::l_brace)) {
2292 Diag(Tok, diag::ext_gnu_statement_expr);
2295 Result =
ExprError(
Diag(OpenLoc, diag::err_stmtexpr_file_scope));
2301 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
2304 "statement expr not in code context");
2314 if (!
Stmt.isInvalid()) {
2320 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
2326 if (tokenKind == tok::kw___bridge)
2328 else if (tokenKind == tok::kw___bridge_transfer)
2330 else if (tokenKind == tok::kw___bridge_retained)
2335 assert(tokenKind == tok::kw___bridge_retain);
2338 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2340 "__bridge_retained");
2345 ColonProtection.restore();
2346 RParenLoc = T.getCloseLocation();
2347 ExprResult SubExpr = ParseCastExpression(
false);
2353 BridgeKeywordLoc, Ty.
get(),
2354 RParenLoc, SubExpr.
get());
2355 }
else if (ExprType >= CompoundLiteral &&
2356 isTypeIdInParens(isAmbiguousTypeId)) {
2365 if (isAmbiguousTypeId && !stopIfCastExpr) {
2366 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,
2368 RParenLoc = T.getCloseLocation();
2374 ParseSpecifierQualifierList(DS);
2376 ParseDeclarator(DeclaratorInfo);
2381 if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) &&
2395 ColonProtection.restore();
2396 RParenLoc = T.getCloseLocation();
2397 if (Tok.is(tok::l_brace)) {
2398 ExprType = CompoundLiteral;
2404 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2407 if (Tok.is(tok::l_paren)) {
2428 Result = ParseCastExpression(
false,
2435 DeclaratorInfo, CastTy,
2436 RParenLoc, Result.
get());
2441 Result = ParsePostfixExpressionSuffix(Result);
2452 if (DeclaratorInfo.isInvalidType())
2457 if (stopIfCastExpr) {
2468 if (Tok.is(tok::identifier) &&
getLangOpts().ObjC1 &&
2469 Tok.getIdentifierInfo() == Ident_super &&
2471 GetLookAheadToken(1).
isNot(tok::period)) {
2472 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2479 Result = ParseCastExpression(
false,
2484 DeclaratorInfo, CastTy,
2485 RParenLoc, Result.
get());
2490 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2493 }
else if (Tok.is(tok::ellipsis) &&
2496 }
else if (isTypeCast) {
2500 ExprVector ArgExprs;
2501 CommaLocsTy CommaLocs;
2503 if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) {
2508 return ParseFoldExpression(ArgExprs[0], T);
2510 ExprType = SimpleExpr;
2523 ExprType = SimpleExpr;
2526 return ParseFoldExpression(Result, T);
2529 if (!Result.
isInvalid() && Tok.is(tok::r_paren))
2541 RParenLoc = T.getCloseLocation();
2554 Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
2557 assert(Tok.is(tok::l_brace) &&
"Not a compound literal!");
2559 Diag(LParenLoc, diag::ext_c99_compound_literal);
2574 ExprResult Parser::ParseStringLiteralExpression(
bool AllowUserDefinedLiteral) {
2575 assert(isTokenStringLiteral() &&
"Not a string literal!");
2582 StringToks.push_back(Tok);
2583 ConsumeStringToken();
2584 }
while (isTokenStringLiteral());
2605 ExprResult Parser::ParseGenericSelectionExpression() {
2606 assert(Tok.is(tok::kw__Generic) &&
"_Generic keyword expected");
2610 Diag(KeyLoc, diag::ext_c11_generic_selection);
2613 if (T.expectAndConsume())
2630 if (ExpectAndConsume(tok::comma)) {
2640 if (Tok.is(tok::kw_default)) {
2644 Diag(Tok, diag::err_duplicate_default_assoc);
2645 Diag(DefaultLoc, diag::note_previous_default_assoc);
2660 Types.push_back(Ty);
2662 if (ExpectAndConsume(tok::colon)) {
2671 if (ER.isInvalid()) {
2675 Exprs.push_back(ER.get());
2679 if (T.getCloseLocation().isInvalid())
2683 T.getCloseLocation(),
2684 ControllingExpr.
get(),
2706 Kind = Tok.getKind();
2711 assert(Tok.is(tok::ellipsis) &&
"not a fold-expression");
2715 if (Tok.isNot(tok::r_paren)) {
2717 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
2719 if (Kind != tok::unknown && Tok.getKind() !=
Kind)
2720 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
2722 Kind = Tok.getKind();
2733 ? diag::warn_cxx14_compat_fold_expression
2734 : diag::ext_fold_expression);
2765 std::function<
void()> Completer) {
2766 bool SawError =
false;
2768 if (Tok.is(tok::code_completion)) {
2779 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2780 Expr = ParseBraceInitializer();
2784 if (Tok.is(tok::ellipsis))
2790 Exprs.push_back(Expr.
get());
2793 if (Tok.isNot(tok::comma))
2801 for (
auto &
E : Exprs) {
2825 Exprs.push_back(Expr.
get());
2827 if (Tok.isNot(tok::comma))
2842 if (Tok.is(tok::code_completion)) {
2844 return cutOffParsing();
2849 ParseSpecifierQualifierList(DS);
2854 ParseDeclarator(DeclaratorInfo);
2856 MaybeParseGNUAttributes(DeclaratorInfo);
2872 ExprResult Parser::ParseBlockLiteralExpression() {
2873 assert(Tok.is(tok::caret) &&
"block literal starts with ^");
2877 "block literal parsing");
2895 ParamInfo.SetSourceRange(
SourceRange(Tok.getLocation(), Tok.getLocation()));
2899 if (Tok.is(tok::l_paren)) {
2900 ParseParenDeclarator(ParamInfo);
2905 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
2906 ParamInfo.SetRangeEnd(Tmp);
2907 if (ParamInfo.isInvalidType()) {
2915 MaybeParseGNUAttributes(ParamInfo);
2919 }
else if (!Tok.is(tok::l_brace)) {
2920 ParseBlockId(CaretLoc);
2951 MaybeParseGNUAttributes(ParamInfo);
2959 if (!Tok.is(tok::l_brace)) {
2961 Diag(Tok, diag::err_expected_expression);
2968 if (!
Stmt.isInvalid())
2988 llvm::SmallSet<StringRef, 4> Platforms;
2989 bool HasOtherPlatformSpec =
false;
2991 for (
const auto &Spec : AvailSpecs) {
2992 if (Spec.isOtherPlatformSpec()) {
2993 if (HasOtherPlatformSpec) {
2994 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
2998 HasOtherPlatformSpec =
true;
3002 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3007 StringRef Platform = Spec.getPlatform();
3008 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3009 << Spec.getEndLoc() << Platform;
3014 if (!HasOtherPlatformSpec) {
3015 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3016 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3030 if (Tok.is(tok::star)) {
3034 if (Tok.is(tok::code_completion)) {
3039 if (Tok.isNot(tok::identifier)) {
3040 Diag(Tok, diag::err_avail_query_expected_platform_name);
3046 VersionTuple Version = ParseVersionTuple(VersionRange);
3048 if (Version.
empty())
3051 StringRef GivenPlatform = PlatformIdentifier->
Ident->
getName();
3052 StringRef Platform =
3053 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3055 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty()) {
3057 diag::err_avail_query_unrecognized_platform_name)
3068 assert(Tok.is(tok::kw___builtin_available) ||
3069 Tok.isObjCAtKeyword(tok::objc_available));
3075 if (Parens.expectAndConsume())
3079 bool HasError =
false;
3085 AvailSpecs.push_back(*Spec);
3098 if (Parens.consumeClose())
3102 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.
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
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.
Stmt - This represents one statement.
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
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.
void CodeCompleteObjCClassPropertyRefExpr(Scope *S, IdentifierInfo &ClassName, SourceLocation ClassNameLoc, bool IsBaseExprStatement)
#define REVERTIBLE_TYPE_TRAIT(Name)
void ActOnStartStmtExpr()
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, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
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.
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.
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, ParsedType ObjectType, SourceLocation &TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
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.
static ParsedType getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
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.
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...
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
void ActOnStmtExprError()
void CodeCompleteAvailabilityPlatformName()
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.
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.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
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(...)
bool TryAnnotateTypeOrScopeToken()
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
bool isValid() const
Return true if this is a valid SourceLocation object.
ASTContext & getASTContext() 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, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
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 isVectorType() 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)) {...
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
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
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void * getAsOpaquePtr() const
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool IsArrow, bool IsBaseExprStatement)
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)
bool mightBeIntendedToBeTemplateName(ExprResult E)
Determine whether it's plausible that E was intended to be a template-name.
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)
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)
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...
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...
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
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.
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.
SourceLocation getLocStart() const LLVM_READONLY
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