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::compat_cxx11_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/BuiltinTraits.inc"
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) &&
907 if (Tok.isOneOf(tok::annot_cxxscope, tok::annot_pack_indexing_type,
908 tok::annot_template_id))
909 return ParseCastExpression(ParseKind, isAddressOfOperand,
910 CorrectionBehavior, isVectorLiteral,
911 NotPrimaryExpression);
917 else if (
Next.is(tok::l_paren) && Tok.is(tok::identifier) &&
918 Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
919 IdentifierInfo *II = Tok.getIdentifierInfo();
921 if (isRevertibleTypeTrait(II, &Kind)) {
923 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
924 CorrectionBehavior, isVectorLiteral,
925 NotPrimaryExpression);
929 else if ((!ColonIsSacred &&
Next.is(tok::colon)) ||
930 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
935 if (!Tok.is(tok::identifier))
936 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
937 CorrectionBehavior, isVectorLiteral,
938 NotPrimaryExpression);
944 IdentifierInfo &II = *Tok.getIdentifierInfo();
951 (&II == Ident_super &&
getCurScope()->isInObjcMethodScope()))) {
954 if (Tok.is(tok::code_completion) && &II != Ident_super) {
956 Actions.CodeCompletion().CodeCompleteObjCClassPropertyRefExpr(
957 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
961 if (Tok.isNot(tok::identifier) &&
963 Diag(Tok, diag::err_expected_property_name);
966 IdentifierInfo &PropertyName = *Tok.getIdentifierInfo();
969 Res = Actions.ObjC().ActOnClassPropertyRefExpr(II, PropertyName, ILoc,
978 if (
getLangOpts().
ObjC && &II == Ident_super && !InMessageExpression &&
980 ((Tok.is(tok::identifier) &&
982 Tok.is(tok::code_completion))) {
983 Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc,
nullptr,
994 ((Tok.is(tok::identifier) && !InMessageExpression) ||
995 Tok.is(tok::code_completion))) {
997 if (Tok.is(tok::code_completion) ||
998 Next.is(tok::colon) ||
Next.is(tok::r_square))
1000 if (Typ.get()->isObjCObjectOrInterfaceType()) {
1002 DeclSpec DS(AttrFactory);
1003 DS.SetRangeStart(ILoc);
1004 DS.SetRangeEnd(ILoc);
1005 const char *PrevSpec =
nullptr;
1007 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
1008 Actions.getASTContext().getPrintingPolicy());
1012 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
1016 Res = ParseObjCMessageExpressionBody(SourceLocation(),
1024 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1025 isAddressOfOperand =
false;
1031 CXXScopeSpec ScopeSpec;
1032 SourceLocation TemplateKWLoc;
1033 CastExpressionIdValidator Validator(Tok, CorrectionBehavior);
1034 Validator.IsAddressOfOperand = isAddressOfOperand;
1035 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
1036 Validator.WantExpressionKeywords =
false;
1037 Validator.WantRemainingKeywords =
false;
1039 Validator.WantRemainingKeywords = Tok.isNot(tok::r_paren);
1042 Res = Actions.ActOnIdExpression(
getCurScope(), ScopeSpec, TemplateKWLoc,
1043 Name, Tok.is(tok::l_paren),
1044 isAddressOfOperand, &Validator,
1046 Res = tryParseCXXPackIndexingExpression(Res);
1047 if (!Res.
isInvalid() && Tok.is(tok::less))
1048 checkPotentialAngleBracket(Res);
1051 case tok::char_constant:
1052 case tok::wide_char_constant:
1053 case tok::utf8_char_constant:
1054 case tok::utf16_char_constant:
1055 case tok::utf32_char_constant:
1056 Res = Actions.ActOnCharacterConstant(Tok,
getCurScope());
1059 case tok::kw___func__:
1060 case tok::kw___FUNCTION__:
1061 case tok::kw___FUNCDNAME__:
1062 case tok::kw___FUNCSIG__:
1063 case tok::kw_L__FUNCTION__:
1064 case tok::kw_L__FUNCSIG__:
1065 case tok::kw___PRETTY_FUNCTION__:
1072 Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
1077 case tok::string_literal:
1078 case tok::wide_string_literal:
1079 case tok::utf8_string_literal:
1080 case tok::utf16_string_literal:
1081 case tok::utf32_string_literal:
1084 case tok::kw__Generic:
1085 Res = ParseGenericSelectionExpression();
1087 case tok::kw___builtin_available:
1088 Res = ParseAvailabilityCheckExpr(Tok.getLocation());
1090 case tok::kw___builtin_va_arg:
1091 case tok::kw___builtin_offsetof:
1092 case tok::kw___builtin_choose_expr:
1093 case tok::kw___builtin_astype:
1094 case tok::kw___builtin_convertvector:
1095 case tok::kw___builtin_COLUMN:
1096 case tok::kw___builtin_FILE:
1097 case tok::kw___builtin_FILE_NAME:
1098 case tok::kw___builtin_FUNCTION:
1099 case tok::kw___builtin_FUNCSIG:
1100 case tok::kw___builtin_LINE:
1101 case tok::kw___builtin_source_location:
1102 if (NotPrimaryExpression)
1103 *NotPrimaryExpression =
true;
1105 return ParseBuiltinPrimaryExpression();
1106 case tok::kw___null:
1111 case tok::minusminus: {
1112 if (NotPrimaryExpression)
1113 *NotPrimaryExpression =
true;
1118 Token SavedTok = Tok;
1121 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedTok.
getKind(),
1135 UnconsumeToken(SavedTok);
1139 Expr *Arg = Res.
get();
1143 Res = Actions.CreateRecoveryExpr(SavedTok.
getLocation(),
1149 if (NotPrimaryExpression)
1150 *NotPrimaryExpression =
true;
1153 PreferredType.enterUnary(Actions, Tok.getLocation(), tok::amp, SavedLoc);
1158 Expr *Arg = Res.
get();
1159 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Arg);
1161 Res = Actions.CreateRecoveryExpr(Tok.getLocation(), Arg->
getEndLoc(),
1172 case tok::kw___real:
1173 case tok::kw___imag: {
1174 if (NotPrimaryExpression)
1175 *NotPrimaryExpression =
true;
1177 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedKind, SavedLoc);
1180 Expr *Arg = Res.
get();
1181 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Arg,
1182 isAddressOfOperand);
1184 Res = Actions.CreateRecoveryExpr(SavedLoc, Arg->
getEndLoc(), Arg);
1189 case tok::kw_co_await: {
1190 if (NotPrimaryExpression)
1191 *NotPrimaryExpression =
true;
1195 Res = Actions.ActOnCoawaitExpr(
getCurScope(), CoawaitLoc, Res.
get());
1199 case tok::kw___extension__:{
1201 if (NotPrimaryExpression)
1202 *NotPrimaryExpression =
true;
1203 ExtensionRAIIObject O(Diags);
1207 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.
get());
1210 case tok::kw__Alignof:
1211 diagnoseUseOfC11Keyword(Tok);
1213 case tok::kw_alignof:
1214 case tok::kw___alignof:
1216 case tok::kw_sizeof:
1220 case tok::kw___datasizeof:
1221 case tok::kw_vec_step:
1223 case tok::kw___builtin_omp_required_simd_align:
1224 case tok::kw___builtin_vectorelements:
1225 case tok::kw__Countof:
1226 if (NotPrimaryExpression)
1227 *NotPrimaryExpression =
true;
1228 AllowSuffix =
false;
1229 Res = ParseUnaryExprOrTypeTraitExpression();
1231 case tok::caretcaret: {
1237 if (NotPrimaryExpression)
1238 *NotPrimaryExpression =
true;
1239 AllowSuffix =
false;
1240 Res = ParseCXXReflectExpression();
1244 if (NotPrimaryExpression)
1245 *NotPrimaryExpression =
true;
1247 if (Tok.isNot(tok::identifier))
1248 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1251 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1253 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1254 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(),
1256 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD);
1258 AllowSuffix =
false;
1261 case tok::kw_const_cast:
1262 case tok::kw_dynamic_cast:
1263 case tok::kw_reinterpret_cast:
1264 case tok::kw_static_cast:
1265 case tok::kw_addrspace_cast:
1266 if (NotPrimaryExpression)
1267 *NotPrimaryExpression =
true;
1268 Res = ParseCXXCasts();
1270 case tok::kw___builtin_bit_cast:
1271 if (NotPrimaryExpression)
1272 *NotPrimaryExpression =
true;
1273 Res = ParseBuiltinBitCast();
1275 case tok::kw_typeid:
1276 if (NotPrimaryExpression)
1277 *NotPrimaryExpression =
true;
1278 Res = ParseCXXTypeid();
1280 case tok::kw___uuidof:
1281 if (NotPrimaryExpression)
1282 *NotPrimaryExpression =
true;
1283 Res = ParseCXXUuidof();
1286 Res = ParseCXXThis();
1288 case tok::kw___builtin_sycl_unique_stable_name:
1289 Res = ParseSYCLUniqueStableNameExpression();
1292 case tok::annot_typename:
1293 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1297 DeclSpec DS(AttrFactory);
1298 DS.SetRangeStart(Tok.getLocation());
1299 DS.SetRangeEnd(Tok.getLastLoc());
1301 const char *PrevSpec =
nullptr;
1303 DS.SetTypeSpecType(
TST_typename, Tok.getAnnotationEndLoc(),
1304 PrevSpec, DiagID,
Type,
1305 Actions.getASTContext().getPrintingPolicy());
1309 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
1313 ConsumeAnnotationToken();
1314 Res = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1320 case tok::annot_decltype:
1321 case tok::annot_pack_indexing_type:
1323 case tok::kw_wchar_t:
1324 case tok::kw_char8_t:
1325 case tok::kw_char16_t:
1326 case tok::kw_char32_t:
1331 case tok::kw___int64:
1332 case tok::kw___int128:
1333 case tok::kw__ExtInt:
1334 case tok::kw__BitInt:
1335 case tok::kw_signed:
1336 case tok::kw_unsigned:
1339 case tok::kw_double:
1340 case tok::kw___bf16:
1341 case tok::kw__Float16:
1342 case tok::kw___float128:
1343 case tok::kw___ibm128:
1346 case tok::kw_typename:
1347 case tok::kw_typeof:
1348 case tok::kw_typeof_unqual:
1349 case tok::kw___vector:
1350 case tok::kw__Accum:
1351 case tok::kw__Fract:
1353#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1354#include "clang/Basic/OpenCLImageTypes.def"
1355#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
1356#include "clang/Basic/HLSLIntangibleTypes.def"
1359 Diag(Tok, diag::err_expected_expression);
1364 if (NotPrimaryExpression)
1365 *NotPrimaryExpression =
true;
1367 if (SavedKind == tok::kw_typename) {
1382 DeclSpec DS(AttrFactory);
1384 ParseCXXSimpleTypeSpecifier(DS);
1385 if (Tok.isNot(tok::l_paren) &&
1387 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1388 << DS.getSourceRange());
1390 if (Tok.is(tok::l_brace))
1391 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
1393 Res = ParseCXXTypeConstructExpression(DS);
1397 case tok::annot_cxxscope: {
1402 if (!Tok.is(tok::annot_cxxscope))
1403 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1404 CorrectionBehavior, isVectorLiteral,
1405 NotPrimaryExpression);
1408 if (
Next.is(tok::annot_template_id)) {
1409 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(
Next);
1415 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1419 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1420 CorrectionBehavior, isVectorLiteral,
1421 NotPrimaryExpression);
1426 Res = ParseCXXIdExpression(isAddressOfOperand);
1430 case tok::annot_template_id: {
1431 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1438 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1439 CorrectionBehavior, isVectorLiteral,
1440 NotPrimaryExpression);
1447 case tok::kw_operator:
1448 Res = ParseCXXIdExpression(isAddressOfOperand);
1451 case tok::coloncolon: {
1456 if (!Tok.is(tok::coloncolon))
1457 return ParseCastExpression(ParseKind, isAddressOfOperand,
1458 CorrectionBehavior, isVectorLiteral,
1459 NotPrimaryExpression);
1464 if (Tok.is(tok::kw_new)) {
1465 if (NotPrimaryExpression)
1466 *NotPrimaryExpression =
true;
1467 Res = ParseCXXNewExpression(
true, CCLoc);
1468 AllowSuffix =
false;
1471 if (Tok.is(tok::kw_delete)) {
1472 if (NotPrimaryExpression)
1473 *NotPrimaryExpression =
true;
1474 Res = ParseCXXDeleteExpression(
true, CCLoc);
1475 AllowSuffix =
false;
1480 Diag(CCLoc, diag::err_expected_expression);
1485 if (NotPrimaryExpression)
1486 *NotPrimaryExpression =
true;
1487 Res = ParseCXXNewExpression(
false, Tok.getLocation());
1488 AllowSuffix =
false;
1491 case tok::kw_delete:
1492 if (NotPrimaryExpression)
1493 *NotPrimaryExpression =
true;
1494 Res = ParseCXXDeleteExpression(
false, Tok.getLocation());
1495 AllowSuffix =
false;
1498 case tok::kw_requires:
1499 Res = ParseRequiresExpression();
1500 AllowSuffix =
false;
1503 case tok::kw_noexcept: {
1504 if (NotPrimaryExpression)
1505 *NotPrimaryExpression =
true;
1506 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1510 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1522 Res = Actions.ActOnNoexceptExpr(KeyLoc,
T.getOpenLocation(), Res.
get(),
1523 T.getCloseLocation());
1524 AllowSuffix =
false;
1528#define TYPE_TRAIT(N,Spelling,K) \
1529 case tok::kw_##Spelling:
1530#include "clang/Basic/TokenKinds.def"
1531 Res = ParseTypeTrait();
1534 case tok::kw___array_rank:
1535 case tok::kw___array_extent:
1536 if (NotPrimaryExpression)
1537 *NotPrimaryExpression =
true;
1538 Res = ParseArrayTypeTrait();
1541 case tok::kw___builtin_ptrauth_type_discriminator:
1542 return ParseBuiltinPtrauthTypeDiscriminator();
1544 case tok::kw___is_lvalue_expr:
1545 case tok::kw___is_rvalue_expr:
1546 if (NotPrimaryExpression)
1547 *NotPrimaryExpression =
true;
1548 Res = ParseExpressionTrait();
1552 if (NotPrimaryExpression)
1553 *NotPrimaryExpression =
true;
1555 return ParseObjCAtExpression(AtLoc);
1558 Res = ParseBlockLiteralExpression();
1560 case tok::code_completion: {
1562 Actions.CodeCompletion().CodeCompleteExpression(
1563 getCurScope(), PreferredType.get(Tok.getLocation()),
1564 false, isAddressOfOperand);
1567#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
1568#include "clang/Basic/BuiltinTraits.inc"
1572 Tok.setKind(tok::identifier);
1573 Diag(Tok, diag::ext_keyword_as_ident)
1574 << Tok.getIdentifierInfo()->getName() << 0;
1575 goto ParseIdentifier;
1577 goto ExpectedExpression;
1586 Res = TryParseLambdaExpression();
1590 if (NotPrimaryExpression)
1591 *NotPrimaryExpression =
true;
1592 Res = ParseObjCMessageExpression();
1596 Res = ParseLambdaExpression();
1600 Res = ParseObjCMessageExpression();
1625 switch (Tok.getKind()) {
1629 case tok::minusminus:
1632 if (Tok.isAtStartOfLine())
1647 Diag(Tok.getLocation(), diag::err_postfix_after_unary_requires_parens)
1655 PreferredType = SavedType;
1656 Res = ParsePostfixExpressionSuffix(Res);
1658 !
getActions().getOpenCLOptions().isAvailableOption(
1660 if (Expr *PostfixExpr = Res.
get()) {
1661 QualType Ty = PostfixExpr->getType();
1663 Diag(PostfixExpr->getExprLoc(),
1664 diag::err_opencl_taking_function_address_parser);
1673Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1677 auto SavedType = PreferredType;
1680 PreferredType = SavedType;
1681 switch (Tok.getKind()) {
1682 case tok::code_completion:
1683 if (InMessageExpression)
1687 Actions.CodeCompletion().CodeCompletePostfixExpression(
1688 getCurScope(), LHS, PreferredType.get(Tok.getLocation()));
1691 case tok::identifier:
1697 LHS = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1698 nullptr, LHS.
get());
1706 case tok::l_square: {
1714 isSimpleObjCMessageExpression())
1719 if (CheckProhibitedCXX11Attribute()) {
1724 Loc =
T.getOpenLocation();
1726 SourceLocation ColonLocFirst, ColonLocSecond;
1727 ExprVector ArgExprs;
1728 bool HasError =
false;
1729 PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.
get());
1735 if ((!
getLangOpts().OpenMP && !AllowOpenACCArraySections) ||
1736 Tok.isNot(tok::colon)) {
1740 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
1741 Idx = ParseBraceInitializer();
1748 ArgExprs.push_back(Idx.
get());
1750 }
else if (Tok.isNot(tok::r_square)) {
1751 if (ParseExpressionList(ArgExprs)) {
1761 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {
1763 if (Tok.is(tok::colon)) {
1766 if (Tok.isNot(tok::r_square))
1769 }
else if (ArgExprs.size() <= 1 &&
getLangOpts().OpenMP) {
1771 if (Tok.is(tok::colon)) {
1774 if (Tok.isNot(tok::r_square) &&
1776 ((Tok.isNot(tok::colon) &&
getLangOpts().OpenMP >= 50)))) {
1781 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||
1782 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
1783 Tok.is(tok::colon)) {
1786 if (Tok.isNot(tok::r_square)) {
1792 SourceLocation RLoc = Tok.getLocation();
1793 if (!LHS.
isInvalid() && !HasError && !Length.isInvalid() &&
1794 !Stride.
isInvalid() && Tok.is(tok::r_square)) {
1800 if (AllowOpenACCArraySections) {
1802 "Stride/second colon not allowed for OpenACC");
1803 LHS = Actions.OpenACC().ActOnArraySectionExpr(
1804 LHS.
get(), Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
1805 ColonLocFirst, Length.get(), RLoc);
1807 LHS = Actions.OpenMP().ActOnOMPArraySectionExpr(
1808 LHS.
get(), Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
1809 ColonLocFirst, ColonLocSecond, Length.get(), Stride.
get(),
1813 LHS = Actions.ActOnArraySubscriptExpr(
getCurScope(), LHS.
get(), Loc,
1826 case tok::lesslessless: {
1831 Expr *ExecConfig =
nullptr;
1835 if (OpKind == tok::lesslessless) {
1836 ExprVector ExecConfigExprs;
1839 if (ParseSimpleExpressionList(ExecConfigExprs)) {
1843 SourceLocation CloseLoc;
1849 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1850 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1856 if (ExpectAndConsume(tok::l_paren))
1859 Loc = PrevTokLocation;
1863 ExprResult ECResult = Actions.CUDA().ActOnExecConfigExpr(
1864 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);
1868 ExecConfig = ECResult.
get();
1872 Loc = PT.getOpenLocation();
1875 ExprVector ArgExprs;
1876 auto RunSignatureHelp = [&]() -> QualType {
1877 QualType PreferredType =
1878 Actions.CodeCompletion().ProduceCallSignatureHelp(
1879 LHS.
get(), ArgExprs, PT.getOpenLocation());
1880 CalledSignatureHelp =
true;
1881 return PreferredType;
1883 bool ExpressionListIsInvalid =
false;
1884 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1885 if (Tok.isNot(tok::r_paren)) {
1886 if ((ExpressionListIsInvalid = ParseExpressionList(ArgExprs, [&] {
1887 PreferredType.enterFunctionArgument(Tok.getLocation(),
1894 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
1903 }
else if (ExpressionListIsInvalid) {
1904 Expr *
Fn = LHS.
get();
1905 ArgExprs.insert(ArgExprs.begin(), Fn);
1906 LHS = Actions.CreateRecoveryExpr(
Fn->getBeginLoc(), Tok.getLocation(),
1909 }
else if (Tok.isNot(tok::r_paren)) {
1910 bool HadErrors =
false;
1913 for (
auto &E : ArgExprs)
1914 if (E->containsErrors())
1925 Expr *
Fn = LHS.
get();
1926 SourceLocation RParLoc = Tok.getLocation();
1927 LHS = Actions.ActOnCallExpr(
getCurScope(), Fn, Loc, ArgExprs, RParLoc,
1930 ArgExprs.insert(ArgExprs.begin(), Fn);
1932 Actions.CreateRecoveryExpr(
Fn->getBeginLoc(), RParLoc, ArgExprs);
1948 bool MayBePseudoDestructor =
false;
1949 Expr* OrigLHS = !LHS.
isInvalid() ? LHS.
get() :
nullptr;
1951 PreferredType.enterMemAccess(Actions, Tok.getLocation(), OrigLHS);
1954 Expr *
Base = OrigLHS;
1955 const Type* BaseType =
Base->getType().getTypePtrOrNull();
1956 if (BaseType && Tok.is(tok::l_paren) &&
1959 Diag(OpLoc, diag::err_function_is_not_record)
1960 << OpKind <<
Base->getSourceRange()
1962 return ParsePostfixExpressionSuffix(Base);
1965 LHS = Actions.ActOnStartCXXMemberReference(
getCurScope(), Base, OpLoc,
1967 MayBePseudoDestructor);
1972 if (Tok.is(tok::code_completion)) {
1978 ParseOptionalCXXScopeSpecifier(
1980 false, &MayBePseudoDestructor);
1982 ObjectType =
nullptr;
1985 if (Tok.is(tok::code_completion)) {
1987 OpKind == tok::arrow ? tok::period : tok::arrow;
1992 Sema::TentativeAnalysisScope Trap(Actions);
1993 CorrectedLHS = Actions.ActOnStartCXXMemberReference(
1994 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
1995 MayBePseudoDestructor);
1999 Expr *CorrectedBase = CorrectedLHS.get();
2001 CorrectedBase =
Base;
2005 Actions.CodeCompletion().CodeCompleteMemberReferenceExpr(
2006 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,
2007 Base && ExprStatementTokLoc ==
Base->getBeginLoc(),
2008 PreferredType.get(Tok.getLocation()));
2013 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
2014 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
2026 SourceLocation TemplateKWLoc;
2029 Tok.is(tok::kw_class)) {
2037 IdentifierInfo *Id = Tok.getIdentifierInfo();
2046 false, &TemplateKWLoc, Name)) {
2051 LHS = Actions.ActOnMemberAccessExpr(
getCurScope(), LHS.
get(), OpLoc,
2052 OpKind, SS, TemplateKWLoc, Name,
2053 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
2056 if (Tok.is(tok::less))
2057 checkPotentialAngleBracket(LHS);
2058 }
else if (OrigLHS && Name.
isValid()) {
2060 LHS = Actions.CreateRecoveryExpr(OrigLHS->
getBeginLoc(),
2066 case tok::minusminus:
2068 Expr *Arg = LHS.
get();
2069 LHS = Actions.ActOnPostfixUnaryOp(
getCurScope(), Tok.getLocation(),
2070 Tok.getKind(), Arg);
2072 LHS = Actions.CreateRecoveryExpr(Arg->
getBeginLoc(),
2073 Tok.getLocation(), Arg);
2082Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
2087 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,
2088 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,
2089 tok::kw__Alignof, tok::kw_vec_step,
2090 tok::kw___builtin_omp_required_simd_align,
2091 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2092 "Not a typeof/sizeof/alignof/vec_step expression!");
2097 if (Tok.isNot(tok::l_paren)) {
2100 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2101 tok::kw_alignof, tok::kw__Alignof)) {
2102 if (isTypeIdUnambiguously()) {
2103 DeclSpec DS(AttrFactory);
2104 ParseSpecifierQualifierList(DS);
2107 ParseDeclarator(DeclaratorInfo);
2109 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.
getLocation());
2110 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
2113 diag::err_expected_parentheses_around_typename)
2116 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
2126 if (OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
2137 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2138 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof) &&
2139 Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2140 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof))
2141 Actions.runWithSufficientStackSpace(Tok.getLocation(), [&] {
2142 Operand = ParseCastExpression(CastParseKind::UnaryExprOnly);
2161 bool ParenKnownToBeNonCast =
2162 OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual);
2164 SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
2166 Operand = ParseParenExpression(
2171 CastRange = SourceRange(LParenLoc, RParenLoc);
2181 !OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {
2196ExprResult Parser::ParseSYCLUniqueStableNameExpression() {
2197 assert(Tok.is(tok::kw___builtin_sycl_unique_stable_name) &&
2198 "Not __builtin_sycl_unique_stable_name");
2204 if (
T.expectAndConsume(diag::err_expected_lparen_after,
2205 "__builtin_sycl_unique_stable_name"))
2215 if (
T.consumeClose())
2218 return Actions.SYCL().ActOnUniqueStableNameExpr(
2219 OpLoc,
T.getOpenLocation(),
T.getCloseLocation(), Ty.
get());
2222ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
2223 assert(Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2224 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
2225 tok::kw___builtin_omp_required_simd_align,
2226 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2227 "Not a sizeof/alignof/vec_step expression!");
2232 if (Tok.is(tok::ellipsis) && OpTok.
is(tok::kw_sizeof)) {
2234 SourceLocation LParenLoc, RParenLoc;
2235 IdentifierInfo *Name =
nullptr;
2236 SourceLocation NameLoc;
2237 if (Tok.is(tok::l_paren)) {
2240 LParenLoc =
T.getOpenLocation();
2241 if (Tok.is(tok::identifier)) {
2242 Name = Tok.getIdentifierInfo();
2245 RParenLoc =
T.getCloseLocation();
2247 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2249 Diag(Tok, diag::err_expected_parameter_pack);
2252 }
else if (Tok.is(tok::identifier)) {
2253 Name = Tok.getIdentifierInfo();
2255 LParenLoc = PP.getLocForEndOfToken(EllipsisLoc);
2256 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2257 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2262 Diag(Tok, diag::err_sizeof_parameter_pack);
2272 return Actions.ActOnSizeofParameterPackExpr(
getCurScope(),
2279 OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2280 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2282 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.
getName();
2284 Diag(OpTok, diag::warn_c2y_compat_keyword) << OpTok.
getName();
2292 SourceRange CastRange;
2298 UnaryExprOrTypeTrait ExprKind = UETT_SizeOf;
2300 case tok::kw_alignof:
2301 case tok::kw__Alignof:
2302 ExprKind = UETT_AlignOf;
2304 case tok::kw___alignof:
2305 ExprKind = UETT_PreferredAlignOf;
2307 case tok::kw_vec_step:
2308 ExprKind = UETT_VecStep;
2310 case tok::kw___builtin_omp_required_simd_align:
2311 ExprKind = UETT_OpenMPRequiredSimdAlign;
2313 case tok::kw___datasizeof:
2314 ExprKind = UETT_DataSizeOf;
2316 case tok::kw___builtin_vectorelements:
2317 ExprKind = UETT_VectorElements;
2319 case tok::kw__Countof:
2320 ExprKind = UETT_CountOf;
2323 Diag(OpTok, diag::ext_c2y_feature) << OpTok.
getName();
2330 return Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.
getLocation(),
2336 if (OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2349ExprResult Parser::ParseBuiltinPrimaryExpression() {
2351 const IdentifierInfo *BuiltinII = Tok.getIdentifierInfo();
2357 if (Tok.isNot(tok::l_paren))
2358 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2367 default: llvm_unreachable(
"Not a builtin primary expression!");
2368 case tok::kw___builtin_va_arg: {
2371 if (ExpectAndConsume(tok::comma)) {
2378 if (Tok.isNot(tok::r_paren)) {
2379 Diag(Tok, diag::err_expected) << tok::r_paren;
2386 Res = Actions.ActOnVAArg(StartLoc, Expr.get(), Ty.
get(), ConsumeParen());
2389 case tok::kw___builtin_offsetof: {
2390 SourceLocation TypeLoc = Tok.getLocation();
2392 if (Tok.getLocation().isMacroID()) {
2394 Tok.getLocation(), PP.getSourceManager(),
getLangOpts());
2395 if (MacroName ==
"offsetof")
2408 if (ExpectAndConsume(tok::comma)) {
2413 auto TriggerCompletion = [&](
const Designation &D) {
2415 Actions.CodeCompletion().CodeCompleteOffsetOfDesignator(
2416 Actions.GetTypeFromParser(Ty.
get()), D);
2421 if (Tok.is(tok::code_completion)) {
2422 TriggerCompletion(D);
2425 if (Tok.isNot(tok::identifier)) {
2426 Diag(Tok, diag::err_expected) << tok::identifier;
2432 Tok.getIdentifierInfo(), SourceLocation(), Tok.getLocation()));
2437 if (Tok.is(tok::period)) {
2441 if (Tok.is(tok::code_completion)) {
2442 TriggerCompletion(D);
2445 if (Tok.isNot(tok::identifier)) {
2446 Diag(Tok, diag::err_expected) << tok::identifier;
2451 Tok.getIdentifierInfo(), DotLoc, Tok.getLocation()));
2453 }
else if (Tok.is(tok::l_square)) {
2454 if (CheckProhibitedCXX11Attribute())
2476 if (Tok.is(tok::code_completion)) {
2480 if (Tok.isNot(tok::r_paren)) {
2488 Actions.ActOnBuiltinOffsetOf(
getCurScope(), StartLoc, TypeLoc,
2489 Ty.
get(), D, PT.getCloseLocation());
2496 case tok::kw___builtin_choose_expr: {
2498 if (Cond.isInvalid()) {
2502 if (ExpectAndConsume(tok::comma)) {
2508 if (Expr1.isInvalid()) {
2512 if (ExpectAndConsume(tok::comma)) {
2518 if (Expr2.isInvalid()) {
2522 if (Tok.isNot(tok::r_paren)) {
2523 Diag(Tok, diag::err_expected) << tok::r_paren;
2526 Res = Actions.ActOnChooseExpr(StartLoc, Cond.get(), Expr1.get(),
2527 Expr2.get(), ConsumeParen());
2530 case tok::kw___builtin_astype: {
2533 if (Expr.isInvalid()) {
2538 if (ExpectAndConsume(tok::comma)) {
2549 if (Tok.isNot(tok::r_paren)) {
2550 Diag(Tok, diag::err_expected) << tok::r_paren;
2555 Res = Actions.ActOnAsTypeExpr(Expr.get(), DestTy.
get(), StartLoc,
2559 case tok::kw___builtin_convertvector: {
2562 if (Expr.isInvalid()) {
2567 if (ExpectAndConsume(tok::comma)) {
2578 if (Tok.isNot(tok::r_paren)) {
2579 Diag(Tok, diag::err_expected) << tok::r_paren;
2584 Res = Actions.ActOnConvertVectorExpr(Expr.get(), DestTy.
get(), StartLoc,
2588 case tok::kw___builtin_COLUMN:
2589 case tok::kw___builtin_FILE:
2590 case tok::kw___builtin_FILE_NAME:
2591 case tok::kw___builtin_FUNCTION:
2592 case tok::kw___builtin_FUNCSIG:
2593 case tok::kw___builtin_LINE:
2594 case tok::kw___builtin_source_location: {
2596 if (Tok.isNot(tok::r_paren)) {
2597 Diag(Tok, diag::err_expected) << tok::r_paren;
2603 case tok::kw___builtin_FILE:
2605 case tok::kw___builtin_FILE_NAME:
2607 case tok::kw___builtin_FUNCTION:
2609 case tok::kw___builtin_FUNCSIG:
2611 case tok::kw___builtin_LINE:
2613 case tok::kw___builtin_COLUMN:
2615 case tok::kw___builtin_source_location:
2618 llvm_unreachable(
"invalid keyword");
2621 Res = Actions.ActOnSourceLocExpr(Kind, StartLoc, ConsumeParen());
2631 return ParsePostfixExpressionSuffix(Res.
get());
2634bool Parser::tryParseOpenMPArrayShapingCastPart() {
2635 assert(Tok.is(tok::l_square) &&
"Expected open bracket");
2636 bool ErrorFound =
true;
2637 TentativeParsingAction TPA(*
this);
2639 if (Tok.isNot(tok::l_square))
2644 while (!
SkipUntil(tok::r_square, tok::annot_pragma_openmp_end,
2647 if (Tok.isNot(tok::r_square))
2652 if (Tok.is(tok::r_paren)) {
2656 }
while (Tok.isNot(tok::annot_pragma_openmp_end));
2662Parser::ParseParenExpression(
ParenParseOption &ExprType,
bool StopIfCastExpr,
2666 assert(Tok.is(tok::l_paren) &&
"Not a paren expr!");
2669 if (
T.consumeOpen())
2671 SourceLocation OpenLoc =
T.getOpenLocation();
2673 PreferredType.enterParenExpr(Tok.getLocation(), OpenLoc);
2676 bool isAmbiguousTypeId;
2679 if (Tok.is(tok::code_completion)) {
2681 Actions.CodeCompletion().CodeCompleteExpression(
2682 getCurScope(), PreferredType.get(Tok.getLocation()),
2689 Tok.isOneOf(tok::kw___bridge,
2690 tok::kw___bridge_transfer,
2691 tok::kw___bridge_retained,
2692 tok::kw___bridge_retain));
2693 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2695 StringRef BridgeCastName = Tok.getName();
2697 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2698 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2708 Diag(Tok, OpenLoc.
isMacroID() ? diag::ext_gnu_statement_expr_macro
2709 : diag::ext_gnu_statement_expr);
2711 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
2719 DeclContext *CodeDC = Actions.CurContext;
2723 "statement expr not in code context");
2725 Sema::ContextRAII SavedContext(Actions, CodeDC,
false);
2727 Actions.ActOnStartStmtExpr();
2729 StmtResult Stmt(ParseCompoundStatement(
true));
2733 if (!Stmt.isInvalid()) {
2737 Actions.ActOnStmtExprError();
2746 if (tokenKind == tok::kw___bridge)
2748 else if (tokenKind == tok::kw___bridge_transfer)
2750 else if (tokenKind == tok::kw___bridge_retained)
2755 assert(tokenKind == tok::kw___bridge_retain);
2757 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2758 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2760 "__bridge_retained");
2765 ColonProtection.restore();
2766 RParenLoc =
T.getCloseLocation();
2768 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get().
get());
2774 return Actions.ObjC().ActOnObjCBridgedCast(
getCurScope(), OpenLoc, Kind,
2775 BridgeKeywordLoc, Ty.
get(),
2776 RParenLoc, SubExpr.
get());
2778 isTypeIdInParens(isAmbiguousTypeId)) {
2787 if (isAmbiguousTypeId && !StopIfCastExpr) {
2788 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy,
T,
2790 RParenLoc =
T.getCloseLocation();
2795 DeclSpec DS(AttrFactory);
2796 ParseSpecifierQualifierList(DS);
2799 ParseDeclarator(DeclaratorInfo);
2804 if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) &&
2810 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2812 Result = ParseObjCMessageExpressionBody(SourceLocation(),
2818 ColonProtection.restore();
2819 RParenLoc =
T.getCloseLocation();
2825 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2827 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2837 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2851 Result = ParseCastExpression(
2857 if (!
Result.isInvalid()) {
2859 DeclaratorInfo, CastTy,
2860 RParenLoc,
Result.get());
2864 if (!
Result.isInvalid()) {
2876 if (DeclaratorInfo.isInvalidType())
2881 if (StopIfCastExpr) {
2885 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2893 Tok.getIdentifierInfo() == Ident_super &&
2896 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2897 << SourceRange(OpenLoc, RParenLoc);
2901 PreferredType.enterTypeCast(Tok.getLocation(), CastTy.
get());
2904 Result = ParseCastExpression(
2908 if (!
Result.isInvalid()) {
2910 DeclaratorInfo, CastTy,
2911 RParenLoc,
Result.get());
2916 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2927 ExprVector ArgExprs;
2929 if (!ParseSimpleExpressionList(ArgExprs)) {
2933 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2935 return ParseFoldExpression(ArgExprs[0],
T);
2939 Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
2942 }
else if (
getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&
2944 tryParseOpenMPArrayShapingCastPart()) {
2945 bool ErrorFound =
false;
2946 SmallVector<Expr *, 4> OMPDimensions;
2947 SmallVector<SourceRange, 4> OMPBracketsRanges;
2954 while (!
SkipUntil(tok::r_square, tok::r_paren,
2959 OMPDimensions.push_back(NumElements.
get());
2960 OMPBracketsRanges.push_back(TS.getRange());
2961 }
while (Tok.isNot(tok::r_paren));
2964 RParenLoc =
T.getCloseLocation();
2968 }
else if (!
Result.isInvalid()) {
2969 Result = Actions.OpenMP().ActOnOMPArrayShapingExpr(
2970 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);
2978 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2980 return ParseFoldExpression(
Result,
T);
2985 if (!
Result.isInvalid() && Tok.is(tok::r_paren))
2987 Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(),
Result.get());
2991 if (
Result.isInvalid()) {
2997 RParenLoc =
T.getCloseLocation();
3002Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
3005 assert(Tok.is(tok::l_brace) &&
"Not a compound literal!");
3007 Diag(LParenLoc, diag::ext_c99_compound_literal);
3008 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get());
3010 if (!
Result.isInvalid() && Ty)
3011 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc,
Result.get());
3028 "Not a string-literal-like token!");
3036 StringToks.push_back(
Tok);
3041 assert(!AllowUserDefinedLiteral &&
"UDL are always evaluated");
3046 return Actions.ActOnStringLiteral(StringToks,
3051ExprResult Parser::ParseGenericSelectionExpression() {
3052 assert(Tok.is(tok::kw__Generic) &&
"_Generic keyword expected");
3054 diagnoseUseOfC11Keyword(Tok);
3058 if (
T.expectAndConsume())
3065 if (isTypeIdForGenericSelection()) {
3072 SourceLocation Loc = LIT->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
3073 DiagCompat(Loc, diag_compat::generic_with_type_arg);
3086 if (ExpectAndConsume(tok::comma)) {
3091 SourceLocation DefaultLoc;
3092 SmallVector<ParsedType, 12> Types;
3096 if (Tok.is(tok::kw_default)) {
3100 Diag(Tok, diag::err_duplicate_default_assoc);
3101 Diag(DefaultLoc, diag::note_previous_default_assoc);
3116 Types.push_back(Ty);
3118 if (ExpectAndConsume(tok::colon)) {
3130 Exprs.push_back(ER.
get());
3134 if (
T.getCloseLocation().isInvalid())
3137 void *ExprOrTy = ControllingExpr.
isUsable()
3138 ? ControllingExpr.
get()
3141 return Actions.ActOnGenericSelectionExpr(
3142 KeyLoc, DefaultLoc,
T.getCloseLocation(), ControllingExpr.
isUsable(),
3143 ExprOrTy, Types, Exprs);
3154 SourceLocation FirstOpLoc;
3156 Kind = Tok.getKind();
3157 assert(isFoldOperator(Kind) &&
"missing fold-operator");
3161 assert(Tok.is(tok::ellipsis) &&
"not a fold-expression");
3165 if (Tok.isNot(tok::r_paren)) {
3166 if (!isFoldOperator(Tok.getKind()))
3167 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
3169 if (Kind != tok::unknown && Tok.getKind() != Kind)
3170 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
3171 << SourceRange(FirstOpLoc);
3172 Kind = Tok.getKind();
3182 DiagCompat(EllipsisLoc, diag_compat::fold_expression);
3185 return Actions.ActOnCXXFoldExpr(
getCurScope(),
T.getOpenLocation(), LHS.
get(),
3186 Kind, EllipsisLoc, RHS.
get(),
3187 T.getCloseLocation());
3190void Parser::injectEmbedTokens() {
3191 EmbedAnnotationData *
Data =
3192 reinterpret_cast<EmbedAnnotationData *
>(Tok.getAnnotationValue());
3193 MutableArrayRef<Token> Toks(PP.getPreprocessorAllocator().Allocate<Token>(
3194 Data->BinaryData.size() * 2 - 1),
3195 Data->BinaryData.size() * 2 - 1);
3197 for (
auto &Byte :
Data->BinaryData) {
3198 Toks[I].startToken();
3199 Toks[I].setKind(tok::binary_data);
3200 Toks[I].setLocation(Tok.getLocation());
3201 Toks[I].setLength(1);
3202 Toks[I].setLiteralData(&Byte);
3203 if (I != ((
Data->BinaryData.size() - 1) * 2)) {
3204 Toks[I + 1].startToken();
3205 Toks[I + 1].setKind(tok::comma);
3206 Toks[I + 1].setLocation(Tok.getLocation());
3210 PP.EnterTokenStream(std::move(Toks),
true,
3216 llvm::function_ref<
void()> ExpressionStarts,
3217 bool FailImmediatelyOnInvalidExpr,
3218 bool ParsingExpansionStmtInitList) {
3219 bool SawError =
false;
3221 if (ExpressionStarts)
3226 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
3227 Expr = ParseBraceInitializer();
3231 if (Tok.is(tok::ellipsis))
3233 else if (Tok.is(tok::code_completion)) {
3245 if (FailImmediatelyOnInvalidExpr)
3250 ParsingExpansionStmtInitList ? tok::r_brace : tok::r_paren,
3253 Exprs.push_back(Expr.
get());
3256 if (Tok.isNot(tok::comma))
3263 if (ParsingExpansionStmtInitList && Tok.is(tok::r_brace))
3266 checkPotentialAngleBracketDelimiter(Comma);
3277 Exprs.push_back(Expr.
get());
3281 if (Tok.isNot(tok::comma) ||
NextToken().
is(tok::ellipsis))
3287 checkPotentialAngleBracketDelimiter(Comma);
3292 if (Tok.is(tok::code_completion)) {
3294 Actions.CodeCompletion().CodeCompleteOrdinaryName(
3300 DeclSpec DS(AttrFactory);
3301 ParseSpecifierQualifierList(DS);
3307 ParseDeclarator(DeclaratorInfo);
3309 MaybeParseGNUAttributes(DeclaratorInfo);
3312 Actions.ActOnBlockArguments(CaretLoc, DeclaratorInfo,
getCurScope());
3315ExprResult Parser::ParseBlockLiteralExpression() {
3316 assert(Tok.is(tok::caret) &&
"block literal starts with ^");
3319 PrettyStackTraceLoc CrashInfo(PP.getSourceManager(), CaretLoc,
3320 "block literal parsing");
3333 DeclSpec DS(AttrFactory);
3339 ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation()));
3343 if (Tok.is(tok::l_paren)) {
3344 ParseParenDeclarator(ParamInfo);
3348 SourceLocation Tmp = ParamInfo.getSourceRange().getEnd();
3349 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
3350 ParamInfo.SetRangeEnd(Tmp);
3351 if (ParamInfo.isInvalidType()) {
3359 MaybeParseGNUAttributes(ParamInfo);
3362 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3363 }
else if (!Tok.is(tok::l_brace)) {
3364 ParseBlockId(CaretLoc);
3367 SourceLocation NoLoc;
3368 ParamInfo.AddTypeInfo(
3386 CaretLoc, ParamInfo),
3389 MaybeParseGNUAttributes(ParamInfo);
3392 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3397 if (!Tok.is(tok::l_brace)) {
3399 Diag(Tok, diag::err_expected_expression);
3403 EnterExpressionEvaluationContextForFunction PotentiallyEvaluated(
3405 StmtResult Stmt(ParseCompoundStatementBody());
3407 if (!Stmt.isInvalid())
3416 return Actions.ObjC().ActOnObjCBoolLiteral(
ConsumeToken(), Kind);
3423 llvm::SmallSet<StringRef, 4> Platforms;
3424 bool HasOtherPlatformSpec =
false;
3426 for (
const auto &Spec : AvailSpecs) {
3427 if (Spec.isOtherPlatformSpec()) {
3428 if (HasOtherPlatformSpec) {
3429 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3433 HasOtherPlatformSpec =
true;
3437 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3442 StringRef Platform = Spec.getPlatform();
3443 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3444 << Spec.getEndLoc() << Platform;
3449 if (!HasOtherPlatformSpec) {
3450 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3451 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3459std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() {
3460 if (Tok.is(tok::star)) {
3464 if (Tok.is(tok::code_completion)) {
3466 Actions.CodeCompletion().CodeCompleteAvailabilityPlatformName();
3467 return std::nullopt;
3469 if (Tok.isNot(tok::identifier)) {
3470 Diag(Tok, diag::err_avail_query_expected_platform_name);
3471 return std::nullopt;
3474 IdentifierLoc *PlatformIdentifier = ParseIdentifierLoc();
3475 SourceRange VersionRange;
3476 VersionTuple Version = ParseVersionTuple(VersionRange);
3478 if (Version.empty())
3479 return std::nullopt;
3481 StringRef GivenPlatform =
3483 StringRef Platform =
3484 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3486 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||
3487 (GivenPlatform.contains(
"xros") || GivenPlatform.contains(
"xrOS"))) {
3489 diag::err_avail_query_unrecognized_platform_name)
3491 return std::nullopt;
3495 if (Platform ==
"anyappleos" &&
3498 diag::err_avail_query_anyappleos_min_version)
3499 << Version.getAsString();
3500 return std::nullopt;
3503 return AvailabilitySpec(Version, Platform, PlatformIdentifier->
getLoc(),
3509 assert(Tok.is(tok::kw___builtin_available) ||
3510 Tok.isObjCAtKeyword(tok::objc_available));
3516 if (
Parens.expectAndConsume())
3519 SmallVector<AvailabilitySpec, 4> AvailSpecs;
3520 bool HasError =
false;
3522 std::optional<AvailabilitySpec> Spec = ParseAvailabilitySpec();
3526 AvailSpecs.push_back(*Spec);
3539 if (
Parens.consumeClose())
3542 return Actions.ObjC().ActOnObjCAvailabilityCheckExpr(
3543 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 { ....
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)
DiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
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.
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer.
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.
Top level wrappers for InstallAPI frontend operations.
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,...
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
const FunctionProtoType * T
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.