42#include "llvm/ADT/SmallVector.h"
49 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
55 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
59Parser::ParseExpressionWithLeadingExtension(
SourceLocation ExtLoc) {
69 LHS = Actions.ActOnUnaryOp(
getCurScope(), ExtLoc, tok::kw___extension__,
72 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
77 if (Tok.is(tok::code_completion)) {
79 Actions.CodeCompletion().CodeCompleteExpression(
80 getCurScope(), PreferredType.get(Tok.getLocation()));
84 if (Tok.is(tok::kw_throw))
85 return ParseThrowExpression();
86 if (Tok.is(tok::kw_co_yield))
87 return ParseCoyieldExpression();
91 false, CorrectionBehavior);
96 if (Tok.is(tok::code_completion)) {
98 Actions.CodeCompletion().CodeCompleteExpression(
99 getCurScope(), PreferredType.get(Tok.getLocation()));
110Parser::ParseAssignmentExprWithObjCMessageExprStart(
SourceLocation LBracLoc,
113 Expr *ReceiverExpr) {
115 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
116 ReceiverType, ReceiverExpr);
117 R = ParsePostfixExpressionSuffix(R);
123 assert(Actions.ExprEvalContexts.back().Context ==
125 "Call this function only if your ExpressionEvaluationContext is "
126 "already ConstantEvaluated");
128 CorrectionBehavior));
130 return Actions.ActOnConstantExpression(Res);
149 Actions.ExprEvalContexts.back().InConditionallyConstantEvaluateContext =
true;
163 for (
auto Iter = Actions.ExprEvalContexts.rbegin() + 1;
164 Iter != Actions.ExprEvalContexts.rend(); ++Iter) {
165 if (!Iter->isUnevaluated())
167 Iter->InConditionallyConstantEvaluateContext =
true;
176 Actions.currentEvaluationContext().IsCaseExpr =
true;
182 return Actions.ActOnCaseExpr(CaseLoc, Res);
190 if (Res.
isUsable() && !Actions.CheckConstraintExpression(Res.
get())) {
200 bool NotPrimaryExpression =
false;
201 auto ParsePrimary = [&]() {
205 false, &NotPrimaryExpression);
209 E = ParsePostfixExpressionSuffix(E);
216 ? diag::note_unparenthesized_non_primary_expr_in_requires_clause
217 : diag::err_unparenthesized_non_primary_expr_in_requires_clause)
225 if (NotPrimaryExpression ||
232 Tok.isOneOf(tok::period, tok::plusplus, tok::minusminus) ||
233 (Tok.is(tok::l_square) && !
NextToken().
is(tok::l_square))) {
234 E = RecoverFromNonPrimary(E,
false);
237 NotPrimaryExpression =
false;
239 bool PossibleNonPrimary;
240 bool IsConstraintExpr =
241 Actions.CheckConstraintExpression(E.
get(), Tok, &PossibleNonPrimary,
242 IsTrailingRequiresClause);
243 if (!IsConstraintExpr || PossibleNonPrimary) {
248 if (PossibleNonPrimary)
249 E = RecoverFromNonPrimary(E, !IsConstraintExpr);
257 while (Tok.is(tok::ampamp)) {
264 tok::ampamp, LHS.
get(), RHS.
get());
278 while (Tok.is(tok::pipepipe)) {
286 tok::pipepipe, LHS.
get(), RHS.
get());
295bool Parser::isNotExpressionStart() {
297 if (K == tok::l_brace || K == tok::r_brace ||
298 K == tok::kw_for || K == tok::kw_while ||
299 K == tok::kw_if || K == tok::kw_else ||
300 K == tok::kw_goto || K == tok::kw_try)
303 return isKnownToBeDeclarationSpecifier();
306bool Parser::isFoldOperator(
prec::Level Level)
const {
318 GreaterThanIsOperator,
320 SourceLocation ColonLoc;
322 auto SavedType = PreferredType;
325 PreferredType = SavedType;
329 if (NextTokPrec < MinPrec)
340 if (OpToken.
is(tok::caretcaret)) {
351 UnconsumeToken(OpToken);
352 PP.EnterToken(Caret,
true);
353 return ParseRHSOfBinaryExpression(LHS, MinPrec);
359 if (OpToken.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
360 tok::greatergreatergreater) &&
361 checkPotentialAngleBracketDelimiter(OpToken))
369 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
370 PP.EnterToken(Tok,
true);
377 if (isFoldOperator(NextTokPrec) && Tok.is(tok::ellipsis)) {
380 PP.EnterToken(Tok,
true);
391 Tok.isOneOf(tok::colon, tok::r_square) &&
393 PP.EnterToken(Tok,
true);
403 SourceLocation BraceLoc = Tok.getLocation();
404 TernaryMiddle = ParseBraceInitializer();
405 if (!TernaryMiddle.isInvalid()) {
406 Diag(BraceLoc, diag::err_init_list_bin_op)
407 << 1 << PP.getSpelling(OpToken)
408 << Actions.getExprRange(TernaryMiddle.get());
411 }
else if (Tok.isNot(tok::colon)) {
423 TernaryMiddle =
nullptr;
424 Diag(Tok, diag::ext_gnu_conditional_expr);
427 if (TernaryMiddle.isInvalid()) {
429 TernaryMiddle =
nullptr;
437 SourceLocation FILoc = Tok.getLocation();
438 const char *FIText =
": ";
439 const SourceManager &
SM = PP.getSourceManager();
440 if (FILoc.
isFileID() || PP.isAtStartOfMacroExpansion(FILoc, &FILoc)) {
442 bool IsInvalid =
false;
443 const char *SourcePtr =
445 if (!IsInvalid && *SourcePtr ==
' ') {
448 if (!IsInvalid && *SourcePtr ==
' ') {
455 Diag(Tok, diag::err_expected)
457 Diag(OpToken, diag::note_matching) << tok::question;
458 ColonLoc = Tok.getLocation();
462 PreferredType.enterBinary(Actions, Tok.getLocation(), LHS.
get(),
475 bool RHSIsInitList =
false;
477 RHS = ParseBraceInitializer();
478 RHSIsInitList =
true;
486 if (RHS.
isInvalid() && Tok.isNot(tok::semi)) {
502 if (ThisPrec < NextTokPrec ||
503 (ThisPrec == NextTokPrec && isRightAssoc)) {
505 Diag(Tok, diag::err_init_list_bin_op)
506 << 0 << PP.getSpelling(Tok) << Actions.getExprRange(RHS.
get());
514 RHS = ParseRHSOfBinaryExpression(RHS,
515 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
516 RHSIsInitList =
false;
518 if (RHS.
isInvalid() && Tok.isNot(tok::semi)) {
528 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
529 << Actions.getExprRange(RHS.
get());
530 }
else if (ColonLoc.
isValid()) {
531 Diag(ColonLoc, diag::err_init_list_bin_op)
533 << Actions.getExprRange(RHS.
get());
536 Diag(OpToken, diag::err_init_list_bin_op)
537 << 1 << PP.getSpelling(OpToken)
538 << Actions.getExprRange(RHS.
get());
549 }
else if (TernaryMiddle.isInvalid()) {
553 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
555 diag::warn_cxx11_right_shift_in_template_arg,
556 SourceRange(Actions.getExprRange(LHS.
get()).getBegin(),
557 Actions.getExprRange(RHS.
get()).getEnd()));
565 {LHS.get(), RHS.get()});
569 ExprResult CondOp = Actions.ActOnConditionalOp(
573 std::vector<clang::Expr *> Args;
575 if (TernaryMiddle.get())
576 Args = {LHS.
get(), TernaryMiddle.get(), RHS.
get()};
578 Args = {LHS.
get(), RHS.
get()};
590Parser::ParseCastExpression(
CastParseKind ParseKind,
bool isAddressOfOperand,
592 bool isVectorLiteral,
bool *NotPrimaryExpression) {
594 ExprResult Res = ParseCastExpression(ParseKind, isAddressOfOperand,
595 NotCastExpr, CorrectionBehavior,
596 isVectorLiteral, NotPrimaryExpression);
598 Diag(Tok, diag::err_expected_expression);
605 CastExpressionIdValidator(Token
Next,
608 WantTypeSpecifiers = WantFunctionLikeCasts =
609 (CorrectionBehavior != TypoCorrectionTypeBehavior::AllowNonTypes);
611 (CorrectionBehavior != TypoCorrectionTypeBehavior::AllowTypes);
614 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
620 return WantTypeSpecifiers;
625 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
628 for (
auto *
C : candidate) {
636 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
637 return std::make_unique<CastExpressionIdValidator>(*
this);
648 if (RevertibleTypeTraits.empty()) {
652#define RTT_JOIN(X, Y) X##Y
653#define REVERTIBLE_TYPE_TRAIT(Name) \
654 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
711#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
712 REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
713#include "clang/Basic/TransformTypeTraits.def"
714#undef REVERTIBLE_TYPE_TRAIT
717 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known =
718 RevertibleTypeTraits.find(II);
719 if (Known != RevertibleTypeTraits.end()) {
721 *
Kind = Known->second;
727ExprResult Parser::ParseBuiltinPtrauthTypeDiscriminator() {
731 if (T.expectAndConsume())
740 SourceLocation EndLoc = Tok.getLocation();
742 return Actions.ActOnUnaryExprOrTypeTraitExpr(
743 Loc, UETT_PtrAuthTypeDiscriminator,
748Parser::ParseCastExpression(
CastParseKind ParseKind,
bool isAddressOfOperand,
751 bool isVectorLiteral,
bool *NotPrimaryExpression) {
754 auto SavedType = PreferredType;
760 bool AllowSuffix =
true;
789 SourceLocation RParenLoc;
790 Res = ParseParenExpression(ParenExprType,
false,
800 switch (ParenExprType) {
823 case tok::numeric_constant:
824 case tok::binary_data:
828 Res = Actions.ActOnNumericConstant(Tok,
getCurScope());
834 Res = ParseCXXBoolLiteral();
837 case tok::kw___objc_yes:
838 case tok::kw___objc_no:
839 Res = ParseObjCBoolLiteral();
842 case tok::kw_nullptr:
844 Diag(Tok, diag::warn_cxx98_compat_nullptr);
847 : diag::ext_c_nullptr) << Tok.getName();
852 case tok::annot_primary_expr:
853 case tok::annot_overload_set:
854 Res = getExprAnnotation(Tok);
855 if (!Res.
isInvalid() && Tok.getKind() == tok::annot_overload_set)
856 Res = Actions.ActOnNameClassifiedAsOverloadSet(
getCurScope(), Res.
get());
857 ConsumeAnnotationToken();
858 if (!Res.
isInvalid() && Tok.is(tok::less))
859 checkPotentialAngleBracket(Res);
862 case tok::annot_non_type:
863 case tok::annot_non_type_dependent:
864 case tok::annot_non_type_undeclared: {
866 Res = tryParseCXXIdExpression(SS, isAddressOfOperand);
868 "should not perform typo correction on annotation token");
872 case tok::annot_embed: {
874 return ParseCastExpression(ParseKind, isAddressOfOperand,
875 CorrectionBehavior, isVectorLiteral,
876 NotPrimaryExpression);
879 case tok::kw___super:
880 case tok::kw_decltype:
884 assert(Tok.isNot(tok::kw_decltype) && Tok.isNot(tok::kw___super));
885 return ParseCastExpression(ParseKind, isAddressOfOperand,
886 CorrectionBehavior, isVectorLiteral,
887 NotPrimaryExpression);
889 case tok::identifier:
900 if (
Next.is(tok::ellipsis) && Tok.is(tok::identifier) &&
906 Tok.isOneOf(tok::annot_pack_indexing_type, tok::annot_cxxscope))
907 return ParseCastExpression(ParseKind, isAddressOfOperand,
908 CorrectionBehavior, isVectorLiteral,
909 NotPrimaryExpression);
915 else if (
Next.is(tok::l_paren) && Tok.is(tok::identifier) &&
916 Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
917 IdentifierInfo *II = Tok.getIdentifierInfo();
919 if (isRevertibleTypeTrait(II, &Kind)) {
921 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
922 CorrectionBehavior, isVectorLiteral,
923 NotPrimaryExpression);
927 else if ((!ColonIsSacred &&
Next.is(tok::colon)) ||
928 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
933 if (!Tok.is(tok::identifier))
934 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
935 CorrectionBehavior, isVectorLiteral,
936 NotPrimaryExpression);
942 IdentifierInfo &II = *Tok.getIdentifierInfo();
949 (&II == Ident_super &&
getCurScope()->isInObjcMethodScope()))) {
952 if (Tok.is(tok::code_completion) && &II != Ident_super) {
954 Actions.CodeCompletion().CodeCompleteObjCClassPropertyRefExpr(
955 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
959 if (Tok.isNot(tok::identifier) &&
961 Diag(Tok, diag::err_expected_property_name);
964 IdentifierInfo &PropertyName = *Tok.getIdentifierInfo();
967 Res = Actions.ObjC().ActOnClassPropertyRefExpr(II, PropertyName, ILoc,
976 if (
getLangOpts().
ObjC && &II == Ident_super && !InMessageExpression &&
978 ((Tok.is(tok::identifier) &&
980 Tok.is(tok::code_completion))) {
981 Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc,
nullptr,
992 ((Tok.is(tok::identifier) && !InMessageExpression) ||
993 Tok.is(tok::code_completion))) {
995 if (Tok.is(tok::code_completion) ||
996 Next.is(tok::colon) ||
Next.is(tok::r_square))
998 if (Typ.get()->isObjCObjectOrInterfaceType()) {
1000 DeclSpec DS(AttrFactory);
1001 DS.SetRangeStart(ILoc);
1002 DS.SetRangeEnd(ILoc);
1003 const char *PrevSpec =
nullptr;
1005 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
1006 Actions.getASTContext().getPrintingPolicy());
1010 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
1014 Res = ParseObjCMessageExpressionBody(SourceLocation(),
1022 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1023 isAddressOfOperand =
false;
1029 CXXScopeSpec ScopeSpec;
1030 SourceLocation TemplateKWLoc;
1031 CastExpressionIdValidator Validator(Tok, CorrectionBehavior);
1032 Validator.IsAddressOfOperand = isAddressOfOperand;
1033 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
1034 Validator.WantExpressionKeywords =
false;
1035 Validator.WantRemainingKeywords =
false;
1037 Validator.WantRemainingKeywords = Tok.isNot(tok::r_paren);
1040 Res = Actions.ActOnIdExpression(
getCurScope(), ScopeSpec, TemplateKWLoc,
1041 Name, Tok.is(tok::l_paren),
1042 isAddressOfOperand, &Validator,
1044 Res = tryParseCXXPackIndexingExpression(Res);
1045 if (!Res.
isInvalid() && Tok.is(tok::less))
1046 checkPotentialAngleBracket(Res);
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_L__FUNCSIG__:
1063 case tok::kw___PRETTY_FUNCTION__:
1070 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:
1082 case tok::kw__Generic:
1083 Res = ParseGenericSelectionExpression();
1085 case tok::kw___builtin_available:
1086 Res = ParseAvailabilityCheckExpr(Tok.getLocation());
1088 case tok::kw___builtin_va_arg:
1089 case tok::kw___builtin_offsetof:
1090 case tok::kw___builtin_choose_expr:
1091 case tok::kw___builtin_astype:
1092 case tok::kw___builtin_convertvector:
1093 case tok::kw___builtin_COLUMN:
1094 case tok::kw___builtin_FILE:
1095 case tok::kw___builtin_FILE_NAME:
1096 case tok::kw___builtin_FUNCTION:
1097 case tok::kw___builtin_FUNCSIG:
1098 case tok::kw___builtin_LINE:
1099 case tok::kw___builtin_source_location:
1100 if (NotPrimaryExpression)
1101 *NotPrimaryExpression =
true;
1103 return ParseBuiltinPrimaryExpression();
1104 case tok::kw___null:
1109 case tok::minusminus: {
1110 if (NotPrimaryExpression)
1111 *NotPrimaryExpression =
true;
1116 Token SavedTok = Tok;
1119 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedTok.
getKind(),
1133 UnconsumeToken(SavedTok);
1137 Expr *Arg = Res.
get();
1141 Res = Actions.CreateRecoveryExpr(SavedTok.
getLocation(),
1147 if (NotPrimaryExpression)
1148 *NotPrimaryExpression =
true;
1151 PreferredType.enterUnary(Actions, Tok.getLocation(), tok::amp, SavedLoc);
1156 Expr *Arg = Res.
get();
1157 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Arg);
1159 Res = Actions.CreateRecoveryExpr(Tok.getLocation(), Arg->
getEndLoc(),
1170 case tok::kw___real:
1171 case tok::kw___imag: {
1172 if (NotPrimaryExpression)
1173 *NotPrimaryExpression =
true;
1175 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedKind, SavedLoc);
1178 Expr *Arg = Res.
get();
1179 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Arg,
1180 isAddressOfOperand);
1182 Res = Actions.CreateRecoveryExpr(SavedLoc, Arg->
getEndLoc(), Arg);
1187 case tok::kw_co_await: {
1188 if (NotPrimaryExpression)
1189 *NotPrimaryExpression =
true;
1193 Res = Actions.ActOnCoawaitExpr(
getCurScope(), CoawaitLoc, Res.
get());
1197 case tok::kw___extension__:{
1199 if (NotPrimaryExpression)
1200 *NotPrimaryExpression =
true;
1201 ExtensionRAIIObject O(Diags);
1205 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.
get());
1208 case tok::kw__Alignof:
1209 diagnoseUseOfC11Keyword(Tok);
1211 case tok::kw_alignof:
1212 case tok::kw___alignof:
1214 case tok::kw_sizeof:
1218 case tok::kw___datasizeof:
1219 case tok::kw_vec_step:
1221 case tok::kw___builtin_omp_required_simd_align:
1222 case tok::kw___builtin_vectorelements:
1223 case tok::kw__Countof:
1224 if (NotPrimaryExpression)
1225 *NotPrimaryExpression =
true;
1226 AllowSuffix =
false;
1227 Res = ParseUnaryExprOrTypeTraitExpression();
1229 case tok::caretcaret: {
1235 if (NotPrimaryExpression)
1236 *NotPrimaryExpression =
true;
1237 AllowSuffix =
false;
1238 Res = ParseCXXReflectExpression();
1242 if (NotPrimaryExpression)
1243 *NotPrimaryExpression =
true;
1245 if (Tok.isNot(tok::identifier))
1246 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1249 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1251 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1252 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(),
1254 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD);
1256 AllowSuffix =
false;
1259 case tok::kw_const_cast:
1260 case tok::kw_dynamic_cast:
1261 case tok::kw_reinterpret_cast:
1262 case tok::kw_static_cast:
1263 case tok::kw_addrspace_cast:
1264 if (NotPrimaryExpression)
1265 *NotPrimaryExpression =
true;
1266 Res = ParseCXXCasts();
1268 case tok::kw___builtin_bit_cast:
1269 if (NotPrimaryExpression)
1270 *NotPrimaryExpression =
true;
1271 Res = ParseBuiltinBitCast();
1273 case tok::kw_typeid:
1274 if (NotPrimaryExpression)
1275 *NotPrimaryExpression =
true;
1276 Res = ParseCXXTypeid();
1278 case tok::kw___uuidof:
1279 if (NotPrimaryExpression)
1280 *NotPrimaryExpression =
true;
1281 Res = ParseCXXUuidof();
1284 Res = ParseCXXThis();
1286 case tok::kw___builtin_sycl_unique_stable_name:
1287 Res = ParseSYCLUniqueStableNameExpression();
1290 case tok::annot_typename:
1291 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1295 DeclSpec DS(AttrFactory);
1296 DS.SetRangeStart(Tok.getLocation());
1297 DS.SetRangeEnd(Tok.getLastLoc());
1299 const char *PrevSpec =
nullptr;
1301 DS.SetTypeSpecType(
TST_typename, Tok.getAnnotationEndLoc(),
1302 PrevSpec, DiagID,
Type,
1303 Actions.getASTContext().getPrintingPolicy());
1307 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
1311 ConsumeAnnotationToken();
1312 Res = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1318 case tok::annot_decltype:
1319 case tok::annot_pack_indexing_type:
1321 case tok::kw_wchar_t:
1322 case tok::kw_char8_t:
1323 case tok::kw_char16_t:
1324 case tok::kw_char32_t:
1329 case tok::kw___int64:
1330 case tok::kw___int128:
1331 case tok::kw__ExtInt:
1332 case tok::kw__BitInt:
1333 case tok::kw_signed:
1334 case tok::kw_unsigned:
1337 case tok::kw_double:
1338 case tok::kw___bf16:
1339 case tok::kw__Float16:
1340 case tok::kw___float128:
1341 case tok::kw___ibm128:
1344 case tok::kw_typename:
1345 case tok::kw_typeof:
1346 case tok::kw_typeof_unqual:
1347 case tok::kw___vector:
1348 case tok::kw__Accum:
1349 case tok::kw__Fract:
1351#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1352#include "clang/Basic/OpenCLImageTypes.def"
1353#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
1354#include "clang/Basic/HLSLIntangibleTypes.def"
1357 Diag(Tok, diag::err_expected_expression);
1362 if (NotPrimaryExpression)
1363 *NotPrimaryExpression =
true;
1365 if (SavedKind == tok::kw_typename) {
1380 DeclSpec DS(AttrFactory);
1382 ParseCXXSimpleTypeSpecifier(DS);
1383 if (Tok.isNot(tok::l_paren) &&
1385 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1386 << DS.getSourceRange());
1388 if (Tok.is(tok::l_brace))
1389 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1391 Res = ParseCXXTypeConstructExpression(DS);
1395 case tok::annot_cxxscope: {
1400 if (!Tok.is(tok::annot_cxxscope))
1401 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1402 CorrectionBehavior, isVectorLiteral,
1403 NotPrimaryExpression);
1406 if (
Next.is(tok::annot_template_id)) {
1407 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(
Next);
1413 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1417 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1418 CorrectionBehavior, isVectorLiteral,
1419 NotPrimaryExpression);
1424 Res = ParseCXXIdExpression(isAddressOfOperand);
1428 case tok::annot_template_id: {
1429 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1436 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1437 CorrectionBehavior, isVectorLiteral,
1438 NotPrimaryExpression);
1445 case tok::kw_operator:
1446 Res = ParseCXXIdExpression(isAddressOfOperand);
1449 case tok::coloncolon: {
1454 if (!Tok.is(tok::coloncolon))
1455 return ParseCastExpression(ParseKind, isAddressOfOperand,
1456 CorrectionBehavior, isVectorLiteral,
1457 NotPrimaryExpression);
1462 if (Tok.is(tok::kw_new)) {
1463 if (NotPrimaryExpression)
1464 *NotPrimaryExpression =
true;
1465 Res = ParseCXXNewExpression(
true, CCLoc);
1466 AllowSuffix =
false;
1469 if (Tok.is(tok::kw_delete)) {
1470 if (NotPrimaryExpression)
1471 *NotPrimaryExpression =
true;
1472 Res = ParseCXXDeleteExpression(
true, CCLoc);
1473 AllowSuffix =
false;
1478 Diag(CCLoc, diag::err_expected_expression);
1483 if (NotPrimaryExpression)
1484 *NotPrimaryExpression =
true;
1485 Res = ParseCXXNewExpression(
false, Tok.getLocation());
1486 AllowSuffix =
false;
1489 case tok::kw_delete:
1490 if (NotPrimaryExpression)
1491 *NotPrimaryExpression =
true;
1492 Res = ParseCXXDeleteExpression(
false, Tok.getLocation());
1493 AllowSuffix =
false;
1496 case tok::kw_requires:
1497 Res = ParseRequiresExpression();
1498 AllowSuffix =
false;
1501 case tok::kw_noexcept: {
1502 if (NotPrimaryExpression)
1503 *NotPrimaryExpression =
true;
1504 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1508 if (T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1520 Res = Actions.ActOnNoexceptExpr(KeyLoc, T.getOpenLocation(), Res.
get(),
1521 T.getCloseLocation());
1522 AllowSuffix =
false;
1526#define TYPE_TRAIT(N,Spelling,K) \
1527 case tok::kw_##Spelling:
1528#include "clang/Basic/TokenKinds.def"
1529 Res = ParseTypeTrait();
1532 case tok::kw___array_rank:
1533 case tok::kw___array_extent:
1534 if (NotPrimaryExpression)
1535 *NotPrimaryExpression =
true;
1536 Res = ParseArrayTypeTrait();
1539 case tok::kw___builtin_ptrauth_type_discriminator:
1540 return ParseBuiltinPtrauthTypeDiscriminator();
1542 case tok::kw___is_lvalue_expr:
1543 case tok::kw___is_rvalue_expr:
1544 if (NotPrimaryExpression)
1545 *NotPrimaryExpression =
true;
1546 Res = ParseExpressionTrait();
1550 if (NotPrimaryExpression)
1551 *NotPrimaryExpression =
true;
1553 return ParseObjCAtExpression(AtLoc);
1556 Res = ParseBlockLiteralExpression();
1558 case tok::code_completion: {
1560 Actions.CodeCompletion().CodeCompleteExpression(
1561 getCurScope(), PreferredType.get(Tok.getLocation()),
1562 false, isAddressOfOperand);
1565#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
1566#include "clang/Basic/TransformTypeTraits.def"
1570 Tok.setKind(tok::identifier);
1571 Diag(Tok, diag::ext_keyword_as_ident)
1572 << Tok.getIdentifierInfo()->getName() << 0;
1573 goto ParseIdentifier;
1575 goto ExpectedExpression;
1584 Res = TryParseLambdaExpression();
1588 if (NotPrimaryExpression)
1589 *NotPrimaryExpression =
true;
1590 Res = ParseObjCMessageExpression();
1594 Res = ParseLambdaExpression();
1598 Res = ParseObjCMessageExpression();
1623 switch (Tok.getKind()) {
1627 case tok::minusminus:
1630 if (Tok.isAtStartOfLine())
1645 Diag(Tok.getLocation(), diag::err_postfix_after_unary_requires_parens)
1653 PreferredType = SavedType;
1654 Res = ParsePostfixExpressionSuffix(Res);
1656 !
getActions().getOpenCLOptions().isAvailableOption(
1658 if (Expr *PostfixExpr = Res.
get()) {
1659 QualType Ty = PostfixExpr->getType();
1661 Diag(PostfixExpr->getExprLoc(),
1662 diag::err_opencl_taking_function_address_parser);
1671Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1675 auto SavedType = PreferredType;
1678 PreferredType = SavedType;
1679 switch (Tok.getKind()) {
1680 case tok::code_completion:
1681 if (InMessageExpression)
1685 Actions.CodeCompletion().CodeCompletePostfixExpression(
1686 getCurScope(), LHS, PreferredType.get(Tok.getLocation()));
1689 case tok::identifier:
1695 LHS = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1696 nullptr, LHS.
get());
1704 case tok::l_square: {
1712 isSimpleObjCMessageExpression())
1717 if (CheckProhibitedCXX11Attribute()) {
1722 Loc = T.getOpenLocation();
1724 SourceLocation ColonLocFirst, ColonLocSecond;
1725 ExprVector ArgExprs;
1726 bool HasError =
false;
1727 PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.
get());
1733 if ((!
getLangOpts().OpenMP && !AllowOpenACCArraySections) ||
1734 Tok.isNot(tok::colon)) {
1738 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1739 Idx = ParseBraceInitializer();
1746 ArgExprs.push_back(Idx.
get());
1748 }
else if (Tok.isNot(tok::r_square)) {
1749 if (ParseExpressionList(ArgExprs)) {
1759 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {
1761 if (Tok.is(tok::colon)) {
1764 if (Tok.isNot(tok::r_square))
1767 }
else if (ArgExprs.size() <= 1 &&
getLangOpts().OpenMP) {
1769 if (Tok.is(tok::colon)) {
1772 if (Tok.isNot(tok::r_square) &&
1774 ((Tok.isNot(tok::colon) &&
getLangOpts().OpenMP >= 50)))) {
1779 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||
1780 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
1781 Tok.is(tok::colon)) {
1784 if (Tok.isNot(tok::r_square)) {
1790 SourceLocation RLoc = Tok.getLocation();
1791 if (!LHS.
isInvalid() && !HasError && !Length.isInvalid() &&
1792 !Stride.
isInvalid() && Tok.is(tok::r_square)) {
1798 if (AllowOpenACCArraySections) {
1800 "Stride/second colon not allowed for OpenACC");
1801 LHS = Actions.OpenACC().ActOnArraySectionExpr(
1802 LHS.
get(), Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
1803 ColonLocFirst, Length.get(), RLoc);
1805 LHS = Actions.OpenMP().ActOnOMPArraySectionExpr(
1806 LHS.
get(), Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
1807 ColonLocFirst, ColonLocSecond, Length.get(), Stride.
get(),
1811 LHS = Actions.ActOnArraySubscriptExpr(
getCurScope(), LHS.
get(), Loc,
1824 case tok::lesslessless: {
1829 Expr *ExecConfig =
nullptr;
1833 if (OpKind == tok::lesslessless) {
1834 ExprVector ExecConfigExprs;
1837 if (ParseSimpleExpressionList(ExecConfigExprs)) {
1841 SourceLocation CloseLoc;
1847 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1848 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1854 if (ExpectAndConsume(tok::l_paren))
1857 Loc = PrevTokLocation;
1861 ExprResult ECResult = Actions.CUDA().ActOnExecConfigExpr(
1862 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);
1866 ExecConfig = ECResult.
get();
1870 Loc = PT.getOpenLocation();
1873 ExprVector ArgExprs;
1874 auto RunSignatureHelp = [&]() -> QualType {
1875 QualType PreferredType =
1876 Actions.CodeCompletion().ProduceCallSignatureHelp(
1877 LHS.
get(), ArgExprs, PT.getOpenLocation());
1878 CalledSignatureHelp =
true;
1879 return PreferredType;
1881 bool ExpressionListIsInvalid =
false;
1882 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1883 if (Tok.isNot(tok::r_paren)) {
1884 if ((ExpressionListIsInvalid = ParseExpressionList(ArgExprs, [&] {
1885 PreferredType.enterFunctionArgument(Tok.getLocation(),
1892 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
1901 }
else if (ExpressionListIsInvalid) {
1902 Expr *
Fn = LHS.
get();
1903 ArgExprs.insert(ArgExprs.begin(), Fn);
1904 LHS = Actions.CreateRecoveryExpr(
Fn->getBeginLoc(), Tok.getLocation(),
1907 }
else if (Tok.isNot(tok::r_paren)) {
1908 bool HadErrors =
false;
1911 for (
auto &E : ArgExprs)
1912 if (E->containsErrors())
1923 Expr *
Fn = LHS.
get();
1924 SourceLocation RParLoc = Tok.getLocation();
1925 LHS = Actions.ActOnCallExpr(
getCurScope(), Fn, Loc, ArgExprs, RParLoc,
1928 ArgExprs.insert(ArgExprs.begin(), Fn);
1930 Actions.CreateRecoveryExpr(
Fn->getBeginLoc(), RParLoc, ArgExprs);
1946 bool MayBePseudoDestructor =
false;
1947 Expr* OrigLHS = !LHS.
isInvalid() ? LHS.
get() :
nullptr;
1949 PreferredType.enterMemAccess(Actions, Tok.getLocation(), OrigLHS);
1952 Expr *
Base = OrigLHS;
1953 const Type* BaseType =
Base->getType().getTypePtrOrNull();
1954 if (BaseType && Tok.is(tok::l_paren) &&
1957 Diag(OpLoc, diag::err_function_is_not_record)
1958 << OpKind <<
Base->getSourceRange()
1960 return ParsePostfixExpressionSuffix(Base);
1963 LHS = Actions.ActOnStartCXXMemberReference(
getCurScope(), Base, OpLoc,
1965 MayBePseudoDestructor);
1970 if (Tok.is(tok::code_completion)) {
1976 ParseOptionalCXXScopeSpecifier(
1978 false, &MayBePseudoDestructor);
1980 ObjectType =
nullptr;
1983 if (Tok.is(tok::code_completion)) {
1985 OpKind == tok::arrow ? tok::period : tok::arrow;
1990 Sema::TentativeAnalysisScope Trap(Actions);
1991 CorrectedLHS = Actions.ActOnStartCXXMemberReference(
1992 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
1993 MayBePseudoDestructor);
1997 Expr *CorrectedBase = CorrectedLHS.get();
1999 CorrectedBase =
Base;
2003 Actions.CodeCompletion().CodeCompleteMemberReferenceExpr(
2004 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,
2005 Base && ExprStatementTokLoc ==
Base->getBeginLoc(),
2006 PreferredType.get(Tok.getLocation()));
2011 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
2012 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
2024 SourceLocation TemplateKWLoc;
2027 Tok.is(tok::kw_class)) {
2035 IdentifierInfo *Id = Tok.getIdentifierInfo();
2044 false, &TemplateKWLoc, Name)) {
2049 LHS = Actions.ActOnMemberAccessExpr(
getCurScope(), LHS.
get(), OpLoc,
2050 OpKind, SS, TemplateKWLoc, Name,
2051 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
2054 if (Tok.is(tok::less))
2055 checkPotentialAngleBracket(LHS);
2056 }
else if (OrigLHS && Name.
isValid()) {
2058 LHS = Actions.CreateRecoveryExpr(OrigLHS->
getBeginLoc(),
2064 case tok::minusminus:
2066 Expr *Arg = LHS.
get();
2067 LHS = Actions.ActOnPostfixUnaryOp(
getCurScope(), Tok.getLocation(),
2068 Tok.getKind(), Arg);
2070 LHS = Actions.CreateRecoveryExpr(Arg->
getBeginLoc(),
2071 Tok.getLocation(), Arg);
2080Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
2085 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,
2086 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,
2087 tok::kw__Alignof, tok::kw_vec_step,
2088 tok::kw___builtin_omp_required_simd_align,
2089 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2090 "Not a typeof/sizeof/alignof/vec_step expression!");
2095 if (Tok.isNot(tok::l_paren)) {
2098 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2099 tok::kw_alignof, tok::kw__Alignof)) {
2100 if (isTypeIdUnambiguously()) {
2101 DeclSpec DS(AttrFactory);
2102 ParseSpecifierQualifierList(DS);
2105 ParseDeclarator(DeclaratorInfo);
2107 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.
getLocation());
2108 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
2111 diag::err_expected_parentheses_around_typename)
2114 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
2124 if (OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
2135 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2136 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof) &&
2137 Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2138 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof))
2139 Actions.runWithSufficientStackSpace(Tok.getLocation(), [&] {
2140 Operand = ParseCastExpression(CastParseKind::UnaryExprOnly);
2159 bool ParenKnownToBeNonCast =
2160 OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual);
2162 SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
2164 Operand = ParseParenExpression(
2169 CastRange = SourceRange(LParenLoc, RParenLoc);
2179 !OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {
2194ExprResult Parser::ParseSYCLUniqueStableNameExpression() {
2195 assert(Tok.is(tok::kw___builtin_sycl_unique_stable_name) &&
2196 "Not __builtin_sycl_unique_stable_name");
2202 if (T.expectAndConsume(diag::err_expected_lparen_after,
2203 "__builtin_sycl_unique_stable_name"))
2213 if (T.consumeClose())
2216 return Actions.SYCL().ActOnUniqueStableNameExpr(
2217 OpLoc, T.getOpenLocation(), T.getCloseLocation(), Ty.
get());
2220ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
2221 assert(Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2222 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
2223 tok::kw___builtin_omp_required_simd_align,
2224 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2225 "Not a sizeof/alignof/vec_step expression!");
2230 if (Tok.is(tok::ellipsis) && OpTok.
is(tok::kw_sizeof)) {
2232 SourceLocation LParenLoc, RParenLoc;
2233 IdentifierInfo *Name =
nullptr;
2234 SourceLocation NameLoc;
2235 if (Tok.is(tok::l_paren)) {
2238 LParenLoc = T.getOpenLocation();
2239 if (Tok.is(tok::identifier)) {
2240 Name = Tok.getIdentifierInfo();
2243 RParenLoc = T.getCloseLocation();
2245 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2247 Diag(Tok, diag::err_expected_parameter_pack);
2250 }
else if (Tok.is(tok::identifier)) {
2251 Name = Tok.getIdentifierInfo();
2253 LParenLoc = PP.getLocForEndOfToken(EllipsisLoc);
2254 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2255 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2260 Diag(Tok, diag::err_sizeof_parameter_pack);
2270 return Actions.ActOnSizeofParameterPackExpr(
getCurScope(),
2277 OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2278 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2280 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.
getName();
2282 Diag(OpTok, diag::warn_c2y_compat_keyword) << OpTok.
getName();
2290 SourceRange CastRange;
2298 case tok::kw_alignof:
2299 case tok::kw__Alignof:
2300 ExprKind = UETT_AlignOf;
2302 case tok::kw___alignof:
2303 ExprKind = UETT_PreferredAlignOf;
2305 case tok::kw_vec_step:
2306 ExprKind = UETT_VecStep;
2308 case tok::kw___builtin_omp_required_simd_align:
2309 ExprKind = UETT_OpenMPRequiredSimdAlign;
2311 case tok::kw___datasizeof:
2312 ExprKind = UETT_DataSizeOf;
2314 case tok::kw___builtin_vectorelements:
2315 ExprKind = UETT_VectorElements;
2317 case tok::kw__Countof:
2318 ExprKind = UETT_CountOf;
2321 Diag(OpTok, diag::ext_c2y_feature) << OpTok.
getName();
2328 return Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.
getLocation(),
2334 if (OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2347ExprResult Parser::ParseBuiltinPrimaryExpression() {
2349 const IdentifierInfo *BuiltinII = Tok.getIdentifierInfo();
2355 if (Tok.isNot(tok::l_paren))
2356 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2365 default: llvm_unreachable(
"Not a builtin primary expression!");
2366 case tok::kw___builtin_va_arg: {
2369 if (ExpectAndConsume(tok::comma)) {
2376 if (Tok.isNot(tok::r_paren)) {
2377 Diag(Tok, diag::err_expected) << tok::r_paren;
2384 Res = Actions.ActOnVAArg(StartLoc, Expr.get(), Ty.
get(), ConsumeParen());
2387 case tok::kw___builtin_offsetof: {
2388 SourceLocation TypeLoc = Tok.getLocation();
2390 if (Tok.getLocation().isMacroID()) {
2392 Tok.getLocation(), PP.getSourceManager(),
getLangOpts());
2393 if (MacroName ==
"offsetof")
2406 if (ExpectAndConsume(tok::comma)) {
2411 auto TriggerCompletion = [&](
const Designation &D) {
2413 Actions.CodeCompletion().CodeCompleteOffsetOfDesignator(
2414 Actions.GetTypeFromParser(Ty.
get()), D);
2419 if (Tok.is(tok::code_completion)) {
2420 TriggerCompletion(D);
2423 if (Tok.isNot(tok::identifier)) {
2424 Diag(Tok, diag::err_expected) << tok::identifier;
2433 SmallVector<Sema::OffsetOfComponent, 4> Comps;
2435 Comps.push_back(Sema::OffsetOfComponent());
2436 Comps.back().isBrackets =
false;
2437 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2438 Comps.back().LocStart = Comps.back().LocEnd = Tok.getLocation();
2440 Tok.getIdentifierInfo(), SourceLocation(), Tok.getLocation()));
2445 if (Tok.is(tok::period)) {
2447 Comps.push_back(Sema::OffsetOfComponent());
2448 Comps.back().isBrackets =
false;
2451 if (Tok.is(tok::code_completion)) {
2452 TriggerCompletion(D);
2455 if (Tok.isNot(tok::identifier)) {
2456 Diag(Tok, diag::err_expected) << tok::identifier;
2460 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2461 Comps.back().LocEnd = Tok.getLocation();
2463 Tok.getIdentifierInfo(), Comps.back().LocStart, Tok.getLocation()));
2465 }
else if (Tok.is(tok::l_square)) {
2466 if (CheckProhibitedCXX11Attribute())
2470 Comps.push_back(Sema::OffsetOfComponent());
2471 Comps.back().isBrackets =
true;
2474 Comps.back().LocStart = ST.getOpenLocation();
2480 Comps.back().U.E = Res.
get();
2483 Comps.back().LocEnd = ST.getCloseLocation();
2493 if (Tok.is(tok::code_completion)) {
2497 if (Tok.isNot(tok::r_paren)) {
2504 Res = Actions.ActOnBuiltinOffsetOf(
getCurScope(), StartLoc, TypeLoc,
2506 PT.getCloseLocation());
2513 case tok::kw___builtin_choose_expr: {
2515 if (
Cond.isInvalid()) {
2519 if (ExpectAndConsume(tok::comma)) {
2525 if (Expr1.isInvalid()) {
2529 if (ExpectAndConsume(tok::comma)) {
2535 if (Expr2.isInvalid()) {
2539 if (Tok.isNot(tok::r_paren)) {
2540 Diag(Tok, diag::err_expected) << tok::r_paren;
2543 Res = Actions.ActOnChooseExpr(StartLoc,
Cond.get(), Expr1.get(),
2544 Expr2.get(), ConsumeParen());
2547 case tok::kw___builtin_astype: {
2550 if (Expr.isInvalid()) {
2555 if (ExpectAndConsume(tok::comma)) {
2566 if (Tok.isNot(tok::r_paren)) {
2567 Diag(Tok, diag::err_expected) << tok::r_paren;
2572 Res = Actions.ActOnAsTypeExpr(Expr.get(), DestTy.
get(), StartLoc,
2576 case tok::kw___builtin_convertvector: {
2579 if (Expr.isInvalid()) {
2584 if (ExpectAndConsume(tok::comma)) {
2595 if (Tok.isNot(tok::r_paren)) {
2596 Diag(Tok, diag::err_expected) << tok::r_paren;
2601 Res = Actions.ActOnConvertVectorExpr(Expr.get(), DestTy.
get(), StartLoc,
2605 case tok::kw___builtin_COLUMN:
2606 case tok::kw___builtin_FILE:
2607 case tok::kw___builtin_FILE_NAME:
2608 case tok::kw___builtin_FUNCTION:
2609 case tok::kw___builtin_FUNCSIG:
2610 case tok::kw___builtin_LINE:
2611 case tok::kw___builtin_source_location: {
2613 if (Tok.isNot(tok::r_paren)) {
2614 Diag(Tok, diag::err_expected) << tok::r_paren;
2620 case tok::kw___builtin_FILE:
2622 case tok::kw___builtin_FILE_NAME:
2624 case tok::kw___builtin_FUNCTION:
2626 case tok::kw___builtin_FUNCSIG:
2628 case tok::kw___builtin_LINE:
2630 case tok::kw___builtin_COLUMN:
2632 case tok::kw___builtin_source_location:
2635 llvm_unreachable(
"invalid keyword");
2638 Res = Actions.ActOnSourceLocExpr(Kind, StartLoc, ConsumeParen());
2648 return ParsePostfixExpressionSuffix(Res.
get());
2651bool Parser::tryParseOpenMPArrayShapingCastPart() {
2652 assert(Tok.is(tok::l_square) &&
"Expected open bracket");
2653 bool ErrorFound =
true;
2654 TentativeParsingAction TPA(*
this);
2656 if (Tok.isNot(tok::l_square))
2661 while (!
SkipUntil(tok::r_square, tok::annot_pragma_openmp_end,
2664 if (Tok.isNot(tok::r_square))
2669 if (Tok.is(tok::r_paren)) {
2673 }
while (Tok.isNot(tok::annot_pragma_openmp_end));
2679Parser::ParseParenExpression(
ParenParseOption &ExprType,
bool StopIfCastExpr,
2683 assert(Tok.is(tok::l_paren) &&
"Not a paren expr!");
2686 if (T.consumeOpen())
2688 SourceLocation OpenLoc = T.getOpenLocation();
2690 PreferredType.enterParenExpr(Tok.getLocation(), OpenLoc);
2693 bool isAmbiguousTypeId;
2696 if (Tok.is(tok::code_completion)) {
2698 Actions.CodeCompletion().CodeCompleteExpression(
2699 getCurScope(), PreferredType.get(Tok.getLocation()),
2706 Tok.isOneOf(tok::kw___bridge,
2707 tok::kw___bridge_transfer,
2708 tok::kw___bridge_retained,
2709 tok::kw___bridge_retain));
2710 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2712 StringRef BridgeCastName = Tok.getName();
2714 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2715 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2725 Diag(Tok, OpenLoc.
isMacroID() ? diag::ext_gnu_statement_expr_macro
2726 : diag::ext_gnu_statement_expr);
2728 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
2736 DeclContext *CodeDC = Actions.CurContext;
2740 "statement expr not in code context");
2742 Sema::ContextRAII SavedContext(Actions, CodeDC,
false);
2744 Actions.ActOnStartStmtExpr();
2746 StmtResult Stmt(ParseCompoundStatement(
true));
2750 if (!Stmt.isInvalid()) {
2754 Actions.ActOnStmtExprError();
2763 if (tokenKind == tok::kw___bridge)
2765 else if (tokenKind == tok::kw___bridge_transfer)
2767 else if (tokenKind == tok::kw___bridge_retained)
2772 assert(tokenKind == tok::kw___bridge_retain);
2774 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2775 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2777 "__bridge_retained");
2782 ColonProtection.restore();
2783 RParenLoc = T.getCloseLocation();
2785 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get().
get());
2791 return Actions.ObjC().ActOnObjCBridgedCast(
getCurScope(), OpenLoc, Kind,
2792 BridgeKeywordLoc, Ty.
get(),
2793 RParenLoc, SubExpr.
get());
2795 isTypeIdInParens(isAmbiguousTypeId)) {
2804 if (isAmbiguousTypeId && !StopIfCastExpr) {
2805 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,
2807 RParenLoc = T.getCloseLocation();
2812 DeclSpec DS(AttrFactory);
2813 ParseSpecifierQualifierList(DS);
2816 ParseDeclarator(DeclaratorInfo);
2821 if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) &&
2827 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2829 Result = ParseObjCMessageExpressionBody(SourceLocation(),
2835 ColonProtection.restore();
2836 RParenLoc = T.getCloseLocation();
2842 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2844 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2854 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2868 Result = ParseCastExpression(
2874 if (!
Result.isInvalid()) {
2876 DeclaratorInfo, CastTy,
2877 RParenLoc,
Result.get());
2881 if (!
Result.isInvalid()) {
2893 if (DeclaratorInfo.isInvalidType())
2898 if (StopIfCastExpr) {
2902 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2910 Tok.getIdentifierInfo() == Ident_super &&
2913 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2914 << SourceRange(OpenLoc, RParenLoc);
2918 PreferredType.enterTypeCast(Tok.getLocation(), CastTy.
get());
2921 Result = ParseCastExpression(
2925 if (!
Result.isInvalid()) {
2927 DeclaratorInfo, CastTy,
2928 RParenLoc,
Result.get());
2933 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2944 ExprVector ArgExprs;
2946 if (!ParseSimpleExpressionList(ArgExprs)) {
2950 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2952 return ParseFoldExpression(ArgExprs[0], T);
2956 Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
2959 }
else if (
getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&
2961 tryParseOpenMPArrayShapingCastPart()) {
2962 bool ErrorFound =
false;
2963 SmallVector<Expr *, 4> OMPDimensions;
2964 SmallVector<SourceRange, 4> OMPBracketsRanges;
2971 while (!
SkipUntil(tok::r_square, tok::r_paren,
2976 OMPDimensions.push_back(NumElements.
get());
2977 OMPBracketsRanges.push_back(TS.getRange());
2978 }
while (Tok.isNot(tok::r_paren));
2981 RParenLoc = T.getCloseLocation();
2985 }
else if (!
Result.isInvalid()) {
2986 Result = Actions.OpenMP().ActOnOMPArrayShapingExpr(
2987 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);
2995 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2997 return ParseFoldExpression(
Result, T);
3002 if (!
Result.isInvalid() && Tok.is(tok::r_paren))
3004 Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(),
Result.get());
3008 if (
Result.isInvalid()) {
3014 RParenLoc = T.getCloseLocation();
3019Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
3022 assert(Tok.is(tok::l_brace) &&
"Not a compound literal!");
3024 Diag(LParenLoc, diag::ext_c99_compound_literal);
3025 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get());
3027 if (!
Result.isInvalid() && Ty)
3028 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc,
Result.get());
3045 "Not a string-literal-like token!");
3053 StringToks.push_back(
Tok);
3058 assert(!AllowUserDefinedLiteral &&
"UDL are always evaluated");
3063 return Actions.ActOnStringLiteral(StringToks,
3068ExprResult Parser::ParseGenericSelectionExpression() {
3069 assert(Tok.is(tok::kw__Generic) &&
"_Generic keyword expected");
3071 diagnoseUseOfC11Keyword(Tok);
3075 if (T.expectAndConsume())
3082 if (isTypeIdForGenericSelection()) {
3089 SourceLocation Loc = LIT->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
3091 : diag::ext_c2y_generic_with_type_arg);
3104 if (ExpectAndConsume(tok::comma)) {
3109 SourceLocation DefaultLoc;
3110 SmallVector<ParsedType, 12> Types;
3114 if (Tok.is(tok::kw_default)) {
3118 Diag(Tok, diag::err_duplicate_default_assoc);
3119 Diag(DefaultLoc, diag::note_previous_default_assoc);
3134 Types.push_back(Ty);
3136 if (ExpectAndConsume(tok::colon)) {
3148 Exprs.push_back(ER.
get());
3152 if (T.getCloseLocation().isInvalid())
3155 void *ExprOrTy = ControllingExpr.
isUsable()
3156 ? ControllingExpr.
get()
3159 return Actions.ActOnGenericSelectionExpr(
3160 KeyLoc, DefaultLoc, T.getCloseLocation(), ControllingExpr.
isUsable(),
3161 ExprOrTy, Types, Exprs);
3172 SourceLocation FirstOpLoc;
3174 Kind = Tok.getKind();
3175 assert(isFoldOperator(Kind) &&
"missing fold-operator");
3179 assert(Tok.is(tok::ellipsis) &&
"not a fold-expression");
3183 if (Tok.isNot(tok::r_paren)) {
3184 if (!isFoldOperator(Tok.getKind()))
3185 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
3187 if (Kind != tok::unknown && Tok.getKind() != Kind)
3188 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
3189 << SourceRange(FirstOpLoc);
3190 Kind = Tok.getKind();
3201 ? diag::warn_cxx14_compat_fold_expression
3202 : diag::ext_fold_expression);
3206 Kind, EllipsisLoc, RHS.
get(),
3210void Parser::injectEmbedTokens() {
3211 EmbedAnnotationData *
Data =
3212 reinterpret_cast<EmbedAnnotationData *
>(Tok.getAnnotationValue());
3213 MutableArrayRef<Token> Toks(PP.getPreprocessorAllocator().Allocate<Token>(
3214 Data->BinaryData.size() * 2 - 1),
3215 Data->BinaryData.size() * 2 - 1);
3217 for (
auto &Byte :
Data->BinaryData) {
3218 Toks[I].startToken();
3219 Toks[I].setKind(tok::binary_data);
3220 Toks[I].setLocation(Tok.getLocation());
3221 Toks[I].setLength(1);
3222 Toks[I].setLiteralData(&Byte);
3223 if (I != ((
Data->BinaryData.size() - 1) * 2)) {
3224 Toks[I + 1].startToken();
3225 Toks[I + 1].setKind(tok::comma);
3226 Toks[I + 1].setLocation(Tok.getLocation());
3230 PP.EnterTokenStream(std::move(Toks),
true,
3236 llvm::function_ref<
void()> ExpressionStarts,
3237 bool FailImmediatelyOnInvalidExpr) {
3238 bool SawError =
false;
3240 if (ExpressionStarts)
3245 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3246 Expr = ParseBraceInitializer();
3250 if (Tok.is(tok::ellipsis))
3252 else if (Tok.is(tok::code_completion)) {
3264 if (FailImmediatelyOnInvalidExpr)
3268 Exprs.push_back(Expr.
get());
3271 if (Tok.isNot(tok::comma))
3276 checkPotentialAngleBracketDelimiter(Comma);
3287 Exprs.push_back(Expr.
get());
3291 if (Tok.isNot(tok::comma) ||
NextToken().
is(tok::ellipsis))
3297 checkPotentialAngleBracketDelimiter(Comma);
3302 if (Tok.is(tok::code_completion)) {
3304 Actions.CodeCompletion().CodeCompleteOrdinaryName(
3310 DeclSpec DS(AttrFactory);
3311 ParseSpecifierQualifierList(DS);
3317 ParseDeclarator(DeclaratorInfo);
3319 MaybeParseGNUAttributes(DeclaratorInfo);
3322 Actions.ActOnBlockArguments(CaretLoc, DeclaratorInfo,
getCurScope());
3325ExprResult Parser::ParseBlockLiteralExpression() {
3326 assert(Tok.is(tok::caret) &&
"block literal starts with ^");
3329 PrettyStackTraceLoc CrashInfo(PP.getSourceManager(), CaretLoc,
3330 "block literal parsing");
3343 DeclSpec DS(AttrFactory);
3349 ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation()));
3353 if (Tok.is(tok::l_paren)) {
3354 ParseParenDeclarator(ParamInfo);
3358 SourceLocation Tmp = ParamInfo.getSourceRange().getEnd();
3359 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
3360 ParamInfo.SetRangeEnd(Tmp);
3361 if (ParamInfo.isInvalidType()) {
3369 MaybeParseGNUAttributes(ParamInfo);
3372 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3373 }
else if (!Tok.is(tok::l_brace)) {
3374 ParseBlockId(CaretLoc);
3377 SourceLocation NoLoc;
3378 ParamInfo.AddTypeInfo(
3396 CaretLoc, ParamInfo),
3399 MaybeParseGNUAttributes(ParamInfo);
3402 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3407 if (!Tok.is(tok::l_brace)) {
3409 Diag(Tok, diag::err_expected_expression);
3413 EnterExpressionEvaluationContextForFunction PotentiallyEvaluated(
3415 StmtResult Stmt(ParseCompoundStatementBody());
3417 if (!Stmt.isInvalid())
3426 return Actions.ObjC().ActOnObjCBoolLiteral(
ConsumeToken(), Kind);
3433 llvm::SmallSet<StringRef, 4> Platforms;
3434 bool HasOtherPlatformSpec =
false;
3436 for (
const auto &Spec : AvailSpecs) {
3437 if (Spec.isOtherPlatformSpec()) {
3438 if (HasOtherPlatformSpec) {
3439 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3443 HasOtherPlatformSpec =
true;
3447 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3452 StringRef Platform = Spec.getPlatform();
3453 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3454 << Spec.getEndLoc() << Platform;
3459 if (!HasOtherPlatformSpec) {
3460 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3461 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3469std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() {
3470 if (Tok.is(tok::star)) {
3474 if (Tok.is(tok::code_completion)) {
3476 Actions.CodeCompletion().CodeCompleteAvailabilityPlatformName();
3477 return std::nullopt;
3479 if (Tok.isNot(tok::identifier)) {
3480 Diag(Tok, diag::err_avail_query_expected_platform_name);
3481 return std::nullopt;
3484 IdentifierLoc *PlatformIdentifier = ParseIdentifierLoc();
3485 SourceRange VersionRange;
3486 VersionTuple Version = ParseVersionTuple(VersionRange);
3488 if (Version.empty())
3489 return std::nullopt;
3491 StringRef GivenPlatform =
3493 StringRef Platform =
3494 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3496 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||
3497 (GivenPlatform.contains(
"xros") || GivenPlatform.contains(
"xrOS"))) {
3499 diag::err_avail_query_unrecognized_platform_name)
3501 return std::nullopt;
3505 if (Platform ==
"anyappleos" &&
3508 diag::err_avail_query_anyappleos_min_version)
3509 << Version.getAsString();
3510 return std::nullopt;
3513 return AvailabilitySpec(Version, Platform, PlatformIdentifier->
getLoc(),
3519 assert(Tok.is(tok::kw___builtin_available) ||
3520 Tok.isObjCAtKeyword(tok::objc_available));
3526 if (
Parens.expectAndConsume())
3529 SmallVector<AvailabilitySpec, 4> AvailSpecs;
3530 bool HasError =
false;
3532 std::optional<AvailabilitySpec> Spec = ParseAvailabilitySpec();
3536 AvailSpecs.push_back(*Spec);
3549 if (
Parens.consumeClose())
3552 return Actions.ObjC().ActOnObjCAvailabilityCheckExpr(
3553 AvailSpecs, BeginLoc,
Parens.getCloseLocation());
Defines the clang::ASTContext interface.
static Decl::Kind getKind(const Decl *D)
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the clang::Expr interface and subclasses for C++ expressions.
static bool CheckAvailabilitySpecList(Parser &P, ArrayRef< AvailabilitySpec > AvailSpecs)
Validate availability spec list, emitting diagnostics if necessary.
#define REVERTIBLE_TYPE_TRAIT(Name)
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
This file declares semantic analysis for CUDA constructs.
This file declares facilities that support code completion.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenACC constructs and clauses.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis for SYCL constructs.
static bool validateAnyAppleOSVersion(const llvm::VersionTuple &Version)
Returns true if the anyAppleOS version is valid (empty or >= 26.0).
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
SourceLocation getOpenLocation() const
SourceLocation getCloseLocation() const
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
void AddDesignator(Designator D)
AddDesignator - Add a designator to the end of this list.
static Designator CreateArrayDesignator(Expr *Index, SourceLocation LBracketLoc)
Creates an array designator.
void setRBracketLoc(SourceLocation RBracketLoc) const
static Designator CreateFieldDesignator(const IdentifierInfo *FieldName, SourceLocation DotLoc, SourceLocation FieldLoc)
Creates a field designator.
RAII object that enters a new expression evaluation context.
This represents one expression.
bool containsErrors() const
Whether this expression contains subexpressions which had errors.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
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.
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
SourceLocation getLoc() const
IdentifierInfo * getIdentifierInfo() const
static StringRef getImmediateMacroNameForDiagnostics(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Retrieve the name of the immediate macro expansion.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
void * getAsOpaquePtr() const
static const ParsedAttributesView & none()
ParseScope - Introduces a new scope for parsing.
Parser - This implements a parser for the C family of languages.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName.
bool TryAnnotateTypeOrScopeToken(ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, bool IsAddressOfOperand=false)
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
ParseStringLiteralExpression - This handles the various token types that form string literals,...
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
Sema & getActions() const
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
ExprResult ParseCaseExpression(SourceLocation CaseLoc)
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
ExprResult ParseConstantExpressionInExprEvalContext(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
friend class ColonProtectionRAIIObject
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
const Token & GetLookAheadToken(unsigned N)
GetLookAheadToken - This peeks ahead N tokens and returns that token without consuming any tokens.
ExprResult ParseConstantExpression()
ExprResult ParseConditionalExpression()
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
ExprResult ParseArrayBoundExpression()
friend class InMessageExpressionRAIIObject
ExprResult ParseConstraintLogicalAndExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-and-expression.
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 ...
friend class OffsetOfStateRAIIObject
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Simple precedence-based parser for binary/ternary operators.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtSemi
Stop skipping at semicolon.
ExprResult ParseUnevaluatedStringLiteralExpression()
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
ExprResult ParseAssignmentExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Parse an expr that doesn't include (top-level) commas.
friend class BalancedDelimiterTracker
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getCanonicalType() const
@ BlockScope
This is a scope that corresponds to a block/closure object.
@ CompoundStmtScope
This is a compound statement scope.
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ DeclScope
This is a scope that can contain a declaration.
@ PCC_Type
Code completion occurs where only a type is permitted.
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
const char * getName() const
void setLength(unsigned Len)
void setKind(tok::TokenKind K)
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)) {....
tok::TokenKind getKind() const
bool isOneOf(Ts... Ks) const
void setLocation(SourceLocation L)
void startToken()
Reset all flags to cleared.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
bool isFunctionType() const
bool isVectorType() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
SourceLocation getEndLoc() const LLVM_READONLY
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
TypoCorrectionTypeBehavior
If a typo should be encountered, should typo correction suggest type names, non type names,...
bool tokenIsLikeStringLiteral(const Token &Tok, const LangOptions &LO)
Return true if the token is a string literal, or a function local predefined macro,...
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
@ OBC_Bridge
Bridging via __bridge, which does nothing but reinterpret the bits.
@ OBC_BridgeTransfer
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC.
@ OBC_BridgeRetained
Bridging via __bridge_retain, which makes an ARC object available as a +1 C pointer.
@ Type
The name was classified as a type.
prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, bool CPlusPlus11)
Return the precedence of the specified binary operator token.
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
ParenExprKind
In a call to ParseParenExpression, are the initial parentheses part of an operator that requires the ...
U cast(CodeGen::Address addr)
CastParseKind
Control what ParseCastExpression will parse.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
ParenParseOption
ParenParseOption - Control what ParseParenExpression will parse.
ActionResult< Expr * > ExprResult
@ Parens
New-expression has a C++98 paren-delimited initializer.
@ EST_None
no exception specification
ActionResult< Stmt * > StmtResult
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(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
TemplateNameKind Kind
The kind of template that Template refers to.