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)
338 if (OpToken.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
339 tok::greatergreatergreater) &&
340 checkPotentialAngleBracketDelimiter(OpToken))
348 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
349 PP.EnterToken(Tok,
true);
356 if (isFoldOperator(NextTokPrec) && Tok.is(tok::ellipsis)) {
359 PP.EnterToken(Tok,
true);
370 Tok.isOneOf(tok::colon, tok::r_square) &&
372 PP.EnterToken(Tok,
true);
382 SourceLocation BraceLoc = Tok.getLocation();
383 TernaryMiddle = ParseBraceInitializer();
384 if (!TernaryMiddle.isInvalid()) {
385 Diag(BraceLoc, diag::err_init_list_bin_op)
386 << 1 << PP.getSpelling(OpToken)
387 << Actions.getExprRange(TernaryMiddle.get());
390 }
else if (Tok.isNot(tok::colon)) {
402 TernaryMiddle =
nullptr;
403 Diag(Tok, diag::ext_gnu_conditional_expr);
406 if (TernaryMiddle.isInvalid()) {
408 TernaryMiddle =
nullptr;
416 SourceLocation FILoc = Tok.getLocation();
417 const char *FIText =
": ";
418 const SourceManager &
SM = PP.getSourceManager();
419 if (FILoc.
isFileID() || PP.isAtStartOfMacroExpansion(FILoc, &FILoc)) {
421 bool IsInvalid =
false;
422 const char *SourcePtr =
424 if (!IsInvalid && *SourcePtr ==
' ') {
427 if (!IsInvalid && *SourcePtr ==
' ') {
434 Diag(Tok, diag::err_expected)
436 Diag(OpToken, diag::note_matching) << tok::question;
437 ColonLoc = Tok.getLocation();
441 PreferredType.enterBinary(Actions, Tok.getLocation(), LHS.
get(),
454 bool RHSIsInitList =
false;
456 RHS = ParseBraceInitializer();
457 RHSIsInitList =
true;
479 if (ThisPrec < NextTokPrec ||
480 (ThisPrec == NextTokPrec && isRightAssoc)) {
482 Diag(Tok, diag::err_init_list_bin_op)
483 << 0 << PP.getSpelling(Tok) << Actions.getExprRange(RHS.
get());
491 RHS = ParseRHSOfBinaryExpression(RHS,
492 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
493 RHSIsInitList =
false;
505 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
506 << Actions.getExprRange(RHS.
get());
507 }
else if (ColonLoc.
isValid()) {
508 Diag(ColonLoc, diag::err_init_list_bin_op)
510 << Actions.getExprRange(RHS.
get());
513 Diag(OpToken, diag::err_init_list_bin_op)
514 << 1 << PP.getSpelling(OpToken)
515 << Actions.getExprRange(RHS.
get());
522 if (TernaryMiddle.isInvalid()) {
526 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
528 diag::warn_cxx11_right_shift_in_template_arg,
529 SourceRange(Actions.getExprRange(LHS.
get()).getBegin(),
530 Actions.getExprRange(RHS.
get()).getEnd()));
538 {LHS.get(), RHS.get()});
542 ExprResult CondOp = Actions.ActOnConditionalOp(
546 std::vector<clang::Expr *> Args;
548 if (TernaryMiddle.get())
549 Args = {LHS.
get(), TernaryMiddle.get(), RHS.
get()};
551 Args = {LHS.
get(), RHS.
get()};
563Parser::ParseCastExpression(
CastParseKind ParseKind,
bool isAddressOfOperand,
565 bool isVectorLiteral,
bool *NotPrimaryExpression) {
567 ExprResult Res = ParseCastExpression(ParseKind, isAddressOfOperand,
568 NotCastExpr, CorrectionBehavior,
569 isVectorLiteral, NotPrimaryExpression);
571 Diag(Tok, diag::err_expected_expression);
578 CastExpressionIdValidator(Token
Next,
581 WantTypeSpecifiers = WantFunctionLikeCasts =
582 (CorrectionBehavior != TypoCorrectionTypeBehavior::AllowNonTypes);
584 (CorrectionBehavior != TypoCorrectionTypeBehavior::AllowTypes);
587 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
593 return WantTypeSpecifiers;
598 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
601 for (
auto *
C : candidate) {
609 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
610 return std::make_unique<CastExpressionIdValidator>(*
this);
621 if (RevertibleTypeTraits.empty()) {
625#define RTT_JOIN(X, Y) X##Y
626#define REVERTIBLE_TYPE_TRAIT(Name) \
627 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
684#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
685 REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
686#include "clang/Basic/TransformTypeTraits.def"
687#undef REVERTIBLE_TYPE_TRAIT
690 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known =
691 RevertibleTypeTraits.find(II);
692 if (Known != RevertibleTypeTraits.end()) {
694 *
Kind = Known->second;
700ExprResult Parser::ParseBuiltinPtrauthTypeDiscriminator() {
704 if (
T.expectAndConsume())
713 SourceLocation EndLoc = Tok.getLocation();
715 return Actions.ActOnUnaryExprOrTypeTraitExpr(
716 Loc, UETT_PtrAuthTypeDiscriminator,
721Parser::ParseCastExpression(
CastParseKind ParseKind,
bool isAddressOfOperand,
724 bool isVectorLiteral,
bool *NotPrimaryExpression) {
727 auto SavedType = PreferredType;
733 bool AllowSuffix =
true;
762 SourceLocation RParenLoc;
763 Res = ParseParenExpression(ParenExprType,
false,
773 switch (ParenExprType) {
796 case tok::numeric_constant:
797 case tok::binary_data:
801 Res = Actions.ActOnNumericConstant(Tok,
getCurScope());
807 Res = ParseCXXBoolLiteral();
810 case tok::kw___objc_yes:
811 case tok::kw___objc_no:
812 Res = ParseObjCBoolLiteral();
815 case tok::kw_nullptr:
817 Diag(Tok, diag::warn_cxx98_compat_nullptr);
820 : diag::ext_c_nullptr) << Tok.getName();
825 case tok::annot_primary_expr:
826 case tok::annot_overload_set:
827 Res = getExprAnnotation(Tok);
828 if (!Res.
isInvalid() && Tok.getKind() == tok::annot_overload_set)
829 Res = Actions.ActOnNameClassifiedAsOverloadSet(
getCurScope(), Res.
get());
830 ConsumeAnnotationToken();
831 if (!Res.
isInvalid() && Tok.is(tok::less))
832 checkPotentialAngleBracket(Res);
835 case tok::annot_non_type:
836 case tok::annot_non_type_dependent:
837 case tok::annot_non_type_undeclared: {
840 Res = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
842 "should not perform typo correction on annotation token");
846 case tok::annot_embed: {
848 return ParseCastExpression(ParseKind, isAddressOfOperand,
849 CorrectionBehavior, isVectorLiteral,
850 NotPrimaryExpression);
853 case tok::kw___super:
854 case tok::kw_decltype:
858 assert(Tok.isNot(tok::kw_decltype) && Tok.isNot(tok::kw___super));
859 return ParseCastExpression(ParseKind, isAddressOfOperand,
860 CorrectionBehavior, isVectorLiteral,
861 NotPrimaryExpression);
863 case tok::identifier:
874 if (
Next.is(tok::ellipsis) && Tok.is(tok::identifier) &&
880 Tok.isOneOf(tok::annot_pack_indexing_type, tok::annot_cxxscope))
881 return ParseCastExpression(ParseKind, isAddressOfOperand,
882 CorrectionBehavior, isVectorLiteral,
883 NotPrimaryExpression);
889 else if (
Next.is(tok::l_paren) && Tok.is(tok::identifier) &&
890 Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
891 IdentifierInfo *II = Tok.getIdentifierInfo();
893 if (isRevertibleTypeTrait(II, &Kind)) {
895 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
896 CorrectionBehavior, isVectorLiteral,
897 NotPrimaryExpression);
901 else if ((!ColonIsSacred &&
Next.is(tok::colon)) ||
902 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
907 if (!Tok.is(tok::identifier))
908 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
909 CorrectionBehavior, isVectorLiteral,
910 NotPrimaryExpression);
916 IdentifierInfo &II = *Tok.getIdentifierInfo();
923 (&II == Ident_super &&
getCurScope()->isInObjcMethodScope()))) {
926 if (Tok.is(tok::code_completion) && &II != Ident_super) {
928 Actions.CodeCompletion().CodeCompleteObjCClassPropertyRefExpr(
929 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
933 if (Tok.isNot(tok::identifier) &&
935 Diag(Tok, diag::err_expected_property_name);
938 IdentifierInfo &PropertyName = *Tok.getIdentifierInfo();
941 Res = Actions.ObjC().ActOnClassPropertyRefExpr(II, PropertyName, ILoc,
950 if (
getLangOpts().
ObjC && &II == Ident_super && !InMessageExpression &&
952 ((Tok.is(tok::identifier) &&
954 Tok.is(tok::code_completion))) {
955 Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc,
nullptr,
966 ((Tok.is(tok::identifier) && !InMessageExpression) ||
967 Tok.is(tok::code_completion))) {
969 if (Tok.is(tok::code_completion) ||
970 Next.is(tok::colon) ||
Next.is(tok::r_square))
972 if (Typ.get()->isObjCObjectOrInterfaceType()) {
974 DeclSpec DS(AttrFactory);
975 DS.SetRangeStart(ILoc);
976 DS.SetRangeEnd(ILoc);
977 const char *PrevSpec =
nullptr;
979 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
980 Actions.getASTContext().getPrintingPolicy());
984 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
988 Res = ParseObjCMessageExpressionBody(SourceLocation(),
996 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
997 isAddressOfOperand =
false;
1003 CXXScopeSpec ScopeSpec;
1004 SourceLocation TemplateKWLoc;
1006 CastExpressionIdValidator Validator(Tok, CorrectionBehavior);
1007 Validator.IsAddressOfOperand = isAddressOfOperand;
1008 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
1009 Validator.WantExpressionKeywords =
false;
1010 Validator.WantRemainingKeywords =
false;
1012 Validator.WantRemainingKeywords = Tok.isNot(tok::r_paren);
1015 Res = Actions.ActOnIdExpression(
1016 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren),
1017 isAddressOfOperand, &Validator,
1019 Tok.is(tok::r_paren) ?
nullptr : &Replacement);
1021 UnconsumeToken(Replacement);
1022 return ParseCastExpression(
1023 ParseKind, isAddressOfOperand, NotCastExpr, CorrectionBehavior,
1024 false, NotPrimaryExpression);
1026 Res = tryParseCXXPackIndexingExpression(Res);
1027 if (!Res.
isInvalid() && Tok.is(tok::less))
1028 checkPotentialAngleBracket(Res);
1031 case tok::char_constant:
1032 case tok::wide_char_constant:
1033 case tok::utf8_char_constant:
1034 case tok::utf16_char_constant:
1035 case tok::utf32_char_constant:
1036 Res = Actions.ActOnCharacterConstant(Tok,
getCurScope());
1039 case tok::kw___func__:
1040 case tok::kw___FUNCTION__:
1041 case tok::kw___FUNCDNAME__:
1042 case tok::kw___FUNCSIG__:
1043 case tok::kw_L__FUNCTION__:
1044 case tok::kw_L__FUNCSIG__:
1045 case tok::kw___PRETTY_FUNCTION__:
1052 Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
1057 case tok::string_literal:
1058 case tok::wide_string_literal:
1059 case tok::utf8_string_literal:
1060 case tok::utf16_string_literal:
1061 case tok::utf32_string_literal:
1064 case tok::kw__Generic:
1065 Res = ParseGenericSelectionExpression();
1067 case tok::kw___builtin_available:
1068 Res = ParseAvailabilityCheckExpr(Tok.getLocation());
1070 case tok::kw___builtin_va_arg:
1071 case tok::kw___builtin_offsetof:
1072 case tok::kw___builtin_choose_expr:
1073 case tok::kw___builtin_astype:
1074 case tok::kw___builtin_convertvector:
1075 case tok::kw___builtin_COLUMN:
1076 case tok::kw___builtin_FILE:
1077 case tok::kw___builtin_FILE_NAME:
1078 case tok::kw___builtin_FUNCTION:
1079 case tok::kw___builtin_FUNCSIG:
1080 case tok::kw___builtin_LINE:
1081 case tok::kw___builtin_source_location:
1082 if (NotPrimaryExpression)
1083 *NotPrimaryExpression =
true;
1085 return ParseBuiltinPrimaryExpression();
1086 case tok::kw___null:
1091 case tok::minusminus: {
1092 if (NotPrimaryExpression)
1093 *NotPrimaryExpression =
true;
1098 Token SavedTok = Tok;
1101 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedTok.
getKind(),
1115 UnconsumeToken(SavedTok);
1119 Expr *Arg = Res.
get();
1123 Res = Actions.CreateRecoveryExpr(SavedTok.
getLocation(),
1129 if (NotPrimaryExpression)
1130 *NotPrimaryExpression =
true;
1133 PreferredType.enterUnary(Actions, Tok.getLocation(), tok::amp, SavedLoc);
1138 Expr *Arg = Res.
get();
1139 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Arg);
1141 Res = Actions.CreateRecoveryExpr(Tok.getLocation(), Arg->
getEndLoc(),
1152 case tok::kw___real:
1153 case tok::kw___imag: {
1154 if (NotPrimaryExpression)
1155 *NotPrimaryExpression =
true;
1157 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedKind, SavedLoc);
1160 Expr *Arg = Res.
get();
1161 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Arg,
1162 isAddressOfOperand);
1164 Res = Actions.CreateRecoveryExpr(SavedLoc, Arg->
getEndLoc(), Arg);
1169 case tok::kw_co_await: {
1170 if (NotPrimaryExpression)
1171 *NotPrimaryExpression =
true;
1175 Res = Actions.ActOnCoawaitExpr(
getCurScope(), CoawaitLoc, Res.
get());
1179 case tok::kw___extension__:{
1181 if (NotPrimaryExpression)
1182 *NotPrimaryExpression =
true;
1183 ExtensionRAIIObject O(Diags);
1187 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.
get());
1190 case tok::kw__Alignof:
1191 diagnoseUseOfC11Keyword(Tok);
1193 case tok::kw_alignof:
1194 case tok::kw___alignof:
1196 case tok::kw_sizeof:
1200 case tok::kw___datasizeof:
1201 case tok::kw_vec_step:
1203 case tok::kw___builtin_omp_required_simd_align:
1204 case tok::kw___builtin_vectorelements:
1205 case tok::kw__Countof:
1206 if (NotPrimaryExpression)
1207 *NotPrimaryExpression =
true;
1208 AllowSuffix =
false;
1209 Res = ParseUnaryExprOrTypeTraitExpression();
1212 if (NotPrimaryExpression)
1213 *NotPrimaryExpression =
true;
1215 if (Tok.isNot(tok::identifier))
1216 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1219 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1221 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1222 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(),
1224 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD);
1226 AllowSuffix =
false;
1229 case tok::kw_const_cast:
1230 case tok::kw_dynamic_cast:
1231 case tok::kw_reinterpret_cast:
1232 case tok::kw_static_cast:
1233 case tok::kw_addrspace_cast:
1234 if (NotPrimaryExpression)
1235 *NotPrimaryExpression =
true;
1236 Res = ParseCXXCasts();
1238 case tok::kw___builtin_bit_cast:
1239 if (NotPrimaryExpression)
1240 *NotPrimaryExpression =
true;
1241 Res = ParseBuiltinBitCast();
1243 case tok::kw_typeid:
1244 if (NotPrimaryExpression)
1245 *NotPrimaryExpression =
true;
1246 Res = ParseCXXTypeid();
1248 case tok::kw___uuidof:
1249 if (NotPrimaryExpression)
1250 *NotPrimaryExpression =
true;
1251 Res = ParseCXXUuidof();
1254 Res = ParseCXXThis();
1256 case tok::kw___builtin_sycl_unique_stable_name:
1257 Res = ParseSYCLUniqueStableNameExpression();
1260 case tok::annot_typename:
1261 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1265 DeclSpec DS(AttrFactory);
1266 DS.SetRangeStart(Tok.getLocation());
1267 DS.SetRangeEnd(Tok.getLastLoc());
1269 const char *PrevSpec =
nullptr;
1271 DS.SetTypeSpecType(
TST_typename, Tok.getAnnotationEndLoc(),
1272 PrevSpec, DiagID,
Type,
1273 Actions.getASTContext().getPrintingPolicy());
1277 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
1281 ConsumeAnnotationToken();
1282 Res = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1288 case tok::annot_decltype:
1289 case tok::annot_pack_indexing_type:
1291 case tok::kw_wchar_t:
1292 case tok::kw_char8_t:
1293 case tok::kw_char16_t:
1294 case tok::kw_char32_t:
1299 case tok::kw___int64:
1300 case tok::kw___int128:
1301 case tok::kw__ExtInt:
1302 case tok::kw__BitInt:
1303 case tok::kw_signed:
1304 case tok::kw_unsigned:
1307 case tok::kw_double:
1308 case tok::kw___bf16:
1309 case tok::kw__Float16:
1310 case tok::kw___float128:
1311 case tok::kw___ibm128:
1314 case tok::kw_typename:
1315 case tok::kw_typeof:
1316 case tok::kw___vector:
1317 case tok::kw__Accum:
1318 case tok::kw__Fract:
1320#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1321#include "clang/Basic/OpenCLImageTypes.def"
1322#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
1323#include "clang/Basic/HLSLIntangibleTypes.def"
1326 Diag(Tok, diag::err_expected_expression);
1331 if (NotPrimaryExpression)
1332 *NotPrimaryExpression =
true;
1334 if (SavedKind == tok::kw_typename) {
1349 DeclSpec DS(AttrFactory);
1351 ParseCXXSimpleTypeSpecifier(DS);
1352 if (Tok.isNot(tok::l_paren) &&
1354 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1355 << DS.getSourceRange());
1357 if (Tok.is(tok::l_brace))
1358 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1360 Res = ParseCXXTypeConstructExpression(DS);
1364 case tok::annot_cxxscope: {
1369 if (!Tok.is(tok::annot_cxxscope))
1370 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1371 CorrectionBehavior, isVectorLiteral,
1372 NotPrimaryExpression);
1375 if (
Next.is(tok::annot_template_id)) {
1376 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(
Next);
1382 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1386 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1387 CorrectionBehavior, isVectorLiteral,
1388 NotPrimaryExpression);
1393 Res = ParseCXXIdExpression(isAddressOfOperand);
1397 case tok::annot_template_id: {
1398 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1405 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1406 CorrectionBehavior, isVectorLiteral,
1407 NotPrimaryExpression);
1414 case tok::kw_operator:
1415 Res = ParseCXXIdExpression(isAddressOfOperand);
1418 case tok::coloncolon: {
1423 if (!Tok.is(tok::coloncolon))
1424 return ParseCastExpression(ParseKind, isAddressOfOperand,
1425 CorrectionBehavior, isVectorLiteral,
1426 NotPrimaryExpression);
1431 if (Tok.is(tok::kw_new)) {
1432 if (NotPrimaryExpression)
1433 *NotPrimaryExpression =
true;
1434 Res = ParseCXXNewExpression(
true, CCLoc);
1435 AllowSuffix =
false;
1438 if (Tok.is(tok::kw_delete)) {
1439 if (NotPrimaryExpression)
1440 *NotPrimaryExpression =
true;
1441 Res = ParseCXXDeleteExpression(
true, CCLoc);
1442 AllowSuffix =
false;
1447 Diag(CCLoc, diag::err_expected_expression);
1452 if (NotPrimaryExpression)
1453 *NotPrimaryExpression =
true;
1454 Res = ParseCXXNewExpression(
false, Tok.getLocation());
1455 AllowSuffix =
false;
1458 case tok::kw_delete:
1459 if (NotPrimaryExpression)
1460 *NotPrimaryExpression =
true;
1461 Res = ParseCXXDeleteExpression(
false, Tok.getLocation());
1462 AllowSuffix =
false;
1465 case tok::kw_requires:
1466 Res = ParseRequiresExpression();
1467 AllowSuffix =
false;
1470 case tok::kw_noexcept: {
1471 if (NotPrimaryExpression)
1472 *NotPrimaryExpression =
true;
1473 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1477 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1489 Res = Actions.ActOnNoexceptExpr(KeyLoc,
T.getOpenLocation(), Res.
get(),
1490 T.getCloseLocation());
1491 AllowSuffix =
false;
1495#define TYPE_TRAIT(N,Spelling,K) \
1496 case tok::kw_##Spelling:
1497#include "clang/Basic/TokenKinds.def"
1498 Res = ParseTypeTrait();
1501 case tok::kw___array_rank:
1502 case tok::kw___array_extent:
1503 if (NotPrimaryExpression)
1504 *NotPrimaryExpression =
true;
1505 Res = ParseArrayTypeTrait();
1508 case tok::kw___builtin_ptrauth_type_discriminator:
1509 return ParseBuiltinPtrauthTypeDiscriminator();
1511 case tok::kw___is_lvalue_expr:
1512 case tok::kw___is_rvalue_expr:
1513 if (NotPrimaryExpression)
1514 *NotPrimaryExpression =
true;
1515 Res = ParseExpressionTrait();
1519 if (NotPrimaryExpression)
1520 *NotPrimaryExpression =
true;
1522 return ParseObjCAtExpression(AtLoc);
1525 Res = ParseBlockLiteralExpression();
1527 case tok::code_completion: {
1529 Actions.CodeCompletion().CodeCompleteExpression(
1530 getCurScope(), PreferredType.get(Tok.getLocation()));
1533#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
1534#include "clang/Basic/TransformTypeTraits.def"
1538 Tok.setKind(tok::identifier);
1539 Diag(Tok, diag::ext_keyword_as_ident)
1540 << Tok.getIdentifierInfo()->getName() << 0;
1541 goto ParseIdentifier;
1543 goto ExpectedExpression;
1552 Res = TryParseLambdaExpression();
1556 if (NotPrimaryExpression)
1557 *NotPrimaryExpression =
true;
1558 Res = ParseObjCMessageExpression();
1562 Res = ParseLambdaExpression();
1566 Res = ParseObjCMessageExpression();
1591 switch (Tok.getKind()) {
1595 case tok::minusminus:
1598 if (Tok.isAtStartOfLine())
1613 Diag(Tok.getLocation(), diag::err_postfix_after_unary_requires_parens)
1621 PreferredType = SavedType;
1622 Res = ParsePostfixExpressionSuffix(Res);
1624 !
getActions().getOpenCLOptions().isAvailableOption(
1626 if (Expr *PostfixExpr = Res.
get()) {
1627 QualType Ty = PostfixExpr->getType();
1629 Diag(PostfixExpr->getExprLoc(),
1630 diag::err_opencl_taking_function_address_parser);
1639Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1643 auto SavedType = PreferredType;
1646 PreferredType = SavedType;
1647 switch (Tok.getKind()) {
1648 case tok::code_completion:
1649 if (InMessageExpression)
1653 Actions.CodeCompletion().CodeCompletePostfixExpression(
1654 getCurScope(), LHS, PreferredType.get(Tok.getLocation()));
1657 case tok::identifier:
1663 LHS = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1664 nullptr, LHS.
get());
1672 case tok::l_square: {
1680 isSimpleObjCMessageExpression())
1685 if (CheckProhibitedCXX11Attribute()) {
1690 Loc =
T.getOpenLocation();
1692 SourceLocation ColonLocFirst, ColonLocSecond;
1693 ExprVector ArgExprs;
1694 bool HasError =
false;
1695 PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.
get());
1701 if ((!
getLangOpts().OpenMP && !AllowOpenACCArraySections) ||
1702 Tok.isNot(tok::colon)) {
1706 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1707 Idx = ParseBraceInitializer();
1714 ArgExprs.push_back(Idx.
get());
1716 }
else if (Tok.isNot(tok::r_square)) {
1717 if (ParseExpressionList(ArgExprs)) {
1727 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {
1729 if (Tok.is(tok::colon)) {
1732 if (Tok.isNot(tok::r_square))
1735 }
else if (ArgExprs.size() <= 1 &&
getLangOpts().OpenMP) {
1737 if (Tok.is(tok::colon)) {
1740 if (Tok.isNot(tok::r_square) &&
1742 ((Tok.isNot(tok::colon) &&
getLangOpts().OpenMP >= 50)))) {
1747 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||
1748 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
1749 Tok.is(tok::colon)) {
1752 if (Tok.isNot(tok::r_square)) {
1758 SourceLocation RLoc = Tok.getLocation();
1759 if (!LHS.
isInvalid() && !HasError && !Length.isInvalid() &&
1760 !Stride.
isInvalid() && Tok.is(tok::r_square)) {
1766 if (AllowOpenACCArraySections) {
1768 "Stride/second colon not allowed for OpenACC");
1769 LHS = Actions.OpenACC().ActOnArraySectionExpr(
1770 LHS.
get(), Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
1771 ColonLocFirst, Length.get(), RLoc);
1773 LHS = Actions.OpenMP().ActOnOMPArraySectionExpr(
1774 LHS.
get(), Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
1775 ColonLocFirst, ColonLocSecond, Length.get(), Stride.
get(),
1779 LHS = Actions.ActOnArraySubscriptExpr(
getCurScope(), LHS.
get(), Loc,
1792 case tok::lesslessless: {
1797 Expr *ExecConfig =
nullptr;
1801 if (OpKind == tok::lesslessless) {
1802 ExprVector ExecConfigExprs;
1805 if (ParseSimpleExpressionList(ExecConfigExprs)) {
1809 SourceLocation CloseLoc;
1815 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1816 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1822 if (ExpectAndConsume(tok::l_paren))
1825 Loc = PrevTokLocation;
1829 ExprResult ECResult = Actions.CUDA().ActOnExecConfigExpr(
1830 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);
1834 ExecConfig = ECResult.
get();
1838 Loc = PT.getOpenLocation();
1841 ExprVector ArgExprs;
1842 auto RunSignatureHelp = [&]() -> QualType {
1843 QualType PreferredType =
1844 Actions.CodeCompletion().ProduceCallSignatureHelp(
1845 LHS.
get(), ArgExprs, PT.getOpenLocation());
1846 CalledSignatureHelp =
true;
1847 return PreferredType;
1849 bool ExpressionListIsInvalid =
false;
1850 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1851 if (Tok.isNot(tok::r_paren)) {
1852 if ((ExpressionListIsInvalid = ParseExpressionList(ArgExprs, [&] {
1853 PreferredType.enterFunctionArgument(Tok.getLocation(),
1860 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
1869 }
else if (ExpressionListIsInvalid) {
1870 Expr *
Fn = LHS.
get();
1871 ArgExprs.insert(ArgExprs.begin(), Fn);
1872 LHS = Actions.CreateRecoveryExpr(
Fn->getBeginLoc(), Tok.getLocation(),
1875 }
else if (Tok.isNot(tok::r_paren)) {
1876 bool HadErrors =
false;
1879 for (
auto &E : ArgExprs)
1880 if (E->containsErrors())
1891 Expr *
Fn = LHS.
get();
1892 SourceLocation RParLoc = Tok.getLocation();
1893 LHS = Actions.ActOnCallExpr(
getCurScope(), Fn, Loc, ArgExprs, RParLoc,
1896 ArgExprs.insert(ArgExprs.begin(), Fn);
1898 Actions.CreateRecoveryExpr(
Fn->getBeginLoc(), RParLoc, ArgExprs);
1914 bool MayBePseudoDestructor =
false;
1915 Expr* OrigLHS = !LHS.
isInvalid() ? LHS.
get() :
nullptr;
1917 PreferredType.enterMemAccess(Actions, Tok.getLocation(), OrigLHS);
1920 Expr *
Base = OrigLHS;
1921 const Type* BaseType =
Base->getType().getTypePtrOrNull();
1922 if (BaseType && Tok.is(tok::l_paren) &&
1925 Diag(OpLoc, diag::err_function_is_not_record)
1926 << OpKind <<
Base->getSourceRange()
1928 return ParsePostfixExpressionSuffix(Base);
1931 LHS = Actions.ActOnStartCXXMemberReference(
getCurScope(), Base, OpLoc,
1933 MayBePseudoDestructor);
1938 if (Tok.is(tok::code_completion)) {
1944 ParseOptionalCXXScopeSpecifier(
1946 false, &MayBePseudoDestructor);
1948 ObjectType =
nullptr;
1951 if (Tok.is(tok::code_completion)) {
1953 OpKind == tok::arrow ? tok::period : tok::arrow;
1958 Sema::TentativeAnalysisScope Trap(Actions);
1959 CorrectedLHS = Actions.ActOnStartCXXMemberReference(
1960 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
1961 MayBePseudoDestructor);
1965 Expr *CorrectedBase = CorrectedLHS.get();
1967 CorrectedBase =
Base;
1971 Actions.CodeCompletion().CodeCompleteMemberReferenceExpr(
1972 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,
1973 Base && ExprStatementTokLoc ==
Base->getBeginLoc(),
1974 PreferredType.get(Tok.getLocation()));
1979 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
1980 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
1992 SourceLocation TemplateKWLoc;
1995 Tok.is(tok::kw_class)) {
2003 IdentifierInfo *Id = Tok.getIdentifierInfo();
2012 false, &TemplateKWLoc, Name)) {
2017 LHS = Actions.ActOnMemberAccessExpr(
getCurScope(), LHS.
get(), OpLoc,
2018 OpKind, SS, TemplateKWLoc, Name,
2019 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
2022 if (Tok.is(tok::less))
2023 checkPotentialAngleBracket(LHS);
2024 }
else if (OrigLHS && Name.
isValid()) {
2026 LHS = Actions.CreateRecoveryExpr(OrigLHS->
getBeginLoc(),
2032 case tok::minusminus:
2034 Expr *Arg = LHS.
get();
2035 LHS = Actions.ActOnPostfixUnaryOp(
getCurScope(), Tok.getLocation(),
2036 Tok.getKind(), Arg);
2038 LHS = Actions.CreateRecoveryExpr(Arg->
getBeginLoc(),
2039 Tok.getLocation(), Arg);
2048Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
2053 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,
2054 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,
2055 tok::kw__Alignof, tok::kw_vec_step,
2056 tok::kw___builtin_omp_required_simd_align,
2057 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2058 "Not a typeof/sizeof/alignof/vec_step expression!");
2063 if (Tok.isNot(tok::l_paren)) {
2066 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2067 tok::kw_alignof, tok::kw__Alignof)) {
2068 if (isTypeIdUnambiguously()) {
2069 DeclSpec DS(AttrFactory);
2070 ParseSpecifierQualifierList(DS);
2073 ParseDeclarator(DeclaratorInfo);
2075 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.
getLocation());
2076 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
2079 diag::err_expected_parentheses_around_typename)
2082 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
2092 if (OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
2103 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2104 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof) &&
2105 Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2106 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof))
2107 Actions.runWithSufficientStackSpace(Tok.getLocation(), [&] {
2108 Operand = ParseCastExpression(CastParseKind::UnaryExprOnly);
2127 bool ParenKnownToBeNonCast =
2128 OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual);
2130 SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
2132 Operand = ParseParenExpression(
2137 CastRange = SourceRange(LParenLoc, RParenLoc);
2147 !OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {
2162ExprResult Parser::ParseSYCLUniqueStableNameExpression() {
2163 assert(Tok.is(tok::kw___builtin_sycl_unique_stable_name) &&
2164 "Not __builtin_sycl_unique_stable_name");
2170 if (
T.expectAndConsume(diag::err_expected_lparen_after,
2171 "__builtin_sycl_unique_stable_name"))
2181 if (
T.consumeClose())
2184 return Actions.SYCL().ActOnUniqueStableNameExpr(
2185 OpLoc,
T.getOpenLocation(),
T.getCloseLocation(), Ty.
get());
2188ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
2189 assert(Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2190 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
2191 tok::kw___builtin_omp_required_simd_align,
2192 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2193 "Not a sizeof/alignof/vec_step expression!");
2198 if (Tok.is(tok::ellipsis) && OpTok.
is(tok::kw_sizeof)) {
2200 SourceLocation LParenLoc, RParenLoc;
2201 IdentifierInfo *Name =
nullptr;
2202 SourceLocation NameLoc;
2203 if (Tok.is(tok::l_paren)) {
2206 LParenLoc =
T.getOpenLocation();
2207 if (Tok.is(tok::identifier)) {
2208 Name = Tok.getIdentifierInfo();
2211 RParenLoc =
T.getCloseLocation();
2213 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2215 Diag(Tok, diag::err_expected_parameter_pack);
2218 }
else if (Tok.is(tok::identifier)) {
2219 Name = Tok.getIdentifierInfo();
2221 LParenLoc = PP.getLocForEndOfToken(EllipsisLoc);
2222 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2223 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2228 Diag(Tok, diag::err_sizeof_parameter_pack);
2238 return Actions.ActOnSizeofParameterPackExpr(
getCurScope(),
2245 OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2246 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2248 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.
getName();
2250 Diag(OpTok, diag::warn_c2y_compat_keyword) << OpTok.
getName();
2258 SourceRange CastRange;
2266 case tok::kw_alignof:
2267 case tok::kw__Alignof:
2268 ExprKind = UETT_AlignOf;
2270 case tok::kw___alignof:
2271 ExprKind = UETT_PreferredAlignOf;
2273 case tok::kw_vec_step:
2274 ExprKind = UETT_VecStep;
2276 case tok::kw___builtin_omp_required_simd_align:
2277 ExprKind = UETT_OpenMPRequiredSimdAlign;
2279 case tok::kw___datasizeof:
2280 ExprKind = UETT_DataSizeOf;
2282 case tok::kw___builtin_vectorelements:
2283 ExprKind = UETT_VectorElements;
2285 case tok::kw__Countof:
2286 ExprKind = UETT_CountOf;
2289 Diag(OpTok, diag::ext_c2y_feature) << OpTok.
getName();
2296 return Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.
getLocation(),
2302 if (OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2315ExprResult Parser::ParseBuiltinPrimaryExpression() {
2317 const IdentifierInfo *BuiltinII = Tok.getIdentifierInfo();
2323 if (Tok.isNot(tok::l_paren))
2324 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2333 default: llvm_unreachable(
"Not a builtin primary expression!");
2334 case tok::kw___builtin_va_arg: {
2337 if (ExpectAndConsume(tok::comma)) {
2344 if (Tok.isNot(tok::r_paren)) {
2345 Diag(Tok, diag::err_expected) << tok::r_paren;
2352 Res = Actions.ActOnVAArg(StartLoc, Expr.get(), Ty.
get(), ConsumeParen());
2355 case tok::kw___builtin_offsetof: {
2356 SourceLocation TypeLoc = Tok.getLocation();
2358 if (Tok.getLocation().isMacroID()) {
2360 Tok.getLocation(), PP.getSourceManager(),
getLangOpts());
2361 if (MacroName ==
"offsetof")
2374 if (ExpectAndConsume(tok::comma)) {
2380 if (Tok.isNot(tok::identifier)) {
2381 Diag(Tok, diag::err_expected) << tok::identifier;
2387 SmallVector<Sema::OffsetOfComponent, 4> Comps;
2389 Comps.push_back(Sema::OffsetOfComponent());
2390 Comps.back().isBrackets =
false;
2391 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2392 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2396 if (Tok.is(tok::period)) {
2398 Comps.push_back(Sema::OffsetOfComponent());
2399 Comps.back().isBrackets =
false;
2402 if (Tok.isNot(tok::identifier)) {
2403 Diag(Tok, diag::err_expected) << tok::identifier;
2407 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2409 }
else if (Tok.is(tok::l_square)) {
2410 if (CheckProhibitedCXX11Attribute())
2414 Comps.push_back(Sema::OffsetOfComponent());
2415 Comps.back().isBrackets =
true;
2418 Comps.back().LocStart = ST.getOpenLocation();
2424 Comps.back().U.E = Res.
get();
2427 Comps.back().LocEnd = ST.getCloseLocation();
2429 if (Tok.isNot(tok::r_paren)) {
2436 Res = Actions.ActOnBuiltinOffsetOf(
getCurScope(), StartLoc, TypeLoc,
2438 PT.getCloseLocation());
2445 case tok::kw___builtin_choose_expr: {
2447 if (
Cond.isInvalid()) {
2451 if (ExpectAndConsume(tok::comma)) {
2457 if (Expr1.isInvalid()) {
2461 if (ExpectAndConsume(tok::comma)) {
2467 if (Expr2.isInvalid()) {
2471 if (Tok.isNot(tok::r_paren)) {
2472 Diag(Tok, diag::err_expected) << tok::r_paren;
2475 Res = Actions.ActOnChooseExpr(StartLoc,
Cond.get(), Expr1.get(),
2476 Expr2.get(), ConsumeParen());
2479 case tok::kw___builtin_astype: {
2482 if (Expr.isInvalid()) {
2487 if (ExpectAndConsume(tok::comma)) {
2498 if (Tok.isNot(tok::r_paren)) {
2499 Diag(Tok, diag::err_expected) << tok::r_paren;
2504 Res = Actions.ActOnAsTypeExpr(Expr.get(), DestTy.
get(), StartLoc,
2508 case tok::kw___builtin_convertvector: {
2511 if (Expr.isInvalid()) {
2516 if (ExpectAndConsume(tok::comma)) {
2527 if (Tok.isNot(tok::r_paren)) {
2528 Diag(Tok, diag::err_expected) << tok::r_paren;
2533 Res = Actions.ActOnConvertVectorExpr(Expr.get(), DestTy.
get(), StartLoc,
2537 case tok::kw___builtin_COLUMN:
2538 case tok::kw___builtin_FILE:
2539 case tok::kw___builtin_FILE_NAME:
2540 case tok::kw___builtin_FUNCTION:
2541 case tok::kw___builtin_FUNCSIG:
2542 case tok::kw___builtin_LINE:
2543 case tok::kw___builtin_source_location: {
2545 if (Tok.isNot(tok::r_paren)) {
2546 Diag(Tok, diag::err_expected) << tok::r_paren;
2552 case tok::kw___builtin_FILE:
2554 case tok::kw___builtin_FILE_NAME:
2556 case tok::kw___builtin_FUNCTION:
2558 case tok::kw___builtin_FUNCSIG:
2560 case tok::kw___builtin_LINE:
2562 case tok::kw___builtin_COLUMN:
2564 case tok::kw___builtin_source_location:
2567 llvm_unreachable(
"invalid keyword");
2570 Res = Actions.ActOnSourceLocExpr(Kind, StartLoc, ConsumeParen());
2580 return ParsePostfixExpressionSuffix(Res.
get());
2583bool Parser::tryParseOpenMPArrayShapingCastPart() {
2584 assert(Tok.is(tok::l_square) &&
"Expected open bracket");
2585 bool ErrorFound =
true;
2586 TentativeParsingAction TPA(*
this);
2588 if (Tok.isNot(tok::l_square))
2593 while (!
SkipUntil(tok::r_square, tok::annot_pragma_openmp_end,
2596 if (Tok.isNot(tok::r_square))
2601 if (Tok.is(tok::r_paren)) {
2605 }
while (Tok.isNot(tok::annot_pragma_openmp_end));
2611Parser::ParseParenExpression(
ParenParseOption &ExprType,
bool StopIfCastExpr,
2615 assert(Tok.is(tok::l_paren) &&
"Not a paren expr!");
2618 if (
T.consumeOpen())
2620 SourceLocation OpenLoc =
T.getOpenLocation();
2622 PreferredType.enterParenExpr(Tok.getLocation(), OpenLoc);
2625 bool isAmbiguousTypeId;
2628 if (Tok.is(tok::code_completion)) {
2630 Actions.CodeCompletion().CodeCompleteExpression(
2631 getCurScope(), PreferredType.get(Tok.getLocation()),
2638 Tok.isOneOf(tok::kw___bridge,
2639 tok::kw___bridge_transfer,
2640 tok::kw___bridge_retained,
2641 tok::kw___bridge_retain));
2642 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2644 StringRef BridgeCastName = Tok.getName();
2646 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2647 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2657 Diag(Tok, OpenLoc.
isMacroID() ? diag::ext_gnu_statement_expr_macro
2658 : diag::ext_gnu_statement_expr);
2660 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
2668 DeclContext *CodeDC = Actions.CurContext;
2672 "statement expr not in code context");
2674 Sema::ContextRAII SavedContext(Actions, CodeDC,
false);
2676 Actions.ActOnStartStmtExpr();
2678 StmtResult Stmt(ParseCompoundStatement(
true));
2682 if (!Stmt.isInvalid()) {
2686 Actions.ActOnStmtExprError();
2695 if (tokenKind == tok::kw___bridge)
2697 else if (tokenKind == tok::kw___bridge_transfer)
2699 else if (tokenKind == tok::kw___bridge_retained)
2704 assert(tokenKind == tok::kw___bridge_retain);
2706 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2707 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2709 "__bridge_retained");
2714 ColonProtection.restore();
2715 RParenLoc =
T.getCloseLocation();
2717 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get().
get());
2723 return Actions.ObjC().ActOnObjCBridgedCast(
getCurScope(), OpenLoc, Kind,
2724 BridgeKeywordLoc, Ty.
get(),
2725 RParenLoc, SubExpr.
get());
2727 isTypeIdInParens(isAmbiguousTypeId)) {
2736 if (isAmbiguousTypeId && !StopIfCastExpr) {
2737 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy,
T,
2739 RParenLoc =
T.getCloseLocation();
2744 DeclSpec DS(AttrFactory);
2745 ParseSpecifierQualifierList(DS);
2748 ParseDeclarator(DeclaratorInfo);
2753 if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) &&
2759 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2761 Result = ParseObjCMessageExpressionBody(SourceLocation(),
2767 ColonProtection.restore();
2768 RParenLoc =
T.getCloseLocation();
2774 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2776 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2786 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2800 Result = ParseCastExpression(
2806 if (!
Result.isInvalid()) {
2808 DeclaratorInfo, CastTy,
2809 RParenLoc,
Result.get());
2813 if (!
Result.isInvalid()) {
2825 if (DeclaratorInfo.isInvalidType())
2830 if (StopIfCastExpr) {
2834 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2842 Tok.getIdentifierInfo() == Ident_super &&
2845 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2846 << SourceRange(OpenLoc, RParenLoc);
2850 PreferredType.enterTypeCast(Tok.getLocation(), CastTy.
get());
2853 Result = ParseCastExpression(
2857 if (!
Result.isInvalid()) {
2859 DeclaratorInfo, CastTy,
2860 RParenLoc,
Result.get());
2865 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2876 ExprVector ArgExprs;
2878 if (!ParseSimpleExpressionList(ArgExprs)) {
2882 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2884 return ParseFoldExpression(ArgExprs[0],
T);
2888 Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
2891 }
else if (
getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&
2893 tryParseOpenMPArrayShapingCastPart()) {
2894 bool ErrorFound =
false;
2895 SmallVector<Expr *, 4> OMPDimensions;
2896 SmallVector<SourceRange, 4> OMPBracketsRanges;
2903 while (!
SkipUntil(tok::r_square, tok::r_paren,
2908 OMPDimensions.push_back(NumElements.
get());
2909 OMPBracketsRanges.push_back(TS.getRange());
2910 }
while (Tok.isNot(tok::r_paren));
2913 RParenLoc =
T.getCloseLocation();
2917 }
else if (!
Result.isInvalid()) {
2918 Result = Actions.OpenMP().ActOnOMPArrayShapingExpr(
2919 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);
2927 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2929 return ParseFoldExpression(
Result,
T);
2934 if (!
Result.isInvalid() && Tok.is(tok::r_paren))
2936 Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(),
Result.get());
2940 if (
Result.isInvalid()) {
2946 RParenLoc =
T.getCloseLocation();
2951Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
2954 assert(Tok.is(tok::l_brace) &&
"Not a compound literal!");
2956 Diag(LParenLoc, diag::ext_c99_compound_literal);
2957 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get());
2959 if (!
Result.isInvalid() && Ty)
2960 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc,
Result.get());
2977 "Not a string-literal-like token!");
2985 StringToks.push_back(
Tok);
2990 assert(!AllowUserDefinedLiteral &&
"UDL are always evaluated");
2995 return Actions.ActOnStringLiteral(StringToks,
3000ExprResult Parser::ParseGenericSelectionExpression() {
3001 assert(Tok.is(tok::kw__Generic) &&
"_Generic keyword expected");
3003 diagnoseUseOfC11Keyword(Tok);
3007 if (
T.expectAndConsume())
3014 if (isTypeIdForGenericSelection()) {
3021 SourceLocation Loc = LIT->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
3023 : diag::ext_c2y_generic_with_type_arg);
3036 if (ExpectAndConsume(tok::comma)) {
3041 SourceLocation DefaultLoc;
3042 SmallVector<ParsedType, 12> Types;
3046 if (Tok.is(tok::kw_default)) {
3050 Diag(Tok, diag::err_duplicate_default_assoc);
3051 Diag(DefaultLoc, diag::note_previous_default_assoc);
3066 Types.push_back(Ty);
3068 if (ExpectAndConsume(tok::colon)) {
3080 Exprs.push_back(ER.
get());
3084 if (
T.getCloseLocation().isInvalid())
3087 void *ExprOrTy = ControllingExpr.
isUsable()
3088 ? ControllingExpr.
get()
3091 return Actions.ActOnGenericSelectionExpr(
3092 KeyLoc, DefaultLoc,
T.getCloseLocation(), ControllingExpr.
isUsable(),
3093 ExprOrTy, Types, Exprs);
3104 SourceLocation FirstOpLoc;
3106 Kind = Tok.getKind();
3107 assert(isFoldOperator(Kind) &&
"missing fold-operator");
3111 assert(Tok.is(tok::ellipsis) &&
"not a fold-expression");
3115 if (Tok.isNot(tok::r_paren)) {
3116 if (!isFoldOperator(Tok.getKind()))
3117 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
3119 if (Kind != tok::unknown && Tok.getKind() != Kind)
3120 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
3121 << SourceRange(FirstOpLoc);
3122 Kind = Tok.getKind();
3133 ? diag::warn_cxx14_compat_fold_expression
3134 : diag::ext_fold_expression);
3137 return Actions.ActOnCXXFoldExpr(
getCurScope(),
T.getOpenLocation(), LHS.
get(),
3138 Kind, EllipsisLoc, RHS.
get(),
3139 T.getCloseLocation());
3142void Parser::injectEmbedTokens() {
3143 EmbedAnnotationData *
Data =
3144 reinterpret_cast<EmbedAnnotationData *
>(Tok.getAnnotationValue());
3145 MutableArrayRef<Token> Toks(PP.getPreprocessorAllocator().Allocate<Token>(
3146 Data->BinaryData.size() * 2 - 1),
3147 Data->BinaryData.size() * 2 - 1);
3149 for (
auto &Byte :
Data->BinaryData) {
3150 Toks[I].startToken();
3151 Toks[I].setKind(tok::binary_data);
3152 Toks[I].setLocation(Tok.getLocation());
3153 Toks[I].setLength(1);
3154 Toks[I].setLiteralData(&Byte);
3155 if (I != ((
Data->BinaryData.size() - 1) * 2)) {
3156 Toks[I + 1].startToken();
3157 Toks[I + 1].setKind(tok::comma);
3158 Toks[I + 1].setLocation(Tok.getLocation());
3162 PP.EnterTokenStream(std::move(Toks),
true,
3168 llvm::function_ref<
void()> ExpressionStarts,
3169 bool FailImmediatelyOnInvalidExpr) {
3170 bool SawError =
false;
3172 if (ExpressionStarts)
3177 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3178 Expr = ParseBraceInitializer();
3182 if (Tok.is(tok::ellipsis))
3184 else if (Tok.is(tok::code_completion)) {
3196 if (FailImmediatelyOnInvalidExpr)
3200 Exprs.push_back(Expr.
get());
3203 if (Tok.isNot(tok::comma))
3208 checkPotentialAngleBracketDelimiter(Comma);
3219 Exprs.push_back(Expr.
get());
3223 if (Tok.isNot(tok::comma) ||
NextToken().
is(tok::ellipsis))
3229 checkPotentialAngleBracketDelimiter(Comma);
3234 if (Tok.is(tok::code_completion)) {
3236 Actions.CodeCompletion().CodeCompleteOrdinaryName(
3242 DeclSpec DS(AttrFactory);
3243 ParseSpecifierQualifierList(DS);
3249 ParseDeclarator(DeclaratorInfo);
3251 MaybeParseGNUAttributes(DeclaratorInfo);
3254 Actions.ActOnBlockArguments(CaretLoc, DeclaratorInfo,
getCurScope());
3257ExprResult Parser::ParseBlockLiteralExpression() {
3258 assert(Tok.is(tok::caret) &&
"block literal starts with ^");
3261 PrettyStackTraceLoc CrashInfo(PP.getSourceManager(), CaretLoc,
3262 "block literal parsing");
3275 DeclSpec DS(AttrFactory);
3281 ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation()));
3285 if (Tok.is(tok::l_paren)) {
3286 ParseParenDeclarator(ParamInfo);
3290 SourceLocation Tmp = ParamInfo.getSourceRange().getEnd();
3291 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
3292 ParamInfo.SetRangeEnd(Tmp);
3293 if (ParamInfo.isInvalidType()) {
3301 MaybeParseGNUAttributes(ParamInfo);
3304 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3305 }
else if (!Tok.is(tok::l_brace)) {
3306 ParseBlockId(CaretLoc);
3309 SourceLocation NoLoc;
3310 ParamInfo.AddTypeInfo(
3328 CaretLoc, ParamInfo),
3331 MaybeParseGNUAttributes(ParamInfo);
3334 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3339 if (!Tok.is(tok::l_brace)) {
3341 Diag(Tok, diag::err_expected_expression);
3345 EnterExpressionEvaluationContextForFunction PotentiallyEvaluated(
3347 StmtResult Stmt(ParseCompoundStatementBody());
3349 if (!Stmt.isInvalid())
3358 return Actions.ObjC().ActOnObjCBoolLiteral(
ConsumeToken(), Kind);
3365 llvm::SmallSet<StringRef, 4> Platforms;
3366 bool HasOtherPlatformSpec =
false;
3368 for (
const auto &Spec : AvailSpecs) {
3369 if (Spec.isOtherPlatformSpec()) {
3370 if (HasOtherPlatformSpec) {
3371 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3375 HasOtherPlatformSpec =
true;
3379 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3384 StringRef Platform = Spec.getPlatform();
3385 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3386 << Spec.getEndLoc() << Platform;
3391 if (!HasOtherPlatformSpec) {
3392 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3393 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3401std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() {
3402 if (Tok.is(tok::star)) {
3406 if (Tok.is(tok::code_completion)) {
3408 Actions.CodeCompletion().CodeCompleteAvailabilityPlatformName();
3409 return std::nullopt;
3411 if (Tok.isNot(tok::identifier)) {
3412 Diag(Tok, diag::err_avail_query_expected_platform_name);
3413 return std::nullopt;
3416 IdentifierLoc *PlatformIdentifier = ParseIdentifierLoc();
3417 SourceRange VersionRange;
3418 VersionTuple Version = ParseVersionTuple(VersionRange);
3420 if (Version.empty())
3421 return std::nullopt;
3423 StringRef GivenPlatform =
3425 StringRef Platform =
3426 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3428 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||
3429 (GivenPlatform.contains(
"xros") || GivenPlatform.contains(
"xrOS"))) {
3431 diag::err_avail_query_unrecognized_platform_name)
3433 return std::nullopt;
3436 return AvailabilitySpec(Version, Platform, PlatformIdentifier->
getLoc(),
3442 assert(Tok.is(tok::kw___builtin_available) ||
3443 Tok.isObjCAtKeyword(tok::objc_available));
3449 if (
Parens.expectAndConsume())
3452 SmallVector<AvailabilitySpec, 4> AvailSpecs;
3453 bool HasError =
false;
3455 std::optional<AvailabilitySpec> Spec = ParseAvailabilitySpec();
3459 AvailSpecs.push_back(*Spec);
3472 if (
Parens.consumeClose())
3475 return Actions.ObjC().ActOnObjCAvailabilityCheckExpr(
3476 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.
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
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.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
ParseStringLiteralExpression - This handles the various token types that form string literals,...
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
Sema & getActions() const
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
ExprResult ParseCaseExpression(SourceLocation CaseLoc)
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
ExprResult ParseConstantExpressionInExprEvalContext(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
friend class ColonProtectionRAIIObject
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
const Token & GetLookAheadToken(unsigned N)
GetLookAheadToken - This peeks ahead N tokens and returns that token without consuming any tokens.
ExprResult ParseConstantExpression()
ExprResult ParseConditionalExpression()
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
ExprResult ParseArrayBoundExpression()
friend class InMessageExpressionRAIIObject
ExprResult ParseConstraintLogicalAndExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-and-expression.
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
friend class OffsetOfStateRAIIObject
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Simple precedence-based parser for binary/ternary operators.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtSemi
Stop skipping at semicolon.
bool TryAnnotateTypeOrScopeToken(ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
ExprResult ParseUnevaluatedStringLiteralExpression()
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
ExprResult ParseAssignmentExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
Parse an expr that doesn't include (top-level) commas.
friend class BalancedDelimiterTracker
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getCanonicalType() const
@ BlockScope
This is a scope that corresponds to a block/closure object.
@ CompoundStmtScope
This is a compound statement scope.
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ DeclScope
This is a scope that can contain a declaration.
@ PCC_Type
Code completion occurs where only a type is permitted.
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation 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
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.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
TypoCorrectionTypeBehavior
If a typo should be encountered, should typo correction suggest type names, non type names,...
bool tokenIsLikeStringLiteral(const Token &Tok, const LangOptions &LO)
Return true if the token is a string literal, or a function local predefined macro,...
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
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.