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));
238 bool Parser::isNotExpressionStart() {
240 if (K == tok::l_brace || K == tok::r_brace ||
241 K == tok::kw_for || K == tok::kw_while ||
242 K == tok::kw_if || K == tok::kw_else ||
243 K == tok::kw_goto || K == tok::kw_try)
246 return isKnownToBeDeclarationSpecifier();
254 TentativeParsingAction TPA(*
this);
256 if (
SkipUntil(tok::greater, tok::greatergreater, tok::greatergreatergreater,
261 ParseGreaterThanInTemplateList(Greater,
true,
false);
287 GreaterThanIsOperator,
295 if (NextTokPrec < MinPrec)
302 if (OpToken.
is(tok::caretcaret)) {
303 return ExprError(
Diag(Tok, diag::err_opencl_logical_exclusive_or));
310 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
320 (isKnownToBeDeclarationSpecifier() ||
321 Tok.
isOneOf(tok::greater, tok::greatergreater,
322 tok::greatergreatergreater)) &&
323 diagnoseUnknownTemplateId(LHS, OpToken.
getLocation()))
328 if (isFoldOperator(NextTokPrec) && Tok.
is(tok::ellipsis)) {
339 if (Tok.
isNot(tok::colon)) {
351 TernaryMiddle =
nullptr;
356 TernaryMiddle =
nullptr;
357 Diag(Tok, diag::ext_gnu_conditional_expr);
366 const char *FIText =
": ";
370 bool IsInvalid =
false;
371 const char *SourcePtr =
373 if (!IsInvalid && *SourcePtr ==
' ') {
376 if (!IsInvalid && *SourcePtr ==
' ') {
383 Diag(Tok, diag::err_expected)
385 Diag(OpToken, diag::note_matching) << tok::question;
409 bool RHSIsInitList =
false;
411 RHS = ParseBraceInitializer();
412 RHSIsInitList =
true;
416 RHS = ParseCastExpression(
false);
439 if (ThisPrec < NextTokPrec ||
440 (ThisPrec == NextTokPrec && isRightAssoc)) {
442 Diag(Tok, diag::err_init_list_bin_op)
451 RHS = ParseRHSOfBinaryExpression(RHS,
452 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
453 RHSIsInitList =
false;
470 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
473 Diag(OpToken, diag::err_init_list_bin_op)
487 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
489 diag::warn_cxx11_right_shift_in_template_arg,
498 LHS.
get(), TernaryMiddle.
get(),
522 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
523 bool isAddressOfOperand,
525 bool isVectorLiteral) {
527 ExprResult Res = ParseCastExpression(isUnaryExpression,
533 Diag(Tok, diag::err_expected_expression);
540 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
541 :
NextToken(Next), AllowNonTypes(AllowNonTypes) {
542 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
545 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
550 if (isa<TypeDecl>(ND))
551 return WantTypeSpecifiers;
559 for (
auto *
C : candidate) {
561 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:
798 case tok::numeric_constant:
802 Res = Actions.ActOnNumericConstant(Tok,
getCurScope());
808 Res = ParseCXXBoolLiteral();
811 case tok::kw___objc_yes:
812 case tok::kw___objc_no:
813 return ParseObjCBoolLiteral();
815 case tok::kw_nullptr:
816 Diag(Tok, diag::warn_cxx98_compat_nullptr);
819 case tok::annot_primary_expr:
820 assert(Res.
get() ==
nullptr &&
"Stray primary-expression annotation?");
821 Res = getExprAnnotation(Tok);
822 ConsumeAnnotationToken();
825 case tok::kw___super:
826 case tok::kw_decltype:
830 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
831 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
833 case tok::identifier: {
846 if (Next.
is(tok::l_paren) &&
847 Tok.
is(tok::identifier) &&
848 Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
851 if (RevertibleTypeTraits.empty()) {
852 #define RTT_JOIN(X,Y) X##Y 853 #define REVERTIBLE_TYPE_TRAIT(Name) \ 854 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] \ 855 = RTT_JOIN(tok::kw_,Name) 908 #undef REVERTIBLE_TYPE_TRAIT 915 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known
916 = RevertibleTypeTraits.find(II);
917 if (Known != RevertibleTypeTraits.end()) {
918 Tok.setKind(Known->second);
919 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
920 NotCastExpr, isTypeCast);
924 if ((!ColonIsSacred && Next.
is(tok::colon)) ||
925 Next.
isOneOf(tok::coloncolon, tok::less, tok::l_paren,
930 if (!Tok.
is(tok::identifier))
931 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
947 if (Tok.
is(tok::code_completion) && &II != Ident_super) {
948 Actions.CodeCompleteObjCClassPropertyRefExpr(
949 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
954 if (Tok.
isNot(tok::identifier) &&
956 Diag(Tok, diag::err_expected_property_name);
962 Res = Actions.ActOnClassPropertyRefExpr(II, PropertyName,
971 if (
getLangOpts().ObjC1 && &II == Ident_super && !InMessageExpression &&
973 ((Tok.
is(tok::identifier) &&
975 Tok.
is(tok::code_completion))) {
976 Res = ParseObjCMessageExpressionBody(
SourceLocation(), ILoc,
nullptr,
987 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
988 Tok.
is(tok::code_completion))) {
990 if (Tok.
is(tok::code_completion) ||
991 Next.
is(tok::colon) || Next.
is(tok::r_square))
993 if (Typ.get()->isObjCObjectOrInterfaceType()) {
998 const char *PrevSpec =
nullptr;
1001 Actions.getASTContext().getPrintingPolicy());
1017 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1018 isAddressOfOperand =
false;
1027 auto Validator = llvm::make_unique<CastExpressionIdValidator>(
1029 Validator->IsAddressOfOperand = isAddressOfOperand;
1030 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
1031 Validator->WantExpressionKeywords =
false;
1032 Validator->WantRemainingKeywords =
false;
1034 Validator->WantRemainingKeywords = Tok.isNot(tok::r_paren);
1037 Res = Actions.ActOnIdExpression(
1038 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren),
1039 isAddressOfOperand, std::move(Validator),
1042 if (!Res.isInvalid() && !Res.get()) {
1043 UnconsumeToken(Replacement);
1044 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1045 NotCastExpr, isTypeCast);
1049 case tok::char_constant:
1050 case tok::wide_char_constant:
1051 case tok::utf8_char_constant:
1052 case tok::utf16_char_constant:
1053 case tok::utf32_char_constant:
1054 Res = Actions.ActOnCharacterConstant(Tok,
getCurScope());
1057 case tok::kw___func__:
1058 case tok::kw___FUNCTION__:
1059 case tok::kw___FUNCDNAME__:
1060 case tok::kw___FUNCSIG__:
1061 case tok::kw_L__FUNCTION__:
1062 case tok::kw___PRETTY_FUNCTION__:
1063 Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
1066 case tok::string_literal:
1067 case tok::wide_string_literal:
1068 case tok::utf8_string_literal:
1069 case tok::utf16_string_literal:
1070 case tok::utf32_string_literal:
1071 Res = ParseStringLiteralExpression(
true);
1073 case tok::kw__Generic:
1074 Res = ParseGenericSelectionExpression();
1076 case tok::kw___builtin_available:
1077 return ParseAvailabilityCheckExpr(Tok.getLocation());
1078 case tok::kw___builtin_va_arg:
1079 case tok::kw___builtin_offsetof:
1080 case tok::kw___builtin_choose_expr:
1081 case tok::kw___builtin_astype:
1082 case tok::kw___builtin_convertvector:
1083 return ParseBuiltinPrimaryExpression();
1084 case tok::kw___null:
1088 case tok::minusminus: {
1093 Token SavedTok = Tok;
1104 assert(Res.isInvalid());
1105 UnconsumeToken(SavedTok);
1108 if (!Res.isInvalid())
1110 SavedKind, Res.get());
1116 Res = ParseCastExpression(
false,
true);
1117 if (!Res.isInvalid())
1118 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1127 case tok::kw___real:
1128 case tok::kw___imag: {
1130 Res = ParseCastExpression(
false);
1131 if (!Res.isInvalid())
1132 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1136 case tok::kw_co_await: {
1138 Res = ParseCastExpression(
false);
1139 if (!Res.isInvalid())
1140 Res = Actions.ActOnCoawaitExpr(
getCurScope(), CoawaitLoc, Res.get());
1144 case tok::kw___extension__:{
1148 Res = ParseCastExpression(
false);
1149 if (!Res.isInvalid())
1150 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.get());
1153 case tok::kw__Alignof:
1155 Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
1157 case tok::kw_alignof:
1158 case tok::kw___alignof:
1160 case tok::kw_sizeof:
1162 case tok::kw_vec_step:
1164 case tok::kw___builtin_omp_required_simd_align:
1165 return ParseUnaryExprOrTypeTraitExpression();
1168 if (Tok.
isNot(tok::identifier))
1169 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1172 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1174 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1175 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(),
1177 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD);
1181 case tok::kw_const_cast:
1182 case tok::kw_dynamic_cast:
1183 case tok::kw_reinterpret_cast:
1184 case tok::kw_static_cast:
1185 Res = ParseCXXCasts();
1187 case tok::kw_typeid:
1188 Res = ParseCXXTypeid();
1190 case tok::kw___uuidof:
1191 Res = ParseCXXUuidof();
1194 Res = ParseCXXThis();
1197 case tok::annot_typename:
1198 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1206 const char *PrevSpec =
nullptr;
1209 PrevSpec, DiagID, Type,
1210 Actions.getASTContext().getPrintingPolicy());
1217 ConsumeAnnotationToken();
1224 case tok::annot_decltype:
1226 case tok::kw_wchar_t:
1227 case tok::kw_char16_t:
1228 case tok::kw_char32_t:
1233 case tok::kw___int64:
1234 case tok::kw___int128:
1235 case tok::kw_signed:
1236 case tok::kw_unsigned:
1239 case tok::kw_double:
1240 case tok::kw__Float16:
1241 case tok::kw___float128:
1243 case tok::kw_typename:
1244 case tok::kw_typeof:
1245 case tok::kw___vector:
1246 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: 1247 #include "clang/Basic/OpenCLImageTypes.def" 1250 Diag(Tok, diag::err_expected_expression);
1254 if (SavedKind == tok::kw_typename) {
1260 if (!Actions.isSimpleTypeSpecifier(Tok.getKind()))
1271 ParseCXXSimpleTypeSpecifier(DS);
1272 if (Tok.
isNot(tok::l_paren) &&
1274 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1277 if (Tok.
is(tok::l_brace))
1278 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1280 Res = ParseCXXTypeConstructExpression(DS);
1284 case tok::annot_cxxscope: {
1289 if (!Tok.
is(tok::annot_cxxscope))
1290 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1291 NotCastExpr, isTypeCast);
1294 if (Next.
is(tok::annot_template_id)) {
1301 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1303 AnnotateTemplateIdTokenAsType();
1304 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1305 NotCastExpr, isTypeCast);
1310 Res = ParseCXXIdExpression(isAddressOfOperand);
1314 case tok::annot_template_id: {
1320 AnnotateTemplateIdTokenAsType();
1321 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1322 NotCastExpr, isTypeCast);
1329 case tok::kw_operator:
1330 Res = ParseCXXIdExpression(isAddressOfOperand);
1333 case tok::coloncolon: {
1338 if (!Tok.
is(tok::coloncolon))
1339 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
1344 if (Tok.
is(tok::kw_new))
1345 return ParseCXXNewExpression(
true, CCLoc);
1346 if (Tok.
is(tok::kw_delete))
1347 return ParseCXXDeleteExpression(
true, CCLoc);
1350 Diag(CCLoc, diag::err_expected_expression);
1355 return ParseCXXNewExpression(
false, Tok.getLocation());
1357 case tok::kw_delete:
1358 return ParseCXXDeleteExpression(
false, Tok.getLocation());
1360 case tok::kw_noexcept: {
1361 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1382 #define TYPE_TRAIT(N,Spelling,K) \ 1383 case tok::kw_##Spelling: 1384 #include "clang/Basic/TokenKinds.def" 1385 return ParseTypeTrait();
1387 case tok::kw___array_rank:
1388 case tok::kw___array_extent:
1389 return ParseArrayTypeTrait();
1391 case tok::kw___is_lvalue_expr:
1392 case tok::kw___is_rvalue_expr:
1393 return ParseExpressionTrait();
1397 return ParseObjCAtExpression(AtLoc);
1400 Res = ParseBlockLiteralExpression();
1402 case tok::code_completion: {
1415 Res = TryParseLambdaExpression();
1416 if (!Res.isInvalid() && !Res.get())
1417 Res = ParseObjCMessageExpression();
1420 Res = ParseLambdaExpression();
1424 Res = ParseObjCMessageExpression();
1438 Res = ParsePostfixExpressionSuffix(Res);
1440 if (
Expr *PostfixExpr = Res.
get()) {
1441 QualType Ty = PostfixExpr->getType();
1443 Diag(PostfixExpr->getExprLoc(),
1444 diag::err_opencl_taking_function_address_parser);
1473 Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1478 switch (Tok.getKind()) {
1479 case tok::code_completion:
1480 if (InMessageExpression)
1483 Actions.CodeCompletePostfixExpression(
getCurScope(), LHS);
1487 case tok::identifier:
1491 if (
getLangOpts().ObjC1 && !InMessageExpression &&
1494 nullptr, LHS.
get());
1502 case tok::l_square: {
1509 if (
getLangOpts().ObjC1 && Tok.isAtStartOfLine() &&
1510 isSimpleObjCMessageExpression())
1515 if (CheckProhibitedCXX11Attribute()) {
1516 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1526 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1527 Idx = ParseBraceInitializer();
1531 if (!Tok.
is(tok::colon)) {
1535 if (Tok.
is(tok::colon)) {
1538 if (Tok.
isNot(tok::r_square))
1548 Tok.
is(tok::r_square)) {
1550 LHS = Actions.ActOnOMPArraySectionExpr(LHS.
get(), Loc, Idx.
get(),
1553 LHS = Actions.ActOnArraySubscriptExpr(
getCurScope(), LHS.
get(), Loc,
1560 (void)Actions.CorrectDelayedTyposInExpr(OrigLHS);
1561 (void)Actions.CorrectDelayedTyposInExpr(Idx);
1562 (void)Actions.CorrectDelayedTyposInExpr(Length);
1573 case tok::lesslessless: {
1578 Expr *ExecConfig =
nullptr;
1582 if (OpKind == tok::lesslessless) {
1587 if (ParseSimpleExpressionList(ExecConfigExprs, ExecConfigCommaLocs)) {
1588 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1598 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1599 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1605 if (ExpectAndConsume(tok::l_paren))
1608 Loc = PrevTokLocation;
1619 ExecConfig = ECResult.
get();
1629 if (Tok.
is(tok::code_completion)) {
1635 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1636 if (Tok.
isNot(tok::r_paren)) {
1637 if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
1640 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1643 for (
auto &E : ArgExprs)
1644 Actions.CorrectDelayedTyposInExpr(E);
1652 }
else if (Tok.
isNot(tok::r_paren)) {
1653 bool HadDelayedTypo =
false;
1654 if (Actions.CorrectDelayedTyposInExpr(LHS).get() != LHS.
get())
1655 HadDelayedTypo =
true;
1656 for (
auto &E : ArgExprs)
1657 if (Actions.CorrectDelayedTyposInExpr(E).get() != E)
1658 HadDelayedTypo =
true;
1668 assert((ArgExprs.size() == 0 ||
1669 ArgExprs.size()-1 == CommaLocs.size())&&
1670 "Unexpected number of commas!");
1672 ArgExprs, Tok.getLocation(),
1688 bool MayBePseudoDestructor =
false;
1692 if (BaseType && Tok.
is(tok::l_paren) &&
1695 Diag(OpLoc, diag::err_function_is_not_record)
1698 return ParsePostfixExpressionSuffix(Base);
1701 LHS = Actions.ActOnStartCXXMemberReference(
getCurScope(), Base,
1702 OpLoc, OpKind, ObjectType,
1703 MayBePseudoDestructor);
1707 ParseOptionalCXXScopeSpecifier(SS, ObjectType,
1709 &MayBePseudoDestructor);
1711 ObjectType =
nullptr;
1714 if (Tok.
is(tok::code_completion)) {
1717 Actions.CodeCompleteMemberReferenceExpr(
1719 ExprStatementTokLoc ==
Base->getLocStart());
1725 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
1726 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
1740 if (
getLangOpts().ObjC2 && OpKind == tok::period &&
1741 Tok.
is(tok::kw_class)) {
1758 ObjectType, TemplateKWLoc, Name)) {
1759 (void)Actions.CorrectDelayedTyposInExpr(LHS);
1764 LHS = Actions.ActOnMemberAccessExpr(
getCurScope(), LHS.
get(), OpLoc,
1765 OpKind, SS, TemplateKWLoc, Name,
1766 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
1771 case tok::minusminus:
1773 LHS = Actions.ActOnPostfixUnaryOp(
getCurScope(), Tok.getLocation(),
1774 Tok.getKind(), LHS.
get());
1806 Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1811 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_sizeof, tok::kw___alignof,
1812 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
1813 tok::kw___builtin_omp_required_simd_align) &&
1814 "Not a typeof/sizeof/alignof/vec_step expression!");
1819 if (Tok.
isNot(tok::l_paren)) {
1822 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1823 tok::kw__Alignof)) {
1824 if (isTypeIdUnambiguously()) {
1826 ParseSpecifierQualifierList(DS);
1828 ParseDeclarator(DeclaratorInfo);
1831 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
1832 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
1848 Operand = ParseCastExpression(
true);
1854 ParenParseOption ExprType =
CastExpr;
1857 Operand = ParseParenExpression(ExprType,
true,
1858 false, CastTy, RParenLoc);
1873 if (!Operand.isInvalid())
1874 Operand = ParsePostfixExpressionSuffix(Operand.get());
1896 ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
1897 assert(Tok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1898 tok::kw__Alignof, tok::kw_vec_step,
1899 tok::kw___builtin_omp_required_simd_align) &&
1900 "Not a sizeof/alignof/vec_step expression!");
1905 if (Tok.
is(tok::ellipsis) && OpTok.is(tok::kw_sizeof)) {
1910 if (Tok.
is(tok::l_paren)) {
1914 if (Tok.
is(tok::identifier)) {
1915 Name = Tok.getIdentifierInfo();
1920 RParenLoc = PP.getLocForEndOfToken(NameLoc);
1922 Diag(Tok, diag::err_expected_parameter_pack);
1925 }
else if (Tok.
is(tok::identifier)) {
1926 Name = Tok.getIdentifierInfo();
1928 LParenLoc = PP.getLocForEndOfToken(EllipsisLoc);
1929 RParenLoc = PP.getLocForEndOfToken(NameLoc);
1930 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
1935 Diag(Tok, diag::err_sizeof_parameter_pack);
1945 return Actions.ActOnSizeofParameterPackExpr(
getCurScope(),
1946 OpTok.getLocation(),
1951 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
1952 Diag(OpTok, diag::warn_cxx98_compat_alignof);
1961 ExprResult Operand = ParseExprAfterUnaryExprOrTypeTrait(OpTok,
1967 if (OpTok.isOneOf(tok::kw_alignof, tok::kw___alignof, tok::kw__Alignof))
1969 else if (OpTok.is(tok::kw_vec_step))
1971 else if (OpTok.is(tok::kw___builtin_omp_required_simd_align))
1975 return Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(),
1981 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
1982 Diag(OpTok, diag::ext_alignof_expr) << OpTok.getIdentifierInfo();
1986 Operand = Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.getLocation(),
2010 ExprResult Parser::ParseBuiltinPrimaryExpression() {
2018 if (Tok.
isNot(tok::l_paren))
2019 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2028 default: llvm_unreachable(
"Not a builtin primary expression!");
2029 case tok::kw___builtin_va_arg: {
2032 if (ExpectAndConsume(tok::comma)) {
2039 if (Tok.
isNot(tok::r_paren)) {
2040 Diag(Tok, diag::err_expected) << tok::r_paren;
2047 Res = Actions.ActOnVAArg(StartLoc, Expr.
get(), Ty.
get(), ConsumeParen());
2050 case tok::kw___builtin_offsetof: {
2058 if (ExpectAndConsume(tok::comma)) {
2064 if (Tok.
isNot(tok::identifier)) {
2065 Diag(Tok, diag::err_expected) << tok::identifier;
2074 Comps.back().isBrackets =
false;
2075 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2076 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2080 if (Tok.
is(tok::period)) {
2083 Comps.back().isBrackets =
false;
2086 if (Tok.
isNot(tok::identifier)) {
2087 Diag(Tok, diag::err_expected) << tok::identifier;
2091 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2094 }
else if (Tok.
is(tok::l_square)) {
2095 if (CheckProhibitedCXX11Attribute())
2100 Comps.back().isBrackets =
true;
2109 Comps.back().U.E = Res.
get();
2114 if (Tok.
isNot(tok::r_paren)) {
2121 Res = Actions.ActOnBuiltinOffsetOf(
getCurScope(), StartLoc, TypeLoc,
2130 case tok::kw___builtin_choose_expr: {
2136 if (ExpectAndConsume(tok::comma)) {
2146 if (ExpectAndConsume(tok::comma)) {
2156 if (Tok.
isNot(tok::r_paren)) {
2157 Diag(Tok, diag::err_expected) << tok::r_paren;
2160 Res = Actions.ActOnChooseExpr(StartLoc, Cond.
get(), Expr1.
get(),
2161 Expr2.
get(), ConsumeParen());
2164 case tok::kw___builtin_astype: {
2172 if (ExpectAndConsume(tok::comma)) {
2183 if (Tok.
isNot(tok::r_paren)) {
2184 Diag(Tok, diag::err_expected) << tok::r_paren;
2189 Res = Actions.ActOnAsTypeExpr(Expr.
get(), DestTy.
get(), StartLoc,
2193 case tok::kw___builtin_convertvector: {
2201 if (ExpectAndConsume(tok::comma)) {
2212 if (Tok.
isNot(tok::r_paren)) {
2213 Diag(Tok, diag::err_expected) << tok::r_paren;
2218 Res = Actions.ActOnConvertVectorExpr(Expr.
get(), DestTy.
get(), StartLoc,
2229 return ParsePostfixExpressionSuffix(Res.
get());
2258 Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
2261 assert(Tok.
is(tok::l_paren) &&
"Not a paren expr!");
2269 bool isAmbiguousTypeId;
2272 if (Tok.
is(tok::code_completion)) {
2283 tok::kw___bridge_transfer,
2284 tok::kw___bridge_retained,
2285 tok::kw___bridge_retain));
2286 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2288 StringRef BridgeCastName = Tok.getName();
2290 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2291 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2301 Diag(Tok, diag::ext_gnu_statement_expr);
2304 Result =
ExprError(
Diag(OpenLoc, diag::err_stmtexpr_file_scope));
2310 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
2313 "statement expr not in code context");
2317 Actions.ActOnStartStmtExpr();
2324 Result = Actions.ActOnStmtExpr(OpenLoc, Stmt.
get(), Tok.getLocation());
2326 Actions.ActOnStmtExprError();
2329 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
2335 if (tokenKind == tok::kw___bridge)
2337 else if (tokenKind == tok::kw___bridge_transfer)
2339 else if (tokenKind == tok::kw___bridge_retained)
2344 assert(tokenKind == tok::kw___bridge_retain);
2346 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2347 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2349 "__bridge_retained");
2354 ColonProtection.restore();
2356 ExprResult SubExpr = ParseCastExpression(
false);
2361 return Actions.ActOnObjCBridgedCast(
getCurScope(), OpenLoc, Kind,
2362 BridgeKeywordLoc, Ty.
get(),
2363 RParenLoc, SubExpr.
get());
2364 }
else if (ExprType >= CompoundLiteral &&
2365 isTypeIdInParens(isAmbiguousTypeId)) {
2374 if (isAmbiguousTypeId && !stopIfCastExpr) {
2375 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,
2383 ParseSpecifierQualifierList(DS);
2385 ParseDeclarator(DeclaratorInfo);
2396 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2404 ColonProtection.restore();
2406 if (Tok.
is(tok::l_brace)) {
2407 ExprType = CompoundLiteral;
2411 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2413 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2416 if (Tok.
is(tok::l_paren)) {
2423 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2437 Result = ParseCastExpression(
false,
2443 Result = Actions.ActOnCastExpr(
getCurScope(), OpenLoc,
2444 DeclaratorInfo, CastTy,
2445 RParenLoc, Result.
get());
2450 Result = ParsePostfixExpressionSuffix(Result);
2466 if (stopIfCastExpr) {
2470 Ty = Actions.ActOnTypeName(
getCurScope(), DeclaratorInfo);
2478 Tok.getIdentifierInfo() == Ident_super &&
2480 GetLookAheadToken(1).isNot(tok::period)) {
2481 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2488 Result = ParseCastExpression(
false,
2492 Result = Actions.ActOnCastExpr(
getCurScope(), OpenLoc,
2493 DeclaratorInfo, CastTy,
2494 RParenLoc, Result.
get());
2499 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2502 }
else if (Tok.
is(tok::ellipsis) &&
2505 }
else if (isTypeCast) {
2512 if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) {
2515 if (ArgExprs.size() == 1 && isFoldOperator(Tok.getKind()) &&
2517 return ParseFoldExpression(ArgExprs[0], T);
2519 ExprType = SimpleExpr;
2520 Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
2530 Result = Actions.CorrectDelayedTyposInExpr(Result);
2532 ExprType = SimpleExpr;
2534 if (isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis))
2535 return ParseFoldExpression(Result, T);
2540 Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(), Result.
get());
2563 Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
2566 assert(Tok.
is(tok::l_brace) &&
"Not a compound literal!");
2568 Diag(LParenLoc, diag::ext_c99_compound_literal);
2571 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc, Result.
get());
2583 ExprResult Parser::ParseStringLiteralExpression(
bool AllowUserDefinedLiteral) {
2584 assert(isTokenStringLiteral() &&
"Not a string literal!");
2591 StringToks.push_back(Tok);
2592 ConsumeStringToken();
2593 }
while (isTokenStringLiteral());
2596 return Actions.ActOnStringLiteral(StringToks,
2614 ExprResult Parser::ParseGenericSelectionExpression() {
2615 assert(Tok.
is(tok::kw__Generic) &&
"_Generic keyword expected");
2619 Diag(KeyLoc, diag::ext_c11_generic_selection);
2639 if (ExpectAndConsume(tok::comma)) {
2649 if (Tok.
is(tok::kw_default)) {
2653 Diag(Tok, diag::err_duplicate_default_assoc);
2654 Diag(DefaultLoc, diag::note_previous_default_assoc);
2669 Types.push_back(Ty);
2671 if (ExpectAndConsume(tok::colon)) {
2680 if (ER.isInvalid()) {
2684 Exprs.push_back(ER.get());
2691 return Actions.ActOnGenericSelectionExpr(KeyLoc, DefaultLoc,
2693 ControllingExpr.
get(),
2715 Kind = Tok.getKind();
2716 assert(isFoldOperator(Kind) &&
"missing fold-operator");
2720 assert(Tok.
is(tok::ellipsis) &&
"not a fold-expression");
2724 if (Tok.
isNot(tok::r_paren)) {
2725 if (!isFoldOperator(Tok.getKind()))
2726 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
2728 if (Kind != tok::unknown && Tok.getKind() !=
Kind)
2729 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
2731 Kind = Tok.getKind();
2742 ? diag::warn_cxx14_compat_fold_expression
2743 : diag::ext_fold_expression);
2774 llvm::function_ref<
void()> Completer) {
2775 bool SawError =
false;
2777 if (Tok.
is(tok::code_completion)) {
2788 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2789 Expr = ParseBraceInitializer();
2793 if (Tok.
is(tok::ellipsis))
2799 Exprs.push_back(Expr.
get());
2802 if (Tok.
isNot(tok::comma))
2810 for (
auto &E : Exprs) {
2834 Exprs.push_back(Expr.
get());
2836 if (Tok.
isNot(tok::comma))
2851 if (Tok.
is(tok::code_completion)) {
2853 return cutOffParsing();
2858 ParseSpecifierQualifierList(DS);
2863 ParseDeclarator(DeclaratorInfo);
2865 MaybeParseGNUAttributes(DeclaratorInfo);
2868 Actions.ActOnBlockArguments(CaretLoc, DeclaratorInfo,
getCurScope());
2881 ExprResult Parser::ParseBlockLiteralExpression() {
2882 assert(Tok.
is(tok::caret) &&
"block literal starts with ^");
2886 "block literal parsing");
2908 if (Tok.
is(tok::l_paren)) {
2909 ParseParenDeclarator(ParamInfo);
2924 MaybeParseGNUAttributes(ParamInfo);
2927 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
2928 }
else if (!Tok.
is(tok::l_brace)) {
2929 ParseBlockId(CaretLoc);
2960 MaybeParseGNUAttributes(ParamInfo);
2963 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
2968 if (!Tok.
is(tok::l_brace)) {
2970 Diag(Tok, diag::err_expected_expression);
2978 Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.
get(),
getCurScope());
2990 return Actions.ActOnObjCBoolLiteral(
ConsumeToken(), Kind);
2997 llvm::SmallSet<StringRef, 4> Platforms;
2998 bool HasOtherPlatformSpec =
false;
3000 for (
const auto &Spec : AvailSpecs) {
3001 if (Spec.isOtherPlatformSpec()) {
3002 if (HasOtherPlatformSpec) {
3003 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3007 HasOtherPlatformSpec =
true;
3011 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3016 StringRef Platform = Spec.getPlatform();
3017 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3018 << Spec.getEndLoc() << Platform;
3023 if (!HasOtherPlatformSpec) {
3024 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3025 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3039 if (Tok.
is(tok::star)) {
3043 if (Tok.
is(tok::code_completion)) {
3044 Actions.CodeCompleteAvailabilityPlatformName();
3048 if (Tok.
isNot(tok::identifier)) {
3049 Diag(Tok, diag::err_avail_query_expected_platform_name);
3055 VersionTuple Version = ParseVersionTuple(VersionRange);
3057 if (Version.
empty())
3060 StringRef GivenPlatform = PlatformIdentifier->
Ident->
getName();
3061 StringRef Platform =
3062 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3064 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty()) {
3066 diag::err_avail_query_unrecognized_platform_name)
3077 assert(Tok.
is(tok::kw___builtin_available) ||
3088 bool HasError =
false;
3094 AvailSpecs.push_back(*Spec);
3110 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
Represents a version number in the form major[.minor[.subminor[.build]]].
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
void diagnoseExprIntendedAsTemplateName(Scope *S, ExprResult TemplateName, SourceLocation Less, SourceLocation Greater)
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
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)
ActionResult< Expr * > ExprResult
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.
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 AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Token - This structure provides full information about a lexed token.
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, ParsedType ObjectType, SourceLocation &TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
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.
const FunctionProtoType * T
This file defines the classes used to store parsed information about declaration-specifiers and decla...
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
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero)...
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
LabelDecl - 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)
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.
const Type * getTypePtrOrNull() const
bool mightBeIntendedToBeTemplateName(ExprResult E)
Determine whether it's plausible that E was intended to be a template-name.
This is a scope that can contain a declaration.
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".
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.
NamedDecl - This represents a decl with a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
void SetRangeEnd(SourceLocation Loc)
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
This class handles loading and caching of source files into memory.
Code completion occurs in a parenthesized expression, which might also be a type cast.
One specifier in an expression.
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.