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)) {
346 UnconsumeToken(OpToken);
347 PP.EnterToken(Caret,
true);
348 return ParseRHSOfBinaryExpression(LHS, MinPrec);
354 if (OpToken.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
355 tok::greatergreatergreater) &&
356 checkPotentialAngleBracketDelimiter(OpToken))
364 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
365 PP.EnterToken(Tok,
true);
372 if (isFoldOperator(NextTokPrec) && Tok.is(tok::ellipsis)) {
375 PP.EnterToken(Tok,
true);
386 Tok.isOneOf(tok::colon, tok::r_square) &&
388 PP.EnterToken(Tok,
true);
398 SourceLocation BraceLoc = Tok.getLocation();
399 TernaryMiddle = ParseBraceInitializer();
400 if (!TernaryMiddle.isInvalid()) {
401 Diag(BraceLoc, diag::err_init_list_bin_op)
402 << 1 << PP.getSpelling(OpToken)
403 << Actions.getExprRange(TernaryMiddle.get());
406 }
else if (Tok.isNot(tok::colon)) {
418 TernaryMiddle =
nullptr;
419 Diag(Tok, diag::ext_gnu_conditional_expr);
422 if (TernaryMiddle.isInvalid()) {
424 TernaryMiddle =
nullptr;
432 SourceLocation FILoc = Tok.getLocation();
433 const char *FIText =
": ";
434 const SourceManager &SM = PP.getSourceManager();
435 if (FILoc.
isFileID() || PP.isAtStartOfMacroExpansion(FILoc, &FILoc)) {
437 bool IsInvalid =
false;
438 const char *SourcePtr =
440 if (!IsInvalid && *SourcePtr ==
' ') {
443 if (!IsInvalid && *SourcePtr ==
' ') {
450 Diag(Tok, diag::err_expected)
452 Diag(OpToken, diag::note_matching) << tok::question;
453 ColonLoc = Tok.getLocation();
457 PreferredType.enterBinary(Actions, Tok.getLocation(), LHS.
get(),
470 bool RHSIsInitList =
false;
472 RHS = ParseBraceInitializer();
473 RHSIsInitList =
true;
481 if (RHS.
isInvalid() && Tok.isNot(tok::semi)) {
497 if (ThisPrec < NextTokPrec ||
498 (ThisPrec == NextTokPrec && isRightAssoc)) {
500 Diag(Tok, diag::err_init_list_bin_op)
501 << 0 << PP.getSpelling(Tok) << Actions.getExprRange(RHS.
get());
509 RHS = ParseRHSOfBinaryExpression(RHS,
510 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
511 RHSIsInitList =
false;
513 if (RHS.
isInvalid() && Tok.isNot(tok::semi)) {
523 Diag(OpToken, diag::compat_cxx11_generalized_initializer_lists)
524 << Actions.getExprRange(RHS.
get());
525 }
else if (ColonLoc.
isValid()) {
526 Diag(ColonLoc, diag::err_init_list_bin_op)
528 << Actions.getExprRange(RHS.
get());
531 Diag(OpToken, diag::err_init_list_bin_op)
532 << 1 << PP.getSpelling(OpToken)
533 << Actions.getExprRange(RHS.
get());
544 }
else if (TernaryMiddle.isInvalid()) {
548 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
550 diag::warn_cxx11_right_shift_in_template_arg,
551 SourceRange(Actions.getExprRange(LHS.
get()).getBegin(),
552 Actions.getExprRange(RHS.
get()).getEnd()));
560 {LHS.get(), RHS.get()});
564 ExprResult CondOp = Actions.ActOnConditionalOp(
568 std::vector<clang::Expr *> Args;
570 if (TernaryMiddle.get())
571 Args = {LHS.
get(), TernaryMiddle.get(), RHS.
get()};
573 Args = {LHS.
get(), RHS.
get()};
585Parser::ParseCastExpression(
CastParseKind ParseKind,
bool isAddressOfOperand,
587 bool isVectorLiteral,
bool *NotPrimaryExpression) {
589 ExprResult Res = ParseCastExpression(ParseKind, isAddressOfOperand,
590 NotCastExpr, CorrectionBehavior,
591 isVectorLiteral, NotPrimaryExpression);
593 Diag(Tok, diag::err_expected_expression);
600 CastExpressionIdValidator(Token
Next,
603 WantTypeSpecifiers = WantFunctionLikeCasts =
604 (CorrectionBehavior != TypoCorrectionTypeBehavior::AllowNonTypes);
606 (CorrectionBehavior != TypoCorrectionTypeBehavior::AllowTypes);
609 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
615 return WantTypeSpecifiers;
620 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
623 for (
auto *
C : candidate) {
631 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
632 return std::make_unique<CastExpressionIdValidator>(*
this);
643 if (RevertibleTypeTraits.empty()) {
647#define RTT_JOIN(X, Y) X##Y
648#define REVERTIBLE_TYPE_TRAIT(Name) \
649 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
706#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
707 REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
708#include "clang/Basic/BuiltinTraits.inc"
709#undef REVERTIBLE_TYPE_TRAIT
712 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known =
713 RevertibleTypeTraits.find(II);
714 if (Known != RevertibleTypeTraits.end()) {
716 *
Kind = Known->second;
722ExprResult Parser::ParseBuiltinPtrauthTypeDiscriminator() {
726 if (
T.expectAndConsume())
735 SourceLocation EndLoc = Tok.getLocation();
737 return Actions.ActOnUnaryExprOrTypeTraitExpr(
738 Loc, UETT_PtrAuthTypeDiscriminator,
743Parser::ParseCastExpression(
CastParseKind ParseKind,
bool isAddressOfOperand,
746 bool isVectorLiteral,
bool *NotPrimaryExpression) {
749 auto SavedType = PreferredType;
755 bool AllowSuffix =
true;
784 SourceLocation RParenLoc;
785 Res = ParseParenExpression(ParenExprType,
false,
795 switch (ParenExprType) {
818 case tok::numeric_constant:
819 case tok::binary_data:
823 Res = Actions.ActOnNumericConstant(Tok,
getCurScope());
829 Res = ParseCXXBoolLiteral();
832 case tok::kw___objc_yes:
833 case tok::kw___objc_no:
834 Res = ParseObjCBoolLiteral();
837 case tok::kw_nullptr:
839 Diag(Tok, diag::warn_cxx98_compat_nullptr);
842 : diag::ext_c_nullptr) << Tok.getName();
847 case tok::annot_primary_expr:
848 case tok::annot_overload_set:
849 Res = getExprAnnotation(Tok);
850 if (!Res.
isInvalid() && Tok.getKind() == tok::annot_overload_set)
851 Res = Actions.ActOnNameClassifiedAsOverloadSet(
getCurScope(), Res.
get());
852 ConsumeAnnotationToken();
853 if (!Res.
isInvalid() && Tok.is(tok::less))
854 checkPotentialAngleBracket(Res);
857 case tok::annot_non_type:
858 case tok::annot_non_type_dependent:
859 case tok::annot_non_type_undeclared: {
861 Res = tryParseCXXIdExpression(SS, isAddressOfOperand);
863 "should not perform typo correction on annotation token");
867 case tok::annot_embed: {
869 return ParseCastExpression(ParseKind, isAddressOfOperand,
870 CorrectionBehavior, isVectorLiteral,
871 NotPrimaryExpression);
874 case tok::kw___super:
875 case tok::kw_decltype:
879 assert(Tok.isNot(tok::kw_decltype) && Tok.isNot(tok::kw___super));
880 return ParseCastExpression(ParseKind, isAddressOfOperand,
881 CorrectionBehavior, isVectorLiteral,
882 NotPrimaryExpression);
884 case tok::identifier:
895 if (
Next.is(tok::ellipsis) && Tok.is(tok::identifier) &&
902 if (Tok.isOneOf(tok::annot_cxxscope, tok::annot_pack_indexing_type,
903 tok::annot_template_id, tok::annot_typename))
904 return ParseCastExpression(ParseKind, isAddressOfOperand,
905 CorrectionBehavior, isVectorLiteral,
906 NotPrimaryExpression);
912 else if (
Next.is(tok::l_paren) && Tok.is(tok::identifier) &&
913 Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
914 IdentifierInfo *II = Tok.getIdentifierInfo();
916 if (isRevertibleTypeTrait(II, &Kind)) {
918 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
919 CorrectionBehavior, isVectorLiteral,
920 NotPrimaryExpression);
924 else if ((!ColonIsSacred &&
Next.is(tok::colon)) ||
925 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
930 if (!Tok.is(tok::identifier))
931 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
932 CorrectionBehavior, isVectorLiteral,
933 NotPrimaryExpression);
939 IdentifierInfo &II = *Tok.getIdentifierInfo();
946 (&II == Ident_super &&
getCurScope()->isInObjcMethodScope()))) {
949 if (Tok.is(tok::code_completion) && &II != Ident_super) {
951 Actions.CodeCompletion().CodeCompleteObjCClassPropertyRefExpr(
952 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
956 if (Tok.isNot(tok::identifier) &&
958 Diag(Tok, diag::err_expected_property_name);
961 IdentifierInfo &PropertyName = *Tok.getIdentifierInfo();
964 Res = Actions.ObjC().ActOnClassPropertyRefExpr(II, PropertyName, ILoc,
973 if (
getLangOpts().
ObjC && &II == Ident_super && !InMessageExpression &&
975 ((Tok.is(tok::identifier) &&
977 Tok.is(tok::code_completion))) {
978 Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc,
nullptr,
989 ((Tok.is(tok::identifier) && !InMessageExpression) ||
990 Tok.is(tok::code_completion))) {
992 if (Tok.is(tok::code_completion) ||
993 Next.is(tok::colon) ||
Next.is(tok::r_square))
995 if (Typ.get()->isObjCObjectOrInterfaceType()) {
997 DeclSpec DS(AttrFactory);
998 DS.SetRangeStart(ILoc);
999 DS.SetRangeEnd(ILoc);
1000 const char *PrevSpec =
nullptr;
1002 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
1003 Actions.getASTContext().getPrintingPolicy());
1007 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
1011 Res = ParseObjCMessageExpressionBody(SourceLocation(),
1019 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1020 isAddressOfOperand =
false;
1026 CXXScopeSpec ScopeSpec;
1027 SourceLocation TemplateKWLoc;
1028 CastExpressionIdValidator Validator(Tok, CorrectionBehavior);
1029 Validator.IsAddressOfOperand = isAddressOfOperand;
1030 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
1031 Validator.WantExpressionKeywords =
false;
1032 Validator.WantRemainingKeywords =
false;
1034 Validator.WantRemainingKeywords = Tok.isNot(tok::r_paren);
1037 Res = Actions.ActOnIdExpression(
getCurScope(), ScopeSpec, TemplateKWLoc,
1038 Name, Tok.is(tok::l_paren),
1039 isAddressOfOperand, &Validator,
1041 Res = tryParseCXXPackIndexingExpression(Res);
1042 if (!Res.
isInvalid() && Tok.is(tok::less))
1043 checkPotentialAngleBracket(Res);
1046 case tok::char_constant:
1047 case tok::wide_char_constant:
1048 case tok::utf8_char_constant:
1049 case tok::utf16_char_constant:
1050 case tok::utf32_char_constant:
1051 Res = Actions.ActOnCharacterConstant(Tok,
getCurScope());
1054 case tok::kw___func__:
1055 case tok::kw___FUNCTION__:
1056 case tok::kw___FUNCDNAME__:
1057 case tok::kw___FUNCSIG__:
1058 case tok::kw_L__FUNCTION__:
1059 case tok::kw_L__FUNCSIG__:
1060 case tok::kw___PRETTY_FUNCTION__:
1067 Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
1072 case tok::string_literal:
1073 case tok::wide_string_literal:
1074 case tok::utf8_string_literal:
1075 case tok::utf16_string_literal:
1076 case tok::utf32_string_literal:
1079 case tok::kw__Generic:
1080 Res = ParseGenericSelectionExpression();
1082 case tok::kw___builtin_available:
1083 Res = ParseAvailabilityCheckExpr(Tok.getLocation());
1085 case tok::kw___builtin_va_arg:
1086 case tok::kw___builtin_offsetof:
1087 case tok::kw___builtin_choose_expr:
1088 case tok::kw___builtin_astype:
1089 case tok::kw___builtin_convertvector:
1090 case tok::kw___builtin_COLUMN:
1091 case tok::kw___builtin_FILE:
1092 case tok::kw___builtin_FILE_NAME:
1093 case tok::kw___builtin_FUNCTION:
1094 case tok::kw___builtin_FUNCSIG:
1095 case tok::kw___builtin_LINE:
1096 case tok::kw___builtin_source_location:
1097 if (NotPrimaryExpression)
1098 *NotPrimaryExpression =
true;
1100 return ParseBuiltinPrimaryExpression();
1101 case tok::kw___null:
1106 case tok::minusminus: {
1107 if (NotPrimaryExpression)
1108 *NotPrimaryExpression =
true;
1113 Token SavedTok = Tok;
1116 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedTok.
getKind(),
1130 UnconsumeToken(SavedTok);
1134 Expr *Arg = Res.
get();
1138 Res = Actions.CreateRecoveryExpr(SavedTok.
getLocation(),
1144 if (NotPrimaryExpression)
1145 *NotPrimaryExpression =
true;
1148 PreferredType.enterUnary(Actions, Tok.getLocation(), tok::amp, SavedLoc);
1153 Expr *Arg = Res.
get();
1154 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Arg);
1156 Res = Actions.CreateRecoveryExpr(Tok.getLocation(), Arg->
getEndLoc(),
1167 case tok::kw___real:
1168 case tok::kw___imag: {
1169 if (NotPrimaryExpression)
1170 *NotPrimaryExpression =
true;
1172 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedKind, SavedLoc);
1175 Expr *Arg = Res.
get();
1176 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Arg,
1177 isAddressOfOperand);
1179 Res = Actions.CreateRecoveryExpr(SavedLoc, Arg->
getEndLoc(), Arg);
1184 case tok::kw_co_await: {
1185 if (NotPrimaryExpression)
1186 *NotPrimaryExpression =
true;
1190 Res = Actions.ActOnCoawaitExpr(
getCurScope(), CoawaitLoc, Res.
get());
1194 case tok::kw___extension__:{
1196 if (NotPrimaryExpression)
1197 *NotPrimaryExpression =
true;
1198 ExtensionRAIIObject O(Diags);
1202 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.
get());
1205 case tok::kw__Alignof:
1206 diagnoseUseOfC11Keyword(Tok);
1208 case tok::kw_alignof:
1209 case tok::kw___alignof:
1211 case tok::kw_sizeof:
1215 case tok::kw___datasizeof:
1216 case tok::kw_vec_step:
1218 case tok::kw___builtin_omp_required_simd_align:
1219 case tok::kw___builtin_vectorelements:
1220 case tok::kw__Countof:
1221 if (NotPrimaryExpression)
1222 *NotPrimaryExpression =
true;
1223 AllowSuffix =
false;
1224 Res = ParseUnaryExprOrTypeTraitExpression();
1226 case tok::caretcaret: {
1232 if (NotPrimaryExpression)
1233 *NotPrimaryExpression =
true;
1234 AllowSuffix =
false;
1235 Res = ParseCXXReflectExpression();
1239 if (NotPrimaryExpression)
1240 *NotPrimaryExpression =
true;
1242 if (Tok.isNot(tok::identifier))
1243 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1246 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1248 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1249 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(),
1251 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD);
1253 AllowSuffix =
false;
1256 case tok::kw_const_cast:
1257 case tok::kw_dynamic_cast:
1258 case tok::kw_reinterpret_cast:
1259 case tok::kw_static_cast:
1260 case tok::kw_addrspace_cast:
1261 if (NotPrimaryExpression)
1262 *NotPrimaryExpression =
true;
1263 Res = ParseCXXCasts();
1265 case tok::kw___builtin_bit_cast:
1266 if (NotPrimaryExpression)
1267 *NotPrimaryExpression =
true;
1268 Res = ParseBuiltinBitCast();
1270 case tok::kw_typeid:
1271 if (NotPrimaryExpression)
1272 *NotPrimaryExpression =
true;
1273 Res = ParseCXXTypeid();
1275 case tok::kw___uuidof:
1276 if (NotPrimaryExpression)
1277 *NotPrimaryExpression =
true;
1278 Res = ParseCXXUuidof();
1281 Res = ParseCXXThis();
1283 case tok::kw___builtin_sycl_unique_stable_name:
1284 Res = ParseSYCLUniqueStableNameExpression();
1287 case tok::annot_typename:
1288 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1292 DeclSpec DS(AttrFactory);
1293 DS.SetRangeStart(Tok.getLocation());
1294 DS.SetRangeEnd(Tok.getLastLoc());
1296 const char *PrevSpec =
nullptr;
1298 DS.SetTypeSpecType(
TST_typename, Tok.getAnnotationEndLoc(),
1299 PrevSpec, DiagID,
Type,
1300 Actions.getASTContext().getPrintingPolicy());
1304 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
1308 ConsumeAnnotationToken();
1309 Res = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1315 case tok::annot_decltype:
1316 case tok::annot_pack_indexing_type:
1318 case tok::kw_wchar_t:
1319 case tok::kw_char8_t:
1320 case tok::kw_char16_t:
1321 case tok::kw_char32_t:
1326 case tok::kw___int64:
1327 case tok::kw___int128:
1328 case tok::kw__ExtInt:
1329 case tok::kw__BitInt:
1330 case tok::kw_signed:
1331 case tok::kw_unsigned:
1334 case tok::kw_double:
1335 case tok::kw___bf16:
1336 case tok::kw__Float16:
1337 case tok::kw___float128:
1338 case tok::kw___ibm128:
1341 case tok::kw_typename:
1342 case tok::kw_typeof:
1343 case tok::kw_typeof_unqual:
1344 case tok::kw___vector:
1345 case tok::kw__Accum:
1346 case tok::kw__Fract:
1348#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1349#include "clang/Basic/OpenCLImageTypes.def"
1350#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
1351#include "clang/Basic/HLSLIntangibleTypes.def"
1352#define HLSL_PACKED_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
1353#include "clang/Basic/HLSLPackedTypes.def"
1356 Diag(Tok, diag::err_expected_expression);
1361 if (NotPrimaryExpression)
1362 *NotPrimaryExpression =
true;
1364 if (SavedKind == tok::kw_typename) {
1379 DeclSpec DS(AttrFactory);
1381 ParseCXXSimpleTypeSpecifier(DS);
1382 if (Tok.isNot(tok::l_paren) &&
1384 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1385 << DS.getSourceRange());
1387 if (Tok.is(tok::l_brace))
1388 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
1390 Res = ParseCXXTypeConstructExpression(DS);
1394 case tok::annot_cxxscope: {
1399 if (!Tok.is(tok::annot_cxxscope))
1400 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1401 CorrectionBehavior, isVectorLiteral,
1402 NotPrimaryExpression);
1405 if (
Next.is(tok::annot_template_id)) {
1406 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(
Next);
1412 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1416 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1417 CorrectionBehavior, isVectorLiteral,
1418 NotPrimaryExpression);
1423 Res = ParseCXXIdExpression(isAddressOfOperand);
1427 case tok::annot_template_id: {
1428 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1435 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1436 CorrectionBehavior, isVectorLiteral,
1437 NotPrimaryExpression);
1444 case tok::kw_operator:
1445 Res = ParseCXXIdExpression(isAddressOfOperand);
1448 case tok::coloncolon: {
1453 if (!Tok.is(tok::coloncolon))
1454 return ParseCastExpression(ParseKind, isAddressOfOperand,
1455 CorrectionBehavior, isVectorLiteral,
1456 NotPrimaryExpression);
1461 if (Tok.is(tok::kw_new)) {
1462 if (NotPrimaryExpression)
1463 *NotPrimaryExpression =
true;
1464 Res = ParseCXXNewExpression(
true, CCLoc);
1465 AllowSuffix =
false;
1468 if (Tok.is(tok::kw_delete)) {
1469 if (NotPrimaryExpression)
1470 *NotPrimaryExpression =
true;
1471 Res = ParseCXXDeleteExpression(
true, CCLoc);
1472 AllowSuffix =
false;
1477 Diag(CCLoc, diag::err_expected_expression);
1482 if (NotPrimaryExpression)
1483 *NotPrimaryExpression =
true;
1484 Res = ParseCXXNewExpression(
false, Tok.getLocation());
1485 AllowSuffix =
false;
1488 case tok::kw_delete:
1489 if (NotPrimaryExpression)
1490 *NotPrimaryExpression =
true;
1491 Res = ParseCXXDeleteExpression(
false, Tok.getLocation());
1492 AllowSuffix =
false;
1495 case tok::kw_requires:
1496 Res = ParseRequiresExpression();
1497 AllowSuffix =
false;
1500 case tok::kw_noexcept: {
1501 if (NotPrimaryExpression)
1502 *NotPrimaryExpression =
true;
1503 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1507 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1519 Res = Actions.ActOnNoexceptExpr(KeyLoc,
T.getOpenLocation(), Res.
get(),
1520 T.getCloseLocation());
1521 AllowSuffix =
false;
1525#define TYPE_TRAIT(N,Spelling,K) \
1526 case tok::kw_##Spelling:
1527#include "clang/Basic/TokenKinds.def"
1528 Res = ParseTypeTrait();
1531 case tok::kw___array_rank:
1532 case tok::kw___array_extent:
1533 if (NotPrimaryExpression)
1534 *NotPrimaryExpression =
true;
1535 Res = ParseArrayTypeTrait();
1538 case tok::kw___builtin_ptrauth_type_discriminator:
1539 return ParseBuiltinPtrauthTypeDiscriminator();
1541 case tok::kw___is_lvalue_expr:
1542 case tok::kw___is_rvalue_expr:
1543 if (NotPrimaryExpression)
1544 *NotPrimaryExpression =
true;
1545 Res = ParseExpressionTrait();
1549 if (NotPrimaryExpression)
1550 *NotPrimaryExpression =
true;
1552 return ParseObjCAtExpression(AtLoc);
1555 Res = ParseBlockLiteralExpression();
1557 case tok::code_completion: {
1559 Actions.CodeCompletion().CodeCompleteExpression(
1560 getCurScope(), PreferredType.get(Tok.getLocation()),
1561 false, isAddressOfOperand);
1564#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
1565#include "clang/Basic/BuiltinTraits.inc"
1569 Tok.setKind(tok::identifier);
1570 Diag(Tok, diag::ext_keyword_as_ident)
1571 << Tok.getIdentifierInfo()->getName() << 0;
1572 goto ParseIdentifier;
1574 goto ExpectedExpression;
1583 Res = TryParseLambdaExpression();
1587 if (NotPrimaryExpression)
1588 *NotPrimaryExpression =
true;
1589 Res = ParseObjCMessageExpression();
1593 Res = ParseLambdaExpression();
1597 Res = ParseObjCMessageExpression();
1622 switch (Tok.getKind()) {
1626 case tok::minusminus:
1629 if (Tok.isAtStartOfLine())
1644 Diag(Tok.getLocation(), diag::err_postfix_after_unary_requires_parens)
1652 PreferredType = SavedType;
1653 Res = ParsePostfixExpressionSuffix(Res);
1655 !
getActions().getOpenCLOptions().isAvailableOption(
1657 if (Expr *PostfixExpr = Res.
get()) {
1658 QualType Ty = PostfixExpr->getType();
1660 Diag(PostfixExpr->getExprLoc(),
1661 diag::err_opencl_taking_function_address_parser);
1670Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1674 auto SavedType = PreferredType;
1677 PreferredType = SavedType;
1678 switch (Tok.getKind()) {
1679 case tok::code_completion:
1680 if (InMessageExpression)
1684 Actions.CodeCompletion().CodeCompletePostfixExpression(
1685 getCurScope(), LHS, PreferredType.get(Tok.getLocation()));
1688 case tok::identifier:
1694 LHS = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1695 nullptr, LHS.
get());
1703 case tok::l_square: {
1711 isSimpleObjCMessageExpression())
1716 if (CheckProhibitedCXX11Attribute()) {
1721 Loc =
T.getOpenLocation();
1723 SourceLocation ColonLocFirst, ColonLocSecond;
1724 ExprVector ArgExprs;
1725 bool HasError =
false;
1726 PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.
get());
1732 if ((!
getLangOpts().OpenMP && !AllowOpenACCArraySections) ||
1733 Tok.isNot(tok::colon)) {
1737 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
1738 Idx = ParseBraceInitializer();
1745 ArgExprs.push_back(Idx.
get());
1747 }
else if (Tok.isNot(tok::r_square)) {
1748 if (ParseExpressionList(ArgExprs)) {
1758 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {
1760 if (Tok.is(tok::colon)) {
1763 if (Tok.isNot(tok::r_square))
1766 }
else if (ArgExprs.size() <= 1 &&
getLangOpts().OpenMP) {
1768 if (Tok.is(tok::colon)) {
1771 if (Tok.isNot(tok::r_square) &&
1773 ((Tok.isNot(tok::colon) &&
getLangOpts().OpenMP >= 50)))) {
1778 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||
1779 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
1780 Tok.is(tok::colon)) {
1783 if (Tok.isNot(tok::r_square)) {
1789 SourceLocation RLoc = Tok.getLocation();
1790 if (!LHS.
isInvalid() && !HasError && !Length.isInvalid() &&
1791 !Stride.
isInvalid() && Tok.is(tok::r_square)) {
1797 if (AllowOpenACCArraySections) {
1799 "Stride/second colon not allowed for OpenACC");
1800 LHS = Actions.OpenACC().ActOnArraySectionExpr(
1801 LHS.
get(), Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
1802 ColonLocFirst, Length.get(), RLoc);
1804 LHS = Actions.OpenMP().ActOnOMPArraySectionExpr(
1805 LHS.
get(), Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
1806 ColonLocFirst, ColonLocSecond, Length.get(), Stride.
get(),
1810 LHS = Actions.ActOnArraySubscriptExpr(
getCurScope(), LHS.
get(), Loc,
1823 case tok::lesslessless: {
1828 Expr *ExecConfig =
nullptr;
1832 if (OpKind == tok::lesslessless) {
1833 ExprVector ExecConfigExprs;
1836 if (ParseSimpleExpressionList(ExecConfigExprs)) {
1840 SourceLocation CloseLoc;
1846 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1847 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1853 if (ExpectAndConsume(tok::l_paren))
1856 Loc = PrevTokLocation;
1860 ExprResult ECResult = Actions.CUDA().ActOnExecConfigExpr(
1861 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);
1865 ExecConfig = ECResult.
get();
1869 Loc = PT.getOpenLocation();
1872 ExprVector ArgExprs;
1873 auto RunSignatureHelp = [&]() -> QualType {
1874 QualType PreferredType =
1875 Actions.CodeCompletion().ProduceCallSignatureHelp(
1876 LHS.
get(), ArgExprs, PT.getOpenLocation());
1877 CalledSignatureHelp =
true;
1878 return PreferredType;
1880 bool ExpressionListIsInvalid =
false;
1881 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1882 if (Tok.isNot(tok::r_paren)) {
1883 if ((ExpressionListIsInvalid = ParseExpressionList(ArgExprs, [&] {
1884 PreferredType.enterFunctionArgument(Tok.getLocation(),
1891 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
1900 }
else if (ExpressionListIsInvalid) {
1901 Expr *
Fn = LHS.
get();
1902 ArgExprs.insert(ArgExprs.begin(), Fn);
1903 LHS = Actions.CreateRecoveryExpr(
Fn->getBeginLoc(), Tok.getLocation(),
1906 }
else if (Tok.isNot(tok::r_paren)) {
1907 bool HadErrors =
false;
1910 for (
auto &E : ArgExprs)
1911 if (E->containsErrors())
1922 Expr *
Fn = LHS.
get();
1923 SourceLocation RParLoc = Tok.getLocation();
1924 LHS = Actions.ActOnCallExpr(
getCurScope(), Fn, Loc, ArgExprs, RParLoc,
1927 ArgExprs.insert(ArgExprs.begin(), Fn);
1929 Actions.CreateRecoveryExpr(
Fn->getBeginLoc(), RParLoc, ArgExprs);
1945 bool MayBePseudoDestructor =
false;
1946 Expr* OrigLHS = !LHS.
isInvalid() ? LHS.
get() :
nullptr;
1948 PreferredType.enterMemAccess(Actions, Tok.getLocation(), OrigLHS);
1951 Expr *
Base = OrigLHS;
1952 const Type* BaseType =
Base->getType().getTypePtrOrNull();
1953 if (BaseType && Tok.is(tok::l_paren) &&
1956 Diag(OpLoc, diag::err_function_is_not_record)
1957 << OpKind <<
Base->getSourceRange()
1959 return ParsePostfixExpressionSuffix(Base);
1962 LHS = Actions.ActOnStartCXXMemberReference(
getCurScope(), Base, OpLoc,
1964 MayBePseudoDestructor);
1969 if (Tok.is(tok::code_completion)) {
1975 ParseOptionalCXXScopeSpecifier(
1977 false, &MayBePseudoDestructor);
1979 ObjectType =
nullptr;
1982 if (Tok.is(tok::code_completion)) {
1984 OpKind == tok::arrow ? tok::period : tok::arrow;
1989 Sema::TentativeAnalysisScope Trap(Actions);
1990 CorrectedLHS = Actions.ActOnStartCXXMemberReference(
1991 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
1992 MayBePseudoDestructor);
1996 Expr *CorrectedBase = CorrectedLHS.get();
1998 CorrectedBase =
Base;
2002 Actions.CodeCompletion().CodeCompleteMemberReferenceExpr(
2003 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,
2004 Base && ExprStatementTokLoc ==
Base->getBeginLoc(),
2005 PreferredType.get(Tok.getLocation()));
2010 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
2011 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
2023 SourceLocation TemplateKWLoc;
2026 Tok.is(tok::kw_class)) {
2034 IdentifierInfo *Id = Tok.getIdentifierInfo();
2043 false, &TemplateKWLoc, Name)) {
2048 LHS = Actions.ActOnMemberAccessExpr(
getCurScope(), LHS.
get(), OpLoc,
2049 OpKind, SS, TemplateKWLoc, Name,
2050 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
2053 if (Tok.is(tok::less))
2054 checkPotentialAngleBracket(LHS);
2055 }
else if (OrigLHS && Name.
isValid()) {
2057 LHS = Actions.CreateRecoveryExpr(OrigLHS->
getBeginLoc(),
2063 case tok::minusminus:
2065 Expr *Arg = LHS.
get();
2066 LHS = Actions.ActOnPostfixUnaryOp(
getCurScope(), Tok.getLocation(),
2067 Tok.getKind(), Arg);
2069 LHS = Actions.CreateRecoveryExpr(Arg->
getBeginLoc(),
2070 Tok.getLocation(), Arg);
2079Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
2084 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,
2085 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,
2086 tok::kw__Alignof, tok::kw_vec_step,
2087 tok::kw___builtin_omp_required_simd_align,
2088 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2089 "Not a typeof/sizeof/alignof/vec_step expression!");
2094 if (Tok.isNot(tok::l_paren)) {
2097 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2098 tok::kw_alignof, tok::kw__Alignof)) {
2099 if (isTypeIdUnambiguously()) {
2100 DeclSpec DS(AttrFactory);
2101 ParseSpecifierQualifierList(DS);
2104 ParseDeclarator(DeclaratorInfo);
2106 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.
getLocation());
2107 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
2110 diag::err_expected_parentheses_around_typename)
2113 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
2123 if (OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
2134 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2135 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof) &&
2136 Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2137 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof))
2138 Actions.runWithSufficientStackSpace(Tok.getLocation(), [&] {
2139 Operand = ParseCastExpression(CastParseKind::UnaryExprOnly);
2158 bool ParenKnownToBeNonCast =
2159 OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual);
2161 SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
2163 Operand = ParseParenExpression(
2168 CastRange = SourceRange(LParenLoc, RParenLoc);
2178 !OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {
2193ExprResult Parser::ParseSYCLUniqueStableNameExpression() {
2194 assert(Tok.is(tok::kw___builtin_sycl_unique_stable_name) &&
2195 "Not __builtin_sycl_unique_stable_name");
2201 if (
T.expectAndConsume(diag::err_expected_lparen_after,
2202 "__builtin_sycl_unique_stable_name"))
2212 if (
T.consumeClose())
2215 return Actions.SYCL().ActOnUniqueStableNameExpr(
2216 OpLoc,
T.getOpenLocation(),
T.getCloseLocation(), Ty.
get());
2219ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
2220 assert(Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2221 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
2222 tok::kw___builtin_omp_required_simd_align,
2223 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2224 "Not a sizeof/alignof/vec_step expression!");
2229 if (Tok.is(tok::ellipsis) && OpTok.
is(tok::kw_sizeof)) {
2231 SourceLocation LParenLoc, RParenLoc;
2232 IdentifierInfo *Name =
nullptr;
2233 SourceLocation NameLoc;
2234 if (Tok.is(tok::l_paren)) {
2237 LParenLoc =
T.getOpenLocation();
2238 if (Tok.is(tok::identifier)) {
2239 Name = Tok.getIdentifierInfo();
2242 RParenLoc =
T.getCloseLocation();
2244 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2246 Diag(Tok, diag::err_expected_parameter_pack);
2249 }
else if (Tok.is(tok::identifier)) {
2250 Name = Tok.getIdentifierInfo();
2252 LParenLoc = PP.getLocForEndOfToken(EllipsisLoc);
2253 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2254 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2259 Diag(Tok, diag::err_sizeof_parameter_pack);
2269 return Actions.ActOnSizeofParameterPackExpr(
getCurScope(),
2276 OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2277 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2279 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.
getName();
2281 Diag(OpTok, diag::warn_c2y_compat_keyword) << OpTok.
getName();
2289 SourceRange CastRange;
2295 UnaryExprOrTypeTrait ExprKind = UETT_SizeOf;
2297 case tok::kw_alignof:
2298 case tok::kw__Alignof:
2299 ExprKind = UETT_AlignOf;
2301 case tok::kw___alignof:
2302 ExprKind = UETT_PreferredAlignOf;
2304 case tok::kw_vec_step:
2305 ExprKind = UETT_VecStep;
2307 case tok::kw___builtin_omp_required_simd_align:
2308 ExprKind = UETT_OpenMPRequiredSimdAlign;
2310 case tok::kw___datasizeof:
2311 ExprKind = UETT_DataSizeOf;
2313 case tok::kw___builtin_vectorelements:
2314 ExprKind = UETT_VectorElements;
2316 case tok::kw__Countof:
2317 ExprKind = UETT_CountOf;
2320 Diag(OpTok, diag::ext_c2y_feature) << OpTok.
getName();
2327 return Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.
getLocation(),
2333 if (OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2346ExprResult Parser::ParseBuiltinPrimaryExpression() {
2348 const IdentifierInfo *BuiltinII = Tok.getIdentifierInfo();
2354 if (Tok.isNot(tok::l_paren))
2355 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2364 default: llvm_unreachable(
"Not a builtin primary expression!");
2365 case tok::kw___builtin_va_arg: {
2368 if (ExpectAndConsume(tok::comma)) {
2375 if (Tok.isNot(tok::r_paren)) {
2376 Diag(Tok, diag::err_expected) << tok::r_paren;
2383 Res = Actions.ActOnVAArg(StartLoc, Expr.get(), Ty.
get(), ConsumeParen());
2386 case tok::kw___builtin_offsetof: {
2387 SourceLocation TypeLoc = Tok.getLocation();
2389 if (Tok.getLocation().isMacroID()) {
2391 Tok.getLocation(), PP.getSourceManager(),
getLangOpts());
2392 if (MacroName ==
"offsetof")
2405 if (ExpectAndConsume(tok::comma)) {
2410 auto TriggerCompletion = [&](
const Designation &D) {
2412 Actions.CodeCompletion().CodeCompleteOffsetOfDesignator(
2413 Actions.GetTypeFromParser(Ty.
get()), D);
2418 if (Tok.is(tok::code_completion)) {
2419 TriggerCompletion(D);
2422 if (Tok.isNot(tok::identifier)) {
2423 Diag(Tok, diag::err_expected) << tok::identifier;
2429 Tok.getIdentifierInfo(), SourceLocation(), Tok.getLocation()));
2434 if (Tok.is(tok::period)) {
2438 if (Tok.is(tok::code_completion)) {
2439 TriggerCompletion(D);
2442 if (Tok.isNot(tok::identifier)) {
2443 Diag(Tok, diag::err_expected) << tok::identifier;
2448 Tok.getIdentifierInfo(), DotLoc, Tok.getLocation()));
2450 }
else if (Tok.is(tok::l_square)) {
2451 if (CheckProhibitedCXX11Attribute())
2473 if (Tok.is(tok::code_completion)) {
2477 if (Tok.isNot(tok::r_paren)) {
2485 Actions.ActOnBuiltinOffsetOf(
getCurScope(), StartLoc, TypeLoc,
2486 Ty.
get(), D, PT.getCloseLocation());
2493 case tok::kw___builtin_choose_expr: {
2495 if (Cond.isInvalid()) {
2499 if (ExpectAndConsume(tok::comma)) {
2505 if (Expr1.isInvalid()) {
2509 if (ExpectAndConsume(tok::comma)) {
2515 if (Expr2.isInvalid()) {
2519 if (Tok.isNot(tok::r_paren)) {
2520 Diag(Tok, diag::err_expected) << tok::r_paren;
2523 Res = Actions.ActOnChooseExpr(StartLoc, Cond.get(), Expr1.get(),
2524 Expr2.get(), ConsumeParen());
2527 case tok::kw___builtin_astype: {
2530 if (Expr.isInvalid()) {
2535 if (ExpectAndConsume(tok::comma)) {
2546 if (Tok.isNot(tok::r_paren)) {
2547 Diag(Tok, diag::err_expected) << tok::r_paren;
2552 Res = Actions.ActOnAsTypeExpr(Expr.get(), DestTy.
get(), StartLoc,
2556 case tok::kw___builtin_convertvector: {
2559 if (Expr.isInvalid()) {
2564 if (ExpectAndConsume(tok::comma)) {
2575 if (Tok.isNot(tok::r_paren)) {
2576 Diag(Tok, diag::err_expected) << tok::r_paren;
2581 Res = Actions.ActOnConvertVectorExpr(Expr.get(), DestTy.
get(), StartLoc,
2585 case tok::kw___builtin_COLUMN:
2586 case tok::kw___builtin_FILE:
2587 case tok::kw___builtin_FILE_NAME:
2588 case tok::kw___builtin_FUNCTION:
2589 case tok::kw___builtin_FUNCSIG:
2590 case tok::kw___builtin_LINE:
2591 case tok::kw___builtin_source_location: {
2593 if (Tok.isNot(tok::r_paren)) {
2594 Diag(Tok, diag::err_expected) << tok::r_paren;
2600 case tok::kw___builtin_FILE:
2602 case tok::kw___builtin_FILE_NAME:
2604 case tok::kw___builtin_FUNCTION:
2606 case tok::kw___builtin_FUNCSIG:
2608 case tok::kw___builtin_LINE:
2610 case tok::kw___builtin_COLUMN:
2612 case tok::kw___builtin_source_location:
2615 llvm_unreachable(
"invalid keyword");
2618 Res = Actions.ActOnSourceLocExpr(Kind, StartLoc, ConsumeParen());
2628 return ParsePostfixExpressionSuffix(Res.
get());
2631bool Parser::tryParseOpenMPArrayShapingCastPart() {
2632 assert(Tok.is(tok::l_square) &&
"Expected open bracket");
2633 bool ErrorFound =
true;
2634 TentativeParsingAction TPA(*
this);
2636 if (Tok.isNot(tok::l_square))
2641 while (!
SkipUntil(tok::r_square, tok::annot_pragma_openmp_end,
2644 if (Tok.isNot(tok::r_square))
2649 if (Tok.is(tok::r_paren)) {
2653 }
while (Tok.isNot(tok::annot_pragma_openmp_end));
2659Parser::ParseParenExpression(
ParenParseOption &ExprType,
bool StopIfCastExpr,
2663 assert(Tok.is(tok::l_paren) &&
"Not a paren expr!");
2670 if (
T.consumeOpen())
2672 SourceLocation OpenLoc =
T.getOpenLocation();
2674 PreferredType.enterParenExpr(Tok.getLocation(), OpenLoc);
2677 bool isAmbiguousTypeId;
2680 if (Tok.is(tok::code_completion)) {
2682 Actions.CodeCompletion().CodeCompleteExpression(
2683 getCurScope(), PreferredType.get(Tok.getLocation()),
2690 Tok.isOneOf(tok::kw___bridge,
2691 tok::kw___bridge_transfer,
2692 tok::kw___bridge_retained,
2693 tok::kw___bridge_retain));
2694 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2696 StringRef BridgeCastName = Tok.getName();
2698 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2699 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2709 Diag(Tok, OpenLoc.
isMacroID() ? diag::ext_gnu_statement_expr_macro
2710 : diag::ext_gnu_statement_expr);
2712 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
2720 DeclContext *CodeDC = Actions.CurContext;
2724 "statement expr not in code context");
2726 Sema::ContextRAII SavedContext(Actions, CodeDC,
false);
2728 Actions.ActOnStartStmtExpr();
2730 StmtResult Stmt(ParseCompoundStatement(
true));
2734 if (!Stmt.isInvalid()) {
2738 Actions.ActOnStmtExprError();
2747 if (tokenKind == tok::kw___bridge)
2749 else if (tokenKind == tok::kw___bridge_transfer)
2751 else if (tokenKind == tok::kw___bridge_retained)
2756 assert(tokenKind == tok::kw___bridge_retain);
2758 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2759 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2761 "__bridge_retained");
2766 ColonProtection.restore();
2767 RParenLoc =
T.getCloseLocation();
2769 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get().
get());
2775 return Actions.ObjC().ActOnObjCBridgedCast(
getCurScope(), OpenLoc, Kind,
2776 BridgeKeywordLoc, Ty.
get(),
2777 RParenLoc, SubExpr.
get());
2779 isTypeIdInParens(isAmbiguousTypeId)) {
2788 if (isAmbiguousTypeId && !StopIfCastExpr) {
2789 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy,
T,
2791 RParenLoc =
T.getCloseLocation();
2796 DeclSpec DS(AttrFactory);
2797 ParseSpecifierQualifierList(DS);
2800 ParseDeclarator(DeclaratorInfo);
2805 if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) &&
2811 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2813 Result = ParseObjCMessageExpressionBody(SourceLocation(),
2819 ColonProtection.restore();
2820 RParenLoc =
T.getCloseLocation();
2826 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2828 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2838 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2852 Result = ParseCastExpression(
2858 if (!
Result.isInvalid()) {
2860 DeclaratorInfo, CastTy,
2861 RParenLoc,
Result.get());
2865 if (!
Result.isInvalid()) {
2877 if (DeclaratorInfo.isInvalidType())
2882 if (StopIfCastExpr) {
2886 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2894 Tok.getIdentifierInfo() == Ident_super &&
2897 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2898 << SourceRange(OpenLoc, RParenLoc);
2902 PreferredType.enterTypeCast(Tok.getLocation(), CastTy.
get());
2905 Result = ParseCastExpression(
2909 if (!
Result.isInvalid()) {
2911 DeclaratorInfo, CastTy,
2912 RParenLoc,
Result.get());
2917 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2928 ExprVector ArgExprs;
2930 if (!ParseSimpleExpressionList(ArgExprs)) {
2934 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2936 return ParseFoldExpression(ArgExprs[0],
T);
2940 Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
2943 }
else if (
getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&
2945 tryParseOpenMPArrayShapingCastPart()) {
2946 bool ErrorFound =
false;
2947 SmallVector<Expr *, 4> OMPDimensions;
2948 SmallVector<SourceRange, 4> OMPBracketsRanges;
2955 while (!
SkipUntil(tok::r_square, tok::r_paren,
2960 OMPDimensions.push_back(NumElements.
get());
2961 OMPBracketsRanges.push_back(TS.getRange());
2962 }
while (Tok.isNot(tok::r_paren));
2965 RParenLoc =
T.getCloseLocation();
2969 }
else if (!
Result.isInvalid()) {
2970 Result = Actions.OpenMP().ActOnOMPArrayShapingExpr(
2971 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);
2979 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2981 return ParseFoldExpression(
Result,
T);
2986 if (!
Result.isInvalid() && Tok.is(tok::r_paren))
2988 Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(),
Result.get());
2992 if (
Result.isInvalid()) {
2998 RParenLoc =
T.getCloseLocation();
3003Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
3006 assert(Tok.is(tok::l_brace) &&
"Not a compound literal!");
3008 Diag(LParenLoc, diag::ext_c99_compound_literal);
3009 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get());
3011 if (!
Result.isInvalid() && Ty)
3012 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc,
Result.get());
3029 "Not a string-literal-like token!");
3037 StringToks.push_back(
Tok);
3042 assert(!AllowUserDefinedLiteral &&
"UDL are always evaluated");
3047 return Actions.ActOnStringLiteral(StringToks,
3052ExprResult Parser::ParseGenericSelectionExpression() {
3053 assert(Tok.is(tok::kw__Generic) &&
"_Generic keyword expected");
3055 diagnoseUseOfC11Keyword(Tok);
3059 if (
T.expectAndConsume())
3066 if (isTypeIdForGenericSelection()) {
3073 SourceLocation Loc = LIT->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
3074 DiagCompat(Loc, diag_compat::generic_with_type_arg);
3087 if (ExpectAndConsume(tok::comma)) {
3092 SourceLocation DefaultLoc;
3093 SmallVector<ParsedType, 12> Types;
3097 if (Tok.is(tok::kw_default)) {
3101 Diag(Tok, diag::err_duplicate_default_assoc);
3102 Diag(DefaultLoc, diag::note_previous_default_assoc);
3118 Types.push_back(Ty);
3120 if (ExpectAndConsume(tok::colon)) {
3132 Exprs.push_back(ER.
get());
3136 if (
T.getCloseLocation().isInvalid())
3139 void *ExprOrTy = ControllingExpr.
isUsable()
3140 ? ControllingExpr.
get()
3143 return Actions.ActOnGenericSelectionExpr(
3144 KeyLoc, DefaultLoc,
T.getCloseLocation(), ControllingExpr.
isUsable(),
3145 ExprOrTy, Types, Exprs);
3156 SourceLocation FirstOpLoc;
3158 Kind = Tok.getKind();
3159 assert(isFoldOperator(Kind) &&
"missing fold-operator");
3163 assert(Tok.is(tok::ellipsis) &&
"not a fold-expression");
3167 if (Tok.isNot(tok::r_paren)) {
3168 if (!isFoldOperator(Tok.getKind()))
3169 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
3171 if (Kind != tok::unknown && Tok.getKind() != Kind)
3172 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
3173 << SourceRange(FirstOpLoc);
3174 Kind = Tok.getKind();
3184 DiagCompat(EllipsisLoc, diag_compat::fold_expression);
3187 return Actions.ActOnCXXFoldExpr(
getCurScope(),
T.getOpenLocation(), LHS.
get(),
3188 Kind, EllipsisLoc, RHS.
get(),
3189 T.getCloseLocation());
3192void Parser::injectEmbedTokens() {
3193 EmbedAnnotationData *
Data =
3194 reinterpret_cast<EmbedAnnotationData *
>(Tok.getAnnotationValue());
3195 MutableArrayRef<Token> Toks(PP.getPreprocessorAllocator().Allocate<Token>(
3196 Data->BinaryData.size() * 2 - 1),
3197 Data->BinaryData.size() * 2 - 1);
3199 for (
auto &Byte :
Data->BinaryData) {
3200 Toks[I] =
Token::create(tok::binary_data, Tok.getLocation(), 1);
3201 Toks[I].setLiteralData(&Byte);
3202 if (I != ((
Data->BinaryData.size() - 1) * 2)) {
3207 PP.EnterTokenStream(std::move(Toks),
true,
3213 llvm::function_ref<
void()> ExpressionStarts,
3214 bool FailImmediatelyOnInvalidExpr,
3215 bool ParsingExpansionStmtInitList) {
3216 bool SawError =
false;
3218 if (ExpressionStarts)
3223 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
3224 Expr = ParseBraceInitializer();
3228 if (Tok.is(tok::ellipsis))
3230 else if (Tok.is(tok::code_completion)) {
3242 if (FailImmediatelyOnInvalidExpr)
3247 ParsingExpansionStmtInitList ? tok::r_brace : tok::r_paren,
3250 Exprs.push_back(Expr.
get());
3253 if (Tok.isNot(tok::comma))
3260 if (ParsingExpansionStmtInitList && Tok.is(tok::r_brace))
3263 checkPotentialAngleBracketDelimiter(Comma);
3274 Exprs.push_back(Expr.
get());
3278 if (Tok.isNot(tok::comma) ||
NextToken().
is(tok::ellipsis))
3284 checkPotentialAngleBracketDelimiter(Comma);
3289 if (Tok.is(tok::code_completion)) {
3291 Actions.CodeCompletion().CodeCompleteOrdinaryName(
3297 DeclSpec DS(AttrFactory);
3298 ParseSpecifierQualifierList(DS);
3304 ParseDeclarator(DeclaratorInfo);
3306 MaybeParseGNUAttributes(DeclaratorInfo);
3309 Actions.ActOnBlockArguments(CaretLoc, DeclaratorInfo,
getCurScope());
3312ExprResult Parser::ParseBlockLiteralExpression() {
3313 assert(Tok.is(tok::caret) &&
"block literal starts with ^");
3316 PrettyStackTraceLoc CrashInfo(PP.getSourceManager(), CaretLoc,
3317 "block literal parsing");
3330 DeclSpec DS(AttrFactory);
3336 ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation()));
3340 if (Tok.is(tok::l_paren)) {
3341 ParseParenDeclarator(ParamInfo);
3345 SourceLocation Tmp = ParamInfo.getSourceRange().getEnd();
3346 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
3347 ParamInfo.SetRangeEnd(Tmp);
3348 if (ParamInfo.isInvalidType()) {
3356 MaybeParseGNUAttributes(ParamInfo);
3359 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3360 }
else if (!Tok.is(tok::l_brace)) {
3361 ParseBlockId(CaretLoc);
3364 SourceLocation NoLoc;
3365 ParamInfo.AddTypeInfo(
3383 CaretLoc, ParamInfo),
3386 MaybeParseGNUAttributes(ParamInfo);
3389 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3394 if (!Tok.is(tok::l_brace)) {
3396 Diag(Tok, diag::err_expected_expression);
3400 EnterExpressionEvaluationContextForFunction PotentiallyEvaluated(
3402 StmtResult Stmt(ParseCompoundStatementBody());
3404 if (!Stmt.isInvalid())
3413 return Actions.ObjC().ActOnObjCBoolLiteral(
ConsumeToken(), Kind);
3420 llvm::SmallSet<StringRef, 4> Platforms;
3421 bool HasOtherPlatformSpec =
false;
3423 for (
const auto &Spec : AvailSpecs) {
3424 if (Spec.isOtherPlatformSpec()) {
3425 if (HasOtherPlatformSpec) {
3426 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3430 HasOtherPlatformSpec =
true;
3434 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3439 StringRef Platform = Spec.getPlatform();
3440 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3441 << Spec.getEndLoc() << Platform;
3446 if (!HasOtherPlatformSpec) {
3447 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3448 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3456std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() {
3457 if (Tok.is(tok::star)) {
3461 if (Tok.is(tok::code_completion)) {
3463 Actions.CodeCompletion().CodeCompleteAvailabilityPlatformName();
3464 return std::nullopt;
3466 if (Tok.isNot(tok::identifier)) {
3467 Diag(Tok, diag::err_avail_query_expected_platform_name);
3468 return std::nullopt;
3471 IdentifierLoc *PlatformIdentifier = ParseIdentifierLoc();
3472 SourceRange VersionRange;
3473 VersionTuple Version = ParseVersionTuple(VersionRange);
3475 if (Version.empty())
3476 return std::nullopt;
3478 StringRef GivenPlatform =
3480 StringRef Platform =
3481 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3483 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||
3484 (GivenPlatform.contains(
"xros") || GivenPlatform.contains(
"xrOS"))) {
3486 diag::err_avail_query_unrecognized_platform_name)
3488 return std::nullopt;
3492 if (Platform ==
"anyappleos" &&
3495 diag::err_avail_query_anyappleos_min_version)
3496 << Version.getAsString();
3497 return std::nullopt;
3500 return AvailabilitySpec(Version, Platform, PlatformIdentifier->
getLoc(),
3506 assert(Tok.is(tok::kw___builtin_available) ||
3507 Tok.isObjCAtKeyword(tok::objc_available));
3513 if (
Parens.expectAndConsume())
3516 SmallVector<AvailabilitySpec, 4> AvailSpecs;
3517 bool HasError =
false;
3519 std::optional<AvailabilitySpec> Spec = ParseAvailabilitySpec();
3523 AvailSpecs.push_back(*Spec);
3536 if (
Parens.consumeClose())
3539 return Actions.ObjC().ActOnObjCAvailabilityCheckExpr(
3540 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
friend class GenericAssociationTypeRAIIObject
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
static Token create(tok::TokenKind Kind, SourceLocation Loc, unsigned Length=0)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
const char * getName() const
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
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.
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.