32 #include "llvm/ADT/SmallVector.h" 33 using namespace clang;
125 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
136 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
143 Parser::ParseExpressionWithLeadingExtension(
SourceLocation ExtLoc) {
149 LHS = ParseCastExpression(
false);
156 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
161 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,
279 if (NextTokPrec < MinPrec)
286 if (OpToken.
is(tok::caretcaret)) {
287 return ExprError(
Diag(Tok, diag::err_opencl_logical_exclusive_or));
292 if (OpToken.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
293 tok::greatergreatergreater) &&
294 checkPotentialAngleBracketDelimiter(OpToken))
302 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
310 if (isFoldOperator(NextTokPrec) && Tok.
is(tok::ellipsis)) {
324 TernaryMiddle = ParseBraceInitializer();
326 Diag(BraceLoc, diag::err_init_list_bin_op)
331 }
else if (Tok.
isNot(tok::colon)) {
343 TernaryMiddle =
nullptr;
344 Diag(Tok, diag::ext_gnu_conditional_expr);
350 TernaryMiddle =
nullptr;
359 const char *FIText =
": ";
363 bool IsInvalid =
false;
364 const char *SourcePtr =
366 if (!IsInvalid && *SourcePtr ==
' ') {
369 if (!IsInvalid && *SourcePtr ==
' ') {
376 Diag(Tok, diag::err_expected)
378 Diag(OpToken, diag::note_matching) << tok::question;
402 bool RHSIsInitList =
false;
404 RHS = ParseBraceInitializer();
405 RHSIsInitList =
true;
409 RHS = ParseCastExpression(
false);
432 if (ThisPrec < NextTokPrec ||
433 (ThisPrec == NextTokPrec && isRightAssoc)) {
435 Diag(Tok, diag::err_init_list_bin_op)
444 RHS = ParseRHSOfBinaryExpression(RHS,
445 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
446 RHSIsInitList =
false;
463 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
465 }
else if (ColonLoc.isValid()) {
466 Diag(ColonLoc, diag::err_init_list_bin_op)
471 Diag(OpToken, diag::err_init_list_bin_op)
485 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
487 diag::warn_cxx11_right_shift_in_template_arg,
496 LHS.
get(), TernaryMiddle.
get(),
520 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
521 bool isAddressOfOperand,
523 bool isVectorLiteral) {
525 ExprResult Res = ParseCastExpression(isUnaryExpression,
531 Diag(Tok, diag::err_expected_expression);
538 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
539 :
NextToken(Next), AllowNonTypes(AllowNonTypes) {
540 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
543 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
548 if (isa<TypeDecl>(ND))
549 return WantTypeSpecifiers;
557 for (
auto *
C : candidate) {
559 if (isa<ValueDecl>(ND) && !isa<FunctionDecl>(ND))
746 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
747 bool isAddressOfOperand,
750 bool isVectorLiteral) {
770 ParenParseOption ParenExprType =
771 (isUnaryExpression && !
getLangOpts().CPlusPlus) ? CompoundLiteral
775 Res = ParseParenExpression(ParenExprType,
false,
781 switch (ParenExprType) {
782 case SimpleExpr:
break;
784 case CompoundLiteral:
802 case tok::numeric_constant:
806 Res = Actions.ActOnNumericConstant(Tok,
getCurScope());
812 Res = ParseCXXBoolLiteral();
815 case tok::kw___objc_yes:
816 case tok::kw___objc_no:
817 return ParseObjCBoolLiteral();
819 case tok::kw_nullptr:
820 Diag(Tok, diag::warn_cxx98_compat_nullptr);
823 case tok::annot_primary_expr:
824 assert(Res.
get() ==
nullptr &&
"Stray primary-expression annotation?");
825 Res = getExprAnnotation(Tok);
826 ConsumeAnnotationToken();
827 if (!Res.isInvalid() && Tok.
is(tok::less))
828 checkPotentialAngleBracket(Res);
831 case tok::kw___super:
832 case tok::kw_decltype:
836 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
837 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
839 case tok::identifier: {
852 if (Next.
is(tok::l_paren) &&
853 Tok.
is(tok::identifier) &&
854 Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
857 if (RevertibleTypeTraits.empty()) {
858 #define RTT_JOIN(X,Y) X##Y 859 #define REVERTIBLE_TYPE_TRAIT(Name) \ 860 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] \ 861 = RTT_JOIN(tok::kw_,Name) 914 #undef REVERTIBLE_TYPE_TRAIT 921 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known
922 = RevertibleTypeTraits.find(II);
923 if (Known != RevertibleTypeTraits.end()) {
924 Tok.setKind(Known->second);
925 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
926 NotCastExpr, isTypeCast);
930 if ((!ColonIsSacred && Next.
is(tok::colon)) ||
931 Next.
isOneOf(tok::coloncolon, tok::less, tok::l_paren,
936 if (!Tok.
is(tok::identifier))
937 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
953 if (Tok.
is(tok::code_completion) && &II != Ident_super) {
954 Actions.CodeCompleteObjCClassPropertyRefExpr(
955 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
960 if (Tok.
isNot(tok::identifier) &&
962 Diag(Tok, diag::err_expected_property_name);
968 Res = Actions.ActOnClassPropertyRefExpr(II, PropertyName,
977 if (
getLangOpts().ObjC1 && &II == Ident_super && !InMessageExpression &&
979 ((Tok.
is(tok::identifier) &&
981 Tok.
is(tok::code_completion))) {
982 Res = ParseObjCMessageExpressionBody(
SourceLocation(), ILoc,
nullptr,
993 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
994 Tok.
is(tok::code_completion))) {
996 if (Tok.
is(tok::code_completion) ||
997 Next.
is(tok::colon) || Next.
is(tok::r_square))
999 if (Typ.get()->isObjCObjectOrInterfaceType()) {
1004 const char *PrevSpec =
nullptr;
1007 Actions.getASTContext().getPrintingPolicy());
1023 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1024 isAddressOfOperand =
false;
1033 auto Validator = llvm::make_unique<CastExpressionIdValidator>(
1035 Validator->IsAddressOfOperand = isAddressOfOperand;
1036 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
1037 Validator->WantExpressionKeywords =
false;
1038 Validator->WantRemainingKeywords =
false;
1040 Validator->WantRemainingKeywords = Tok.isNot(tok::r_paren);
1043 Res = Actions.ActOnIdExpression(
1044 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren),
1045 isAddressOfOperand, std::move(Validator),
1048 if (!Res.isInvalid() && Res.isUnset()) {
1049 UnconsumeToken(Replacement);
1050 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1051 NotCastExpr, isTypeCast);
1053 if (!Res.isInvalid() && Tok.is(tok::less))
1054 checkPotentialAngleBracket(Res);
1057 case tok::char_constant:
1058 case tok::wide_char_constant:
1059 case tok::utf8_char_constant:
1060 case tok::utf16_char_constant:
1061 case tok::utf32_char_constant:
1062 Res = Actions.ActOnCharacterConstant(Tok,
getCurScope());
1065 case tok::kw___func__:
1066 case tok::kw___FUNCTION__:
1067 case tok::kw___FUNCDNAME__:
1068 case tok::kw___FUNCSIG__:
1069 case tok::kw_L__FUNCTION__:
1070 case tok::kw_L__FUNCSIG__:
1071 case tok::kw___PRETTY_FUNCTION__:
1072 Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
1075 case tok::string_literal:
1076 case tok::wide_string_literal:
1077 case tok::utf8_string_literal:
1078 case tok::utf16_string_literal:
1079 case tok::utf32_string_literal:
1080 Res = ParseStringLiteralExpression(
true);
1082 case tok::kw__Generic:
1083 Res = ParseGenericSelectionExpression();
1085 case tok::kw___builtin_available:
1086 return ParseAvailabilityCheckExpr(Tok.getLocation());
1087 case tok::kw___builtin_va_arg:
1088 case tok::kw___builtin_offsetof:
1089 case tok::kw___builtin_choose_expr:
1090 case tok::kw___builtin_astype:
1091 case tok::kw___builtin_convertvector:
1092 return ParseBuiltinPrimaryExpression();
1093 case tok::kw___null:
1097 case tok::minusminus: {
1102 Token SavedTok = Tok;
1113 assert(Res.isInvalid());
1114 UnconsumeToken(SavedTok);
1117 if (!Res.isInvalid())
1119 SavedKind, Res.get());
1125 Res = ParseCastExpression(
false,
true);
1126 if (!Res.isInvalid())
1127 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1136 case tok::kw___real:
1137 case tok::kw___imag: {
1139 Res = ParseCastExpression(
false);
1140 if (!Res.isInvalid())
1141 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1145 case tok::kw_co_await: {
1147 Res = ParseCastExpression(
false);
1148 if (!Res.isInvalid())
1149 Res = Actions.ActOnCoawaitExpr(
getCurScope(), CoawaitLoc, Res.get());
1153 case tok::kw___extension__:{
1157 Res = ParseCastExpression(
false);
1158 if (!Res.isInvalid())
1159 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1162 case tok::kw__Alignof:
1164 Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
1166 case tok::kw_alignof:
1167 case tok::kw___alignof:
1169 case tok::kw_sizeof:
1171 case tok::kw_vec_step:
1173 case tok::kw___builtin_omp_required_simd_align:
1174 return ParseUnaryExprOrTypeTraitExpression();
1177 if (Tok.
isNot(tok::identifier))
1178 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1181 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1183 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1184 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(),
1186 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD);
1190 case tok::kw_const_cast:
1191 case tok::kw_dynamic_cast:
1192 case tok::kw_reinterpret_cast:
1193 case tok::kw_static_cast:
1194 Res = ParseCXXCasts();
1196 case tok::kw_typeid:
1197 Res = ParseCXXTypeid();
1199 case tok::kw___uuidof:
1200 Res = ParseCXXUuidof();
1203 Res = ParseCXXThis();
1206 case tok::annot_typename:
1207 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1215 const char *PrevSpec =
nullptr;
1218 PrevSpec, DiagID, Type,
1219 Actions.getASTContext().getPrintingPolicy());
1226 ConsumeAnnotationToken();
1233 case tok::annot_decltype:
1235 case tok::kw_wchar_t:
1236 case tok::kw_char8_t:
1237 case tok::kw_char16_t:
1238 case tok::kw_char32_t:
1243 case tok::kw___int64:
1244 case tok::kw___int128:
1245 case tok::kw_signed:
1246 case tok::kw_unsigned:
1249 case tok::kw_double:
1250 case tok::kw__Float16:
1251 case tok::kw___float128:
1253 case tok::kw_typename:
1254 case tok::kw_typeof:
1255 case tok::kw___vector:
1256 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: 1257 #include "clang/Basic/OpenCLImageTypes.def" 1260 Diag(Tok, diag::err_expected_expression);
1264 if (SavedKind == tok::kw_typename) {
1270 if (!Actions.isSimpleTypeSpecifier(Tok.getKind()))
1281 ParseCXXSimpleTypeSpecifier(DS);
1282 if (Tok.
isNot(tok::l_paren) &&
1284 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1287 if (Tok.
is(tok::l_brace))
1288 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1290 Res = ParseCXXTypeConstructExpression(DS);
1294 case tok::annot_cxxscope: {
1299 if (!Tok.
is(tok::annot_cxxscope))
1300 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1301 NotCastExpr, isTypeCast);
1304 if (Next.
is(tok::annot_template_id)) {
1311 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1313 AnnotateTemplateIdTokenAsType();
1314 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1315 NotCastExpr, isTypeCast);
1320 Res = ParseCXXIdExpression(isAddressOfOperand);
1324 case tok::annot_template_id: {
1330 AnnotateTemplateIdTokenAsType();
1331 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1332 NotCastExpr, isTypeCast);
1339 case tok::kw_operator:
1340 Res = ParseCXXIdExpression(isAddressOfOperand);
1343 case tok::coloncolon: {
1348 if (!Tok.
is(tok::coloncolon))
1349 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
1354 if (Tok.
is(tok::kw_new))
1355 return ParseCXXNewExpression(
true, CCLoc);
1356 if (Tok.
is(tok::kw_delete))
1357 return ParseCXXDeleteExpression(
true, CCLoc);
1360 Diag(CCLoc, diag::err_expected_expression);
1365 return ParseCXXNewExpression(
false, Tok.getLocation());
1367 case tok::kw_delete:
1368 return ParseCXXDeleteExpression(
false, Tok.getLocation());
1370 case tok::kw_noexcept: {
1371 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1392 #define TYPE_TRAIT(N,Spelling,K) \ 1393 case tok::kw_##Spelling: 1394 #include "clang/Basic/TokenKinds.def" 1395 return ParseTypeTrait();
1397 case tok::kw___array_rank:
1398 case tok::kw___array_extent:
1399 return ParseArrayTypeTrait();
1401 case tok::kw___is_lvalue_expr:
1402 case tok::kw___is_rvalue_expr:
1403 return ParseExpressionTrait();
1407 return ParseObjCAtExpression(AtLoc);
1410 Res = ParseBlockLiteralExpression();
1412 case tok::code_completion: {
1425 Res = TryParseLambdaExpression();
1426 if (!Res.isInvalid() && !Res.get())
1427 Res = ParseObjCMessageExpression();
1430 Res = ParseLambdaExpression();
1434 Res = ParseObjCMessageExpression();
1448 Res = ParsePostfixExpressionSuffix(Res);
1450 if (
Expr *PostfixExpr = Res.
get()) {
1451 QualType Ty = PostfixExpr->getType();
1453 Diag(PostfixExpr->getExprLoc(),
1454 diag::err_opencl_taking_function_address_parser);
1483 Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1488 switch (Tok.getKind()) {
1489 case tok::code_completion:
1490 if (InMessageExpression)
1493 Actions.CodeCompletePostfixExpression(
getCurScope(), LHS);
1497 case tok::identifier:
1501 if (
getLangOpts().ObjC1 && !InMessageExpression &&
1504 nullptr, LHS.
get());
1512 case tok::l_square: {
1519 if (
getLangOpts().ObjC1 && Tok.isAtStartOfLine() &&
1520 isSimpleObjCMessageExpression())
1525 if (CheckProhibitedCXX11Attribute()) {
1526 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1536 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1537 Idx = ParseBraceInitializer();
1541 if (!Tok.
is(tok::colon)) {
1545 if (Tok.
is(tok::colon)) {
1548 if (Tok.
isNot(tok::r_square))
1558 Tok.
is(tok::r_square)) {
1560 LHS = Actions.ActOnOMPArraySectionExpr(LHS.
get(), Loc, Idx.
get(),
1563 LHS = Actions.ActOnArraySubscriptExpr(
getCurScope(), LHS.
get(), Loc,
1570 (void)Actions.CorrectDelayedTyposInExpr(OrigLHS);
1571 (void)Actions.CorrectDelayedTyposInExpr(Idx);
1572 (void)Actions.CorrectDelayedTyposInExpr(Length);
1583 case tok::lesslessless: {
1588 Expr *ExecConfig =
nullptr;
1592 if (OpKind == tok::lesslessless) {
1597 if (ParseSimpleExpressionList(ExecConfigExprs, ExecConfigCommaLocs)) {
1598 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1608 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1609 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1615 if (ExpectAndConsume(tok::l_paren))
1618 Loc = PrevTokLocation;
1629 ExecConfig = ECResult.
get();
1639 if (Tok.
is(tok::code_completion)) {
1645 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1646 if (Tok.
isNot(tok::r_paren)) {
1647 if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
1650 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1653 for (
auto &E : ArgExprs)
1654 Actions.CorrectDelayedTyposInExpr(E);
1662 }
else if (Tok.
isNot(tok::r_paren)) {
1663 bool HadDelayedTypo =
false;
1664 if (Actions.CorrectDelayedTyposInExpr(LHS).get() != LHS.
get())
1665 HadDelayedTypo =
true;
1666 for (
auto &E : ArgExprs)
1667 if (Actions.CorrectDelayedTyposInExpr(E).get() != E)
1668 HadDelayedTypo =
true;
1678 assert((ArgExprs.size() == 0 ||
1679 ArgExprs.size()-1 == CommaLocs.size())&&
1680 "Unexpected number of commas!");
1682 ArgExprs, Tok.getLocation(),
1698 bool MayBePseudoDestructor =
false;
1704 if (BaseType && Tok.
is(tok::l_paren) &&
1707 Diag(OpLoc, diag::err_function_is_not_record)
1710 return ParsePostfixExpressionSuffix(Base);
1713 LHS = Actions.ActOnStartCXXMemberReference(
getCurScope(), Base,
1714 OpLoc, OpKind, ObjectType,
1715 MayBePseudoDestructor);
1719 ParseOptionalCXXScopeSpecifier(SS, ObjectType,
1721 &MayBePseudoDestructor);
1723 ObjectType =
nullptr;
1726 if (Tok.
is(tok::code_completion)) {
1728 OpKind == tok::arrow ? tok::period : tok::arrow;
1731 const bool DiagsAreSuppressed = Diags.getSuppressAllDiagnostics();
1732 Diags.setSuppressAllDiagnostics(
true);
1733 CorrectedLHS = Actions.ActOnStartCXXMemberReference(
1734 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
1735 MayBePseudoDestructor);
1736 Diags.setSuppressAllDiagnostics(DiagsAreSuppressed);
1740 Expr *CorrectedBase = CorrectedLHS.
get();
1743 Actions.CodeCompleteMemberReferenceExpr(
1744 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,
1745 Base && ExprStatementTokLoc == Base->
getLocStart());
1751 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
1752 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
1766 if (
getLangOpts().ObjC2 && OpKind == tok::period &&
1767 Tok.
is(tok::kw_class)) {
1784 ObjectType, &TemplateKWLoc, Name)) {
1785 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1790 LHS = Actions.ActOnMemberAccessExpr(
getCurScope(), LHS.
get(), OpLoc,
1791 OpKind, SS, TemplateKWLoc, Name,
1792 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
1795 checkPotentialAngleBracket(LHS);
1799 case tok::minusminus:
1801 LHS = Actions.ActOnPostfixUnaryOp(
getCurScope(), Tok.getLocation(),
1802 Tok.getKind(), LHS.
get());
1834 Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1839 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_sizeof, tok::kw___alignof,
1840 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
1841 tok::kw___builtin_omp_required_simd_align) &&
1842 "Not a typeof/sizeof/alignof/vec_step expression!");
1847 if (Tok.
isNot(tok::l_paren)) {
1850 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1851 tok::kw__Alignof)) {
1852 if (isTypeIdUnambiguously()) {
1854 ParseSpecifierQualifierList(DS);
1856 ParseDeclarator(DeclaratorInfo);
1859 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
1860 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
1876 Operand = ParseCastExpression(
true);
1882 ParenParseOption ExprType =
CastExpr;
1885 Operand = ParseParenExpression(ExprType,
true,
1886 false, CastTy, RParenLoc);
1901 if (!Operand.isInvalid())
1902 Operand = ParsePostfixExpressionSuffix(Operand.get());
1924 ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
1925 assert(Tok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1926 tok::kw__Alignof, tok::kw_vec_step,
1927 tok::kw___builtin_omp_required_simd_align) &&
1928 "Not a sizeof/alignof/vec_step expression!");
1933 if (Tok.
is(tok::ellipsis) && OpTok.is(tok::kw_sizeof)) {
1938 if (Tok.
is(tok::l_paren)) {
1942 if (Tok.
is(tok::identifier)) {
1943 Name = Tok.getIdentifierInfo();
1948 RParenLoc = PP.getLocForEndOfToken(NameLoc);
1950 Diag(Tok, diag::err_expected_parameter_pack);
1953 }
else if (Tok.
is(tok::identifier)) {
1954 Name = Tok.getIdentifierInfo();
1956 LParenLoc = PP.getLocForEndOfToken(EllipsisLoc);
1957 RParenLoc = PP.getLocForEndOfToken(NameLoc);
1958 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
1963 Diag(Tok, diag::err_sizeof_parameter_pack);
1973 return Actions.ActOnSizeofParameterPackExpr(
getCurScope(),
1974 OpTok.getLocation(),
1979 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
1980 Diag(OpTok, diag::warn_cxx98_compat_alignof);
1989 ExprResult Operand = ParseExprAfterUnaryExprOrTypeTrait(OpTok,
1995 if (OpTok.isOneOf(tok::kw_alignof, tok::kw___alignof, tok::kw__Alignof))
1997 else if (OpTok.is(tok::kw_vec_step))
1999 else if (OpTok.is(tok::kw___builtin_omp_required_simd_align))
2003 return Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(),
2009 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
2010 Diag(OpTok, diag::ext_alignof_expr) << OpTok.getIdentifierInfo();
2014 Operand = Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(),
2038 ExprResult Parser::ParseBuiltinPrimaryExpression() {
2046 if (Tok.
isNot(tok::l_paren))
2047 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2056 default: llvm_unreachable(
"Not a builtin primary expression!");
2057 case tok::kw___builtin_va_arg: {
2060 if (ExpectAndConsume(tok::comma)) {
2067 if (Tok.
isNot(tok::r_paren)) {
2068 Diag(Tok, diag::err_expected) << tok::r_paren;
2075 Res = Actions.ActOnVAArg(StartLoc, Expr.
get(), Ty.
get(), ConsumeParen());
2078 case tok::kw___builtin_offsetof: {
2086 if (ExpectAndConsume(tok::comma)) {
2092 if (Tok.
isNot(tok::identifier)) {
2093 Diag(Tok, diag::err_expected) << tok::identifier;
2102 Comps.back().isBrackets =
false;
2103 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2104 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2108 if (Tok.
is(tok::period)) {
2111 Comps.back().isBrackets =
false;
2114 if (Tok.
isNot(tok::identifier)) {
2115 Diag(Tok, diag::err_expected) << tok::identifier;
2119 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2122 }
else if (Tok.
is(tok::l_square)) {
2123 if (CheckProhibitedCXX11Attribute())
2128 Comps.back().isBrackets =
true;
2137 Comps.back().U.E = Res.
get();
2142 if (Tok.
isNot(tok::r_paren)) {
2149 Res = Actions.ActOnBuiltinOffsetOf(
getCurScope(), StartLoc, TypeLoc,
2158 case tok::kw___builtin_choose_expr: {
2164 if (ExpectAndConsume(tok::comma)) {
2174 if (ExpectAndConsume(tok::comma)) {
2184 if (Tok.
isNot(tok::r_paren)) {
2185 Diag(Tok, diag::err_expected) << tok::r_paren;
2188 Res = Actions.ActOnChooseExpr(StartLoc, Cond.
get(), Expr1.
get(),
2189 Expr2.
get(), ConsumeParen());
2192 case tok::kw___builtin_astype: {
2200 if (ExpectAndConsume(tok::comma)) {
2211 if (Tok.
isNot(tok::r_paren)) {
2212 Diag(Tok, diag::err_expected) << tok::r_paren;
2217 Res = Actions.ActOnAsTypeExpr(Expr.
get(), DestTy.
get(), StartLoc,
2221 case tok::kw___builtin_convertvector: {
2229 if (ExpectAndConsume(tok::comma)) {
2240 if (Tok.
isNot(tok::r_paren)) {
2241 Diag(Tok, diag::err_expected) << tok::r_paren;
2246 Res = Actions.ActOnConvertVectorExpr(Expr.
get(), DestTy.
get(), StartLoc,
2257 return ParsePostfixExpressionSuffix(Res.
get());
2286 Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
2289 assert(Tok.
is(tok::l_paren) &&
"Not a paren expr!");
2297 bool isAmbiguousTypeId;
2300 if (Tok.
is(tok::code_completion)) {
2311 tok::kw___bridge_transfer,
2312 tok::kw___bridge_retained,
2313 tok::kw___bridge_retain));
2314 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2316 StringRef BridgeCastName = Tok.getName();
2318 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2319 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2329 Diag(Tok, diag::ext_gnu_statement_expr);
2332 Result =
ExprError(
Diag(OpenLoc, diag::err_stmtexpr_file_scope));
2338 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
2341 "statement expr not in code context");
2345 Actions.ActOnStartStmtExpr();
2352 Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.
get(), Tok.getLocation());
2354 Actions.ActOnStmtExprError();
2357 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
2363 if (tokenKind == tok::kw___bridge)
2365 else if (tokenKind == tok::kw___bridge_transfer)
2367 else if (tokenKind == tok::kw___bridge_retained)
2372 assert(tokenKind == tok::kw___bridge_retain);
2374 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2375 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2377 "__bridge_retained");
2382 ColonProtection.restore();
2384 ExprResult SubExpr = ParseCastExpression(
false);
2389 return Actions.ActOnObjCBridgedCast(
getCurScope(), OpenLoc, Kind,
2390 BridgeKeywordLoc, Ty.
get(),
2391 RParenLoc, SubExpr.
get());
2392 }
else if (ExprType >= CompoundLiteral &&
2393 isTypeIdInParens(isAmbiguousTypeId)) {
2402 if (isAmbiguousTypeId && !stopIfCastExpr) {
2403 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,
2411 ParseSpecifierQualifierList(DS);
2413 ParseDeclarator(DeclaratorInfo);
2424 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2432 ColonProtection.restore();
2434 if (Tok.
is(tok::l_brace)) {
2435 ExprType = CompoundLiteral;
2439 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2441 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2444 if (Tok.
is(tok::l_paren)) {
2451 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2465 Result = ParseCastExpression(
false,
2471 Result = Actions.ActOnCastExpr(
getCurScope(), OpenLoc,
2472 DeclaratorInfo, CastTy,
2473 RParenLoc, Result.
get());
2478 Result = ParsePostfixExpressionSuffix(Result);
2494 if (stopIfCastExpr) {
2498 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2506 Tok.getIdentifierInfo() == Ident_super &&
2508 GetLookAheadToken(1).isNot(tok::period)) {
2509 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2516 Result = ParseCastExpression(
false,
2520 Result = Actions.ActOnCastExpr(
getCurScope(), OpenLoc,
2521 DeclaratorInfo, CastTy,
2522 RParenLoc, Result.
get());
2527 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2530 }
else if (ExprType >= FoldExpr && Tok.
is(tok::ellipsis) &&
2532 ExprType = FoldExpr;
2534 }
else if (isTypeCast) {
2541 if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) {
2544 if (ExprType >= FoldExpr && ArgExprs.size() == 1 &&
2545 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2546 ExprType = FoldExpr;
2547 return ParseFoldExpression(ArgExprs[0], T);
2550 ExprType = SimpleExpr;
2551 Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
2561 Result = Actions.CorrectDelayedTyposInExpr(Result);
2564 if (ExprType >= FoldExpr && isFoldOperator(Tok.getKind()) &&
2566 ExprType = FoldExpr;
2567 return ParseFoldExpression(Result, T);
2569 ExprType = SimpleExpr;
2574 Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), Result.
get());
2597 Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
2600 assert(Tok.
is(tok::l_brace) &&
"Not a compound literal!");
2602 Diag(LParenLoc, diag::ext_c99_compound_literal);
2605 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, Result.
get());
2617 ExprResult Parser::ParseStringLiteralExpression(
bool AllowUserDefinedLiteral) {
2618 assert(isTokenStringLiteral() &&
"Not a string literal!");
2625 StringToks.push_back(Tok);
2626 ConsumeStringToken();
2627 }
while (isTokenStringLiteral());
2630 return Actions.ActOnStringLiteral(StringToks,
2648 ExprResult Parser::ParseGenericSelectionExpression() {
2649 assert(Tok.
is(tok::kw__Generic) &&
"_Generic keyword expected");
2653 Diag(KeyLoc, diag::ext_c11_generic_selection);
2673 if (ExpectAndConsume(tok::comma)) {
2683 if (Tok.
is(tok::kw_default)) {
2687 Diag(Tok, diag::err_duplicate_default_assoc);
2688 Diag(DefaultLoc, diag::note_previous_default_assoc);
2703 Types.push_back(Ty);
2705 if (ExpectAndConsume(tok::colon)) {
2714 if (ER.isInvalid()) {
2718 Exprs.push_back(ER.get());
2725 return Actions.ActOnGenericSelectionExpr(KeyLoc, DefaultLoc,
2727 ControllingExpr.
get(),
2749 Kind = Tok.getKind();
2750 assert(isFoldOperator(Kind) &&
"missing fold-operator");
2754 assert(Tok.
is(tok::ellipsis) &&
"not a fold-expression");
2758 if (Tok.
isNot(tok::r_paren)) {
2759 if (!isFoldOperator(Tok.getKind()))
2760 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
2762 if (Kind != tok::unknown && Tok.getKind() !=
Kind)
2763 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
2765 Kind = Tok.getKind();
2776 ? diag::warn_cxx14_compat_fold_expression
2777 : diag::ext_fold_expression);
2808 llvm::function_ref<
void()> Completer) {
2809 bool SawError =
false;
2811 if (Tok.
is(tok::code_completion)) {
2822 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2823 Expr = ParseBraceInitializer();
2827 if (Tok.
is(tok::ellipsis))
2833 Exprs.push_back(Expr.
get());
2836 if (Tok.
isNot(tok::comma))
2842 checkPotentialAngleBracketDelimiter(Comma);
2847 for (
auto &E : Exprs) {
2871 Exprs.push_back(Expr.
get());
2873 if (Tok.
isNot(tok::comma))
2880 checkPotentialAngleBracketDelimiter(Comma);
2891 if (Tok.
is(tok::code_completion)) {
2893 return cutOffParsing();
2898 ParseSpecifierQualifierList(DS);
2903 ParseDeclarator(DeclaratorInfo);
2905 MaybeParseGNUAttributes(DeclaratorInfo);
2908 Actions.ActOnBlockArguments(CaretLoc, DeclaratorInfo,
getCurScope());
2921 ExprResult Parser::ParseBlockLiteralExpression() {
2922 assert(Tok.
is(tok::caret) &&
"block literal starts with ^");
2926 "block literal parsing");
2948 if (Tok.
is(tok::l_paren)) {
2949 ParseParenDeclarator(ParamInfo);
2964 MaybeParseGNUAttributes(ParamInfo);
2967 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
2968 }
else if (!Tok.
is(tok::l_brace)) {
2969 ParseBlockId(CaretLoc);
2995 CaretLoc, ParamInfo),
2998 MaybeParseGNUAttributes(ParamInfo);
3001 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3006 if (!Tok.
is(tok::l_brace)) {
3008 Diag(Tok, diag::err_expected_expression);
3016 Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.
get(),
getCurScope());
3028 return Actions.ActOnObjCBoolLiteral(
ConsumeToken(), Kind);
3035 llvm::SmallSet<StringRef, 4> Platforms;
3036 bool HasOtherPlatformSpec =
false;
3038 for (
const auto &Spec : AvailSpecs) {
3039 if (Spec.isOtherPlatformSpec()) {
3040 if (HasOtherPlatformSpec) {
3041 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3045 HasOtherPlatformSpec =
true;
3049 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3054 StringRef Platform = Spec.getPlatform();
3055 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3056 << Spec.getEndLoc() << Platform;
3061 if (!HasOtherPlatformSpec) {
3062 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3063 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3077 if (Tok.
is(tok::star)) {
3081 if (Tok.
is(tok::code_completion)) {
3082 Actions.CodeCompleteAvailabilityPlatformName();
3086 if (Tok.
isNot(tok::identifier)) {
3087 Diag(Tok, diag::err_avail_query_expected_platform_name);
3093 VersionTuple Version = ParseVersionTuple(VersionRange);
3095 if (Version.empty())
3098 StringRef GivenPlatform = PlatformIdentifier->
Ident->
getName();
3099 StringRef Platform =
3100 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3102 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty()) {
3104 diag::err_avail_query_unrecognized_platform_name)
3115 assert(Tok.
is(tok::kw___builtin_available) ||
3126 bool HasError =
false;
3132 AvailSpecs.push_back(*Spec);
3148 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)) {...
void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS)
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...
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.
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.
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.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
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.
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.
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
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 ...
Code completion occurs within an expression.
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...
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)
Expr - This represents one expression.
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.
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...
SourceLocation getLocStart() const LLVM_READONLY
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.
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.
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.
Code completion occurs in a parenthesized expression, which might also be a type cast.
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.