32 #include "llvm/ADT/SmallString.h"
33 #include "llvm/ADT/SmallVector.h"
34 using namespace clang;
122 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
133 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
140 Parser::ParseExpressionWithLeadingExtension(
SourceLocation ExtLoc) {
146 LHS = ParseCastExpression(
false);
149 if (!LHS.isInvalid())
153 return ParseRHSOfBinaryExpression(LHS,
prec::Comma);
158 if (Tok.
is(tok::code_completion)) {
164 if (Tok.
is(tok::kw_throw))
165 return ParseThrowExpression();
166 if (Tok.
is(tok::kw_co_yield))
167 return ParseCoyieldExpression();
185 Parser::ParseAssignmentExprWithObjCMessageExprStart(
SourceLocation LBracLoc,
188 Expr *ReceiverExpr) {
190 = ParseObjCMessageExpressionBody(LBracLoc, SuperLoc,
191 ReceiverType, ReceiverExpr);
192 R = ParsePostfixExpressionSuffix(R);
205 ExprResult LHS(ParseCastExpression(
false,
false, isTypeCast));
228 bool Parser::isNotExpressionStart() {
230 if (K == tok::l_brace || K == tok::r_brace ||
231 K == tok::kw_for || K == tok::kw_while ||
232 K == tok::kw_if || K == tok::kw_else ||
233 K == tok::kw_goto || K == tok::kw_try)
236 return isKnownToBeDeclarationSpecifier();
251 GreaterThanIsOperator,
259 if (NextTokPrec < MinPrec)
271 if (OpToken.
is(tok::comma) && isNotExpressionStart()) {
290 if (Tok.
isNot(tok::colon)) {
299 if (TernaryMiddle.isInvalid()) {
302 TernaryMiddle =
nullptr;
307 TernaryMiddle =
nullptr;
308 Diag(Tok, diag::ext_gnu_conditional_expr);
317 const char *FIText =
": ";
321 bool IsInvalid =
false;
322 const char *SourcePtr =
324 if (!IsInvalid && *SourcePtr ==
' ') {
327 if (!IsInvalid && *SourcePtr ==
' ') {
334 Diag(Tok, diag::err_expected)
336 Diag(OpToken, diag::note_matching) << tok::question;
360 bool RHSIsInitList =
false;
362 RHS = ParseBraceInitializer();
363 RHSIsInitList =
true;
367 RHS = ParseCastExpression(
false);
373 if (TernaryMiddle.isUsable())
390 if (ThisPrec < NextTokPrec ||
391 (ThisPrec == NextTokPrec && isRightAssoc)) {
393 Diag(Tok, diag::err_init_list_bin_op)
402 RHS = ParseRHSOfBinaryExpression(RHS,
403 static_cast<prec::Level>(ThisPrec + !isRightAssoc));
404 RHSIsInitList =
false;
410 if (TernaryMiddle.isUsable())
421 Diag(OpToken, diag::warn_cxx98_compat_generalized_initializer_lists)
424 Diag(OpToken, diag::err_init_list_bin_op)
433 if (TernaryMiddle.isInvalid()) {
437 if (!GreaterThanIsOperator && OpToken.
is(tok::greatergreater))
439 diag::warn_cxx11_right_shift_in_template_arg,
447 LHS.
get(), TernaryMiddle.get(),
461 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
462 bool isAddressOfOperand,
463 TypeCastState isTypeCast) {
465 ExprResult Res = ParseCastExpression(isUnaryExpression,
470 Diag(Tok, diag::err_expected_expression);
477 CastExpressionIdValidator(
Token Next,
bool AllowTypes,
bool AllowNonTypes)
478 : NextToken(Next), AllowNonTypes(AllowNonTypes) {
479 WantTypeSpecifiers = WantFunctionLikeCasts = AllowTypes;
482 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
487 if (isa<TypeDecl>(ND))
488 return WantTypeSpecifiers;
493 if (!NextToken.isOneOf(tok::equal, tok::arrow, tok::period))
496 for (
auto *
C : candidate) {
498 if (isa<ValueDecl>(ND) && !isa<FunctionDecl>(ND))
681 ExprResult Parser::ParseCastExpression(
bool isUnaryExpression,
682 bool isAddressOfOperand,
684 TypeCastState isTypeCast) {
704 ParenParseOption ParenExprType =
705 (isUnaryExpression && !
getLangOpts().CPlusPlus) ? CompoundLiteral
709 Res = ParseParenExpression(ParenExprType,
false,
712 switch (ParenExprType) {
713 case SimpleExpr:
break;
715 case CompoundLiteral:
729 case tok::numeric_constant:
739 return ParseCXXBoolLiteral();
741 case tok::kw___objc_yes:
742 case tok::kw___objc_no:
743 return ParseObjCBoolLiteral();
745 case tok::kw_nullptr:
746 Diag(Tok, diag::warn_cxx98_compat_nullptr);
749 case tok::annot_primary_expr:
750 assert(Res.
get() ==
nullptr &&
"Stray primary-expression annotation?");
751 Res = getExprAnnotation(Tok);
755 case tok::kw___super:
756 case tok::kw_decltype:
760 assert(Tok.
isNot(tok::kw_decltype) && Tok.
isNot(tok::kw___super));
761 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
763 case tok::identifier: {
776 if (Next.
is(tok::l_paren) &&
777 Tok.
is(tok::identifier) &&
781 if (RevertibleTypeTraits.empty()) {
782 #define RTT_JOIN(X,Y) X##Y
783 #define REVERTIBLE_TYPE_TRAIT(Name) \
784 RevertibleTypeTraits[PP.getIdentifierInfo(#Name)] \
785 = RTT_JOIN(tok::kw_,Name)
836 #undef REVERTIBLE_TYPE_TRAIT
844 = RevertibleTypeTraits.find(II);
845 if (Known != RevertibleTypeTraits.end()) {
847 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
848 NotCastExpr, isTypeCast);
852 if ((!ColonIsSacred && Next.
is(tok::colon)) ||
853 Next.
isOneOf(tok::coloncolon, tok::less, tok::l_paren,
858 if (!Tok.
is(tok::identifier))
859 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
876 if (Tok.
isNot(tok::identifier) &&
878 Diag(Tok, diag::err_expected_property_name);
893 if (
getLangOpts().ObjC1 && &II == Ident_super && !InMessageExpression &&
895 ((Tok.
is(tok::identifier) &&
897 Tok.
is(tok::code_completion))) {
909 ((Tok.
is(tok::identifier) && !InMessageExpression) ||
910 Tok.
is(tok::code_completion))) {
912 if (Tok.
is(tok::code_completion) ||
913 Next.
is(tok::colon) || Next.
is(tok::r_square))
915 if (Typ.get()->isObjCObjectOrInterfaceType()) {
918 DS.SetRangeStart(ILoc);
919 DS.SetRangeEnd(ILoc);
920 const char *PrevSpec =
nullptr;
922 DS.SetTypeSpecType(
TST_typename, ILoc, PrevSpec, DiagID, Typ,
939 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
940 isAddressOfOperand =
false;
949 auto Validator = llvm::make_unique<CastExpressionIdValidator>(
951 Validator->IsAddressOfOperand = isAddressOfOperand;
952 if (Tok.isOneOf(tok::periodstar, tok::arrowstar)) {
953 Validator->WantExpressionKeywords =
false;
954 Validator->WantRemainingKeywords =
false;
956 Validator->WantRemainingKeywords = Tok.
isNot(tok::r_paren);
960 getCurScope(), ScopeSpec, TemplateKWLoc, Name, Tok.is(tok::l_paren),
961 isAddressOfOperand, std::move(Validator),
963 Tok.is(tok::r_paren) ?
nullptr : &Replacement);
964 if (!Res.isInvalid() && !Res.get()) {
965 UnconsumeToken(Replacement);
966 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
967 NotCastExpr, isTypeCast);
971 case tok::char_constant:
972 case tok::wide_char_constant:
973 case tok::utf8_char_constant:
974 case tok::utf16_char_constant:
975 case tok::utf32_char_constant:
979 case tok::kw___func__:
980 case tok::kw___FUNCTION__:
981 case tok::kw___FUNCDNAME__:
982 case tok::kw___FUNCSIG__:
983 case tok::kw_L__FUNCTION__:
984 case tok::kw___PRETTY_FUNCTION__:
988 case tok::string_literal:
989 case tok::wide_string_literal:
990 case tok::utf8_string_literal:
991 case tok::utf16_string_literal:
992 case tok::utf32_string_literal:
993 Res = ParseStringLiteralExpression(
true);
995 case tok::kw__Generic:
996 Res = ParseGenericSelectionExpression();
998 case tok::kw___builtin_va_arg:
999 case tok::kw___builtin_offsetof:
1000 case tok::kw___builtin_choose_expr:
1001 case tok::kw___builtin_astype:
1002 case tok::kw___builtin_convertvector:
1003 return ParseBuiltinPrimaryExpression();
1004 case tok::kw___null:
1008 case tok::minusminus: {
1020 if (!Res.isInvalid())
1027 Res = ParseCastExpression(
false,
true);
1028 if (!Res.isInvalid())
1038 case tok::kw___real:
1039 case tok::kw___imag: {
1041 Res = ParseCastExpression(
false);
1042 if (!Res.isInvalid())
1047 case tok::kw_co_await: {
1049 Res = ParseCastExpression(
false);
1050 if (!Res.isInvalid())
1055 case tok::kw___extension__:{
1059 Res = ParseCastExpression(
false);
1060 if (!Res.isInvalid())
1064 case tok::kw__Alignof:
1066 Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
1068 case tok::kw_alignof:
1069 case tok::kw___alignof:
1071 case tok::kw_sizeof:
1073 case tok::kw_vec_step:
1075 case tok::kw___builtin_omp_required_simd_align:
1076 return ParseUnaryExprOrTypeTraitExpression();
1079 if (Tok.isNot(tok::identifier))
1080 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
1083 return ExprError(
Diag(Tok, diag::err_address_of_label_outside_fn));
1085 Diag(AmpAmpLoc, diag::ext_gnu_address_of_label);
1092 case tok::kw_const_cast:
1093 case tok::kw_dynamic_cast:
1094 case tok::kw_reinterpret_cast:
1095 case tok::kw_static_cast:
1096 Res = ParseCXXCasts();
1098 case tok::kw_typeid:
1099 Res = ParseCXXTypeid();
1101 case tok::kw___uuidof:
1102 Res = ParseCXXUuidof();
1105 Res = ParseCXXThis();
1108 case tok::annot_typename:
1109 if (isStartOfObjCClassMessageMissingOpenBracket()) {
1114 DS.SetRangeStart(Tok.getLocation());
1115 DS.SetRangeEnd(Tok.getLastLoc());
1117 const char *PrevSpec =
nullptr;
1119 DS.SetTypeSpecType(
TST_typename, Tok.getAnnotationEndLoc(),
1120 PrevSpec, DiagID, Type,
1135 case tok::annot_decltype:
1137 case tok::kw_wchar_t:
1138 case tok::kw_char16_t:
1139 case tok::kw_char32_t:
1144 case tok::kw___int64:
1145 case tok::kw___int128:
1146 case tok::kw_signed:
1147 case tok::kw_unsigned:
1150 case tok::kw_double:
1152 case tok::kw_typename:
1153 case tok::kw_typeof:
1154 case tok::kw___vector: {
1156 Diag(Tok, diag::err_expected_expression);
1160 if (SavedKind == tok::kw_typename) {
1177 ParseCXXSimpleTypeSpecifier(DS);
1178 if (Tok.isNot(tok::l_paren) &&
1179 (!
getLangOpts().CPlusPlus11 || Tok.isNot(tok::l_brace)))
1180 return ExprError(
Diag(Tok, diag::err_expected_lparen_after_type)
1181 << DS.getSourceRange());
1183 if (Tok.is(tok::l_brace))
1184 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1186 Res = ParseCXXTypeConstructExpression(DS);
1190 case tok::annot_cxxscope: {
1195 if (!Tok.is(tok::annot_cxxscope))
1196 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1197 NotCastExpr, isTypeCast);
1200 if (Next.
is(tok::annot_template_id)) {
1207 ParseOptionalCXXScopeSpecifier(SS,
ParsedType(),
1209 AnnotateTemplateIdTokenAsType();
1210 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1211 NotCastExpr, isTypeCast);
1216 Res = ParseCXXIdExpression(isAddressOfOperand);
1220 case tok::annot_template_id: {
1226 AnnotateTemplateIdTokenAsType();
1227 return ParseCastExpression(isUnaryExpression, isAddressOfOperand,
1228 NotCastExpr, isTypeCast);
1234 case tok::kw_operator:
1235 Res = ParseCXXIdExpression(isAddressOfOperand);
1238 case tok::coloncolon: {
1243 if (!Tok.is(tok::coloncolon))
1244 return ParseCastExpression(isUnaryExpression, isAddressOfOperand);
1249 if (Tok.is(tok::kw_new))
1250 return ParseCXXNewExpression(
true, CCLoc);
1251 if (Tok.is(tok::kw_delete))
1252 return ParseCXXDeleteExpression(
true, CCLoc);
1255 Diag(CCLoc, diag::err_expected_expression);
1260 return ParseCXXNewExpression(
false, Tok.getLocation());
1262 case tok::kw_delete:
1263 return ParseCXXDeleteExpression(
false, Tok.getLocation());
1265 case tok::kw_noexcept: {
1266 Diag(Tok, diag::warn_cxx98_compat_noexcept_expr);
1270 if (T.expectAndConsume(diag::err_expected_lparen_after,
"noexcept"))
1282 Result.
get(), T.getCloseLocation());
1286 #define TYPE_TRAIT(N,Spelling,K) \
1287 case tok::kw_##Spelling:
1288 #include "clang/Basic/TokenKinds.def"
1289 return ParseTypeTrait();
1291 case tok::kw___array_rank:
1292 case tok::kw___array_extent:
1293 return ParseArrayTypeTrait();
1295 case tok::kw___is_lvalue_expr:
1296 case tok::kw___is_rvalue_expr:
1297 return ParseExpressionTrait();
1301 return ParseObjCAtExpression(AtLoc);
1304 Res = ParseBlockLiteralExpression();
1306 case tok::code_completion: {
1319 Res = TryParseLambdaExpression();
1320 if (!Res.isInvalid() && !Res.get())
1321 Res = ParseObjCMessageExpression();
1324 Res = ParseLambdaExpression();
1328 Res = ParseObjCMessageExpression();
1342 Res = ParsePostfixExpressionSuffix(Res);
1344 if (
Expr *PostfixExpr = Res.get()) {
1345 QualType Ty = PostfixExpr->getType();
1347 Diag(PostfixExpr->getExprLoc(),
1348 diag::err_opencl_taking_function_address_parser);
1377 Parser::ParsePostfixExpressionSuffix(
ExprResult LHS) {
1382 switch (Tok.getKind()) {
1383 case tok::code_completion:
1384 if (InMessageExpression)
1391 case tok::identifier:
1395 if (
getLangOpts().ObjC1 && !InMessageExpression &&
1406 case tok::l_square: {
1413 if (
getLangOpts().ObjC1 && Tok.isAtStartOfLine() &&
1414 isSimpleObjCMessageExpression())
1419 if (CheckProhibitedCXX11Attribute())
1424 Loc = T.getOpenLocation();
1428 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
1429 Idx = ParseBraceInitializer();
1433 if (!Tok.is(tok::colon)) {
1437 if (Tok.is(tok::colon)) {
1440 if (Tok.isNot(tok::r_square))
1449 Tok.is(tok::r_square)) {
1471 case tok::lesslessless: {
1476 Expr *ExecConfig =
nullptr;
1480 if (OpKind == tok::lesslessless) {
1481 ExprVector ExecConfigExprs;
1482 CommaLocsTy ExecConfigCommaLocs;
1485 if (ParseSimpleExpressionList(ExecConfigExprs, ExecConfigCommaLocs)) {
1496 Diag(Tok, diag::err_expected) << tok::greatergreatergreater;
1497 Diag(OpenLoc, diag::note_matching) << tok::lesslessless;
1503 if (ExpectAndConsume(tok::l_paren))
1506 Loc = PrevTokLocation;
1517 ExecConfig = ECResult.
get();
1521 Loc = PT.getOpenLocation();
1524 ExprVector ArgExprs;
1525 CommaLocsTy CommaLocs;
1527 if (Tok.is(tok::code_completion)) {
1533 if (OpKind == tok::l_paren || !LHS.
isInvalid()) {
1534 if (Tok.isNot(tok::r_paren)) {
1535 if (ParseExpressionList(ArgExprs, CommaLocs, [&] {
1541 for (
auto &
E : ArgExprs)
1550 }
else if (Tok.isNot(tok::r_paren)) {
1551 bool HadDelayedTypo =
false;
1553 HadDelayedTypo =
true;
1554 for (
auto &
E : ArgExprs)
1556 HadDelayedTypo =
true;
1566 assert((ArgExprs.size() == 0 ||
1567 ArgExprs.size()-1 == CommaLocs.size())&&
1568 "Unexpected number of commas!");
1570 ArgExprs, Tok.getLocation(),
1586 bool MayBePseudoDestructor =
false;
1590 if (BaseType && Tok.is(tok::l_paren) &&
1593 Diag(OpLoc, diag::err_function_is_not_record)
1594 << OpKind << Base->getSourceRange()
1596 return ParsePostfixExpressionSuffix(Base);
1600 OpLoc, OpKind, ObjectType,
1601 MayBePseudoDestructor);
1605 ParseOptionalCXXScopeSpecifier(SS, ObjectType,
1607 &MayBePseudoDestructor);
1612 if (Tok.is(tok::code_completion)) {
1615 OpLoc, OpKind == tok::arrow);
1621 if (MayBePseudoDestructor && !LHS.
isInvalid()) {
1622 LHS = ParseCXXPseudoDestructor(LHS.
get(), OpLoc, OpKind, SS,
1636 if (
getLangOpts().ObjC2 && OpKind == tok::period &&
1637 Tok.is(tok::kw_class)) {
1653 ObjectType, TemplateKWLoc, Name)) {
1660 OpKind, SS, TemplateKWLoc,
Name,
1661 CurParsedObjCImpl ? CurParsedObjCImpl->Dcl
1666 case tok::minusminus:
1669 Tok.getKind(), LHS.
get());
1701 Parser::ParseExprAfterUnaryExprOrTypeTrait(
const Token &OpTok,
1706 assert(OpTok.
isOneOf(tok::kw_typeof, tok::kw_sizeof, tok::kw___alignof,
1707 tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
1708 tok::kw___builtin_omp_required_simd_align) &&
1709 "Not a typeof/sizeof/alignof/vec_step expression!");
1714 if (Tok.isNot(tok::l_paren)) {
1717 if (OpTok.
isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1718 tok::kw__Alignof)) {
1719 if (isTypeIdUnambiguously()) {
1721 ParseSpecifierQualifierList(DS);
1723 ParseDeclarator(DeclaratorInfo);
1727 Diag(LParenLoc, diag::err_expected_parentheses_around_typename)
1743 Operand = ParseCastExpression(
true);
1749 ParenParseOption ExprType =
CastExpr;
1752 Operand = ParseParenExpression(ExprType,
true,
1753 false, CastTy, RParenLoc);
1768 if (!Operand.isInvalid())
1769 Operand = ParsePostfixExpressionSuffix(Operand.get());
1791 ExprResult Parser::ParseUnaryExprOrTypeTraitExpression() {
1792 assert(Tok.isOneOf(tok::kw_sizeof, tok::kw___alignof, tok::kw_alignof,
1793 tok::kw__Alignof, tok::kw_vec_step,
1794 tok::kw___builtin_omp_required_simd_align) &&
1795 "Not a sizeof/alignof/vec_step expression!");
1800 if (Tok.is(tok::ellipsis) && OpTok.is(tok::kw_sizeof)) {
1805 if (Tok.is(tok::l_paren)) {
1808 LParenLoc = T.getOpenLocation();
1809 if (Tok.is(tok::identifier)) {
1810 Name = Tok.getIdentifierInfo();
1813 RParenLoc = T.getCloseLocation();
1817 Diag(Tok, diag::err_expected_parameter_pack);
1820 }
else if (Tok.is(tok::identifier)) {
1821 Name = Tok.getIdentifierInfo();
1825 Diag(LParenLoc, diag::err_paren_sizeof_parameter_pack)
1830 Diag(Tok, diag::err_sizeof_parameter_pack);
1840 OpTok.getLocation(),
1845 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
1846 Diag(OpTok, diag::warn_cxx98_compat_alignof);
1854 ExprResult Operand = ParseExprAfterUnaryExprOrTypeTrait(OpTok,
1860 if (OpTok.isOneOf(tok::kw_alignof, tok::kw___alignof, tok::kw__Alignof))
1862 else if (OpTok.is(tok::kw_vec_step))
1864 else if (OpTok.is(tok::kw___builtin_omp_required_simd_align))
1874 if (OpTok.isOneOf(tok::kw_alignof, tok::kw__Alignof))
1875 Diag(OpTok, diag::ext_alignof_expr) << OpTok.getIdentifierInfo();
1903 ExprResult Parser::ParseBuiltinPrimaryExpression() {
1911 if (Tok.isNot(tok::l_paren))
1912 return ExprError(
Diag(Tok, diag::err_expected_after) << BuiltinII
1921 default: llvm_unreachable(
"Not a builtin primary expression!");
1922 case tok::kw___builtin_va_arg: {
1925 if (ExpectAndConsume(tok::comma)) {
1932 if (Tok.isNot(tok::r_paren)) {
1933 Diag(Tok, diag::err_expected) << tok::r_paren;
1943 case tok::kw___builtin_offsetof: {
1951 if (ExpectAndConsume(tok::comma)) {
1957 if (Tok.isNot(tok::identifier)) {
1958 Diag(Tok, diag::err_expected) << tok::identifier;
1967 Comps.back().isBrackets =
false;
1968 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
1969 Comps.back().LocStart = Comps.back().LocEnd =
ConsumeToken();
1973 if (Tok.is(tok::period)) {
1976 Comps.back().isBrackets =
false;
1979 if (Tok.isNot(tok::identifier)) {
1980 Diag(Tok, diag::err_expected) << tok::identifier;
1984 Comps.back().U.IdentInfo = Tok.getIdentifierInfo();
1987 }
else if (Tok.is(tok::l_square)) {
1988 if (CheckProhibitedCXX11Attribute())
1993 Comps.back().isBrackets =
true;
1996 Comps.back().LocStart = ST.getOpenLocation();
2002 Comps.back().U.E = Res.
get();
2005 Comps.back().LocEnd = ST.getCloseLocation();
2007 if (Tok.isNot(tok::r_paren)) {
2016 PT.getCloseLocation());
2023 case tok::kw___builtin_choose_expr: {
2025 if (Cond.isInvalid()) {
2029 if (ExpectAndConsume(tok::comma)) {
2035 if (Expr1.isInvalid()) {
2039 if (ExpectAndConsume(tok::comma)) {
2045 if (Expr2.isInvalid()) {
2049 if (Tok.isNot(tok::r_paren)) {
2050 Diag(Tok, diag::err_expected) << tok::r_paren;
2054 Expr2.get(), ConsumeParen());
2057 case tok::kw___builtin_astype: {
2060 if (
Expr.isInvalid()) {
2065 if (ExpectAndConsume(tok::comma)) {
2076 if (Tok.isNot(tok::r_paren)) {
2077 Diag(Tok, diag::err_expected) << tok::r_paren;
2086 case tok::kw___builtin_convertvector: {
2089 if (
Expr.isInvalid()) {
2094 if (ExpectAndConsume(tok::comma)) {
2105 if (Tok.isNot(tok::r_paren)) {
2106 Diag(Tok, diag::err_expected) << tok::r_paren;
2122 return ParsePostfixExpressionSuffix(Res.
get());
2151 Parser::ParseParenExpression(ParenParseOption &ExprType,
bool stopIfCastExpr,
2154 assert(Tok.is(tok::l_paren) &&
"Not a paren expr!");
2157 if (T.consumeOpen())
2162 bool isAmbiguousTypeId;
2165 if (Tok.is(tok::code_completion)) {
2175 Tok.isOneOf(tok::kw___bridge,
2176 tok::kw___bridge_transfer,
2177 tok::kw___bridge_retained,
2178 tok::kw___bridge_retain));
2179 if (BridgeCast && !
getLangOpts().ObjCAutoRefCount) {
2181 StringRef BridgeCastName = Tok.getName();
2184 Diag(BridgeKeywordLoc, diag::warn_arc_bridge_cast_nonarc)
2193 if (ExprType >=
CompoundStmt && Tok.is(tok::l_brace)) {
2194 Diag(Tok, diag::ext_gnu_statement_expr);
2197 Result =
ExprError(
Diag(OpenLoc, diag::err_stmtexpr_file_scope));
2203 while (CodeDC->
isRecord() || isa<EnumDecl>(CodeDC)) {
2206 "statement expr not in code context");
2216 if (!
Stmt.isInvalid()) {
2222 }
else if (ExprType >= CompoundLiteral && BridgeCast) {
2228 if (tokenKind == tok::kw___bridge)
2230 else if (tokenKind == tok::kw___bridge_transfer)
2232 else if (tokenKind == tok::kw___bridge_retained)
2237 assert(tokenKind == tok::kw___bridge_retain);
2240 Diag(BridgeKeywordLoc, diag::err_arc_bridge_retain)
2242 "__bridge_retained");
2247 ColonProtection.restore();
2248 RParenLoc = T.getCloseLocation();
2249 ExprResult SubExpr = ParseCastExpression(
false);
2255 BridgeKeywordLoc, Ty.
get(),
2256 RParenLoc, SubExpr.
get());
2257 }
else if (ExprType >= CompoundLiteral &&
2258 isTypeIdInParens(isAmbiguousTypeId)) {
2267 if (isAmbiguousTypeId && !stopIfCastExpr) {
2268 ExprResult res = ParseCXXAmbiguousParenExpression(ExprType, CastTy, T,
2270 RParenLoc = T.getCloseLocation();
2276 ParseSpecifierQualifierList(DS);
2278 ParseDeclarator(DeclaratorInfo);
2283 if (!DeclaratorInfo.isInvalidType() && Tok.is(tok::identifier) &&
2297 ColonProtection.restore();
2298 RParenLoc = T.getCloseLocation();
2299 if (Tok.is(tok::l_brace)) {
2300 ExprType = CompoundLiteral;
2306 return ParseCompoundLiteralExpression(Ty.
get(), OpenLoc, RParenLoc);
2312 if (DeclaratorInfo.isInvalidType())
2317 if (stopIfCastExpr) {
2328 if (Tok.is(tok::identifier) &&
getLangOpts().ObjC1 &&
2329 Tok.getIdentifierInfo() == Ident_super &&
2331 GetLookAheadToken(1).
isNot(tok::period)) {
2332 Diag(Tok.getLocation(), diag::err_illegal_super_cast)
2339 Result = ParseCastExpression(
false,
2344 DeclaratorInfo, CastTy,
2345 RParenLoc, Result.
get());
2350 Diag(Tok, diag::err_expected_lbrace_in_compound_literal);
2353 }
else if (Tok.is(tok::ellipsis) &&
2356 }
else if (isTypeCast) {
2360 ExprVector ArgExprs;
2361 CommaLocsTy CommaLocs;
2363 if (!ParseSimpleExpressionList(ArgExprs, CommaLocs)) {
2368 return ParseFoldExpression(Result, T);
2370 ExprType = SimpleExpr;
2383 ExprType = SimpleExpr;
2386 return ParseFoldExpression(Result, T);
2389 if (!Result.
isInvalid() && Tok.is(tok::r_paren))
2401 RParenLoc = T.getCloseLocation();
2414 Parser::ParseCompoundLiteralExpression(
ParsedType Ty,
2417 assert(Tok.is(tok::l_brace) &&
"Not a compound literal!");
2419 Diag(LParenLoc, diag::ext_c99_compound_literal);
2434 ExprResult Parser::ParseStringLiteralExpression(
bool AllowUserDefinedLiteral) {
2435 assert(isTokenStringLiteral() &&
"Not a string literal!");
2442 StringToks.push_back(Tok);
2443 ConsumeStringToken();
2444 }
while (isTokenStringLiteral());
2465 ExprResult Parser::ParseGenericSelectionExpression() {
2466 assert(Tok.is(tok::kw__Generic) &&
"_Generic keyword expected");
2470 Diag(KeyLoc, diag::ext_c11_generic_selection);
2473 if (T.expectAndConsume())
2489 if (ExpectAndConsume(tok::comma)) {
2499 if (Tok.is(tok::kw_default)) {
2503 Diag(Tok, diag::err_duplicate_default_assoc);
2504 Diag(DefaultLoc, diag::note_previous_default_assoc);
2519 Types.push_back(Ty);
2521 if (ExpectAndConsume(tok::colon)) {
2530 if (ER.isInvalid()) {
2534 Exprs.push_back(ER.get());
2538 if (T.getCloseLocation().isInvalid())
2542 T.getCloseLocation(),
2543 ControllingExpr.
get(),
2565 Kind = Tok.getKind();
2570 assert(Tok.is(tok::ellipsis) &&
"not a fold-expression");
2574 if (Tok.isNot(tok::r_paren)) {
2576 return Diag(Tok.getLocation(), diag::err_expected_fold_operator);
2578 if (Kind != tok::unknown && Tok.getKind() !=
Kind)
2579 Diag(Tok.getLocation(), diag::err_fold_operator_mismatch)
2581 Kind = Tok.getKind();
2592 ? diag::warn_cxx14_compat_fold_expression
2593 : diag::ext_fold_expression);
2624 std::function<
void()> Completer) {
2625 bool SawError =
false;
2627 if (Tok.is(tok::code_completion)) {
2638 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2639 Expr = ParseBraceInitializer();
2643 if (Tok.is(tok::ellipsis))
2649 Exprs.push_back(Expr.
get());
2652 if (Tok.isNot(tok::comma))
2660 for (
auto &
E : Exprs) {
2684 Exprs.push_back(Expr.
get());
2686 if (Tok.isNot(tok::comma))
2701 if (Tok.is(tok::code_completion)) {
2703 return cutOffParsing();
2708 ParseSpecifierQualifierList(DS);
2712 ParseDeclarator(DeclaratorInfo);
2714 MaybeParseGNUAttributes(DeclaratorInfo);
2730 ExprResult Parser::ParseBlockLiteralExpression() {
2731 assert(Tok.is(tok::caret) &&
"block literal starts with ^");
2735 "block literal parsing");
2752 ParamInfo.SetSourceRange(
SourceRange(Tok.getLocation(), Tok.getLocation()));
2756 if (Tok.is(tok::l_paren)) {
2757 ParseParenDeclarator(ParamInfo);
2762 ParamInfo.SetIdentifier(
nullptr, CaretLoc);
2763 ParamInfo.SetRangeEnd(Tmp);
2764 if (ParamInfo.isInvalidType()) {
2772 MaybeParseGNUAttributes(ParamInfo);
2776 }
else if (!Tok.is(tok::l_brace)) {
2777 ParseBlockId(CaretLoc);
2807 MaybeParseGNUAttributes(ParamInfo);
2815 if (!Tok.is(tok::l_brace)) {
2817 Diag(Tok, diag::err_expected_expression);
2824 if (!
Stmt.isInvalid())
SourceManager & getSourceManager() const
SourceLocation getCloseLocation() const
Defines the clang::ASTContext interface.
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
no exception specification
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
const LangOptions & getLangOpts() const
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
Bridging via __bridge, which does nothing but reinterpret the bits.
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS)
ActionResult< Expr * > ExprResult
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
const char * getCharacterData(SourceLocation SL, bool *Invalid=nullptr) const
Return a pointer to the start of the specified location in the appropriate spelling MemoryBuffer...
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
bool isAtStartOfMacroExpansion(SourceLocation loc, SourceLocation *MacroBegin=nullptr) const
Returns true if the given MacroID location points at the first token of the macro expansion...
const char * getName() const
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
The base class of the type hierarchy.
This indicates that the scope corresponds to a function, which means that labels are set here...
ExprResult ActOnObjCBridgedCast(Scope *S, SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, ParsedType Type, SourceLocation RParenLoc, Expr *SubExpr)
TemplateNameKind Kind
The kind of template that Template refers to.
TypeCastState
TypeCastState - State whether an expression is or may be a type cast.
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
void CodeCompleteCall(Scope *S, Expr *Fn, ArrayRef< Expr * > Args)
RAII object that enters a new expression evaluation context.
void EnterToken(const Token &Tok)
Enters a token in the token stream to be lexed next.
Information about one declarator, including the parsed type information and the identifier.
#define REVERTIBLE_TYPE_TRAIT(Name)
void ActOnStartStmtExpr()
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
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 ...
Information about a template-id annotation token.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
Base wrapper for a particular "section" of type source info.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool TryConsumeToken(tok::TokenKind Expected)
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
One of these records is kept for each identifier that is lexed.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Token - This structure provides full information about a lexed token.
ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc)
ActOnCXXNullPtrLiteral - Parse 'nullptr'.
void setKind(tok::TokenKind K)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
SourceRange getExprRange(Expr *E) const
Code completion occurs where only a type is permitted.
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
A location where the result (returned value) of evaluating a statement should be stored.
This is a scope that corresponds to a block/closure object.
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr * > ArgExprs)
Represents a C++ unqualified-id that has been parsed.
ExprResult ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc, MultiExprArg ExecConfig, SourceLocation GGGLoc)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=ParsedType(), bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool IsArrow)
Code completion occurs within an expression.
If a crash happens while one of these objects are live, the message is printed out along with the spe...
ExprResult ActOnCXXFoldExpr(SourceLocation LParenLoc, Expr *LHS, tok::TokenKind Operator, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation RParenLoc)
Handle a C++1z fold-expression: ( expr op ... op expr ).
Represents a C++ nested-name-specifier or a global scope specifier.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
tok::TokenKind getKind() const
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC...
void ActOnStmtExprError()
CompoundStmt - This represents a group of statements like { stmt stmt }.
TypeResult ParseTypeName(SourceRange *Range=nullptr, Declarator::TheContext Context=Declarator::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
const Type * getTypePtrOrNull() const
Expr - This represents one expression.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
TypeResult ActOnTypeName(Scope *S, Declarator &D)
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
bool isNot(tok::TokenKind K) const
DeclContext * getParent()
getParent - Returns the containing DeclContext.
static bool isFoldOperator(prec::Level Level)
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
The result type of a method or function.
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion...
const clang::PrintingPolicy & getPrintingPolicy() const
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
Stop skipping at semicolon.
Encodes a location in the source.
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
const TemplateArgument * iterator
bool isValid() const
Return true if this is a valid SourceLocation object.
ASTContext & getASTContext() const
LabelDecl - Represents the declaration of a label.
Scope * getCurScope() const
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
ExprResult ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, IdentifierInfo &propertyName, SourceLocation receiverNameLoc, SourceLocation propertyNameLoc)
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLoc, Expr *Length, SourceLocation RBLoc)
bool isFileContext() 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)) {...
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, ParsedType ObjectType, SourceLocation &TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
SourceLocation getOpenLocation() const
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input)
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_astype(...)
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
detail::InMemoryDirectory::const_iterator E
bool isSimpleTypeSpecifier(tok::TokenKind Kind) const
Determine whether the token kind starts a simple-type-specifier.
ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Member, Decl *ObjCImpDecl)
The main callback when the parser finds something like expression .
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
Bridging via __bridge_retain, which makes an ARC object available as a +1 C pointer.
The name refers to a template whose specialization produces a type.
ExprResult ActOnConstantExpression(ExprResult Res)
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)
ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
ExprResult ActOnCoawaitExpr(Scope *S, SourceLocation KwLoc, Expr *E)
bool isFunctionType() const
void * getAsOpaquePtr() const
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
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.
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
This is a scope that can contain a declaration.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
static ParsedType getTypeAnnotation(Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
Captures information about "declaration specifiers".
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
void CodeCompletePostfixExpression(Scope *S, ExprResult LHS)
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult{return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
bool TryAnnotateTypeOrScopeToken(bool EnteringContext=false, bool NeedType=false)
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
static Decl::Kind getKind(const Decl *D)
prec::Level getBinOpPrecedence(tok::TokenKind Kind, bool GreaterThanIsOperator, bool CPlusPlus11)
Return the precedence of the specified binary operator token.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e.g.
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
ExprResult ActOnSizeofParameterPackExpr(Scope *S, SourceLocation OpLoc, IdentifierInfo &Name, SourceLocation NameLoc, SourceLocation RParenLoc)
Called when an expression computing the size of a parameter pack is parsed.
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
This class handles loading and caching of source files into memory.
Code completion occurs in a parenthesized expression, which might also be a type cast.
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
Stop skipping at specified token, but don't skip the token itself.
IdentifierInfo * getIdentifierInfo() const