31 #include "llvm/ADT/SmallVector.h" 32 using namespace clang;
124 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
135 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
142 Parser::ParseExpressionWithLeadingExtension(
SourceLocation ExtLoc) {
148 LHS = ParseCastExpression(
false);
155 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
160 if (Tok.
is(tok::code_completion)) {
167 if (Tok.
is(tok::kw_throw))
168 return ParseThrowExpression();
169 if (Tok.
is(tok::kw_co_yield))
170 return ParseCoyieldExpression();
188 Parser::ParseAssignmentExprWithObjCMessageExprStart(
SourceLocation LBracLoc,
191 Expr *ReceiverExpr) {
193 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
194 ReceiverType, ReceiverExpr);
195 R = ParsePostfixExpressionSuffix(R);
203 "Call this function only if your ExpressionEvaluationContext is " 204 "already ConstantEvaluated");
205 ExprResult LHS(ParseCastExpression(
false,
false, isTypeCast));
246 bool Parser::isNotExpressionStart() {
248 if (K == tok::l_brace || K == tok::r_brace ||
249 K == tok::kw_for || K == tok::kw_while ||
250 K == tok::kw_if || K == tok::kw_else ||
251 K == tok::kw_goto || K == tok::kw_try)
254 return isKnownToBeDeclarationSpecifier();
271 GreaterThanIsOperator,
275 auto SavedType = PreferredType;
278 PreferredType = SavedType;
282 if (NextTokPrec < MinPrec)
289 if (OpToken.
is(tok::caretcaret)) {
290 return ExprError(
Diag(Tok, diag::err_opencl_logical_exclusive_or));
295 if (OpToken.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
296 tok::greatergreatergreater) &&
297 checkPotentialAngleBracketDelimiter(OpToken))
305 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
313 if (isFoldOperator(NextTokPrec) && Tok.
is(tok::ellipsis)) {
327 Tok.
isOneOf(tok::colon, tok::r_square) &&
340 TernaryMiddle = ParseBraceInitializer();
342 Diag(BraceLoc, diag::err_init_list_bin_op)
347 }
else if (Tok.
isNot(tok::colon)) {
359 TernaryMiddle =
nullptr;
360 Diag(Tok, diag::ext_gnu_conditional_expr);
366 TernaryMiddle =
nullptr;
375 const char *FIText =
": ";
379 bool IsInvalid =
false;
380 const char *SourcePtr =
382 if (!IsInvalid && *SourcePtr ==
' ') {
385 if (!IsInvalid && *SourcePtr ==
' ') {
392 Diag(Tok, diag::err_expected)
394 Diag(OpToken, diag::note_matching) << tok::question;
412 bool RHSIsInitList =
false;
414 RHS = ParseBraceInitializer();
415 RHSIsInitList =
true;
419 RHS = ParseCastExpression(
false);
442 if (ThisPrec < NextTokPrec ||
443 (ThisPrec == NextTokPrec && isRightAssoc)) {
445 Diag(Tok, diag::err_init_list_bin_op)
454 RHS = ParseRHSOfBinaryExpression(RHS,
455 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
456 RHSIsInitList =
false;
473 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
475 }
else if (ColonLoc.isValid()) {
476 Diag(ColonLoc, diag::err_init_list_bin_op)
481 Diag(OpToken, diag::err_init_list_bin_op)
495 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
497 diag::warn_cxx11_right_shift_in_template_arg,
506 LHS.
get(), TernaryMiddle.
get(),
530 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
531 bool isAddressOfOperand,
533 bool isVectorLiteral) {
535 ExprResult Res = ParseCastExpression(isUnaryExpression,
541 Diag(Tok, diag::err_expected_expression);
548 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
549 :
NextToken(Next), AllowNonTypes(AllowNonTypes) {
550 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
553 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
558 if (isa<TypeDecl>(ND))
559 return WantTypeSpecifiers;
567 for (
auto *
C : candidate) {
569 if (isa<ValueDecl>(ND) && !isa<FunctionDecl>(ND))
575 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
576 return llvm::make_unique<CastExpressionIdValidator>(*this);
764 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
765 bool isAddressOfOperand,
768 bool isVectorLiteral) {
771 auto SavedType = PreferredType;
789 ParenParseOption ParenExprType =
790 (isUnaryExpression && !
getLangOpts().CPlusPlus) ? CompoundLiteral
794 Res = ParseParenExpression(ParenExprType,
false,
800 switch (ParenExprType) {
801 case SimpleExpr:
break;
803 case CompoundLiteral:
821 case tok::numeric_constant:
825 Res = Actions.ActOnNumericConstant(Tok,
getCurScope());
831 Res = ParseCXXBoolLiteral();
834 case tok::kw___objc_yes:
835 case tok::kw___objc_no:
836 return ParseObjCBoolLiteral();
838 case tok::kw_nullptr:
839 Diag(Tok, diag::warn_cxx98_compat_nullptr);
842 case tok::annot_primary_expr:
843 assert(Res.
get() ==
nullptr &&
"Stray primary-expression annotation?");
844 Res = getExprAnnotation(Tok);
845 ConsumeAnnotationToken();
846 if (!Res.isInvalid() && Tok.
is(tok::less))
847 checkPotentialAngleBracket(Res);
850 case tok::kw___super:
851 case tok::kw_decltype:
855 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
856 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
858 case tok::identifier: {
871 if (Next.
is(tok::l_paren) &&
872 Tok.
is(tok::identifier) &&
873 Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
876 if (RevertibleTypeTraits.empty()) {
877 #define RTT_JOIN(X,Y) X##Y 878 #define REVERTIBLE_TYPE_TRAIT(Name) \ 879 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] \ 880 = RTT_JOIN(tok::kw_,Name) 933 #undef REVERTIBLE_TYPE_TRAIT 940 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known
941 = RevertibleTypeTraits.find(II);
942 if (Known != RevertibleTypeTraits.end()) {
943 Tok.setKind(Known->second);
944 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
945 NotCastExpr, isTypeCast);
949 if ((!ColonIsSacred && Next.
is(tok::colon)) ||
950 Next.
isOneOf(tok::coloncolon, tok::less, tok::l_paren,
955 if (!Tok.
is(tok::identifier))
956 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
972 if (Tok.
is(tok::code_completion) && &II != Ident_super) {
973 Actions.CodeCompleteObjCClassPropertyRefExpr(
974 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
979 if (Tok.
isNot(tok::identifier) &&
981 Diag(Tok, diag::err_expected_property_name);
987 Res = Actions.ActOnClassPropertyRefExpr(II, PropertyName,
996 if (
getLangOpts().ObjC && &II == Ident_super && !InMessageExpression &&
998 ((Tok.
is(tok::identifier) &&
1000 Tok.
is(tok::code_completion))) {
1001 Res = ParseObjCMessageExpressionBody(
SourceLocation(), ILoc,
nullptr,
1012 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
1013 Tok.
is(tok::code_completion))) {
1015 if (Tok.
is(tok::code_completion) ||
1016 Next.
is(tok::colon) || Next.
is(tok::r_square))
1018 if (Typ.get()->isObjCObjectOrInterfaceType()) {
1023 const char *PrevSpec =
nullptr;
1026 Actions.getASTContext().getPrintingPolicy());
1042 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1043 isAddressOfOperand =
false;
1052 CastExpressionIdValidator Validator(
1056 Validator.IsAddressOfOperand = isAddressOfOperand;
1057 if (Tok.
isOneOf(tok::periodstar, tok::arrowstar)) {
1058 Validator.WantExpressionKeywords =
false;
1059 Validator.WantRemainingKeywords =
false;
1061 Validator.WantRemainingKeywords = Tok.
isNot(tok::r_paren);
1064 Res = Actions.ActOnIdExpression(
1065 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
1066 isAddressOfOperand, &Validator,
1068 Tok.
is(tok::r_paren) ? nullptr : &Replacement);
1069 if (!Res.isInvalid() && Res.isUnset()) {
1070 UnconsumeToken(Replacement);
1071 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1072 NotCastExpr, isTypeCast);
1074 if (!Res.isInvalid() && Tok.
is(tok::less))
1075 checkPotentialAngleBracket(Res);
1078 case tok::char_constant:
1079 case tok::wide_char_constant:
1080 case tok::utf8_char_constant:
1081 case tok::utf16_char_constant:
1082 case tok::utf32_char_constant:
1083 Res = Actions.ActOnCharacterConstant(Tok,
getCurScope());
1086 case tok::kw___func__:
1087 case tok::kw___FUNCTION__:
1088 case tok::kw___FUNCDNAME__:
1089 case tok::kw___FUNCSIG__:
1090 case tok::kw_L__FUNCTION__:
1091 case tok::kw_L__FUNCSIG__:
1092 case tok::kw___PRETTY_FUNCTION__:
1093 Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
1096 case tok::string_literal:
1097 case tok::wide_string_literal:
1098 case tok::utf8_string_literal:
1099 case tok::utf16_string_literal:
1100 case tok::utf32_string_literal:
1101 Res = ParseStringLiteralExpression(
true);
1103 case tok::kw__Generic:
1104 Res = ParseGenericSelectionExpression();
1106 case tok::kw___builtin_available:
1107 return ParseAvailabilityCheckExpr(Tok.getLocation());
1108 case tok::kw___builtin_va_arg:
1109 case tok::kw___builtin_offsetof:
1110 case tok::kw___builtin_choose_expr:
1111 case tok::kw___builtin_astype:
1112 case tok::kw___builtin_convertvector:
1113 case tok::kw___builtin_COLUMN:
1114 case tok::kw___builtin_FILE:
1115 case tok::kw___builtin_FUNCTION:
1116 case tok::kw___builtin_LINE:
1117 return ParseBuiltinPrimaryExpression();
1118 case tok::kw___null:
1122 case tok::minusminus: {
1127 Token SavedTok = Tok;
1130 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedTok.
getKind(),
1141 assert(Res.isInvalid());
1142 UnconsumeToken(SavedTok);
1145 if (!Res.isInvalid())
1147 SavedKind, Res.get());
1153 PreferredType.enterUnary(Actions, Tok.getLocation(), tok::amp, SavedLoc);
1154 Res = ParseCastExpression(
false,
true);
1155 if (!Res.isInvalid())
1156 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1165 case tok::kw___real:
1166 case tok::kw___imag: {
1168 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedKind, SavedLoc);
1169 Res = ParseCastExpression(
false);
1170 if (!Res.isInvalid())
1171 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1175 case tok::kw_co_await: {
1177 Res = ParseCastExpression(
false);
1178 if (!Res.isInvalid())
1179 Res = Actions.ActOnCoawaitExpr(
getCurScope(), CoawaitLoc, Res.get());
1183 case tok::kw___extension__:{
1187 Res = ParseCastExpression(
false);
1188 if (!Res.isInvalid())
1189 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1192 case tok::kw__Alignof:
1194 Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
1196 case tok::kw_alignof:
1197 case tok::kw___alignof:
1199 case tok::kw_sizeof:
1201 case tok::kw_vec_step:
1203 case tok::kw___builtin_omp_required_simd_align:
1204 return ParseUnaryExprOrTypeTraitExpression();
1207 if (Tok.
isNot(tok::identifier))
1208 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1211 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1213 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1214 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(),
1216 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD);
1220 case tok::kw_const_cast:
1221 case tok::kw_dynamic_cast:
1222 case tok::kw_reinterpret_cast:
1223 case tok::kw_static_cast:
1224 Res = ParseCXXCasts();
1226 case tok::kw___builtin_bit_cast:
1227 Res = ParseBuiltinBitCast();
1229 case tok::kw_typeid:
1230 Res = ParseCXXTypeid();
1232 case tok::kw___uuidof:
1233 Res = ParseCXXUuidof();
1236 Res = ParseCXXThis();
1239 case tok::annot_typename:
1240 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1248 const char *PrevSpec =
nullptr;
1251 PrevSpec, DiagID, Type,
1252 Actions.getASTContext().getPrintingPolicy());
1259 ConsumeAnnotationToken();
1266 case tok::annot_decltype:
1268 case tok::kw_wchar_t:
1269 case tok::kw_char8_t:
1270 case tok::kw_char16_t:
1271 case tok::kw_char32_t:
1276 case tok::kw___int64:
1277 case tok::kw___int128:
1278 case tok::kw_signed:
1279 case tok::kw_unsigned:
1282 case tok::kw_double:
1283 case tok::kw__Float16:
1284 case tok::kw___float128:
1286 case tok::kw_typename:
1287 case tok::kw_typeof:
1288 case tok::kw___vector:
1289 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: 1290 #include "clang/Basic/OpenCLImageTypes.def" 1293 Diag(Tok, diag::err_expected_expression);
1297 if (SavedKind == tok::kw_typename) {
1303 if (!Actions.isSimpleTypeSpecifier(Tok.getKind()))
1314 ParseCXXSimpleTypeSpecifier(DS);
1315 if (Tok.
isNot(tok::l_paren) &&
1317 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1320 if (Tok.
is(tok::l_brace))
1321 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1323 Res = ParseCXXTypeConstructExpression(DS);
1327 case tok::annot_cxxscope: {
1332 if (!Tok.
is(tok::annot_cxxscope))
1333 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1334 NotCastExpr, isTypeCast);
1337 if (Next.
is(tok::annot_template_id)) {
1344 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1346 AnnotateTemplateIdTokenAsType();
1347 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1348 NotCastExpr, isTypeCast);
1353 Res = ParseCXXIdExpression(isAddressOfOperand);
1357 case tok::annot_template_id: {
1363 AnnotateTemplateIdTokenAsType();
1364 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1365 NotCastExpr, isTypeCast);
1372 case tok::kw_operator:
1373 Res = ParseCXXIdExpression(isAddressOfOperand);
1376 case tok::coloncolon: {
1381 if (!Tok.
is(tok::coloncolon))
1382 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
1387 if (Tok.
is(tok::kw_new))
1388 return ParseCXXNewExpression(
true, CCLoc);
1389 if (Tok.
is(tok::kw_delete))
1390 return ParseCXXDeleteExpression(
true, CCLoc);
1393 Diag(CCLoc, diag::err_expected_expression);
1398 return ParseCXXNewExpression(
false, Tok.getLocation());
1400 case tok::kw_delete:
1401 return ParseCXXDeleteExpression(
false, Tok.getLocation());
1403 case tok::kw_noexcept: {
1404 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1425 #define TYPE_TRAIT(N,Spelling,K) \ 1426 case tok::kw_##Spelling: 1427 #include "clang/Basic/TokenKinds.def" 1428 return ParseTypeTrait();
1430 case tok::kw___array_rank:
1431 case tok::kw___array_extent:
1432 return ParseArrayTypeTrait();
1434 case tok::kw___is_lvalue_expr:
1435 case tok::kw___is_rvalue_expr:
1436 return ParseExpressionTrait();
1440 return ParseObjCAtExpression(AtLoc);
1443 Res = ParseBlockLiteralExpression();
1445 case tok::code_completion: {
1447 PreferredType.get(Tok.getLocation()));
1459 Res = TryParseLambdaExpression();
1460 if (!Res.isInvalid() && !Res.get())
1461 Res = ParseObjCMessageExpression();
1464 Res = ParseLambdaExpression();
1468 Res = ParseObjCMessageExpression();
1482 PreferredType = SavedType;
1483 Res = ParsePostfixExpressionSuffix(Res);
1485 if (
Expr *PostfixExpr = Res.
get()) {
1486 QualType Ty = PostfixExpr->getType();
1488 Diag(PostfixExpr->getExprLoc(),
1489 diag::err_opencl_taking_function_address_parser);
1518 Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1522 auto SavedType = PreferredType;
1525 PreferredType = SavedType;
1526 switch (Tok.getKind()) {
1527 case tok::code_completion:
1528 if (InMessageExpression)
1531 Actions.CodeCompletePostfixExpression(
1536 case tok::identifier:
1543 nullptr, LHS.
get());
1551 case tok::l_square: {
1558 if (
getLangOpts().ObjC && Tok.isAtStartOfLine() &&
1559 isSimpleObjCMessageExpression())
1564 if (CheckProhibitedCXX11Attribute()) {
1565 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1574 PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.
get());
1576 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1577 Idx = ParseBraceInitializer();
1581 if (!Tok.
is(tok::colon)) {
1585 if (Tok.
is(tok::colon)) {
1588 if (Tok.
isNot(tok::r_square))
1596 LHS = Actions.CorrectDelayedTyposInExpr(LHS);
1597 Idx = Actions.CorrectDelayedTyposInExpr(Idx);
1598 Length = Actions.CorrectDelayedTyposInExpr(Length);
1600 Tok.
is(tok::r_square)) {
1602 LHS = Actions.ActOnOMPArraySectionExpr(LHS.
get(), Loc, Idx.
get(),
1605 LHS = Actions.ActOnArraySubscriptExpr(
getCurScope(), LHS.
get(), Loc,
1619 case tok::lesslessless: {
1624 Expr *ExecConfig =
nullptr;
1628 if (OpKind == tok::lesslessless) {
1633 if (ParseSimpleExpressionList(ExecConfigExprs, ExecConfigCommaLocs)) {
1634 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1644 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1645 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1651 if (ExpectAndConsume(tok::l_paren))
1654 Loc = PrevTokLocation;
1665 ExecConfig = ECResult.
get();
1674 auto RunSignatureHelp = [&]() ->
QualType {
1675 QualType PreferredType = Actions.ProduceCallSignatureHelp(
1677 CalledSignatureHelp =
true;
1678 return PreferredType;
1680 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1681 if (Tok.
isNot(tok::r_paren)) {
1682 if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
1683 PreferredType.enterFunctionArgument(Tok.getLocation(),
1686 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1691 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
1695 for (
auto &E : ArgExprs)
1696 Actions.CorrectDelayedTyposInExpr(E);
1704 }
else if (Tok.
isNot(tok::r_paren)) {
1705 bool HadDelayedTypo =
false;
1706 if (Actions.CorrectDelayedTyposInExpr(LHS).get() != LHS.
get())
1707 HadDelayedTypo =
true;
1708 for (
auto &E : ArgExprs)
1709 if (Actions.CorrectDelayedTyposInExpr(E).get() != E)
1710 HadDelayedTypo =
true;
1720 assert((ArgExprs.size() == 0 ||
1721 ArgExprs.size()-1 == CommaLocs.size())&&
1722 "Unexpected number of commas!");
1724 ArgExprs, Tok.getLocation(),
1740 bool MayBePseudoDestructor =
false;
1743 PreferredType.enterMemAccess(Actions, Tok.getLocation(), OrigLHS);
1748 if (BaseType && Tok.
is(tok::l_paren) &&
1751 Diag(OpLoc, diag::err_function_is_not_record)
1754 return ParsePostfixExpressionSuffix(Base);
1757 LHS = Actions.ActOnStartCXXMemberReference(
getCurScope(), Base,
1758 OpLoc, OpKind, ObjectType,
1759 MayBePseudoDestructor);
1763 ParseOptionalCXXScopeSpecifier(SS, ObjectType,
1765 &MayBePseudoDestructor);
1767 ObjectType =
nullptr;
1770 if (Tok.
is(tok::code_completion)) {
1772 OpKind == tok::arrow ? tok::period : tok::arrow;
1775 const bool DiagsAreSuppressed = Diags.getSuppressAllDiagnostics();
1776 Diags.setSuppressAllDiagnostics(
true);
1777 CorrectedLHS = Actions.ActOnStartCXXMemberReference(
1778 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
1779 MayBePseudoDestructor);
1780 Diags.setSuppressAllDiagnostics(DiagsAreSuppressed);
1784 Expr *CorrectedBase = CorrectedLHS.
get();
1786 CorrectedBase = Base;
1789 Actions.CodeCompleteMemberReferenceExpr(
1790 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,
1791 Base && ExprStatementTokLoc == Base->
getBeginLoc(),
1792 PreferredType.get(Tok.getLocation()));
1798 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
1799 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
1813 if (
getLangOpts().ObjC && OpKind == tok::period &&
1814 Tok.
is(tok::kw_class)) {
1832 ObjectType, &TemplateKWLoc, Name)) {
1833 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1838 LHS = Actions.ActOnMemberAccessExpr(
getCurScope(), LHS.
get(), OpLoc,
1839 OpKind, SS, TemplateKWLoc, Name,
1840 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
1843 checkPotentialAngleBracket(LHS);
1847 case tok::minusminus:
1849 LHS = Actions.ActOnPostfixUnaryOp(
getCurScope(), Tok.getLocation(),
1850 Tok.getKind(), LHS.
get());
1882 Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1887 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_sizeof, tok::kw___alignof,
1888 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
1889 tok::kw___builtin_omp_required_simd_align) &&
1890 "Not a typeof/sizeof/alignof/vec_step expression!");
1895 if (Tok.
isNot(tok::l_paren)) {
1898 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1899 tok::kw__Alignof)) {
1900 if (isTypeIdUnambiguously()) {
1902 ParseSpecifierQualifierList(DS);
1904 ParseDeclarator(DeclaratorInfo);
1907 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
1908 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
1924 Operand = ParseCastExpression(
true);
1930 ParenParseOption ExprType =
CastExpr;
1933 Operand = ParseParenExpression(ExprType,
true,
1934 false, CastTy, RParenLoc);
1949 if (!Operand.isInvalid())
1950 Operand = ParsePostfixExpressionSuffix(Operand.get());
1972 ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
1973 assert(Tok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1974 tok::kw__Alignof, tok::kw_vec_step,
1975 tok::kw___builtin_omp_required_simd_align) &&
1976 "Not a sizeof/alignof/vec_step expression!");
1981 if (Tok.
is(tok::ellipsis) && OpTok.is(tok::kw_sizeof)) {
1986 if (Tok.
is(tok::l_paren)) {
1990 if (Tok.
is(tok::identifier)) {
1991 Name = Tok.getIdentifierInfo();
1996 RParenLoc = PP.getLocForEndOfToken(NameLoc);
1998 Diag(Tok, diag::err_expected_parameter_pack);
2001 }
else if (Tok.
is(tok::identifier)) {
2002 Name = Tok.getIdentifierInfo();
2004 LParenLoc = PP.getLocForEndOfToken(EllipsisLoc);
2005 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2006 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2011 Diag(Tok, diag::err_sizeof_parameter_pack);
2021 return Actions.ActOnSizeofParameterPackExpr(
getCurScope(),
2022 OpTok.getLocation(),
2027 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
2028 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2037 ExprResult Operand = ParseExprAfterUnaryExprOrTypeTrait(OpTok,
2043 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
2045 else if (OpTok.is(tok::kw___alignof))
2047 else if (OpTok.is(tok::kw_vec_step))
2049 else if (OpTok.is(tok::kw___builtin_omp_required_simd_align))
2053 return Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(),
2059 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
2060 Diag(OpTok, diag::ext_alignof_expr) << OpTok.getIdentifierInfo();
2064 Operand = Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(),
2092 ExprResult Parser::ParseBuiltinPrimaryExpression() {
2100 if (Tok.
isNot(tok::l_paren))
2101 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2110 default: llvm_unreachable(
"Not a builtin primary expression!");
2111 case tok::kw___builtin_va_arg: {
2114 if (ExpectAndConsume(tok::comma)) {
2121 if (Tok.
isNot(tok::r_paren)) {
2122 Diag(Tok, diag::err_expected) << tok::r_paren;
2129 Res = Actions.ActOnVAArg(StartLoc, Expr.
get(), Ty.
get(), ConsumeParen());
2132 case tok::kw___builtin_offsetof: {
2140 if (ExpectAndConsume(tok::comma)) {
2146 if (Tok.
isNot(tok::identifier)) {
2147 Diag(Tok, diag::err_expected) << tok::identifier;
2156 Comps.back().isBrackets =
false;
2157 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2158 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2162 if (Tok.
is(tok::period)) {
2165 Comps.back().isBrackets =
false;
2168 if (Tok.
isNot(tok::identifier)) {
2169 Diag(Tok, diag::err_expected) << tok::identifier;
2173 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2176 }
else if (Tok.
is(tok::l_square)) {
2177 if (CheckProhibitedCXX11Attribute())
2182 Comps.back().isBrackets =
true;
2191 Comps.back().U.E = Res.
get();
2196 if (Tok.
isNot(tok::r_paren)) {
2203 Res = Actions.ActOnBuiltinOffsetOf(
getCurScope(), StartLoc, TypeLoc,
2212 case tok::kw___builtin_choose_expr: {
2218 if (ExpectAndConsume(tok::comma)) {
2228 if (ExpectAndConsume(tok::comma)) {
2238 if (Tok.
isNot(tok::r_paren)) {
2239 Diag(Tok, diag::err_expected) << tok::r_paren;
2242 Res = Actions.ActOnChooseExpr(StartLoc, Cond.
get(), Expr1.
get(),
2243 Expr2.
get(), ConsumeParen());
2246 case tok::kw___builtin_astype: {
2254 if (ExpectAndConsume(tok::comma)) {
2265 if (Tok.
isNot(tok::r_paren)) {
2266 Diag(Tok, diag::err_expected) << tok::r_paren;
2271 Res = Actions.ActOnAsTypeExpr(Expr.
get(), DestTy.
get(), StartLoc,
2275 case tok::kw___builtin_convertvector: {
2283 if (ExpectAndConsume(tok::comma)) {
2294 if (Tok.
isNot(tok::r_paren)) {
2295 Diag(Tok, diag::err_expected) << tok::r_paren;
2300 Res = Actions.ActOnConvertVectorExpr(Expr.
get(), DestTy.
get(), StartLoc,
2304 case tok::kw___builtin_COLUMN:
2305 case tok::kw___builtin_FILE:
2306 case tok::kw___builtin_FUNCTION:
2307 case tok::kw___builtin_LINE: {
2309 if (Tok.
isNot(tok::r_paren)) {
2310 Diag(Tok, diag::err_expected) << tok::r_paren;
2316 case tok::kw___builtin_FILE:
2318 case tok::kw___builtin_FUNCTION:
2320 case tok::kw___builtin_LINE:
2322 case tok::kw___builtin_COLUMN:
2325 llvm_unreachable(
"invalid keyword");
2328 Res = Actions.ActOnSourceLocExpr(Kind, StartLoc, ConsumeParen());
2338 return ParsePostfixExpressionSuffix(Res.
get());
2367 Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
2370 assert(Tok.
is(tok::l_paren) &&
"Not a paren expr!");
2377 PreferredType.enterParenExpr(Tok.getLocation(), OpenLoc);
2380 bool isAmbiguousTypeId;
2383 if (Tok.
is(tok::code_completion)) {
2384 Actions.CodeCompleteExpression(
2385 getCurScope(), PreferredType.get(Tok.getLocation()),
2386 ExprType >= CompoundLiteral);
2394 tok::kw___bridge_transfer,
2395 tok::kw___bridge_retained,
2396 tok::kw___bridge_retain));
2397 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2399 StringRef BridgeCastName = Tok.getName();
2401 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2402 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2412 Diag(Tok, diag::ext_gnu_statement_expr);
2415 Result =
ExprError(
Diag(OpenLoc, diag::err_stmtexpr_file_scope));
2421 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
2424 "statement expr not in code context");
2428 Actions.ActOnStartStmtExpr();
2435 Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.
get(), Tok.getLocation());
2437 Actions.ActOnStmtExprError();
2440 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
2446 if (tokenKind == tok::kw___bridge)
2448 else if (tokenKind == tok::kw___bridge_transfer)
2450 else if (tokenKind == tok::kw___bridge_retained)
2455 assert(tokenKind == tok::kw___bridge_retain);
2457 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2458 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2460 "__bridge_retained");
2465 ColonProtection.restore();
2468 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get().get());
2469 ExprResult SubExpr = ParseCastExpression(
false);
2474 return Actions.ActOnObjCBridgedCast(
getCurScope(), OpenLoc, Kind,
2475 BridgeKeywordLoc, Ty.
get(),
2476 RParenLoc, SubExpr.
get());
2477 }
else if (ExprType >= CompoundLiteral &&
2478 isTypeIdInParens(isAmbiguousTypeId)) {
2487 if (isAmbiguousTypeId && !stopIfCastExpr) {
2488 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,
2496 ParseSpecifierQualifierList(DS);
2498 ParseDeclarator(DeclaratorInfo);
2509 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2517 ColonProtection.restore();
2519 if (Tok.
is(tok::l_brace)) {
2520 ExprType = CompoundLiteral;
2524 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2526 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2529 if (Tok.
is(tok::l_paren)) {
2536 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2550 Result = ParseCastExpression(
false,
2556 Result = Actions.ActOnCastExpr(
getCurScope(), OpenLoc,
2557 DeclaratorInfo, CastTy,
2558 RParenLoc, Result.
get());
2563 Result = ParsePostfixExpressionSuffix(Result);
2579 if (stopIfCastExpr) {
2583 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2591 Tok.getIdentifierInfo() == Ident_super &&
2593 GetLookAheadToken(1).isNot(tok::period)) {
2594 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2599 PreferredType.enterTypeCast(Tok.getLocation(), CastTy.
get());
2602 Result = ParseCastExpression(
false,
2606 Result = Actions.ActOnCastExpr(
getCurScope(), OpenLoc,
2607 DeclaratorInfo, CastTy,
2608 RParenLoc, Result.
get());
2613 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2616 }
else if (ExprType >= FoldExpr && Tok.
is(tok::ellipsis) &&
2618 ExprType = FoldExpr;
2620 }
else if (isTypeCast) {
2627 if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) {
2630 if (ExprType >= FoldExpr && ArgExprs.size() == 1 &&
2631 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2632 ExprType = FoldExpr;
2633 return ParseFoldExpression(ArgExprs[0], T);
2636 ExprType = SimpleExpr;
2637 Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
2647 Result = Actions.CorrectDelayedTyposInExpr(Result);
2650 if (ExprType >= FoldExpr && isFoldOperator(Tok.getKind()) &&
2652 ExprType = FoldExpr;
2653 return ParseFoldExpression(Result, T);
2655 ExprType = SimpleExpr;
2660 Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), Result.
get());
2683 Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
2686 assert(Tok.
is(tok::l_brace) &&
"Not a compound literal!");
2688 Diag(LParenLoc, diag::ext_c99_compound_literal);
2691 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, Result.
get());
2703 ExprResult Parser::ParseStringLiteralExpression(
bool AllowUserDefinedLiteral) {
2704 assert(isTokenStringLiteral() &&
"Not a string literal!");
2711 StringToks.push_back(Tok);
2712 ConsumeStringToken();
2713 }
while (isTokenStringLiteral());
2716 return Actions.ActOnStringLiteral(StringToks,
2734 ExprResult Parser::ParseGenericSelectionExpression() {
2735 assert(Tok.
is(tok::kw__Generic) &&
"_Generic keyword expected");
2739 Diag(KeyLoc, diag::ext_c11_generic_selection);
2759 if (ExpectAndConsume(tok::comma)) {
2769 if (Tok.
is(tok::kw_default)) {
2773 Diag(Tok, diag::err_duplicate_default_assoc);
2774 Diag(DefaultLoc, diag::note_previous_default_assoc);
2789 Types.push_back(Ty);
2791 if (ExpectAndConsume(tok::colon)) {
2800 if (ER.isInvalid()) {
2804 Exprs.push_back(ER.get());
2811 return Actions.ActOnGenericSelectionExpr(KeyLoc, DefaultLoc,
2813 ControllingExpr.
get(),
2835 Kind = Tok.getKind();
2836 assert(isFoldOperator(Kind) &&
"missing fold-operator");
2840 assert(Tok.
is(tok::ellipsis) &&
"not a fold-expression");
2844 if (Tok.
isNot(tok::r_paren)) {
2845 if (!isFoldOperator(Tok.getKind()))
2846 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
2848 if (Kind != tok::unknown && Tok.getKind() !=
Kind)
2849 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
2851 Kind = Tok.getKind();
2862 ? diag::warn_cxx14_compat_fold_expression
2863 : diag::ext_fold_expression);
2894 llvm::function_ref<
void()> ExpressionStarts) {
2895 bool SawError =
false;
2897 if (ExpressionStarts)
2902 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2903 Expr = ParseBraceInitializer();
2907 if (Tok.
is(tok::ellipsis))
2913 Exprs.push_back(Expr.
get());
2916 if (Tok.
isNot(tok::comma))
2922 checkPotentialAngleBracketDelimiter(Comma);
2927 for (
auto &E : Exprs) {
2951 Exprs.push_back(Expr.
get());
2953 if (Tok.
isNot(tok::comma))
2960 checkPotentialAngleBracketDelimiter(Comma);
2971 if (Tok.
is(tok::code_completion)) {
2973 return cutOffParsing();
2978 ParseSpecifierQualifierList(DS);
2983 ParseDeclarator(DeclaratorInfo);
2985 MaybeParseGNUAttributes(DeclaratorInfo);
2988 Actions.ActOnBlockArguments(CaretLoc, DeclaratorInfo,
getCurScope());
3001 ExprResult Parser::ParseBlockLiteralExpression() {
3002 assert(Tok.
is(tok::caret) &&
"block literal starts with ^");
3006 "block literal parsing");
3028 if (Tok.
is(tok::l_paren)) {
3029 ParseParenDeclarator(ParamInfo);
3044 MaybeParseGNUAttributes(ParamInfo);
3047 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3048 }
else if (!Tok.
is(tok::l_brace)) {
3049 ParseBlockId(CaretLoc);
3071 CaretLoc, ParamInfo),
3074 MaybeParseGNUAttributes(ParamInfo);
3077 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3082 if (!Tok.
is(tok::l_brace)) {
3084 Diag(Tok, diag::err_expected_expression);
3092 Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.
get(),
getCurScope());
3104 return Actions.ActOnObjCBoolLiteral(
ConsumeToken(), Kind);
3111 llvm::SmallSet<StringRef, 4> Platforms;
3112 bool HasOtherPlatformSpec =
false;
3114 for (
const auto &Spec : AvailSpecs) {
3115 if (Spec.isOtherPlatformSpec()) {
3116 if (HasOtherPlatformSpec) {
3117 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3121 HasOtherPlatformSpec =
true;
3125 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3130 StringRef Platform = Spec.getPlatform();
3131 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3132 << Spec.getEndLoc() << Platform;
3137 if (!HasOtherPlatformSpec) {
3138 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3139 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3153 if (Tok.
is(tok::star)) {
3157 if (Tok.
is(tok::code_completion)) {
3158 Actions.CodeCompleteAvailabilityPlatformName();
3162 if (Tok.
isNot(tok::identifier)) {
3163 Diag(Tok, diag::err_avail_query_expected_platform_name);
3169 VersionTuple Version = ParseVersionTuple(VersionRange);
3171 if (Version.empty())
3174 StringRef GivenPlatform = PlatformIdentifier->
Ident->
getName();
3175 StringRef Platform =
3176 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3178 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty()) {
3180 diag::err_avail_query_unrecognized_platform_name)
3191 assert(Tok.
is(tok::kw___builtin_available) ||
3202 bool HasError =
false;
3208 AvailSpecs.push_back(*Spec);
3224 return Actions.ActOnObjCAvailabilityCheckExpr(AvailSpecs, BeginLoc,
Defines the clang::ASTContext interface.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
no exception specification
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
ParseScope - Introduces a new scope for parsing.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
SourceRange getExprRange(Expr *E) const
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.
Stmt - This represents one statement.
Bridging via __bridge, which does nothing but reinterpret the bits.
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 isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
static bool CheckAvailabilitySpecList(Parser &P, ArrayRef< AvailabilitySpec > AvailSpecs)
Validate availability spec list, emitting diagnostics if necessary.
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data)
Perform code-completion in an expression context when we know what type we're looking for...
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer...
The base class of the type hierarchy.
SourceLocation getCloseLocation() const
This indicates that the scope corresponds to a function, which means that labels are set here...
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.
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
ExprResult ActOnCaseExpr(SourceLocation CaseLoc, ExprResult Val)
RAII object that enters a new expression evaluation context.
Information about one declarator, including the parsed type information and the identifier.
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
#define REVERTIBLE_TYPE_TRAIT(Name)
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
tok::TokenKind getKind() const
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.
Base wrapper for a particular "section" of type source info.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
bool TryConsumeToken(tok::TokenKind Expected)
One of these records is kept for each identifier that is lexed.
Used for GCC's __alignof.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
SourceLocation getBeginLoc() const LLVM_READONLY
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Token - This structure provides full information about a lexed token.
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
void * getAsOpaquePtr() const
Code completion occurs where only a type is permitted.
void SetSourceRange(SourceRange R)
bool isInvalidType() const
QualType get(SourceLocation Tok) const
This is a scope that corresponds to a block/closure object.
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.
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 ...
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...
If a crash happens while one of these objects are live, the message is printed out along with the spe...
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...
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC...
SourceRange getSourceRange() const LLVM_READONLY
const char * getName() const
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl *> DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
CompoundStmt - This represents a group of statements like { stmt stmt }.
void SetRangeStart(SourceLocation Loc)
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)
This represents one expression.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
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.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
bool isFileContext() const
This is a compound statement scope.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
SourceLocation getEnd() const
SourceLocation getOpenLocation() const
Wraps an identifier and optional source location for the identifier.
The result type of a method or function.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const LangOptions & getLangOpts() const
SourceManager & getSourceManager() const
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Encodes a location in the source.
bool TryAnnotateTypeOrScopeToken()
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
IdentifierInfo * getIdentifierInfo() const
Represents the declaration of a label.
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them...
bool isAtStartOfMacroExpansion(SourceLocation loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the first token of the macro expansion...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
Used for C's _Alignof and C++'s alignof.
Scope * getCurScope() const
bool isVectorType() const
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
StringRef getName() const
Return the actual identifier string.
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isNot(tok::TokenKind K) const
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
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 expectAndConsume(unsigned DiagID=diag::err_expected, const char *Msg="", tok::TokenKind SkipToTok=tok::unknown)
ExprResult ParseCaseExpression(SourceLocation CaseLoc)
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
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)
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
bool isFunctionType() const
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
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.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
const Type * getTypePtrOrNull() const
This is a scope that can contain a declaration.
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
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)
Captures information about "declaration specifiers".
ActionResult< Expr * > ExprResult
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
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)
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, bool CPlusPlus11)
Return the precedence of the specified binary operator token.
void enterBinary(Sema &S, SourceLocation Tok, Expr *LHS, tok::TokenKind Op)
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
void SetRangeEnd(SourceLocation Loc)
SourceLocation ColonLoc
Location of ':'.
This class handles loading and caching of source files into memory.
One specifier in an expression.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
Stop skipping at specified token, but don't skip the token itself.