42#include "llvm/ADT/SmallVector.h"
49 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
55 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
59Parser::ParseExpressionWithLeadingExtension(
SourceLocation ExtLoc) {
69 LHS = Actions.ActOnUnaryOp(
getCurScope(), ExtLoc, tok::kw___extension__,
72 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
77 if (Tok.is(tok::code_completion)) {
79 Actions.CodeCompletion().CodeCompleteExpression(
80 getCurScope(), PreferredType.get(Tok.getLocation()));
84 if (Tok.is(tok::kw_throw))
85 return ParseThrowExpression();
86 if (Tok.is(tok::kw_co_yield))
87 return ParseCoyieldExpression();
91 false, CorrectionBehavior);
96 if (Tok.is(tok::code_completion)) {
98 Actions.CodeCompletion().CodeCompleteExpression(
99 getCurScope(), PreferredType.get(Tok.getLocation()));
110Parser::ParseAssignmentExprWithObjCMessageExprStart(
SourceLocation LBracLoc,
113 Expr *ReceiverExpr) {
115 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
116 ReceiverType, ReceiverExpr);
117 R = ParsePostfixExpressionSuffix(R);
123 assert(Actions.ExprEvalContexts.back().Context ==
125 "Call this function only if your ExpressionEvaluationContext is "
126 "already ConstantEvaluated");
128 CorrectionBehavior));
130 return Actions.ActOnConstantExpression(Res);
149 Actions.ExprEvalContexts.back().InConditionallyConstantEvaluateContext =
true;
163 for (
auto Iter = Actions.ExprEvalContexts.rbegin() + 1;
164 Iter != Actions.ExprEvalContexts.rend(); ++Iter) {
165 if (!Iter->isUnevaluated())
167 Iter->InConditionallyConstantEvaluateContext =
true;
176 Actions.currentEvaluationContext().IsCaseExpr =
true;
182 return Actions.ActOnCaseExpr(CaseLoc, Res);
190 if (Res.
isUsable() && !Actions.CheckConstraintExpression(Res.
get())) {
200 bool NotPrimaryExpression =
false;
201 auto ParsePrimary = [&]() {
205 false, &NotPrimaryExpression);
209 E = ParsePostfixExpressionSuffix(E);
216 ? diag::note_unparenthesized_non_primary_expr_in_requires_clause
217 : diag::err_unparenthesized_non_primary_expr_in_requires_clause)
225 if (NotPrimaryExpression ||
232 Tok.isOneOf(tok::period, tok::plusplus, tok::minusminus) ||
233 (Tok.is(tok::l_square) && !
NextToken().
is(tok::l_square))) {
234 E = RecoverFromNonPrimary(E,
false);
237 NotPrimaryExpression =
false;
239 bool PossibleNonPrimary;
240 bool IsConstraintExpr =
241 Actions.CheckConstraintExpression(E.
get(), Tok, &PossibleNonPrimary,
242 IsTrailingRequiresClause);
243 if (!IsConstraintExpr || PossibleNonPrimary) {
248 if (PossibleNonPrimary)
249 E = RecoverFromNonPrimary(E, !IsConstraintExpr);
257 while (Tok.is(tok::ampamp)) {
264 tok::ampamp, LHS.
get(), RHS.
get());
278 while (Tok.is(tok::pipepipe)) {
286 tok::pipepipe, LHS.
get(), RHS.
get());
295bool Parser::isNotExpressionStart() {
297 if (K == tok::l_brace || K == tok::r_brace ||
298 K == tok::kw_for || K == tok::kw_while ||
299 K == tok::kw_if || K == tok::kw_else ||
300 K == tok::kw_goto || K == tok::kw_try)
303 return isKnownToBeDeclarationSpecifier();
306bool Parser::isFoldOperator(
prec::Level Level)
const {
318 GreaterThanIsOperator,
320 SourceLocation ColonLoc;
322 auto SavedType = PreferredType;
325 PreferredType = SavedType;
329 if (NextTokPrec < MinPrec)
340 if (OpToken.
is(tok::caretcaret)) {
351 UnconsumeToken(OpToken);
352 PP.EnterToken(Caret,
true);
353 return ParseRHSOfBinaryExpression(LHS, MinPrec);
359 if (OpToken.
isOneOf(tok::comma, tok::greater, tok::greatergreater,
360 tok::greatergreatergreater) &&
361 checkPotentialAngleBracketDelimiter(OpToken))
369 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
370 PP.EnterToken(Tok,
true);
377 if (isFoldOperator(NextTokPrec) && Tok.is(tok::ellipsis)) {
380 PP.EnterToken(Tok,
true);
391 Tok.isOneOf(tok::colon, tok::r_square) &&
393 PP.EnterToken(Tok,
true);
403 SourceLocation BraceLoc = Tok.getLocation();
404 TernaryMiddle = ParseBraceInitializer();
405 if (!TernaryMiddle.isInvalid()) {
406 Diag(BraceLoc, diag::err_init_list_bin_op)
407 << 1 << PP.getSpelling(OpToken)
408 << Actions.getExprRange(TernaryMiddle.get());
411 }
else if (Tok.isNot(tok::colon)) {
423 TernaryMiddle =
nullptr;
424 Diag(Tok, diag::ext_gnu_conditional_expr);
427 if (TernaryMiddle.isInvalid()) {
429 TernaryMiddle =
nullptr;
437 SourceLocation FILoc = Tok.getLocation();
438 const char *FIText =
": ";
439 const SourceManager &
SM = PP.getSourceManager();
440 if (FILoc.
isFileID() || PP.isAtStartOfMacroExpansion(FILoc, &FILoc)) {
442 bool IsInvalid =
false;
443 const char *SourcePtr =
445 if (!IsInvalid && *SourcePtr ==
' ') {
448 if (!IsInvalid && *SourcePtr ==
' ') {
455 Diag(Tok, diag::err_expected)
457 Diag(OpToken, diag::note_matching) << tok::question;
458 ColonLoc = Tok.getLocation();
462 PreferredType.enterBinary(Actions, Tok.getLocation(), LHS.
get(),
475 bool RHSIsInitList =
false;
477 RHS = ParseBraceInitializer();
478 RHSIsInitList =
true;
500 if (ThisPrec < NextTokPrec ||
501 (ThisPrec == NextTokPrec && isRightAssoc)) {
503 Diag(Tok, diag::err_init_list_bin_op)
504 << 0 << PP.getSpelling(Tok) << Actions.getExprRange(RHS.
get());
512 RHS = ParseRHSOfBinaryExpression(RHS,
513 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
514 RHSIsInitList =
false;
526 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
527 << Actions.getExprRange(RHS.
get());
528 }
else if (ColonLoc.
isValid()) {
529 Diag(ColonLoc, diag::err_init_list_bin_op)
531 << Actions.getExprRange(RHS.
get());
534 Diag(OpToken, diag::err_init_list_bin_op)
535 << 1 << PP.getSpelling(OpToken)
536 << Actions.getExprRange(RHS.
get());
543 if (TernaryMiddle.isInvalid()) {
547 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
549 diag::warn_cxx11_right_shift_in_template_arg,
550 SourceRange(Actions.getExprRange(LHS.
get()).getBegin(),
551 Actions.getExprRange(RHS.
get()).getEnd()));
559 {LHS.get(), RHS.get()});
563 ExprResult CondOp = Actions.ActOnConditionalOp(
567 std::vector<clang::Expr *> Args;
569 if (TernaryMiddle.get())
570 Args = {LHS.
get(), TernaryMiddle.get(), RHS.
get()};
572 Args = {LHS.
get(), RHS.
get()};
584Parser::ParseCastExpression(
CastParseKind ParseKind,
bool isAddressOfOperand,
586 bool isVectorLiteral,
bool *NotPrimaryExpression) {
588 ExprResult Res = ParseCastExpression(ParseKind, isAddressOfOperand,
589 NotCastExpr, CorrectionBehavior,
590 isVectorLiteral, NotPrimaryExpression);
592 Diag(Tok, diag::err_expected_expression);
599 CastExpressionIdValidator(Token
Next,
602 WantTypeSpecifiers = WantFunctionLikeCasts =
603 (CorrectionBehavior != TypoCorrectionTypeBehavior::AllowNonTypes);
605 (CorrectionBehavior != TypoCorrectionTypeBehavior::AllowTypes);
608 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
614 return WantTypeSpecifiers;
619 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
622 for (
auto *
C : candidate) {
630 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
631 return std::make_unique<CastExpressionIdValidator>(*
this);
642 if (RevertibleTypeTraits.empty()) {
646#define RTT_JOIN(X, Y) X##Y
647#define REVERTIBLE_TYPE_TRAIT(Name) \
648 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] = RTT_JOIN(tok::kw_, Name)
705#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
706 REVERTIBLE_TYPE_TRAIT(RTT_JOIN(__, Trait));
707#include "clang/Basic/TransformTypeTraits.def"
708#undef REVERTIBLE_TYPE_TRAIT
711 llvm::SmallDenseMap<IdentifierInfo *, tok::TokenKind>::iterator Known =
712 RevertibleTypeTraits.find(II);
713 if (Known != RevertibleTypeTraits.end()) {
715 *
Kind = Known->second;
721ExprResult Parser::ParseBuiltinPtrauthTypeDiscriminator() {
725 if (T.expectAndConsume())
734 SourceLocation EndLoc = Tok.getLocation();
736 return Actions.ActOnUnaryExprOrTypeTraitExpr(
737 Loc, UETT_PtrAuthTypeDiscriminator,
742Parser::ParseCastExpression(
CastParseKind ParseKind,
bool isAddressOfOperand,
745 bool isVectorLiteral,
bool *NotPrimaryExpression) {
748 auto SavedType = PreferredType;
754 bool AllowSuffix =
true;
783 SourceLocation RParenLoc;
784 Res = ParseParenExpression(ParenExprType,
false,
794 switch (ParenExprType) {
817 case tok::numeric_constant:
818 case tok::binary_data:
822 Res = Actions.ActOnNumericConstant(Tok,
getCurScope());
828 Res = ParseCXXBoolLiteral();
831 case tok::kw___objc_yes:
832 case tok::kw___objc_no:
833 Res = ParseObjCBoolLiteral();
836 case tok::kw_nullptr:
838 Diag(Tok, diag::warn_cxx98_compat_nullptr);
841 : diag::ext_c_nullptr) << Tok.getName();
846 case tok::annot_primary_expr:
847 case tok::annot_overload_set:
848 Res = getExprAnnotation(Tok);
849 if (!Res.
isInvalid() && Tok.getKind() == tok::annot_overload_set)
850 Res = Actions.ActOnNameClassifiedAsOverloadSet(
getCurScope(), Res.
get());
851 ConsumeAnnotationToken();
852 if (!Res.
isInvalid() && Tok.is(tok::less))
853 checkPotentialAngleBracket(Res);
856 case tok::annot_non_type:
857 case tok::annot_non_type_dependent:
858 case tok::annot_non_type_undeclared: {
861 Res = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
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) &&
901 Tok.isOneOf(tok::annot_pack_indexing_type, tok::annot_cxxscope))
902 return ParseCastExpression(ParseKind, isAddressOfOperand,
903 CorrectionBehavior, isVectorLiteral,
904 NotPrimaryExpression);
910 else if (
Next.is(tok::l_paren) && Tok.is(tok::identifier) &&
911 Tok.getIdentifierInfo()->hasRevertedTokenIDToIdentifier()) {
912 IdentifierInfo *II = Tok.getIdentifierInfo();
914 if (isRevertibleTypeTrait(II, &Kind)) {
916 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
917 CorrectionBehavior, isVectorLiteral,
918 NotPrimaryExpression);
922 else if ((!ColonIsSacred &&
Next.is(tok::colon)) ||
923 Next.isOneOf(tok::coloncolon, tok::less, tok::l_paren,
928 if (!Tok.is(tok::identifier))
929 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
930 CorrectionBehavior, isVectorLiteral,
931 NotPrimaryExpression);
937 IdentifierInfo &II = *Tok.getIdentifierInfo();
944 (&II == Ident_super &&
getCurScope()->isInObjcMethodScope()))) {
947 if (Tok.is(tok::code_completion) && &II != Ident_super) {
949 Actions.CodeCompletion().CodeCompleteObjCClassPropertyRefExpr(
950 getCurScope(), II, ILoc, ExprStatementTokLoc == ILoc);
954 if (Tok.isNot(tok::identifier) &&
956 Diag(Tok, diag::err_expected_property_name);
959 IdentifierInfo &PropertyName = *Tok.getIdentifierInfo();
962 Res = Actions.ObjC().ActOnClassPropertyRefExpr(II, PropertyName, ILoc,
971 if (
getLangOpts().
ObjC && &II == Ident_super && !InMessageExpression &&
973 ((Tok.is(tok::identifier) &&
975 Tok.is(tok::code_completion))) {
976 Res = ParseObjCMessageExpressionBody(SourceLocation(), ILoc,
nullptr,
987 ((Tok.is(tok::identifier) && !InMessageExpression) ||
988 Tok.is(tok::code_completion))) {
990 if (Tok.is(tok::code_completion) ||
991 Next.is(tok::colon) ||
Next.is(tok::r_square))
993 if (Typ.get()->isObjCObjectOrInterfaceType()) {
995 DeclSpec DS(AttrFactory);
996 DS.SetRangeStart(ILoc);
997 DS.SetRangeEnd(ILoc);
998 const char *PrevSpec =
nullptr;
1000 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
1001 Actions.getASTContext().getPrintingPolicy());
1005 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
1009 Res = ParseObjCMessageExpressionBody(SourceLocation(),
1017 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
1018 isAddressOfOperand =
false;
1024 CXXScopeSpec ScopeSpec;
1025 SourceLocation TemplateKWLoc;
1027 CastExpressionIdValidator Validator(Tok, CorrectionBehavior);
1028 Validator.IsAddressOfOperand = isAddressOfOperand;
1029 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
1030 Validator.WantExpressionKeywords =
false;
1031 Validator.WantRemainingKeywords =
false;
1033 Validator.WantRemainingKeywords = Tok.isNot(tok::r_paren);
1036 Res = Actions.ActOnIdExpression(
1037 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren),
1038 isAddressOfOperand, &Validator,
1040 Tok.is(tok::r_paren) ?
nullptr : &Replacement);
1042 UnconsumeToken(Replacement);
1043 return ParseCastExpression(
1044 ParseKind, isAddressOfOperand, NotCastExpr, CorrectionBehavior,
1045 false, NotPrimaryExpression);
1047 Res = tryParseCXXPackIndexingExpression(Res);
1048 if (!Res.
isInvalid() && Tok.is(tok::less))
1049 checkPotentialAngleBracket(Res);
1052 case tok::char_constant:
1053 case tok::wide_char_constant:
1054 case tok::utf8_char_constant:
1055 case tok::utf16_char_constant:
1056 case tok::utf32_char_constant:
1057 Res = Actions.ActOnCharacterConstant(Tok,
getCurScope());
1060 case tok::kw___func__:
1061 case tok::kw___FUNCTION__:
1062 case tok::kw___FUNCDNAME__:
1063 case tok::kw___FUNCSIG__:
1064 case tok::kw_L__FUNCTION__:
1065 case tok::kw_L__FUNCSIG__:
1066 case tok::kw___PRETTY_FUNCTION__:
1073 Res = Actions.ActOnPredefinedExpr(Tok.getLocation(), SavedKind);
1078 case tok::string_literal:
1079 case tok::wide_string_literal:
1080 case tok::utf8_string_literal:
1081 case tok::utf16_string_literal:
1082 case tok::utf32_string_literal:
1085 case tok::kw__Generic:
1086 Res = ParseGenericSelectionExpression();
1088 case tok::kw___builtin_available:
1089 Res = ParseAvailabilityCheckExpr(Tok.getLocation());
1091 case tok::kw___builtin_va_arg:
1092 case tok::kw___builtin_offsetof:
1093 case tok::kw___builtin_choose_expr:
1094 case tok::kw___builtin_astype:
1095 case tok::kw___builtin_convertvector:
1096 case tok::kw___builtin_COLUMN:
1097 case tok::kw___builtin_FILE:
1098 case tok::kw___builtin_FILE_NAME:
1099 case tok::kw___builtin_FUNCTION:
1100 case tok::kw___builtin_FUNCSIG:
1101 case tok::kw___builtin_LINE:
1102 case tok::kw___builtin_source_location:
1103 if (NotPrimaryExpression)
1104 *NotPrimaryExpression =
true;
1106 return ParseBuiltinPrimaryExpression();
1107 case tok::kw___null:
1112 case tok::minusminus: {
1113 if (NotPrimaryExpression)
1114 *NotPrimaryExpression =
true;
1119 Token SavedTok = Tok;
1122 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedTok.
getKind(),
1136 UnconsumeToken(SavedTok);
1140 Expr *Arg = Res.
get();
1144 Res = Actions.CreateRecoveryExpr(SavedTok.
getLocation(),
1150 if (NotPrimaryExpression)
1151 *NotPrimaryExpression =
true;
1154 PreferredType.enterUnary(Actions, Tok.getLocation(), tok::amp, SavedLoc);
1159 Expr *Arg = Res.
get();
1160 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Arg);
1162 Res = Actions.CreateRecoveryExpr(Tok.getLocation(), Arg->
getEndLoc(),
1173 case tok::kw___real:
1174 case tok::kw___imag: {
1175 if (NotPrimaryExpression)
1176 *NotPrimaryExpression =
true;
1178 PreferredType.enterUnary(Actions, Tok.getLocation(), SavedKind, SavedLoc);
1181 Expr *Arg = Res.
get();
1182 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Arg,
1183 isAddressOfOperand);
1185 Res = Actions.CreateRecoveryExpr(SavedLoc, Arg->
getEndLoc(), Arg);
1190 case tok::kw_co_await: {
1191 if (NotPrimaryExpression)
1192 *NotPrimaryExpression =
true;
1196 Res = Actions.ActOnCoawaitExpr(
getCurScope(), CoawaitLoc, Res.
get());
1200 case tok::kw___extension__:{
1202 if (NotPrimaryExpression)
1203 *NotPrimaryExpression =
true;
1204 ExtensionRAIIObject O(Diags);
1208 Res = Actions.ActOnUnaryOp(
getCurScope(), SavedLoc, SavedKind, Res.
get());
1211 case tok::kw__Alignof:
1212 diagnoseUseOfC11Keyword(Tok);
1214 case tok::kw_alignof:
1215 case tok::kw___alignof:
1217 case tok::kw_sizeof:
1221 case tok::kw___datasizeof:
1222 case tok::kw_vec_step:
1224 case tok::kw___builtin_omp_required_simd_align:
1225 case tok::kw___builtin_vectorelements:
1226 case tok::kw__Countof:
1227 if (NotPrimaryExpression)
1228 *NotPrimaryExpression =
true;
1229 AllowSuffix =
false;
1230 Res = ParseUnaryExprOrTypeTraitExpression();
1232 case tok::caretcaret: {
1238 if (NotPrimaryExpression)
1239 *NotPrimaryExpression =
true;
1240 AllowSuffix =
false;
1241 Res = ParseCXXReflectExpression();
1245 if (NotPrimaryExpression)
1246 *NotPrimaryExpression =
true;
1248 if (Tok.isNot(tok::identifier))
1249 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1252 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1254 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1255 LabelDecl *LD = Actions.LookupOrCreateLabel(Tok.getIdentifierInfo(),
1257 Res = Actions.ActOnAddrLabel(AmpAmpLoc, Tok.getLocation(), LD);
1259 AllowSuffix =
false;
1262 case tok::kw_const_cast:
1263 case tok::kw_dynamic_cast:
1264 case tok::kw_reinterpret_cast:
1265 case tok::kw_static_cast:
1266 case tok::kw_addrspace_cast:
1267 if (NotPrimaryExpression)
1268 *NotPrimaryExpression =
true;
1269 Res = ParseCXXCasts();
1271 case tok::kw___builtin_bit_cast:
1272 if (NotPrimaryExpression)
1273 *NotPrimaryExpression =
true;
1274 Res = ParseBuiltinBitCast();
1276 case tok::kw_typeid:
1277 if (NotPrimaryExpression)
1278 *NotPrimaryExpression =
true;
1279 Res = ParseCXXTypeid();
1281 case tok::kw___uuidof:
1282 if (NotPrimaryExpression)
1283 *NotPrimaryExpression =
true;
1284 Res = ParseCXXUuidof();
1287 Res = ParseCXXThis();
1289 case tok::kw___builtin_sycl_unique_stable_name:
1290 Res = ParseSYCLUniqueStableNameExpression();
1293 case tok::annot_typename:
1294 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1298 DeclSpec DS(AttrFactory);
1299 DS.SetRangeStart(Tok.getLocation());
1300 DS.SetRangeEnd(Tok.getLastLoc());
1302 const char *PrevSpec =
nullptr;
1304 DS.SetTypeSpecType(
TST_typename, Tok.getAnnotationEndLoc(),
1305 PrevSpec, DiagID,
Type,
1306 Actions.getASTContext().getPrintingPolicy());
1310 TypeResult Ty = Actions.ActOnTypeName(DeclaratorInfo);
1314 ConsumeAnnotationToken();
1315 Res = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1321 case tok::annot_decltype:
1322 case tok::annot_pack_indexing_type:
1324 case tok::kw_wchar_t:
1325 case tok::kw_char8_t:
1326 case tok::kw_char16_t:
1327 case tok::kw_char32_t:
1332 case tok::kw___int64:
1333 case tok::kw___int128:
1334 case tok::kw__ExtInt:
1335 case tok::kw__BitInt:
1336 case tok::kw_signed:
1337 case tok::kw_unsigned:
1340 case tok::kw_double:
1341 case tok::kw___bf16:
1342 case tok::kw__Float16:
1343 case tok::kw___float128:
1344 case tok::kw___ibm128:
1347 case tok::kw_typename:
1348 case tok::kw_typeof:
1349 case tok::kw___vector:
1350 case tok::kw__Accum:
1351 case tok::kw__Fract:
1353#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
1354#include "clang/Basic/OpenCLImageTypes.def"
1355#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
1356#include "clang/Basic/HLSLIntangibleTypes.def"
1359 Diag(Tok, diag::err_expected_expression);
1364 if (NotPrimaryExpression)
1365 *NotPrimaryExpression =
true;
1367 if (SavedKind == tok::kw_typename) {
1382 DeclSpec DS(AttrFactory);
1384 ParseCXXSimpleTypeSpecifier(DS);
1385 if (Tok.isNot(tok::l_paren) &&
1387 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1388 << DS.getSourceRange());
1390 if (Tok.is(tok::l_brace))
1391 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1393 Res = ParseCXXTypeConstructExpression(DS);
1397 case tok::annot_cxxscope: {
1402 if (!Tok.is(tok::annot_cxxscope))
1403 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1404 CorrectionBehavior, isVectorLiteral,
1405 NotPrimaryExpression);
1408 if (
Next.is(tok::annot_template_id)) {
1409 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(
Next);
1415 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1419 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1420 CorrectionBehavior, isVectorLiteral,
1421 NotPrimaryExpression);
1426 Res = ParseCXXIdExpression(isAddressOfOperand);
1430 case tok::annot_template_id: {
1431 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1438 return ParseCastExpression(ParseKind, isAddressOfOperand, NotCastExpr,
1439 CorrectionBehavior, isVectorLiteral,
1440 NotPrimaryExpression);
1447 case tok::kw_operator:
1448 Res = ParseCXXIdExpression(isAddressOfOperand);
1451 case tok::coloncolon: {
1456 if (!Tok.is(tok::coloncolon))
1457 return ParseCastExpression(ParseKind, isAddressOfOperand,
1458 CorrectionBehavior, isVectorLiteral,
1459 NotPrimaryExpression);
1464 if (Tok.is(tok::kw_new)) {
1465 if (NotPrimaryExpression)
1466 *NotPrimaryExpression =
true;
1467 Res = ParseCXXNewExpression(
true, CCLoc);
1468 AllowSuffix =
false;
1471 if (Tok.is(tok::kw_delete)) {
1472 if (NotPrimaryExpression)
1473 *NotPrimaryExpression =
true;
1474 Res = ParseCXXDeleteExpression(
true, CCLoc);
1475 AllowSuffix =
false;
1480 Diag(CCLoc, diag::err_expected_expression);
1485 if (NotPrimaryExpression)
1486 *NotPrimaryExpression =
true;
1487 Res = ParseCXXNewExpression(
false, Tok.getLocation());
1488 AllowSuffix =
false;
1491 case tok::kw_delete:
1492 if (NotPrimaryExpression)
1493 *NotPrimaryExpression =
true;
1494 Res = ParseCXXDeleteExpression(
false, Tok.getLocation());
1495 AllowSuffix =
false;
1498 case tok::kw_requires:
1499 Res = ParseRequiresExpression();
1500 AllowSuffix =
false;
1503 case tok::kw_noexcept: {
1504 if (NotPrimaryExpression)
1505 *NotPrimaryExpression =
true;
1506 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1510 if (T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1522 Res = Actions.ActOnNoexceptExpr(KeyLoc, T.getOpenLocation(), Res.
get(),
1523 T.getCloseLocation());
1524 AllowSuffix =
false;
1528#define TYPE_TRAIT(N,Spelling,K) \
1529 case tok::kw_##Spelling:
1530#include "clang/Basic/TokenKinds.def"
1531 Res = ParseTypeTrait();
1534 case tok::kw___array_rank:
1535 case tok::kw___array_extent:
1536 if (NotPrimaryExpression)
1537 *NotPrimaryExpression =
true;
1538 Res = ParseArrayTypeTrait();
1541 case tok::kw___builtin_ptrauth_type_discriminator:
1542 return ParseBuiltinPtrauthTypeDiscriminator();
1544 case tok::kw___is_lvalue_expr:
1545 case tok::kw___is_rvalue_expr:
1546 if (NotPrimaryExpression)
1547 *NotPrimaryExpression =
true;
1548 Res = ParseExpressionTrait();
1552 if (NotPrimaryExpression)
1553 *NotPrimaryExpression =
true;
1555 return ParseObjCAtExpression(AtLoc);
1558 Res = ParseBlockLiteralExpression();
1560 case tok::code_completion: {
1562 Actions.CodeCompletion().CodeCompleteExpression(
1563 getCurScope(), PreferredType.get(Tok.getLocation()));
1566#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
1567#include "clang/Basic/TransformTypeTraits.def"
1571 Tok.setKind(tok::identifier);
1572 Diag(Tok, diag::ext_keyword_as_ident)
1573 << Tok.getIdentifierInfo()->getName() << 0;
1574 goto ParseIdentifier;
1576 goto ExpectedExpression;
1585 Res = TryParseLambdaExpression();
1589 if (NotPrimaryExpression)
1590 *NotPrimaryExpression =
true;
1591 Res = ParseObjCMessageExpression();
1595 Res = ParseLambdaExpression();
1599 Res = ParseObjCMessageExpression();
1624 switch (Tok.getKind()) {
1628 case tok::minusminus:
1631 if (Tok.isAtStartOfLine())
1646 Diag(Tok.getLocation(), diag::err_postfix_after_unary_requires_parens)
1654 PreferredType = SavedType;
1655 Res = ParsePostfixExpressionSuffix(Res);
1657 !
getActions().getOpenCLOptions().isAvailableOption(
1659 if (Expr *PostfixExpr = Res.
get()) {
1660 QualType Ty = PostfixExpr->getType();
1662 Diag(PostfixExpr->getExprLoc(),
1663 diag::err_opencl_taking_function_address_parser);
1672Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1676 auto SavedType = PreferredType;
1679 PreferredType = SavedType;
1680 switch (Tok.getKind()) {
1681 case tok::code_completion:
1682 if (InMessageExpression)
1686 Actions.CodeCompletion().CodeCompletePostfixExpression(
1687 getCurScope(), LHS, PreferredType.get(Tok.getLocation()));
1690 case tok::identifier:
1696 LHS = ParseObjCMessageExpressionBody(SourceLocation(), SourceLocation(),
1697 nullptr, LHS.
get());
1705 case tok::l_square: {
1713 isSimpleObjCMessageExpression())
1718 if (CheckProhibitedCXX11Attribute()) {
1723 Loc = T.getOpenLocation();
1725 SourceLocation ColonLocFirst, ColonLocSecond;
1726 ExprVector ArgExprs;
1727 bool HasError =
false;
1728 PreferredType.enterSubscript(Actions, Tok.getLocation(), LHS.
get());
1734 if ((!
getLangOpts().OpenMP && !AllowOpenACCArraySections) ||
1735 Tok.isNot(tok::colon)) {
1739 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1740 Idx = ParseBraceInitializer();
1747 ArgExprs.push_back(Idx.
get());
1749 }
else if (Tok.isNot(tok::r_square)) {
1750 if (ParseExpressionList(ArgExprs)) {
1760 if (ArgExprs.size() <= 1 && AllowOpenACCArraySections) {
1762 if (Tok.is(tok::colon)) {
1765 if (Tok.isNot(tok::r_square))
1768 }
else if (ArgExprs.size() <= 1 &&
getLangOpts().OpenMP) {
1770 if (Tok.is(tok::colon)) {
1773 if (Tok.isNot(tok::r_square) &&
1775 ((Tok.isNot(tok::colon) &&
getLangOpts().OpenMP >= 50)))) {
1780 (OMPClauseKind == llvm::omp::Clause::OMPC_to ||
1781 OMPClauseKind == llvm::omp::Clause::OMPC_from) &&
1782 Tok.is(tok::colon)) {
1785 if (Tok.isNot(tok::r_square)) {
1791 SourceLocation RLoc = Tok.getLocation();
1792 if (!LHS.
isInvalid() && !HasError && !Length.isInvalid() &&
1793 !Stride.
isInvalid() && Tok.is(tok::r_square)) {
1799 if (AllowOpenACCArraySections) {
1801 "Stride/second colon not allowed for OpenACC");
1802 LHS = Actions.OpenACC().ActOnArraySectionExpr(
1803 LHS.
get(), Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
1804 ColonLocFirst, Length.get(), RLoc);
1806 LHS = Actions.OpenMP().ActOnOMPArraySectionExpr(
1807 LHS.
get(), Loc, ArgExprs.empty() ?
nullptr : ArgExprs[0],
1808 ColonLocFirst, ColonLocSecond, Length.get(), Stride.
get(),
1812 LHS = Actions.ActOnArraySubscriptExpr(
getCurScope(), LHS.
get(), Loc,
1825 case tok::lesslessless: {
1830 Expr *ExecConfig =
nullptr;
1834 if (OpKind == tok::lesslessless) {
1835 ExprVector ExecConfigExprs;
1838 if (ParseSimpleExpressionList(ExecConfigExprs)) {
1842 SourceLocation CloseLoc;
1848 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1849 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1855 if (ExpectAndConsume(tok::l_paren))
1858 Loc = PrevTokLocation;
1862 ExprResult ECResult = Actions.CUDA().ActOnExecConfigExpr(
1863 getCurScope(), OpenLoc, ExecConfigExprs, CloseLoc);
1867 ExecConfig = ECResult.
get();
1871 Loc = PT.getOpenLocation();
1874 ExprVector ArgExprs;
1875 auto RunSignatureHelp = [&]() -> QualType {
1876 QualType PreferredType =
1877 Actions.CodeCompletion().ProduceCallSignatureHelp(
1878 LHS.
get(), ArgExprs, PT.getOpenLocation());
1879 CalledSignatureHelp =
true;
1880 return PreferredType;
1882 bool ExpressionListIsInvalid =
false;
1883 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1884 if (Tok.isNot(tok::r_paren)) {
1885 if ((ExpressionListIsInvalid = ParseExpressionList(ArgExprs, [&] {
1886 PreferredType.enterFunctionArgument(Tok.getLocation(),
1893 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
1902 }
else if (ExpressionListIsInvalid) {
1903 Expr *
Fn = LHS.
get();
1904 ArgExprs.insert(ArgExprs.begin(), Fn);
1905 LHS = Actions.CreateRecoveryExpr(
Fn->getBeginLoc(), Tok.getLocation(),
1908 }
else if (Tok.isNot(tok::r_paren)) {
1909 bool HadErrors =
false;
1912 for (
auto &E : ArgExprs)
1913 if (E->containsErrors())
1924 Expr *
Fn = LHS.
get();
1925 SourceLocation RParLoc = Tok.getLocation();
1926 LHS = Actions.ActOnCallExpr(
getCurScope(), Fn, Loc, ArgExprs, RParLoc,
1929 ArgExprs.insert(ArgExprs.begin(), Fn);
1931 Actions.CreateRecoveryExpr(
Fn->getBeginLoc(), RParLoc, ArgExprs);
1947 bool MayBePseudoDestructor =
false;
1948 Expr* OrigLHS = !LHS.
isInvalid() ? LHS.
get() :
nullptr;
1950 PreferredType.enterMemAccess(Actions, Tok.getLocation(), OrigLHS);
1953 Expr *
Base = OrigLHS;
1954 const Type* BaseType =
Base->getType().getTypePtrOrNull();
1955 if (BaseType && Tok.is(tok::l_paren) &&
1958 Diag(OpLoc, diag::err_function_is_not_record)
1959 << OpKind <<
Base->getSourceRange()
1961 return ParsePostfixExpressionSuffix(Base);
1964 LHS = Actions.ActOnStartCXXMemberReference(
getCurScope(), Base, OpLoc,
1966 MayBePseudoDestructor);
1971 if (Tok.is(tok::code_completion)) {
1977 ParseOptionalCXXScopeSpecifier(
1979 false, &MayBePseudoDestructor);
1981 ObjectType =
nullptr;
1984 if (Tok.is(tok::code_completion)) {
1986 OpKind == tok::arrow ? tok::period : tok::arrow;
1991 Sema::TentativeAnalysisScope Trap(Actions);
1992 CorrectedLHS = Actions.ActOnStartCXXMemberReference(
1993 getCurScope(), OrigLHS, OpLoc, CorrectedOpKind, ObjectType,
1994 MayBePseudoDestructor);
1998 Expr *CorrectedBase = CorrectedLHS.get();
2000 CorrectedBase =
Base;
2004 Actions.CodeCompletion().CodeCompleteMemberReferenceExpr(
2005 getCurScope(), Base, CorrectedBase, OpLoc, OpKind == tok::arrow,
2006 Base && ExprStatementTokLoc ==
Base->getBeginLoc(),
2007 PreferredType.get(Tok.getLocation()));
2012 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
2013 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
2025 SourceLocation TemplateKWLoc;
2028 Tok.is(tok::kw_class)) {
2036 IdentifierInfo *Id = Tok.getIdentifierInfo();
2045 false, &TemplateKWLoc, Name)) {
2050 LHS = Actions.ActOnMemberAccessExpr(
getCurScope(), LHS.
get(), OpLoc,
2051 OpKind, SS, TemplateKWLoc, Name,
2052 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
2055 if (Tok.is(tok::less))
2056 checkPotentialAngleBracket(LHS);
2057 }
else if (OrigLHS && Name.
isValid()) {
2059 LHS = Actions.CreateRecoveryExpr(OrigLHS->
getBeginLoc(),
2065 case tok::minusminus:
2067 Expr *Arg = LHS.
get();
2068 LHS = Actions.ActOnPostfixUnaryOp(
getCurScope(), Tok.getLocation(),
2069 Tok.getKind(), Arg);
2071 LHS = Actions.CreateRecoveryExpr(Arg->
getBeginLoc(),
2072 Tok.getLocation(), Arg);
2081Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
2086 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual, tok::kw_sizeof,
2087 tok::kw___datasizeof, tok::kw___alignof, tok::kw_alignof,
2088 tok::kw__Alignof, tok::kw_vec_step,
2089 tok::kw___builtin_omp_required_simd_align,
2090 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2091 "Not a typeof/sizeof/alignof/vec_step expression!");
2096 if (Tok.isNot(tok::l_paren)) {
2099 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2100 tok::kw_alignof, tok::kw__Alignof)) {
2101 if (isTypeIdUnambiguously()) {
2102 DeclSpec DS(AttrFactory);
2103 ParseSpecifierQualifierList(DS);
2106 ParseDeclarator(DeclaratorInfo);
2108 SourceLocation LParenLoc = PP.getLocForEndOfToken(OpTok.
getLocation());
2109 SourceLocation RParenLoc = PP.getLocForEndOfToken(PrevTokLocation);
2112 diag::err_expected_parentheses_around_typename)
2115 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
2125 if (OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
2136 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2137 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof) &&
2138 Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2139 tok::kw_alignof, tok::kw__Alignof, tok::kw__Countof))
2140 Actions.runWithSufficientStackSpace(Tok.getLocation(), [&] {
2141 Operand = ParseCastExpression(CastParseKind::UnaryExprOnly);
2160 bool ParenKnownToBeNonCast =
2161 OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual);
2163 SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;
2165 Operand = ParseParenExpression(
2170 CastRange = SourceRange(LParenLoc, RParenLoc);
2180 !OpTok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual)) {
2195ExprResult Parser::ParseSYCLUniqueStableNameExpression() {
2196 assert(Tok.is(tok::kw___builtin_sycl_unique_stable_name) &&
2197 "Not __builtin_sycl_unique_stable_name");
2203 if (T.expectAndConsume(diag::err_expected_lparen_after,
2204 "__builtin_sycl_unique_stable_name"))
2214 if (T.consumeClose())
2217 return Actions.SYCL().ActOnUniqueStableNameExpr(
2218 OpLoc, T.getOpenLocation(), T.getCloseLocation(), Ty.
get());
2221ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
2222 assert(Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
2223 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
2224 tok::kw___builtin_omp_required_simd_align,
2225 tok::kw___builtin_vectorelements, tok::kw__Countof) &&
2226 "Not a sizeof/alignof/vec_step expression!");
2231 if (Tok.is(tok::ellipsis) && OpTok.
is(tok::kw_sizeof)) {
2233 SourceLocation LParenLoc, RParenLoc;
2234 IdentifierInfo *Name =
nullptr;
2235 SourceLocation NameLoc;
2236 if (Tok.is(tok::l_paren)) {
2239 LParenLoc = T.getOpenLocation();
2240 if (Tok.is(tok::identifier)) {
2241 Name = Tok.getIdentifierInfo();
2244 RParenLoc = T.getCloseLocation();
2246 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2248 Diag(Tok, diag::err_expected_parameter_pack);
2251 }
else if (Tok.is(tok::identifier)) {
2252 Name = Tok.getIdentifierInfo();
2254 LParenLoc = PP.getLocForEndOfToken(EllipsisLoc);
2255 RParenLoc = PP.getLocForEndOfToken(NameLoc);
2256 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
2261 Diag(Tok, diag::err_sizeof_parameter_pack);
2271 return Actions.ActOnSizeofParameterPackExpr(
getCurScope(),
2278 OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2279 Diag(OpTok, diag::warn_cxx98_compat_alignof);
2281 Diag(OpTok, diag::warn_c23_compat_keyword) << OpTok.
getName();
2283 Diag(OpTok, diag::warn_c2y_compat_keyword) << OpTok.
getName();
2291 SourceRange CastRange;
2299 case tok::kw_alignof:
2300 case tok::kw__Alignof:
2301 ExprKind = UETT_AlignOf;
2303 case tok::kw___alignof:
2304 ExprKind = UETT_PreferredAlignOf;
2306 case tok::kw_vec_step:
2307 ExprKind = UETT_VecStep;
2309 case tok::kw___builtin_omp_required_simd_align:
2310 ExprKind = UETT_OpenMPRequiredSimdAlign;
2312 case tok::kw___datasizeof:
2313 ExprKind = UETT_DataSizeOf;
2315 case tok::kw___builtin_vectorelements:
2316 ExprKind = UETT_VectorElements;
2318 case tok::kw__Countof:
2319 ExprKind = UETT_CountOf;
2322 Diag(OpTok, diag::ext_c2y_feature) << OpTok.
getName();
2329 return Actions.ActOnUnaryExprOrTypeTraitExpr(OpTok.
getLocation(),
2335 if (OpTok.
isOneOf(tok::kw_alignof, tok::kw__Alignof))
2348ExprResult Parser::ParseBuiltinPrimaryExpression() {
2350 const IdentifierInfo *BuiltinII = Tok.getIdentifierInfo();
2356 if (Tok.isNot(tok::l_paren))
2357 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
2366 default: llvm_unreachable(
"Not a builtin primary expression!");
2367 case tok::kw___builtin_va_arg: {
2370 if (ExpectAndConsume(tok::comma)) {
2377 if (Tok.isNot(tok::r_paren)) {
2378 Diag(Tok, diag::err_expected) << tok::r_paren;
2385 Res = Actions.ActOnVAArg(StartLoc, Expr.get(), Ty.
get(), ConsumeParen());
2388 case tok::kw___builtin_offsetof: {
2389 SourceLocation TypeLoc = Tok.getLocation();
2391 if (Tok.getLocation().isMacroID()) {
2393 Tok.getLocation(), PP.getSourceManager(),
getLangOpts());
2394 if (MacroName ==
"offsetof")
2407 if (ExpectAndConsume(tok::comma)) {
2413 if (Tok.isNot(tok::identifier)) {
2414 Diag(Tok, diag::err_expected) << tok::identifier;
2420 SmallVector<Sema::OffsetOfComponent, 4> Comps;
2422 Comps.push_back(Sema::OffsetOfComponent());
2423 Comps.back().isBrackets =
false;
2424 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2425 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
2429 if (Tok.is(tok::period)) {
2431 Comps.push_back(Sema::OffsetOfComponent());
2432 Comps.back().isBrackets =
false;
2435 if (Tok.isNot(tok::identifier)) {
2436 Diag(Tok, diag::err_expected) << tok::identifier;
2440 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
2442 }
else if (Tok.is(tok::l_square)) {
2443 if (CheckProhibitedCXX11Attribute())
2447 Comps.push_back(Sema::OffsetOfComponent());
2448 Comps.back().isBrackets =
true;
2451 Comps.back().LocStart = ST.getOpenLocation();
2457 Comps.back().U.E = Res.
get();
2460 Comps.back().LocEnd = ST.getCloseLocation();
2462 if (Tok.isNot(tok::r_paren)) {
2469 Res = Actions.ActOnBuiltinOffsetOf(
getCurScope(), StartLoc, TypeLoc,
2471 PT.getCloseLocation());
2478 case tok::kw___builtin_choose_expr: {
2480 if (
Cond.isInvalid()) {
2484 if (ExpectAndConsume(tok::comma)) {
2490 if (Expr1.isInvalid()) {
2494 if (ExpectAndConsume(tok::comma)) {
2500 if (Expr2.isInvalid()) {
2504 if (Tok.isNot(tok::r_paren)) {
2505 Diag(Tok, diag::err_expected) << tok::r_paren;
2508 Res = Actions.ActOnChooseExpr(StartLoc,
Cond.get(), Expr1.get(),
2509 Expr2.get(), ConsumeParen());
2512 case tok::kw___builtin_astype: {
2515 if (Expr.isInvalid()) {
2520 if (ExpectAndConsume(tok::comma)) {
2531 if (Tok.isNot(tok::r_paren)) {
2532 Diag(Tok, diag::err_expected) << tok::r_paren;
2537 Res = Actions.ActOnAsTypeExpr(Expr.get(), DestTy.
get(), StartLoc,
2541 case tok::kw___builtin_convertvector: {
2544 if (Expr.isInvalid()) {
2549 if (ExpectAndConsume(tok::comma)) {
2560 if (Tok.isNot(tok::r_paren)) {
2561 Diag(Tok, diag::err_expected) << tok::r_paren;
2566 Res = Actions.ActOnConvertVectorExpr(Expr.get(), DestTy.
get(), StartLoc,
2570 case tok::kw___builtin_COLUMN:
2571 case tok::kw___builtin_FILE:
2572 case tok::kw___builtin_FILE_NAME:
2573 case tok::kw___builtin_FUNCTION:
2574 case tok::kw___builtin_FUNCSIG:
2575 case tok::kw___builtin_LINE:
2576 case tok::kw___builtin_source_location: {
2578 if (Tok.isNot(tok::r_paren)) {
2579 Diag(Tok, diag::err_expected) << tok::r_paren;
2585 case tok::kw___builtin_FILE:
2587 case tok::kw___builtin_FILE_NAME:
2589 case tok::kw___builtin_FUNCTION:
2591 case tok::kw___builtin_FUNCSIG:
2593 case tok::kw___builtin_LINE:
2595 case tok::kw___builtin_COLUMN:
2597 case tok::kw___builtin_source_location:
2600 llvm_unreachable(
"invalid keyword");
2603 Res = Actions.ActOnSourceLocExpr(Kind, StartLoc, ConsumeParen());
2613 return ParsePostfixExpressionSuffix(Res.
get());
2616bool Parser::tryParseOpenMPArrayShapingCastPart() {
2617 assert(Tok.is(tok::l_square) &&
"Expected open bracket");
2618 bool ErrorFound =
true;
2619 TentativeParsingAction TPA(*
this);
2621 if (Tok.isNot(tok::l_square))
2626 while (!
SkipUntil(tok::r_square, tok::annot_pragma_openmp_end,
2629 if (Tok.isNot(tok::r_square))
2634 if (Tok.is(tok::r_paren)) {
2638 }
while (Tok.isNot(tok::annot_pragma_openmp_end));
2644Parser::ParseParenExpression(
ParenParseOption &ExprType,
bool StopIfCastExpr,
2648 assert(Tok.is(tok::l_paren) &&
"Not a paren expr!");
2651 if (T.consumeOpen())
2653 SourceLocation OpenLoc = T.getOpenLocation();
2655 PreferredType.enterParenExpr(Tok.getLocation(), OpenLoc);
2658 bool isAmbiguousTypeId;
2661 if (Tok.is(tok::code_completion)) {
2663 Actions.CodeCompletion().CodeCompleteExpression(
2664 getCurScope(), PreferredType.get(Tok.getLocation()),
2671 Tok.isOneOf(tok::kw___bridge,
2672 tok::kw___bridge_transfer,
2673 tok::kw___bridge_retained,
2674 tok::kw___bridge_retain));
2675 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2677 StringRef BridgeCastName = Tok.getName();
2679 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2680 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2690 Diag(Tok, OpenLoc.
isMacroID() ? diag::ext_gnu_statement_expr_macro
2691 : diag::ext_gnu_statement_expr);
2693 checkCompoundToken(OpenLoc, tok::l_paren, CompoundToken::StmtExprBegin);
2701 DeclContext *CodeDC = Actions.CurContext;
2705 "statement expr not in code context");
2707 Sema::ContextRAII SavedContext(Actions, CodeDC,
false);
2709 Actions.ActOnStartStmtExpr();
2711 StmtResult Stmt(ParseCompoundStatement(
true));
2715 if (!Stmt.isInvalid()) {
2719 Actions.ActOnStmtExprError();
2728 if (tokenKind == tok::kw___bridge)
2730 else if (tokenKind == tok::kw___bridge_transfer)
2732 else if (tokenKind == tok::kw___bridge_retained)
2737 assert(tokenKind == tok::kw___bridge_retain);
2739 if (!PP.getSourceManager().isInSystemHeader(BridgeKeywordLoc))
2740 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2742 "__bridge_retained");
2747 ColonProtection.restore();
2748 RParenLoc = T.getCloseLocation();
2750 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get().
get());
2756 return Actions.ObjC().ActOnObjCBridgedCast(
getCurScope(), OpenLoc, Kind,
2757 BridgeKeywordLoc, Ty.
get(),
2758 RParenLoc, SubExpr.
get());
2760 isTypeIdInParens(isAmbiguousTypeId)) {
2769 if (isAmbiguousTypeId && !StopIfCastExpr) {
2770 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,
2772 RParenLoc = T.getCloseLocation();
2777 DeclSpec DS(AttrFactory);
2778 ParseSpecifierQualifierList(DS);
2781 ParseDeclarator(DeclaratorInfo);
2786 if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) &&
2792 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2794 Result = ParseObjCMessageExpressionBody(SourceLocation(),
2800 ColonProtection.restore();
2801 RParenLoc = T.getCloseLocation();
2807 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2809 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2819 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2833 Result = ParseCastExpression(
2839 if (!
Result.isInvalid()) {
2841 DeclaratorInfo, CastTy,
2842 RParenLoc,
Result.get());
2846 if (!
Result.isInvalid()) {
2858 if (DeclaratorInfo.isInvalidType())
2863 if (StopIfCastExpr) {
2867 Ty = Actions.ActOnTypeName(DeclaratorInfo);
2875 Tok.getIdentifierInfo() == Ident_super &&
2878 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2879 << SourceRange(OpenLoc, RParenLoc);
2883 PreferredType.enterTypeCast(Tok.getLocation(), CastTy.
get());
2886 Result = ParseCastExpression(
2890 if (!
Result.isInvalid()) {
2892 DeclaratorInfo, CastTy,
2893 RParenLoc,
Result.get());
2898 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2909 ExprVector ArgExprs;
2911 if (!ParseSimpleExpressionList(ArgExprs)) {
2915 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2917 return ParseFoldExpression(ArgExprs[0], T);
2921 Result = Actions.ActOnParenListExpr(OpenLoc, Tok.getLocation(),
2924 }
else if (
getLangOpts().OpenMP >= 50 && OpenMPDirectiveParsing &&
2926 tryParseOpenMPArrayShapingCastPart()) {
2927 bool ErrorFound =
false;
2928 SmallVector<Expr *, 4> OMPDimensions;
2929 SmallVector<SourceRange, 4> OMPBracketsRanges;
2936 while (!
SkipUntil(tok::r_square, tok::r_paren,
2941 OMPDimensions.push_back(NumElements.
get());
2942 OMPBracketsRanges.push_back(TS.getRange());
2943 }
while (Tok.isNot(tok::r_paren));
2946 RParenLoc = T.getCloseLocation();
2950 }
else if (!
Result.isInvalid()) {
2951 Result = Actions.OpenMP().ActOnOMPArrayShapingExpr(
2952 Result.get(), OpenLoc, RParenLoc, OMPDimensions, OMPBracketsRanges);
2960 isFoldOperator(Tok.getKind()) &&
NextToken().
is(tok::ellipsis)) {
2962 return ParseFoldExpression(
Result, T);
2967 if (!
Result.isInvalid() && Tok.is(tok::r_paren))
2969 Actions.ActOnParenExpr(OpenLoc, Tok.getLocation(),
Result.get());
2973 if (
Result.isInvalid()) {
2979 RParenLoc = T.getCloseLocation();
2984Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
2987 assert(Tok.is(tok::l_brace) &&
"Not a compound literal!");
2989 Diag(LParenLoc, diag::ext_c99_compound_literal);
2990 PreferredType.enterTypeCast(Tok.getLocation(), Ty.
get());
2992 if (!
Result.isInvalid() && Ty)
2993 return Actions.ActOnCompoundLiteral(LParenLoc, Ty, RParenLoc,
Result.get());
3010 "Not a string-literal-like token!");
3018 StringToks.push_back(
Tok);
3023 assert(!AllowUserDefinedLiteral &&
"UDL are always evaluated");
3028 return Actions.ActOnStringLiteral(StringToks,
3033ExprResult Parser::ParseGenericSelectionExpression() {
3034 assert(Tok.is(tok::kw__Generic) &&
"_Generic keyword expected");
3036 diagnoseUseOfC11Keyword(Tok);
3040 if (T.expectAndConsume())
3047 if (isTypeIdForGenericSelection()) {
3054 SourceLocation Loc = LIT->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
3056 : diag::ext_c2y_generic_with_type_arg);
3069 if (ExpectAndConsume(tok::comma)) {
3074 SourceLocation DefaultLoc;
3075 SmallVector<ParsedType, 12> Types;
3079 if (Tok.is(tok::kw_default)) {
3083 Diag(Tok, diag::err_duplicate_default_assoc);
3084 Diag(DefaultLoc, diag::note_previous_default_assoc);
3099 Types.push_back(Ty);
3101 if (ExpectAndConsume(tok::colon)) {
3113 Exprs.push_back(ER.
get());
3117 if (T.getCloseLocation().isInvalid())
3120 void *ExprOrTy = ControllingExpr.
isUsable()
3121 ? ControllingExpr.
get()
3124 return Actions.ActOnGenericSelectionExpr(
3125 KeyLoc, DefaultLoc, T.getCloseLocation(), ControllingExpr.
isUsable(),
3126 ExprOrTy, Types, Exprs);
3137 SourceLocation FirstOpLoc;
3139 Kind = Tok.getKind();
3140 assert(isFoldOperator(Kind) &&
"missing fold-operator");
3144 assert(Tok.is(tok::ellipsis) &&
"not a fold-expression");
3148 if (Tok.isNot(tok::r_paren)) {
3149 if (!isFoldOperator(Tok.getKind()))
3150 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
3152 if (Kind != tok::unknown && Tok.getKind() != Kind)
3153 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
3154 << SourceRange(FirstOpLoc);
3155 Kind = Tok.getKind();
3166 ? diag::warn_cxx14_compat_fold_expression
3167 : diag::ext_fold_expression);
3171 Kind, EllipsisLoc, RHS.
get(),
3175void Parser::injectEmbedTokens() {
3176 EmbedAnnotationData *
Data =
3177 reinterpret_cast<EmbedAnnotationData *
>(Tok.getAnnotationValue());
3178 MutableArrayRef<Token> Toks(PP.getPreprocessorAllocator().Allocate<Token>(
3179 Data->BinaryData.size() * 2 - 1),
3180 Data->BinaryData.size() * 2 - 1);
3182 for (
auto &Byte :
Data->BinaryData) {
3183 Toks[I].startToken();
3184 Toks[I].setKind(tok::binary_data);
3185 Toks[I].setLocation(Tok.getLocation());
3186 Toks[I].setLength(1);
3187 Toks[I].setLiteralData(&Byte);
3188 if (I != ((
Data->BinaryData.size() - 1) * 2)) {
3189 Toks[I + 1].startToken();
3190 Toks[I + 1].setKind(tok::comma);
3191 Toks[I + 1].setLocation(Tok.getLocation());
3195 PP.EnterTokenStream(std::move(Toks),
true,
3201 llvm::function_ref<
void()> ExpressionStarts,
3202 bool FailImmediatelyOnInvalidExpr) {
3203 bool SawError =
false;
3205 if (ExpressionStarts)
3210 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3211 Expr = ParseBraceInitializer();
3215 if (Tok.is(tok::ellipsis))
3217 else if (Tok.is(tok::code_completion)) {
3229 if (FailImmediatelyOnInvalidExpr)
3233 Exprs.push_back(Expr.
get());
3236 if (Tok.isNot(tok::comma))
3241 checkPotentialAngleBracketDelimiter(Comma);
3252 Exprs.push_back(Expr.
get());
3256 if (Tok.isNot(tok::comma) ||
NextToken().
is(tok::ellipsis))
3262 checkPotentialAngleBracketDelimiter(Comma);
3267 if (Tok.is(tok::code_completion)) {
3269 Actions.CodeCompletion().CodeCompleteOrdinaryName(
3275 DeclSpec DS(AttrFactory);
3276 ParseSpecifierQualifierList(DS);
3282 ParseDeclarator(DeclaratorInfo);
3284 MaybeParseGNUAttributes(DeclaratorInfo);
3287 Actions.ActOnBlockArguments(CaretLoc, DeclaratorInfo,
getCurScope());
3290ExprResult Parser::ParseBlockLiteralExpression() {
3291 assert(Tok.is(tok::caret) &&
"block literal starts with ^");
3294 PrettyStackTraceLoc CrashInfo(PP.getSourceManager(), CaretLoc,
3295 "block literal parsing");
3308 DeclSpec DS(AttrFactory);
3314 ParamInfo.SetSourceRange(SourceRange(Tok.getLocation(), Tok.getLocation()));
3318 if (Tok.is(tok::l_paren)) {
3319 ParseParenDeclarator(ParamInfo);
3323 SourceLocation Tmp = ParamInfo.getSourceRange().getEnd();
3324 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
3325 ParamInfo.SetRangeEnd(Tmp);
3326 if (ParamInfo.isInvalidType()) {
3334 MaybeParseGNUAttributes(ParamInfo);
3337 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3338 }
else if (!Tok.is(tok::l_brace)) {
3339 ParseBlockId(CaretLoc);
3342 SourceLocation NoLoc;
3343 ParamInfo.AddTypeInfo(
3361 CaretLoc, ParamInfo),
3364 MaybeParseGNUAttributes(ParamInfo);
3367 Actions.ActOnBlockArguments(CaretLoc, ParamInfo,
getCurScope());
3372 if (!Tok.is(tok::l_brace)) {
3374 Diag(Tok, diag::err_expected_expression);
3378 EnterExpressionEvaluationContextForFunction PotentiallyEvaluated(
3380 StmtResult Stmt(ParseCompoundStatementBody());
3382 if (!Stmt.isInvalid())
3391 return Actions.ObjC().ActOnObjCBoolLiteral(
ConsumeToken(), Kind);
3398 llvm::SmallSet<StringRef, 4> Platforms;
3399 bool HasOtherPlatformSpec =
false;
3401 for (
const auto &Spec : AvailSpecs) {
3402 if (Spec.isOtherPlatformSpec()) {
3403 if (HasOtherPlatformSpec) {
3404 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_star);
3408 HasOtherPlatformSpec =
true;
3412 bool Inserted = Platforms.insert(Spec.getPlatform()).second;
3417 StringRef Platform = Spec.getPlatform();
3418 P.
Diag(Spec.getBeginLoc(), diag::err_availability_query_repeated_platform)
3419 << Spec.getEndLoc() << Platform;
3424 if (!HasOtherPlatformSpec) {
3425 SourceLocation InsertWildcardLoc = AvailSpecs.back().getEndLoc();
3426 P.
Diag(InsertWildcardLoc, diag::err_availability_query_wildcard_required)
3434std::optional<AvailabilitySpec> Parser::ParseAvailabilitySpec() {
3435 if (Tok.is(tok::star)) {
3439 if (Tok.is(tok::code_completion)) {
3441 Actions.CodeCompletion().CodeCompleteAvailabilityPlatformName();
3442 return std::nullopt;
3444 if (Tok.isNot(tok::identifier)) {
3445 Diag(Tok, diag::err_avail_query_expected_platform_name);
3446 return std::nullopt;
3449 IdentifierLoc *PlatformIdentifier = ParseIdentifierLoc();
3450 SourceRange VersionRange;
3451 VersionTuple Version = ParseVersionTuple(VersionRange);
3453 if (Version.empty())
3454 return std::nullopt;
3456 StringRef GivenPlatform =
3458 StringRef Platform =
3459 AvailabilityAttr::canonicalizePlatformName(GivenPlatform);
3461 if (AvailabilityAttr::getPrettyPlatformName(Platform).empty() ||
3462 (GivenPlatform.contains(
"xros") || GivenPlatform.contains(
"xrOS"))) {
3464 diag::err_avail_query_unrecognized_platform_name)
3466 return std::nullopt;
3469 return AvailabilitySpec(Version, Platform, PlatformIdentifier->
getLoc(),
3475 assert(Tok.is(tok::kw___builtin_available) ||
3476 Tok.isObjCAtKeyword(tok::objc_available));
3482 if (
Parens.expectAndConsume())
3485 SmallVector<AvailabilitySpec, 4> AvailSpecs;
3486 bool HasError =
false;
3488 std::optional<AvailabilitySpec> Spec = ParseAvailabilitySpec();
3492 AvailSpecs.push_back(*Spec);
3505 if (
Parens.consumeClose())
3508 return Actions.ObjC().ActOnObjCAvailabilityCheckExpr(
3509 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 { ....
SourceLocation getOpenLocation() const
SourceLocation getCloseLocation() const
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isFileContext() const
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
void setLength(unsigned Len)
void setKind(tok::TokenKind K)
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
tok::TokenKind getKind() const
bool isOneOf(Ts... Ks) const
void setLocation(SourceLocation L)
void startToken()
Reset all flags to cleared.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
bool isFunctionType() const
bool isVectorType() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
SourceLocation getEndLoc() const LLVM_READONLY
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
TypoCorrectionTypeBehavior
If a typo should be encountered, should typo correction suggest type names, non type names,...
bool tokenIsLikeStringLiteral(const Token &Tok, const LangOptions &LO)
Return true if the token is a string literal, or a function local predefined macro,...
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
@ Result
The result type of a method or function.
ActionResult< ParsedType > TypeResult
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
@ OBC_Bridge
Bridging via __bridge, which does nothing but reinterpret the bits.
@ OBC_BridgeTransfer
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC.
@ OBC_BridgeRetained
Bridging via __bridge_retain, which makes an ARC object available as a +1 C pointer.
@ Type
The name was classified as a type.
prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, bool CPlusPlus11)
Return the precedence of the specified binary operator token.
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
ParenExprKind
In a call to ParseParenExpression, are the initial parentheses part of an operator that requires the ...
U cast(CodeGen::Address addr)
CastParseKind
Control what ParseCastExpression will parse.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
ParenParseOption
ParenParseOption - Control what ParseParenExpression will parse.
ActionResult< Expr * > ExprResult
@ Parens
New-expression has a C++98 paren-delimited initializer.
@ EST_None
no exception specification
ActionResult< Stmt * > StmtResult
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
TemplateNameKind Kind
The kind of template that Template refers to.