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 Tok.
isOneOf(tok::colon, tok::r_square) &&
337 TernaryMiddle = ParseBraceInitializer();
339 Diag(BraceLoc, diag::err_init_list_bin_op)
344 }
else if (Tok.
isNot(tok::colon)) {
356 TernaryMiddle =
nullptr;
357 Diag(Tok, diag::ext_gnu_conditional_expr);
363 TernaryMiddle =
nullptr;
372 const char *FIText =
": ";
376 bool IsInvalid =
false;
377 const char *SourcePtr =
379 if (!IsInvalid && *SourcePtr ==
' ') {
382 if (!IsInvalid && *SourcePtr ==
' ') {
389 Diag(Tok, diag::err_expected)
391 Diag(OpToken, diag::note_matching) << tok::question;
398 if (Tok.
is(tok::code_completion)) {
416 bool RHSIsInitList =
false;
418 RHS = ParseBraceInitializer();
419 RHSIsInitList =
true;
423 RHS = ParseCastExpression(
false);
446 if (ThisPrec < NextTokPrec ||
447 (ThisPrec == NextTokPrec && isRightAssoc)) {
449 Diag(Tok, diag::err_init_list_bin_op)
458 RHS = ParseRHSOfBinaryExpression(RHS,
459 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
460 RHSIsInitList =
false;
477 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
479 }
else if (ColonLoc.isValid()) {
480 Diag(ColonLoc, diag::err_init_list_bin_op)
485 Diag(OpToken, diag::err_init_list_bin_op)
499 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
501 diag::warn_cxx11_right_shift_in_template_arg,
510 LHS.
get(), TernaryMiddle.
get(),
534 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
535 bool isAddressOfOperand,
537 bool isVectorLiteral) {
539 ExprResult Res = ParseCastExpression(isUnaryExpression,
545 Diag(Tok, diag::err_expected_expression);
552 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
553 :
NextToken(Next), AllowNonTypes(AllowNonTypes) {
554 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
557 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
562 if (isa<TypeDecl>(ND))
563 return WantTypeSpecifiers;
571 for (
auto *
C : candidate) {
573 if (isa<ValueDecl>(ND) && !isa<FunctionDecl>(ND))
760 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
761 bool isAddressOfOperand,
764 bool isVectorLiteral) {
784 ParenParseOption ParenExprType =
785 (isUnaryExpression && !
getLangOpts().CPlusPlus) ? CompoundLiteral
789 Res = ParseParenExpression(ParenExprType,
false,
795 switch (ParenExprType) {
796 case SimpleExpr:
break;
798 case CompoundLiteral:
816 case tok::numeric_constant:
820 Res = Actions.ActOnNumericConstant(Tok,
getCurScope());
826 Res = ParseCXXBoolLiteral();
829 case tok::kw___objc_yes:
830 case tok::kw___objc_no:
831 return ParseObjCBoolLiteral();
833 case tok::kw_nullptr:
834 Diag(Tok, diag::warn_cxx98_compat_nullptr);
837 case tok::annot_primary_expr:
838 assert(Res.
get() ==
nullptr &&
"Stray primary-expression annotation?");
839 Res = getExprAnnotation(Tok);
840 ConsumeAnnotationToken();
841 if (!Res.isInvalid() && Tok.
is(tok::less))
842 checkPotentialAngleBracket(Res);
845 case tok::kw___super:
846 case tok::kw_decltype:
850 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
851 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
853 case tok::identifier: {
866 if (Next.
is(tok::l_paren) &&
867 Tok.
is(tok::identifier) &&
868 Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
871 if (RevertibleTypeTraits.empty()) {
872 #define RTT_JOIN(X,Y) X##Y 873 #define REVERTIBLE_TYPE_TRAIT(Name) \ 874 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] \ 875 = RTT_JOIN(tok::kw_,Name) 928 #undef REVERTIBLE_TYPE_TRAIT 935 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known
936 = RevertibleTypeTraits.find(II);
937 if (Known != RevertibleTypeTraits.end()) {
938 Tok.setKind(Known->second);
939 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
940 NotCastExpr, isTypeCast);
944 if ((!ColonIsSacred && Next.
is(tok::colon)) ||
945 Next.
isOneOf(tok::coloncolon, tok::less, tok::l_paren,
950 if (!Tok.
is(tok::identifier))
951 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
967 if (Tok.
is(tok::code_completion) && &II != Ident_super) {
968 Actions.CodeCompleteObjCClassPropertyRefExpr(
969 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
974 if (Tok.
isNot(tok::identifier) &&
976 Diag(Tok, diag::err_expected_property_name);
982 Res = Actions.ActOnClassPropertyRefExpr(II, PropertyName,
991 if (
getLangOpts().ObjC && &II == Ident_super && !InMessageExpression &&
993 ((Tok.
is(tok::identifier) &&
995 Tok.
is(tok::code_completion))) {
996 Res = ParseObjCMessageExpressionBody(
SourceLocation(), ILoc,
nullptr,
1007 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
1008 Tok.
is(tok::code_completion))) {
1010 if (Tok.
is(tok::code_completion) ||
1011 Next.
is(tok::colon) || Next.
is(tok::r_square))
1013 if (Typ.get()->isObjCObjectOrInterfaceType()) {
1018 const char *PrevSpec =
nullptr;
1021 Actions.getASTContext().getPrintingPolicy());
1037 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1038 isAddressOfOperand =
false;
1047 auto Validator = llvm::make_unique<CastExpressionIdValidator>(
1049 Validator->IsAddressOfOperand = isAddressOfOperand;
1050 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
1051 Validator->WantExpressionKeywords =
false;
1052 Validator->WantRemainingKeywords =
false;
1054 Validator->WantRemainingKeywords = Tok.
isNot(tok::r_paren);
1057 Res = Actions.ActOnIdExpression(
1058 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren),
1059 isAddressOfOperand, std::move(Validator),
1061 Tok.is(tok::r_paren) ? nullptr : &Replacement);
1062 if (!Res.isInvalid() && Res.isUnset()) {
1063 UnconsumeToken(Replacement);
1064 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1065 NotCastExpr, isTypeCast);
1067 if (!Res.isInvalid() && Tok.is(tok::less))
1068 checkPotentialAngleBracket(Res);
1071 case tok::char_constant:
1072 case tok::wide_char_constant:
1073 case tok::utf8_char_constant:
1074 case tok::utf16_char_constant:
1075 case tok::utf32_char_constant:
1076 Res = Actions.ActOnCharacterConstant(Tok,
getCurScope());
1079 case tok::kw___func__:
1080 case tok::kw___FUNCTION__:
1081 case tok::kw___FUNCDNAME__:
1082 case tok::kw___FUNCSIG__:
1083 case tok::kw_L__FUNCTION__:
1084 case tok::kw_L__FUNCSIG__:
1085 case tok::kw___PRETTY_FUNCTION__:
1086 Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
1089 case tok::string_literal:
1090 case tok::wide_string_literal:
1091 case tok::utf8_string_literal:
1092 case tok::utf16_string_literal:
1093 case tok::utf32_string_literal:
1094 Res = ParseStringLiteralExpression(
true);
1096 case tok::kw__Generic:
1097 Res = ParseGenericSelectionExpression();
1099 case tok::kw___builtin_available:
1100 return ParseAvailabilityCheckExpr(Tok.getLocation());
1101 case tok::kw___builtin_va_arg:
1102 case tok::kw___builtin_offsetof:
1103 case tok::kw___builtin_choose_expr:
1104 case tok::kw___builtin_astype:
1105 case tok::kw___builtin_convertvector:
1106 return ParseBuiltinPrimaryExpression();
1107 case tok::kw___null:
1111 case tok::minusminus: {
1116 Token SavedTok = Tok;
1127 assert(Res.isInvalid());
1128 UnconsumeToken(SavedTok);
1131 if (!Res.isInvalid())
1133 SavedKind, Res.get());
1139 Res = ParseCastExpression(
false,
true);
1140 if (!Res.isInvalid())
1141 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1150 case tok::kw___real:
1151 case tok::kw___imag: {
1153 Res = ParseCastExpression(
false);
1154 if (!Res.isInvalid())
1155 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1159 case tok::kw_co_await: {
1161 Res = ParseCastExpression(
false);
1162 if (!Res.isInvalid())
1163 Res = Actions.ActOnCoawaitExpr(
getCurScope(), CoawaitLoc, Res.get());
1167 case tok::kw___extension__:{
1171 Res = ParseCastExpression(
false);
1172 if (!Res.isInvalid())
1173 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1176 case tok::kw__Alignof:
1178 Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
1180 case tok::kw_alignof:
1181 case tok::kw___alignof:
1183 case tok::kw_sizeof:
1185 case tok::kw_vec_step:
1187 case tok::kw___builtin_omp_required_simd_align:
1188 return ParseUnaryExprOrTypeTraitExpression();
1191 if (Tok.
isNot(tok::identifier))
1192 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1195 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1197 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1198 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(),
1200 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD);
1204 case tok::kw_const_cast:
1205 case tok::kw_dynamic_cast:
1206 case tok::kw_reinterpret_cast:
1207 case tok::kw_static_cast:
1208 Res = ParseCXXCasts();
1210 case tok::kw_typeid:
1211 Res = ParseCXXTypeid();
1213 case tok::kw___uuidof:
1214 Res = ParseCXXUuidof();
1217 Res = ParseCXXThis();
1220 case tok::annot_typename:
1221 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1229 const char *PrevSpec =
nullptr;
1232 PrevSpec, DiagID, Type,
1233 Actions.getASTContext().getPrintingPolicy());
1240 ConsumeAnnotationToken();
1247 case tok::annot_decltype:
1249 case tok::kw_wchar_t:
1250 case tok::kw_char8_t:
1251 case tok::kw_char16_t:
1252 case tok::kw_char32_t:
1257 case tok::kw___int64:
1258 case tok::kw___int128:
1259 case tok::kw_signed:
1260 case tok::kw_unsigned:
1263 case tok::kw_double:
1264 case tok::kw__Float16:
1265 case tok::kw___float128:
1267 case tok::kw_typename:
1268 case tok::kw_typeof:
1269 case tok::kw___vector:
1270 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: 1271 #include "clang/Basic/OpenCLImageTypes.def" 1274 Diag(Tok, diag::err_expected_expression);
1278 if (SavedKind == tok::kw_typename) {
1284 if (!Actions.isSimpleTypeSpecifier(Tok.getKind()))
1295 ParseCXXSimpleTypeSpecifier(DS);
1296 if (Tok.
isNot(tok::l_paren) &&
1298 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1301 if (Tok.
is(tok::l_brace))
1302 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1304 Res = ParseCXXTypeConstructExpression(DS);
1308 case tok::annot_cxxscope: {
1313 if (!Tok.
is(tok::annot_cxxscope))
1314 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1315 NotCastExpr, isTypeCast);
1318 if (Next.
is(tok::annot_template_id)) {
1325 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1327 AnnotateTemplateIdTokenAsType();
1328 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1329 NotCastExpr, isTypeCast);
1334 Res = ParseCXXIdExpression(isAddressOfOperand);
1338 case tok::annot_template_id: {
1344 AnnotateTemplateIdTokenAsType();
1345 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1346 NotCastExpr, isTypeCast);
1353 case tok::kw_operator:
1354 Res = ParseCXXIdExpression(isAddressOfOperand);
1357 case tok::coloncolon: {
1362 if (!Tok.
is(tok::coloncolon))
1363 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
1368 if (Tok.
is(tok::kw_new))
1369 return ParseCXXNewExpression(
true, CCLoc);
1370 if (Tok.
is(tok::kw_delete))
1371 return ParseCXXDeleteExpression(
true, CCLoc);
1374 Diag(CCLoc, diag::err_expected_expression);
1379 return ParseCXXNewExpression(
false, Tok.getLocation());
1381 case tok::kw_delete:
1382 return ParseCXXDeleteExpression(
false, Tok.getLocation());
1384 case tok::kw_noexcept: {
1385 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1406 #define TYPE_TRAIT(N,Spelling,K) \ 1407 case tok::kw_##Spelling: 1408 #include "clang/Basic/TokenKinds.def" 1409 return ParseTypeTrait();
1411 case tok::kw___array_rank:
1412 case tok::kw___array_extent:
1413 return ParseArrayTypeTrait();
1415 case tok::kw___is_lvalue_expr:
1416 case tok::kw___is_rvalue_expr:
1417 return ParseExpressionTrait();
1421 return ParseObjCAtExpression(AtLoc);
1424 Res = ParseBlockLiteralExpression();
1426 case tok::code_completion: {
1439 Res = TryParseLambdaExpression();
1440 if (!Res.isInvalid() && !Res.get())
1441 Res = ParseObjCMessageExpression();
1444 Res = ParseLambdaExpression();
1448 Res = ParseObjCMessageExpression();
1462 Res = ParsePostfixExpressionSuffix(Res);
1464 if (
Expr *PostfixExpr = Res.
get()) {
1465 QualType Ty = PostfixExpr->getType();
1467 Diag(PostfixExpr->getExprLoc(),
1468 diag::err_opencl_taking_function_address_parser);
1497 Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1502 switch (Tok.getKind()) {
1503 case tok::code_completion:
1504 if (InMessageExpression)
1507 Actions.CodeCompletePostfixExpression(
getCurScope(), LHS);
1511 case tok::identifier:
1518 nullptr, LHS.
get());
1526 case tok::l_square: {
1533 if (
getLangOpts().ObjC && Tok.isAtStartOfLine() &&
1534 isSimpleObjCMessageExpression())
1539 if (CheckProhibitedCXX11Attribute()) {
1540 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1550 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1551 Idx = ParseBraceInitializer();
1555 if (!Tok.
is(tok::colon)) {
1559 if (Tok.
is(tok::colon)) {
1562 if (Tok.
isNot(tok::r_square))
1572 Tok.
is(tok::r_square)) {
1574 LHS = Actions.ActOnOMPArraySectionExpr(LHS.
get(), Loc, Idx.
get(),
1577 LHS = Actions.ActOnArraySubscriptExpr(
getCurScope(), LHS.
get(), Loc,
1584 (void)Actions.CorrectDelayedTyposInExpr(OrigLHS);
1585 (void)Actions.CorrectDelayedTyposInExpr(Idx);
1586 (void)Actions.CorrectDelayedTyposInExpr(Length);
1597 case tok::lesslessless: {
1602 Expr *ExecConfig =
nullptr;
1606 if (OpKind == tok::lesslessless) {
1611 if (ParseSimpleExpressionList(ExecConfigExprs, ExecConfigCommaLocs)) {
1612 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1622 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1623 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1629 if (ExpectAndConsume(tok::l_paren))
1632 Loc = PrevTokLocation;
1643 ExecConfig = ECResult.
get();
1653 if (Tok.
is(tok::code_completion)) {
1654 QualType PreferredType = Actions.ProduceCallSignatureHelp(
1656 CalledSignatureHelp =
true;
1657 Actions.CodeCompleteExpression(
getCurScope(), PreferredType);
1662 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1663 if (Tok.
isNot(tok::r_paren)) {
1664 if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
1665 QualType PreferredType = Actions.ProduceCallSignatureHelp(
1667 CalledSignatureHelp =
true;
1668 Actions.CodeCompleteExpression(
getCurScope(), PreferredType);
1670 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1675 if (PP.isCodeCompletionReached() && !CalledSignatureHelp) {
1678 CalledSignatureHelp =
true;
1682 for (
auto &E : ArgExprs)
1683 Actions.CorrectDelayedTyposInExpr(E);
1691 }
else if (Tok.
isNot(tok::r_paren)) {
1692 bool HadDelayedTypo =
false;
1693 if (Actions.CorrectDelayedTyposInExpr(LHS).get() != LHS.
get())
1694 HadDelayedTypo =
true;
1695 for (
auto &E : ArgExprs)
1696 if (Actions.CorrectDelayedTyposInExpr(E).get() != E)
1697 HadDelayedTypo =
true;
1707 assert((ArgExprs.size() == 0 ||
1708 ArgExprs.size()-1 == CommaLocs.size())&&
1709 "Unexpected number of commas!");
1711 ArgExprs, Tok.getLocation(),
1727 bool MayBePseudoDestructor =
false;
1733 if (BaseType && Tok.
is(tok::l_paren) &&
1736 Diag(OpLoc, diag::err_function_is_not_record)
1739 return ParsePostfixExpressionSuffix(Base);
1742 LHS = Actions.ActOnStartCXXMemberReference(
getCurScope(), Base,
1743 OpLoc, OpKind, ObjectType,
1744 MayBePseudoDestructor);
1748 ParseOptionalCXXScopeSpecifier(SS, ObjectType,
1750 &MayBePseudoDestructor);
1752 ObjectType =
nullptr;
1755 if (Tok.
is(tok::code_completion)) {
1757 OpKind == tok::arrow ? tok::period : tok::arrow;
1760 const bool DiagsAreSuppressed = Diags.getSuppressAllDiagnostics();
1761 Diags.setSuppressAllDiagnostics(
true);
1762 CorrectedLHS = Actions.ActOnStartCXXMemberReference(
1763 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
1764 MayBePseudoDestructor);
1765 Diags.setSuppressAllDiagnostics(DiagsAreSuppressed);
1769 Expr *CorrectedBase = CorrectedLHS.
get();
1771 CorrectedBase = Base;
1774 Actions.CodeCompleteMemberReferenceExpr(
1775 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,
1776 Base && ExprStatementTokLoc == Base->
getBeginLoc());
1782 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
1783 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
1797 if (
getLangOpts().ObjC && OpKind == tok::period &&
1798 Tok.
is(tok::kw_class)) {
1816 ObjectType, &TemplateKWLoc, Name)) {
1817 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1822 LHS = Actions.ActOnMemberAccessExpr(
getCurScope(), LHS.
get(), OpLoc,
1823 OpKind, SS, TemplateKWLoc, Name,
1824 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
1827 checkPotentialAngleBracket(LHS);
1831 case tok::minusminus:
1833 LHS = Actions.ActOnPostfixUnaryOp(
getCurScope(), Tok.getLocation(),
1834 Tok.getKind(), LHS.
get());
1866 Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1871 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_sizeof, tok::kw___alignof,
1872 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
1873 tok::kw___builtin_omp_required_simd_align) &&
1874 "Not a typeof/sizeof/alignof/vec_step expression!");
1879 if (Tok.
isNot(tok::l_paren)) {
1882 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1883 tok::kw__Alignof)) {
1884 if (isTypeIdUnambiguously()) {
1886 ParseSpecifierQualifierList(DS);
1888 ParseDeclarator(DeclaratorInfo);
1891 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
1892 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
1908 Operand = ParseCastExpression(
true);
1914 ParenParseOption ExprType =
CastExpr;
1917 Operand = ParseParenExpression(ExprType,
true,
1918 false, CastTy, RParenLoc);
1933 if (!Operand.isInvalid())
1934 Operand = ParsePostfixExpressionSuffix(Operand.get());
1956 ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
1957 assert(Tok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1958 tok::kw__Alignof, tok::kw_vec_step,
1959 tok::kw___builtin_omp_required_simd_align) &&
1960 "Not a sizeof/alignof/vec_step expression!");
1965 if (Tok.
is(tok::ellipsis) && OpTok.is(tok::kw_sizeof)) {
1970 if (Tok.
is(tok::l_paren)) {
1974 if (Tok.
is(tok::identifier)) {
1975 Name = Tok.getIdentifierInfo();
1980 RParenLoc = PP.getLocForEndOfToken(NameLoc);
1982 Diag(Tok, diag::err_expected_parameter_pack);
1985 }
else if (Tok.
is(tok::identifier)) {
1986 Name = Tok.getIdentifierInfo();
1988 LParenLoc = PP.getLocForEndOfToken(EllipsisLoc);
1989 RParenLoc = PP.getLocForEndOfToken(NameLoc);
1990 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
1995 Diag(Tok, diag::err_sizeof_parameter_pack);
2005 return Actions.ActOnSizeofParameterPackExpr(
getCurScope(),
2006 OpTok.getLocation(),
2011 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
2012 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2021 ExprResult Operand = ParseExprAfterUnaryExprOrTypeTrait(OpTok,
2027 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
2029 else if (OpTok.is(tok::kw___alignof))
2031 else if (OpTok.is(tok::kw_vec_step))
2033 else if (OpTok.is(tok::kw___builtin_omp_required_simd_align))
2037 return Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(),
2043 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
2044 Diag(OpTok, diag::ext_alignof_expr) << OpTok.getIdentifierInfo();
2048 Operand = Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(),
2072 ExprResult Parser::ParseBuiltinPrimaryExpression() {
2080 if (Tok.
isNot(tok::l_paren))
2081 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2090 default: llvm_unreachable(
"Not a builtin primary expression!");
2091 case tok::kw___builtin_va_arg: {
2094 if (ExpectAndConsume(tok::comma)) {
2101 if (Tok.
isNot(tok::r_paren)) {
2102 Diag(Tok, diag::err_expected) << tok::r_paren;
2109 Res = Actions.ActOnVAArg(StartLoc, Expr.
get(), Ty.
get(), ConsumeParen());
2112 case tok::kw___builtin_offsetof: {
2120 if (ExpectAndConsume(tok::comma)) {
2126 if (Tok.
isNot(tok::identifier)) {
2127 Diag(Tok, diag::err_expected) << tok::identifier;
2136 Comps.back().isBrackets =
false;
2137 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2138 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2142 if (Tok.
is(tok::period)) {
2145 Comps.back().isBrackets =
false;
2148 if (Tok.
isNot(tok::identifier)) {
2149 Diag(Tok, diag::err_expected) << tok::identifier;
2153 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2156 }
else if (Tok.
is(tok::l_square)) {
2157 if (CheckProhibitedCXX11Attribute())
2162 Comps.back().isBrackets =
true;
2171 Comps.back().U.E = Res.
get();
2176 if (Tok.
isNot(tok::r_paren)) {
2183 Res = Actions.ActOnBuiltinOffsetOf(
getCurScope(), StartLoc, TypeLoc,
2192 case tok::kw___builtin_choose_expr: {
2198 if (ExpectAndConsume(tok::comma)) {
2208 if (ExpectAndConsume(tok::comma)) {
2218 if (Tok.
isNot(tok::r_paren)) {
2219 Diag(Tok, diag::err_expected) << tok::r_paren;
2222 Res = Actions.ActOnChooseExpr(StartLoc, Cond.
get(), Expr1.
get(),
2223 Expr2.
get(), ConsumeParen());
2226 case tok::kw___builtin_astype: {
2234 if (ExpectAndConsume(tok::comma)) {
2245 if (Tok.
isNot(tok::r_paren)) {
2246 Diag(Tok, diag::err_expected) << tok::r_paren;
2251 Res = Actions.ActOnAsTypeExpr(Expr.
get(), DestTy.
get(), StartLoc,
2255 case tok::kw___builtin_convertvector: {
2263 if (ExpectAndConsume(tok::comma)) {
2274 if (Tok.
isNot(tok::r_paren)) {
2275 Diag(Tok, diag::err_expected) << tok::r_paren;
2280 Res = Actions.ActOnConvertVectorExpr(Expr.
get(), DestTy.
get(), StartLoc,
2291 return ParsePostfixExpressionSuffix(Res.
get());
2320 Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
2323 assert(Tok.
is(tok::l_paren) &&
"Not a paren expr!");
2331 bool isAmbiguousTypeId;
2334 if (Tok.
is(tok::code_completion)) {
2345 tok::kw___bridge_transfer,
2346 tok::kw___bridge_retained,
2347 tok::kw___bridge_retain));
2348 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2350 StringRef BridgeCastName = Tok.getName();
2352 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2353 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2363 Diag(Tok, diag::ext_gnu_statement_expr);
2366 Result =
ExprError(
Diag(OpenLoc, diag::err_stmtexpr_file_scope));
2372 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
2375 "statement expr not in code context");
2379 Actions.ActOnStartStmtExpr();
2386 Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.
get(), Tok.getLocation());
2388 Actions.ActOnStmtExprError();
2391 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
2397 if (tokenKind == tok::kw___bridge)
2399 else if (tokenKind == tok::kw___bridge_transfer)
2401 else if (tokenKind == tok::kw___bridge_retained)
2406 assert(tokenKind == tok::kw___bridge_retain);
2408 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2409 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2411 "__bridge_retained");
2416 ColonProtection.restore();
2418 ExprResult SubExpr = ParseCastExpression(
false);
2423 return Actions.ActOnObjCBridgedCast(
getCurScope(), OpenLoc, Kind,
2424 BridgeKeywordLoc, Ty.
get(),
2425 RParenLoc, SubExpr.
get());
2426 }
else if (ExprType >= CompoundLiteral &&
2427 isTypeIdInParens(isAmbiguousTypeId)) {
2436 if (isAmbiguousTypeId && !stopIfCastExpr) {
2437 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,
2445 ParseSpecifierQualifierList(DS);
2447 ParseDeclarator(DeclaratorInfo);
2458 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2466 ColonProtection.restore();
2468 if (Tok.
is(tok::l_brace)) {
2469 ExprType = CompoundLiteral;
2473 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2475 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2478 if (Tok.
is(tok::l_paren)) {
2485 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2499 Result = ParseCastExpression(
false,
2505 Result = Actions.ActOnCastExpr(
getCurScope(), OpenLoc,
2506 DeclaratorInfo, CastTy,
2507 RParenLoc, Result.
get());
2512 Result = ParsePostfixExpressionSuffix(Result);
2528 if (stopIfCastExpr) {
2532 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2540 Tok.getIdentifierInfo() == Ident_super &&
2542 GetLookAheadToken(1).isNot(tok::period)) {
2543 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2550 Result = ParseCastExpression(
false,
2554 Result = Actions.ActOnCastExpr(
getCurScope(), OpenLoc,
2555 DeclaratorInfo, CastTy,
2556 RParenLoc, Result.
get());
2561 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2564 }
else if (ExprType >= FoldExpr && Tok.
is(tok::ellipsis) &&
2566 ExprType = FoldExpr;
2568 }
else if (isTypeCast) {
2575 if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) {
2578 if (ExprType >= FoldExpr && ArgExprs.size() == 1 &&
2579 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2580 ExprType = FoldExpr;
2581 return ParseFoldExpression(ArgExprs[0], T);
2584 ExprType = SimpleExpr;
2585 Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
2595 Result = Actions.CorrectDelayedTyposInExpr(Result);
2598 if (ExprType >= FoldExpr && isFoldOperator(Tok.getKind()) &&
2600 ExprType = FoldExpr;
2601 return ParseFoldExpression(Result, T);
2603 ExprType = SimpleExpr;
2608 Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), Result.
get());
2631 Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
2634 assert(Tok.
is(tok::l_brace) &&
"Not a compound literal!");
2636 Diag(LParenLoc, diag::ext_c99_compound_literal);
2639 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, Result.
get());
2651 ExprResult Parser::ParseStringLiteralExpression(
bool AllowUserDefinedLiteral) {
2652 assert(isTokenStringLiteral() &&
"Not a string literal!");
2659 StringToks.push_back(Tok);
2660 ConsumeStringToken();
2661 }
while (isTokenStringLiteral());
2664 return Actions.ActOnStringLiteral(StringToks,
2682 ExprResult Parser::ParseGenericSelectionExpression() {
2683 assert(Tok.
is(tok::kw__Generic) &&
"_Generic keyword expected");
2687 Diag(KeyLoc, diag::ext_c11_generic_selection);
2707 if (ExpectAndConsume(tok::comma)) {
2717 if (Tok.
is(tok::kw_default)) {
2721 Diag(Tok, diag::err_duplicate_default_assoc);
2722 Diag(DefaultLoc, diag::note_previous_default_assoc);
2737 Types.push_back(Ty);
2739 if (ExpectAndConsume(tok::colon)) {
2748 if (ER.isInvalid()) {
2752 Exprs.push_back(ER.get());
2759 return Actions.ActOnGenericSelectionExpr(KeyLoc, DefaultLoc,
2761 ControllingExpr.
get(),
2783 Kind = Tok.getKind();
2784 assert(isFoldOperator(Kind) &&
"missing fold-operator");
2788 assert(Tok.
is(tok::ellipsis) &&
"not a fold-expression");
2792 if (Tok.
isNot(tok::r_paren)) {
2793 if (!isFoldOperator(Tok.getKind()))
2794 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
2796 if (Kind != tok::unknown && Tok.getKind() !=
Kind)
2797 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
2799 Kind = Tok.getKind();
2810 ? diag::warn_cxx14_compat_fold_expression
2811 : diag::ext_fold_expression);
2842 llvm::function_ref<
void()> Completer) {
2843 bool SawError =
false;
2845 if (Tok.
is(tok::code_completion)) {
2856 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2857 Expr = ParseBraceInitializer();
2861 if (Tok.
is(tok::ellipsis))
2867 Exprs.push_back(Expr.
get());
2870 if (Tok.
isNot(tok::comma))
2876 checkPotentialAngleBracketDelimiter(Comma);
2881 for (
auto &E : Exprs) {
2905 Exprs.push_back(Expr.
get());
2907 if (Tok.
isNot(tok::comma))
2914 checkPotentialAngleBracketDelimiter(Comma);
2925 if (Tok.
is(tok::code_completion)) {
2927 return cutOffParsing();
2932 ParseSpecifierQualifierList(DS);
2937 ParseDeclarator(DeclaratorInfo);
2939 MaybeParseGNUAttributes(DeclaratorInfo);
2942 Actions.ActOnBlockArguments(CaretLoc, DeclaratorInfo,
getCurScope());
2955 ExprResult Parser::ParseBlockLiteralExpression() {
2956 assert(Tok.
is(tok::caret) &&
"block literal starts with ^");
2960 "block literal parsing");
2982 if (Tok.
is(tok::l_paren)) {
2983 ParseParenDeclarator(ParamInfo);
2998 MaybeParseGNUAttributes(ParamInfo);
3001 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3002 }
else if (!Tok.
is(tok::l_brace)) {
3003 ParseBlockId(CaretLoc);
3025 CaretLoc, ParamInfo),
3028 MaybeParseGNUAttributes(ParamInfo);
3031 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3036 if (!Tok.
is(tok::l_brace)) {
3038 Diag(Tok, diag::err_expected_expression);
3046 Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.
get(),
getCurScope());
3058 return Actions.ActOnObjCBoolLiteral(
ConsumeToken(), Kind);
3065 llvm::SmallSet<StringRef, 4> Platforms;
3066 bool HasOtherPlatformSpec =
false;
3068 for (
const auto &Spec : AvailSpecs) {
3069 if (Spec.isOtherPlatformSpec()) {
3070 if (HasOtherPlatformSpec) {
3071 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3075 HasOtherPlatformSpec =
true;
3079 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3084 StringRef Platform = Spec.getPlatform();
3085 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3086 << Spec.getEndLoc() << Platform;
3091 if (!HasOtherPlatformSpec) {
3092 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3093 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3107 if (Tok.
is(tok::star)) {
3111 if (Tok.
is(tok::code_completion)) {
3112 Actions.CodeCompleteAvailabilityPlatformName();
3116 if (Tok.
isNot(tok::identifier)) {
3117 Diag(Tok, diag::err_avail_query_expected_platform_name);
3123 VersionTuple Version = ParseVersionTuple(VersionRange);
3125 if (Version.empty())
3128 StringRef GivenPlatform = PlatformIdentifier->
Ident->
getName();
3129 StringRef Platform =
3130 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3132 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty()) {
3134 diag::err_avail_query_unrecognized_platform_name)
3145 assert(Tok.
is(tok::kw___builtin_available) ||
3156 bool HasError =
false;
3162 AvailSpecs.push_back(*Spec);
3178 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...
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.
void CodeCompleteBinaryRHS(Scope *S, Expr *LHS, tok::TokenKind Op)
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
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...
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.
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.
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.