26#include "llvm/Support/Compiler.h"
27#include "llvm/Support/ErrorHandling.h"
35 case tok::unknown:
return 0;
37 case tok::kw_addrspace_cast:
return 1;
38 case tok::kw_const_cast:
return 2;
39 case tok::kw_dynamic_cast:
return 3;
40 case tok::kw_reinterpret_cast:
return 4;
41 case tok::kw_static_cast:
return 5;
43 llvm_unreachable(
"Unknown type for digraph error message.");
48bool Parser::areTokensAdjacent(
const Token &
First,
const Token &Second) {
66 P.Diag(DigraphToken.
getLocation(), diag::err_missing_whitespace_digraph)
71 ColonToken.
setKind(tok::coloncolon);
74 DigraphToken.
setKind(tok::less);
85void Parser::CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectType,
88 if (!Next.is(tok::l_square) || Next.getLength() != 2)
91 Token SecondToken = GetLookAheadToken(2);
92 if (!SecondToken.
is(tok::colon) || !areTokensAdjacent(Next, SecondToken))
98 bool MemberOfUnknownSpecialization;
101 Template, MemberOfUnknownSpecialization))
104 FixDigraph(*
this, PP, Next, SecondToken, tok::unknown,
157bool Parser::ParseOptionalCXXScopeSpecifier(
159 bool EnteringContext,
bool *MayBePseudoDestructor,
bool IsTypename,
161 bool InUsingDeclaration) {
163 "Call sites of this function should be guarded by checking for C++");
165 if (Tok.
is(tok::annot_cxxscope)) {
166 assert(!LastII &&
"want last identifier but have already annotated scope");
167 assert(!MayBePseudoDestructor &&
"unexpected annot_cxxscope");
171 ConsumeAnnotationToken();
176 bool CheckForDestructor =
false;
177 if (MayBePseudoDestructor && *MayBePseudoDestructor) {
178 CheckForDestructor =
true;
179 *MayBePseudoDestructor =
false;
185 bool HasScopeSpecifier =
false;
187 if (Tok.
is(tok::coloncolon)) {
190 if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
193 if (NextKind == tok::l_brace) {
202 HasScopeSpecifier =
true;
206 if (Tok.
is(tok::kw___super)) {
208 if (!Tok.
is(tok::coloncolon)) {
216 if (!HasScopeSpecifier &&
217 Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
227 AnnotateExistingDecltypeSpecifier(DS, DeclLoc, EndLoc);
234 HasScopeSpecifier =
true;
237 else if (!HasScopeSpecifier && Tok.
is(tok::identifier) &&
238 GetLookAheadToken(1).is(tok::ellipsis) &&
239 GetLookAheadToken(2).is(tok::l_square)) {
248 DS.getRepAsType().get(), DS.getPackIndexingExpr(), DS.getBeginLoc(),
249 DS.getEllipsisLoc());
262 HasScopeSpecifier =
true;
266 auto SavedType = PreferredType;
268 if (HasScopeSpecifier) {
269 if (Tok.
is(tok::code_completion)) {
274 InUsingDeclaration, ObjectType.
get(),
294 ObjectType =
nullptr;
302 if (Tok.
is(tok::kw_template)) {
306 if (!HasScopeSpecifier && !ObjectType)
309 TentativeParsingAction TPA(*
this);
313 if (Tok.
is(tok::identifier)) {
317 }
else if (Tok.
is(tok::kw_operator)) {
322 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
331 diag::err_id_after_template_in_nested_name_spec)
344 if (Tok.
isNot(tok::less)) {
354 EnteringContext, Template,
true);
355 if (AnnotateTemplateIdToken(Template, TNK, SS, TemplateKWLoc,
362 if (Tok.
is(tok::annot_template_id) &&
NextToken().is(tok::coloncolon)) {
371 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
372 *MayBePseudoDestructor =
true;
377 *LastII = TemplateId->
Name;
380 ConsumeAnnotationToken();
382 assert(Tok.
is(tok::coloncolon) &&
"NextToken() not working properly!");
385 HasScopeSpecifier =
true;
412 if (Tok.
isNot(tok::identifier))
427 if (Next.is(tok::colon) && !ColonIsSacred) {
434 Diag(Next, diag::err_unexpected_colon_in_nested_name_spec)
437 Next.setKind(tok::coloncolon);
441 if (Next.is(tok::coloncolon) && GetLookAheadToken(2).is(tok::l_brace)) {
452 if (Next.is(tok::coloncolon)) {
453 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
454 *MayBePseudoDestructor =
true;
459 const Token &Next2 = GetLookAheadToken(2);
460 if (Next2.
is(tok::kw_private) || Next2.
is(tok::kw_protected) ||
461 Next2.
is(tok::kw_public) || Next2.
is(tok::kw_virtual)) {
462 Diag(Next2, diag::err_unexpected_token_in_nested_name_spec)
467 ColonColon.
setKind(tok::colon);
480 assert(Tok.
isOneOf(tok::coloncolon, tok::colon) &&
481 "NextToken() not working properly!");
482 Token ColonColon = Tok;
485 bool IsCorrectedToColon =
false;
486 bool *CorrectionFlagPtr = ColonIsSacred ? &IsCorrectedToColon :
nullptr;
488 getCurScope(), IdInfo, EnteringContext, SS, CorrectionFlagPtr,
492 if (CorrectionFlagPtr && IsCorrectedToColon) {
493 ColonColon.
setKind(tok::colon);
501 HasScopeSpecifier =
true;
505 CheckForTemplateAndDigraph(Next, ObjectType, EnteringContext, II, SS);
509 if (Next.is(tok::less)) {
514 bool MemberOfUnknownSpecialization;
521 MemberOfUnknownSpecialization)) {
527 isTemplateArgumentList(1) == TPResult::False)
544 if (MemberOfUnknownSpecialization && (ObjectType || SS.
isSet()) &&
545 (IsTypename || isTemplateArgumentList(1) == TPResult::True)) {
548 if (!ObjectHadErrors) {
553 unsigned DiagID = diag::err_missing_dependent_template_keyword;
555 DiagID = diag::warn_missing_dependent_template_keyword;
566 EnteringContext, Template,
true);
583 if (CheckForDestructor && !HasScopeSpecifier && Tok.
is(tok::tilde))
584 *MayBePseudoDestructor =
true;
590 bool isAddressOfOperand,
591 Token &Replacement) {
596 case tok::annot_non_type: {
597 NamedDecl *ND = getNonTypeAnnotation(Tok);
603 case tok::annot_non_type_dependent: {
609 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
610 isAddressOfOperand =
false;
617 case tok::annot_non_type_undeclared: {
619 "undeclared non-type annotation should be unqualified");
634 false, &TemplateKWLoc, Name))
639 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
640 isAddressOfOperand =
false;
643 getCurScope(), SS, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
644 isAddressOfOperand,
nullptr,
false,
650 E = tryParseCXXPackIndexingExpression(E);
653 checkPotentialAngleBracket(E);
658 assert(Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square) &&
664 if (
T.consumeClose() || IndexExpr.
isInvalid())
667 EllipsisLoc,
T.getOpenLocation(),
668 IndexExpr.
get(),
T.getCloseLocation());
672Parser::tryParseCXXPackIndexingExpression(
ExprResult PackIdExpression) {
675 Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square)) {
676 E = ParseCXXPackIndexingExpression(E);
723ExprResult Parser::ParseCXXIdExpression(
bool isAddressOfOperand) {
729 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
735 tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
739 UnconsumeToken(Replacement);
740 Result = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
742 assert(!
Result.isUnset() &&
"Typo correction suggested a keyword replacement "
743 "for a previous keyword suggestion");
795 if (ParseLambdaIntroducer(Intro)) {
802 return ParseLambdaExpressionAfterIntroducer(Intro);
809ExprResult Parser::TryParseLambdaExpression() {
811 "Not at the start of a possible lambda expression.");
814 if (Next.is(tok::eof))
819 if (Next.is(tok::r_square) ||
820 Next.is(tok::equal) ||
821 (Next.is(tok::amp) &&
822 After.isOneOf(tok::r_square, tok::comma)) ||
823 (Next.is(tok::identifier) &&
824 After.is(tok::r_square)) ||
825 Next.is(tok::ellipsis)) {
826 return ParseLambdaExpression();
831 if (Next.is(tok::identifier) &&
After.is(tok::identifier))
841 TentativeParsingAction TPA(*
this);
842 LambdaIntroducerTentativeParse Tentative;
843 if (ParseLambdaIntroducer(Intro, &Tentative)) {
849 case LambdaIntroducerTentativeParse::Success:
853 case LambdaIntroducerTentativeParse::Incomplete:
858 if (ParseLambdaIntroducer(Intro))
862 case LambdaIntroducerTentativeParse::MessageSend:
863 case LambdaIntroducerTentativeParse::Invalid:
870 return ParseLambdaExpressionAfterIntroducer(Intro);
883 LambdaIntroducerTentativeParse *Tentative) {
885 *Tentative = LambdaIntroducerTentativeParse::Success;
887 assert(Tok.
is(tok::l_square) &&
"Lambda expressions begin with '['.");
897 auto Invalid = [&](llvm::function_ref<void()> Action) {
899 *Tentative = LambdaIntroducerTentativeParse::Invalid;
908 auto NonTentativeAction = [&](llvm::function_ref<void()> Action) {
910 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
916 if (Tok.
is(tok::amp) &&
926 }
else if (Tok.
is(tok::equal)) {
933 while (Tok.
isNot(tok::r_square)) {
935 if (Tok.
isNot(tok::comma)) {
940 if (Tok.
is(tok::code_completion) &&
955 if (Tok.
is(tok::code_completion)) {
978 if (Tok.
is(tok::star)) {
980 if (Tok.
is(tok::kw_this)) {
988 }
else if (Tok.
is(tok::kw_this)) {
991 }
else if (Tok.
isOneOf(tok::amp, tok::equal) &&
1003 if (Tok.
is(tok::amp)) {
1007 if (Tok.
is(tok::code_completion)) {
1017 if (Tok.
is(tok::identifier)) {
1020 }
else if (Tok.
is(tok::kw_this)) {
1033 if (Tok.
is(tok::l_paren)) {
1042 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
1043 }
else if (ParseExpressionList(Exprs)) {
1049 Parens.getCloseLocation(),
1052 }
else if (Tok.
isOneOf(tok::l_brace, tok::equal)) {
1065 Init = ParseInitializer();
1066 }
else if (Tok.
is(tok::l_brace)) {
1070 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
1094 Init = ParseInitializer();
1095 if (!
Init.isInvalid())
1104 Tok.
setKind(tok::annot_primary_expr);
1105 setExprAnnotation(Tok,
Init);
1110 ConsumeAnnotationToken();
1119 if (Tentative && Tok.
is(tok::identifier) &&
1122 *Tentative = LambdaIntroducerTentativeParse::MessageSend;
1128 if (llvm::any_of(EllipsisLocs,
1134 !InitCapture ? &EllipsisLocs[2] :
1137 EllipsisLoc = *ExpectedEllipsisLoc;
1139 unsigned DiagID = 0;
1141 DiagID = diag::err_lambda_capture_misplaced_ellipsis;
1147 unsigned NumEllipses = std::accumulate(
1148 std::begin(EllipsisLocs), std::end(EllipsisLocs), 0,
1150 if (NumEllipses > 1)
1151 DiagID = diag::err_lambda_capture_multiple_ellipses;
1154 NonTentativeAction([&] {
1158 if (&Loc != ExpectedEllipsisLoc && Loc.
isValid()) {
1163 assert(DiagLoc.
isValid() &&
"no location for diagnostic");
1167 auto &&D =
Diag(DiagLoc, DiagID);
1168 if (DiagID == diag::err_lambda_capture_misplaced_ellipsis) {
1176 if (&Loc != ExpectedEllipsisLoc && Loc.
isValid())
1188 if (
Init.isUsable())
1190 if (
Init.isUsable()) {
1191 NonTentativeAction([&] {
1198 Loc, Kind ==
LCK_ByRef, EllipsisLoc,
Id, InitKind, InitExpr);
1228 auto ConsumeLocation = [&
P, &DeclEndLoc](
SourceLocation &SpecifierLoc,
1230 if (SpecifierLoc.isValid()) {
1231 P.Diag(
P.getCurToken().getLocation(),
1232 diag::err_lambda_decl_specifier_repeated)
1236 SpecifierLoc =
P.ConsumeToken();
1237 DeclEndLoc = SpecifierLoc;
1241 switch (
P.getCurToken().getKind()) {
1242 case tok::kw_mutable:
1243 ConsumeLocation(MutableLoc, 0);
1245 case tok::kw_static:
1246 ConsumeLocation(StaticLoc, 1);
1248 case tok::kw_constexpr:
1249 ConsumeLocation(ConstexprLoc, 2);
1251 case tok::kw_consteval:
1252 ConsumeLocation(ConstevalLoc, 3);
1263 P.Diag(StaticLoc, !
P.getLangOpts().CPlusPlus23
1264 ? diag::err_static_lambda
1265 : diag::warn_cxx20_compat_static_lambda);
1266 const char *PrevSpec =
nullptr;
1267 unsigned DiagID = 0;
1270 P.getActions().getASTContext().getPrintingPolicy());
1271 assert(PrevSpec ==
nullptr && DiagID == 0 &&
1272 "Static cannot have been set previously!");
1280 P.Diag(ConstexprLoc, !
P.getLangOpts().CPlusPlus17
1281 ? diag::ext_constexpr_on_lambda_cxx17
1282 : diag::warn_cxx14_compat_constexpr_on_lambda);
1283 const char *PrevSpec =
nullptr;
1284 unsigned DiagID = 0;
1287 assert(PrevSpec ==
nullptr && DiagID == 0 &&
1288 "Constexpr cannot have been set previously!");
1296 P.Diag(ConstevalLoc, diag::warn_cxx20_compat_consteval);
1297 const char *PrevSpec =
nullptr;
1298 unsigned DiagID = 0;
1302 P.Diag(ConstevalLoc, DiagID) << PrevSpec;
1318 P.Diag(StaticLoc, diag::err_static_mutable_lambda);
1320 P.Diag(StaticLoc, diag::err_static_lambda_captures);
1326ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
1330 ? diag::warn_cxx98_compat_lambda
1331 : diag::ext_lambda);
1334 "lambda expression parsing");
1339 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1356 if (Tok.
is(tok::kw___noinline__)) {
1359 Attributes.addNew(AttrName, AttrNameLoc,
nullptr,
1360 AttrNameLoc,
nullptr,
1361 0, tok::kw___noinline__);
1362 }
else if (Tok.
is(tok::kw___attribute))
1363 ParseGNUAttributes(Attributes,
nullptr, &D);
1368 D.takeAttributes(Attributes);
1371 MultiParseScope TemplateParamScope(*
this);
1372 if (Tok.
is(tok::less)) {
1374 ? diag::warn_cxx17_compat_lambda_template_parameter_list
1375 : diag::ext_lambda_template_parameter_list);
1379 if (ParseTemplateParameters(TemplateParamScope,
1380 CurTemplateDepthTracker.getDepth(),
1381 TemplateParams, LAngleLoc, RAngleLoc)) {
1386 if (TemplateParams.empty()) {
1388 diag::err_lambda_template_parameter_list_empty);
1399 ++CurTemplateDepthTracker;
1410 Intro, LAngleLoc, TemplateParams, RAngleLoc, RequiresClause);
1418 if (isCXX11AttributeSpecifier()) {
1420 ? diag::warn_cxx20_compat_decl_attrs_on_lambda
1421 : diag::ext_decl_attrs_on_lambda)
1423 MaybeParseCXX11Attributes(D);
1430 bool HasParentheses =
false;
1431 bool HasSpecifiers =
false;
1442 if (Tok.
is(tok::l_paren)) {
1445 LParenLoc =
T.getOpenLocation();
1447 if (Tok.
isNot(tok::r_paren)) {
1449 CurTemplateDepthTracker.getOriginalDepth());
1451 ParseParameterDeclarationClause(D, Attributes, ParamInfo, EllipsisLoc);
1458 CurTemplateDepthTracker.setAddedDepth(1);
1462 DeclEndLoc = RParenLoc =
T.getCloseLocation();
1463 HasParentheses =
true;
1467 Tok.
isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute,
1468 tok::kw_constexpr, tok::kw_consteval, tok::kw_static,
1469 tok::kw___private, tok::kw___global, tok::kw___local,
1470 tok::kw___constant, tok::kw___generic, tok::kw_groupshared,
1471 tok::kw_requires, tok::kw_noexcept) ||
1475 if (HasSpecifiers && !HasParentheses && !
getLangOpts().CPlusPlus23) {
1479 Diag(Tok, diag::ext_lambda_missing_parens)
1483 if (HasParentheses || HasSpecifiers) {
1487 MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attributes);
1495 ConstevalLoc, DeclEndLoc);
1506 if (!HasParentheses)
1509 if (HasSpecifiers || HasParentheses) {
1518 ESpecType = tryParseExceptionSpecification(
1519 false, ESpecRange, DynamicExceptions,
1520 DynamicExceptionRanges, NoexceptExpr, ExceptionSpecTokens);
1523 DeclEndLoc = ESpecRange.
getEnd();
1526 if (MaybeParseCXX11Attributes(Attributes))
1527 DeclEndLoc = Attributes.Range.getEnd();
1530 if (Tok.
isOneOf(tok::kw___private, tok::kw___global, tok::kw___local,
1531 tok::kw___constant, tok::kw___generic)) {
1532 ParseOpenCLQualifiers(DS.getAttributes());
1539 if (Tok.
is(tok::arrow)) {
1542 TrailingReturnType =
1543 ParseTrailingReturnType(Range,
false);
1544 TrailingReturnTypeLoc =
Range.getBegin();
1545 if (
Range.getEnd().isValid())
1546 DeclEndLoc =
Range.getEnd();
1552 false, LParenLoc, ParamInfo.data(),
1553 ParamInfo.size(), EllipsisLoc, RParenLoc,
1555 NoLoc, MutableLoc, ESpecType,
1556 ESpecRange, DynamicExceptions.data(),
1557 DynamicExceptionRanges.data(), DynamicExceptions.size(),
1558 NoexceptExpr.
isUsable() ? NoexceptExpr.
get() :
nullptr,
1560 std::nullopt, LParenLoc,
1561 FunLocalRangeEnd, D, TrailingReturnType,
1562 TrailingReturnTypeLoc, &DS),
1563 std::move(Attributes), DeclEndLoc);
1567 if (HasParentheses && Tok.
is(tok::kw_requires))
1568 ParseTrailingRequiresClause(D);
1575 if (A.getKind() == ParsedAttr::AT_CUDADevice ||
1576 A.getKind() == ParsedAttr::AT_CUDAHost ||
1577 A.getKind() == ParsedAttr::AT_CUDAGlobal)
1578 Diag(A.getLoc(), diag::warn_cuda_attr_lambda_position)
1579 << A.getAttrName()->getName();
1588 ParseScope BodyScope(
this, ScopeFlags);
1593 if (!Tok.
is(tok::l_brace)) {
1594 Diag(Tok, diag::err_expected_lambda_body);
1601 TemplateParamScope.Exit();
1625 const char *CastName =
nullptr;
1628 default: llvm_unreachable(
"Unknown C++ cast!");
1629 case tok::kw_addrspace_cast: CastName =
"addrspace_cast";
break;
1630 case tok::kw_const_cast: CastName =
"const_cast";
break;
1631 case tok::kw_dynamic_cast: CastName =
"dynamic_cast";
break;
1632 case tok::kw_reinterpret_cast: CastName =
"reinterpret_cast";
break;
1633 case tok::kw_static_cast: CastName =
"static_cast";
break;
1641 if (Tok.
is(tok::l_square) && Tok.
getLength() == 2) {
1643 if (Next.is(tok::colon) && areTokensAdjacent(Tok, Next))
1644 FixDigraph(*
this, PP, Tok, Next, Kind,
true);
1647 if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
1652 ParseSpecifierQualifierList(DS,
AS_none,
1653 DeclSpecContext::DSC_type_specifier);
1658 ParseDeclarator(DeclaratorInfo);
1662 if (ExpectAndConsume(tok::greater))
1663 return ExprError(
Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
1667 if (
T.expectAndConsume(diag::err_expected_lparen_after, CastName))
1675 if (!
Result.isInvalid() && !DeclaratorInfo.isInvalidType())
1677 LAngleBracketLoc, DeclaratorInfo,
1679 T.getOpenLocation(),
Result.get(),
1680 T.getCloseLocation());
1692 assert(Tok.
is(tok::kw_typeid) &&
"Not 'typeid'!");
1699 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"typeid"))
1701 LParenLoc =
T.getOpenLocation();
1722 if (isTypeIdInParens()) {
1727 RParenLoc =
T.getCloseLocation();
1732 Ty.
get().getAsOpaquePtr(), RParenLoc);
1741 RParenLoc =
T.getCloseLocation();
1746 Result.get(), RParenLoc);
1759 assert(Tok.
is(tok::kw___uuidof) &&
"Not '__uuidof'!");
1765 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"__uuidof"))
1770 if (isTypeIdInParens()) {
1780 Ty.
get().getAsOpaquePtr(),
1781 T.getCloseLocation());
1795 Result.get(),
T.getCloseLocation());
1842 if (Tok.
is(tok::identifier)) {
1845 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1847 }
else if (Tok.
is(tok::annot_template_id)) {
1853 ConsumeAnnotationToken();
1854 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1857 assert(SS.
isEmpty() &&
"missing last component of nested name specifier");
1862 assert(Tok.
is(tok::tilde) &&
"ParseOptionalCXXScopeSpecifier fail");
1865 if (Tok.
is(tok::kw_decltype) && !FirstTypeName.
isValid()) {
1867 ParseDecltypeSpecifier(DS);
1874 if (!Tok.
is(tok::identifier)) {
1875 Diag(Tok, diag::err_destructor_tilde_identifier);
1880 if (GetLookAheadToken(1).is(tok::ellipsis) &&
1881 GetLookAheadToken(2).is(tok::l_square)) {
1883 ParsePackIndexingType(DS);
1902 if (Tok.
is(tok::less) &&
1903 ParseUnqualifiedIdTemplateId(
1905 Name, NameLoc,
false, SecondTypeName,
1910 SS, FirstTypeName, CCLoc, TildeLoc,
1929 assert(Tok.
is(tok::kw_throw) &&
"Not throw!");
1956 assert(Tok.
is(tok::kw_co_yield) &&
"Not co_yield!");
1961 if (!
Expr.isInvalid())
1972 assert(Tok.
is(tok::kw_this) &&
"Not 'this'!");
1991Parser::ParseCXXTypeConstructExpression(
const DeclSpec &DS) {
1996 assert((Tok.
is(tok::l_paren) ||
1998 &&
"Expected '(' or '{'!");
2000 if (Tok.
is(tok::l_brace)) {
2003 if (
Init.isInvalid())
2017 auto RunSignatureHelp = [&]() {
2022 T.getOpenLocation(),
false);
2023 CalledSignatureHelp =
true;
2024 return PreferredType;
2027 if (Tok.
isNot(tok::r_paren)) {
2028 if (ParseExpressionList(Exprs, [&] {
2029 PreferredType.enterFunctionArgument(Tok.
getLocation(),
2047 Exprs,
T.getCloseLocation(),
2055 assert(Tok.
is(tok::kw_using) &&
"Expected using");
2058 "Unexpected Declarator Context");
2062 DG = ParseUsingDeclaration(Context, {}, DeclStart, DeclEnd, Attrs,
AS_none);
2067 ? diag::ext_alias_in_init_statement
2068 : diag::warn_cxx20_alias_in_init_statement)
2108 ForRangeInfo *FRI,
bool EnterForConditionScope) {
2110 struct ForConditionScopeRAII {
2112 void enter(
bool IsConditionVariable) {
2115 S->setIsConditionVarScope(IsConditionVariable);
2118 ~ForConditionScopeRAII() {
2120 S->setIsConditionVarScope(
false);
2122 } ForConditionScope{EnterForConditionScope ?
getCurScope() : nullptr};
2125 PreferredType.enterCondition(Actions, Tok.
getLocation());
2127 if (Tok.
is(tok::code_completion)) {
2134 MaybeParseCXX11Attributes(attrs);
2136 const auto WarnOnInit = [
this, &CK] {
2138 ? diag::warn_cxx14_compat_init_statement
2139 : diag::ext_init_statement)
2144 switch (isCXXConditionDeclarationOrInitStatement(InitStmt, FRI)) {
2145 case ConditionOrInitStatement::Expression: {
2147 ForConditionScope.enter(
false);
2149 ProhibitAttributes(attrs);
2153 if (InitStmt && Tok.
is(tok::semi)) {
2157 Diag(SemiLoc, diag::warn_empty_init_statement)
2163 return ParseCXXCondition(
nullptr, Loc, CK, MissingOK);
2168 if (
Expr.isInvalid())
2171 if (InitStmt && Tok.
is(tok::semi)) {
2175 return ParseCXXCondition(
nullptr, Loc, CK, MissingOK);
2182 case ConditionOrInitStatement::InitStmtDecl: {
2186 if (Tok.
is(tok::kw_using))
2187 DG = ParseAliasDeclarationInInitStatement(
2192 attrs, DeclSpecAttrs,
true);
2195 return ParseCXXCondition(
nullptr, Loc, CK, MissingOK);
2198 case ConditionOrInitStatement::ForRangeDecl: {
2202 assert(FRI &&
"should not parse a for range declaration here");
2211 case ConditionOrInitStatement::ConditionDecl:
2212 case ConditionOrInitStatement::Error:
2217 ForConditionScope.enter(
true);
2221 ParseSpecifierQualifierList(DS,
AS_none, DeclSpecContext::DSC_condition);
2225 ParseDeclarator(DeclaratorInfo);
2228 if (Tok.
is(tok::kw_asm)) {
2230 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2231 if (AsmLabel.isInvalid()) {
2235 DeclaratorInfo.setAsmLabel(AsmLabel.get());
2236 DeclaratorInfo.SetRangeEnd(Loc);
2240 MaybeParseGNUAttributes(DeclaratorInfo);
2251 bool CopyInitialization = isTokenEqualOrEqualTypo();
2252 if (CopyInitialization)
2258 diag::warn_cxx98_compat_generalized_initializer_lists);
2259 InitExpr = ParseBraceInitializer();
2260 }
else if (CopyInitialization) {
2261 PreferredType.enterVariableInit(Tok.
getLocation(), DeclOut);
2263 }
else if (Tok.
is(tok::l_paren)) {
2267 RParen = ConsumeParen();
2269 diag::err_expected_init_in_condition_lparen)
2310void Parser::ParseCXXSimpleTypeSpecifier(
DeclSpec &DS) {
2312 const char *PrevSpec;
2319 case tok::identifier:
2320 case tok::coloncolon:
2321 llvm_unreachable(
"Annotation token should already be formed!");
2323 llvm_unreachable(
"Not a simple-type-specifier token!");
2326 case tok::annot_typename: {
2330 ConsumeAnnotationToken();
2331 DS.
Finish(Actions, Policy);
2335 case tok::kw__ExtInt:
2336 case tok::kw__BitInt: {
2337 DiagnoseBitIntUse(Tok);
2346 DS.
Finish(Actions, Policy);
2359 case tok::kw___int64:
2363 case tok::kw_signed:
2366 case tok::kw_unsigned:
2381 case tok::kw___int128:
2384 case tok::kw___bf16:
2393 case tok::kw_double:
2396 case tok::kw__Float16:
2399 case tok::kw___float128:
2402 case tok::kw___ibm128:
2405 case tok::kw_wchar_t:
2408 case tok::kw_char8_t:
2411 case tok::kw_char16_t:
2414 case tok::kw_char32_t:
2420 case tok::kw__Accum:
2423 case tok::kw__Fract:
2429#define GENERIC_IMAGE_TYPE(ImgType, Id) \
2430 case tok::kw_##ImgType##_t: \
2431 DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, DiagID, \
2434#include "clang/Basic/OpenCLImageTypes.def"
2436 case tok::annot_decltype:
2437 case tok::kw_decltype:
2439 return DS.
Finish(Actions, Policy);
2441 case tok::annot_pack_indexing_type:
2443 return DS.
Finish(Actions, Policy);
2446 case tok::kw_typeof:
2447 ParseTypeofSpecifier(DS);
2448 DS.
Finish(Actions, Policy);
2453 DS.
Finish(Actions, Policy);
2468 ParseSpecifierQualifierList(DS,
AS_none,
2469 getDeclSpecContextFromDeclaratorContext(Context));
2509bool Parser::ParseUnqualifiedIdTemplateId(
2513 assert(Tok.
is(tok::less) &&
"Expected '<' to finish parsing a template-id");
2517 switch (
Id.getKind()) {
2521 if (AssumeTemplateId) {
2525 ObjectType, EnteringContext, Template,
2528 bool MemberOfUnknownSpecialization;
2531 ObjectType, EnteringContext, Template,
2532 MemberOfUnknownSpecialization);
2537 isTemplateArgumentList(0) == TPResult::False)
2541 ObjectType && isTemplateArgumentList(0) == TPResult::True) {
2544 if (!ObjectHadErrors) {
2551 Name = std::string(
Id.Identifier->getName());
2557 Name +=
Id.Identifier->getName();
2559 Diag(
Id.StartLocation, diag::err_missing_dependent_template_keyword)
2564 getCurScope(), SS, TemplateKWLoc,
Id, ObjectType, EnteringContext,
2574 bool MemberOfUnknownSpecialization;
2578 EnteringContext, Template,
2579 MemberOfUnknownSpecialization);
2587 bool MemberOfUnknownSpecialization;
2592 EnteringContext, Template,
true);
2596 EnteringContext, Template,
2597 MemberOfUnknownSpecialization);
2600 Diag(NameLoc, diag::err_destructor_template_id)
2614 TemplateArgList TemplateArgs;
2615 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs, RAngleLoc,
2636 :
Id.OperatorFunctionId.Operator;
2639 TemplateKWLoc,
Id.StartLocation, TemplateII, OpKind, Template, TNK,
2640 LAngleLoc, RAngleLoc, TemplateArgs,
false, TemplateIds);
2642 Id.setTemplateId(TemplateId);
2651 getCurScope(), SS, TemplateKWLoc, Template, Name, NameLoc, LAngleLoc,
2652 TemplateArgsPtr, RAngleLoc,
true);
2653 if (
Type.isInvalid())
2657 Id.setConstructorName(
Type.get(), NameLoc, RAngleLoc);
2659 Id.setDestructorName(
Id.StartLocation,
Type.get(), RAngleLoc);
2704bool Parser::ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2707 assert(Tok.
is(tok::kw_operator) &&
"Expected 'operator' keyword");
2713 unsigned SymbolIdx = 0;
2718 case tok::kw_delete: {
2719 bool isNew = Tok.
getKind() == tok::kw_new;
2723 if (Tok.
is(tok::l_square) &&
2729 if (
T.getCloseLocation().isInvalid())
2732 SymbolLocations[SymbolIdx++] =
T.getOpenLocation();
2733 SymbolLocations[SymbolIdx++] =
T.getCloseLocation();
2734 Op = isNew? OO_Array_New : OO_Array_Delete;
2736 Op = isNew? OO_New : OO_Delete;
2741#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2743 SymbolLocations[SymbolIdx++] = ConsumeToken(); \
2746#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2747#include "clang/Basic/OperatorKinds.def"
2749 case tok::l_paren: {
2754 if (
T.getCloseLocation().isInvalid())
2757 SymbolLocations[SymbolIdx++] =
T.getOpenLocation();
2758 SymbolLocations[SymbolIdx++] =
T.getCloseLocation();
2763 case tok::l_square: {
2768 if (
T.getCloseLocation().isInvalid())
2771 SymbolLocations[SymbolIdx++] =
T.getOpenLocation();
2772 SymbolLocations[SymbolIdx++] =
T.getCloseLocation();
2777 case tok::code_completion: {
2791 Result.setOperatorFunctionId(KeywordLoc, Op, SymbolLocations);
2805 unsigned DiagId = 0;
2811 while (isTokenStringLiteral()) {
2812 if (!Tok.
is(tok::string_literal) && !DiagId) {
2817 DiagId = diag::err_literal_operator_string_prefix;
2819 Toks.push_back(Tok);
2820 TokLocs.push_back(ConsumeStringToken());
2829 bool IsUDSuffix = !
Literal.getUDSuffix().empty();
2838 }
else if (Tok.
is(tok::identifier)) {
2841 TokLocs.push_back(SuffixLoc);
2853 DiagLoc = TokLocs.front();
2854 DiagId = diag::err_literal_operator_string_not_empty;
2864 SourceRange(TokLocs.front(), TokLocs.back()), Str);
2867 Result.setLiteralOperatorId(II, KeywordLoc, SuffixLoc);
2885 if (ParseCXXTypeSpecifierSeq(
2893 ParseDeclaratorInternal(D,
nullptr);
2901 Result.setConversionFunctionId(KeywordLoc, Ty.
get(),
2902 D.getSourceRange().getEnd());
2943 bool ObjectHadErrors,
bool EnteringContext,
2944 bool AllowDestructorName,
2945 bool AllowConstructorName,
2946 bool AllowDeductionGuide,
2954 bool TemplateSpecified =
false;
2955 if (Tok.
is(tok::kw_template)) {
2956 if (TemplateKWLoc && (ObjectType || SS.
isSet())) {
2957 TemplateSpecified =
true;
2961 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
2969 if (Tok.
is(tok::identifier)) {
2983 if (AllowConstructorName &&
2990 Result.setConstructorName(Ty, IdLoc, IdLoc);
3004 if (Tok.
is(tok::less))
3005 return ParseUnqualifiedIdTemplateId(
3006 SS, ObjectType, ObjectHadErrors,
3008 EnteringContext,
Result, TemplateSpecified);
3009 else if (TemplateSpecified &&
3012 EnteringContext, Template,
3021 if (Tok.
is(tok::annot_template_id)) {
3027 ConsumeAnnotationToken();
3032 if (AllowConstructorName && TemplateId->
Name &&
3040 diag::err_out_of_line_constructor_template_id)
3051 ConsumeAnnotationToken();
3055 Result.setConstructorTemplateId(TemplateId);
3056 ConsumeAnnotationToken();
3062 Result.setTemplateId(TemplateId);
3065 if (TemplateKWLoc && (ObjectType || SS.
isSet()))
3066 *TemplateKWLoc = TemplateLoc;
3068 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
3071 ConsumeAnnotationToken();
3078 if (Tok.
is(tok::kw_operator)) {
3079 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
Result))
3091 return ParseUnqualifiedIdTemplateId(
3092 SS, ObjectType, ObjectHadErrors,
3095 else if (TemplateSpecified &&
3098 EnteringContext, Template,
3106 (AllowDestructorName || SS.
isSet()) && Tok.
is(tok::tilde)) {
3115 if (TemplateSpecified) {
3126 Diag(*TemplateKWLoc, diag::err_unexpected_template_in_destructor_name)
3131 if (SS.
isEmpty() && Tok.
is(tok::kw_decltype)) {
3136 Result.setDestructorName(TildeLoc,
Type, EndLoc);
3143 if (Tok.
isNot(tok::identifier)) {
3144 Diag(Tok, diag::err_destructor_tilde_identifier);
3149 DeclaratorScopeObj DeclScopeObj(*
this, SS);
3157 AnnotateScopeToken(SS,
true);
3160 if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, ObjectHadErrors,
3164 ObjectType =
nullptr;
3165 if (Tok.
isNot(tok::identifier) ||
NextToken().is(tok::coloncolon) ||
3167 Diag(TildeLoc, diag::err_destructor_tilde_scope);
3172 Diag(TildeLoc, diag::err_destructor_tilde_scope)
3178 DeclScopeObj.EnterDeclaratorScope();
3185 if (Tok.
is(tok::less)) {
3186 Result.setDestructorName(TildeLoc,
nullptr, ClassNameLoc);
3187 return ParseUnqualifiedIdTemplateId(
3188 SS, ObjectType, ObjectHadErrors,
3190 ClassNameLoc, EnteringContext,
Result, TemplateSpecified);
3196 ObjectType, EnteringContext);
3200 Result.setDestructorName(TildeLoc, Ty, ClassNameLoc);
3205#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
3206#include "clang/Basic/TransformTypeTraits.def"
3209 Diag(Tok, diag::ext_keyword_as_ident)
3211 goto ParseIdentifier;
3215 Diag(Tok, diag::err_expected_unqualified_id) <<
getLangOpts().CPlusPlus;
3249Parser::ParseCXXNewExpression(
bool UseGlobal,
SourceLocation Start) {
3250 assert(Tok.
is(tok::kw_new) &&
"expected 'new' token");
3256 ExprVector PlacementArgs;
3263 if (Tok.
is(tok::l_paren)) {
3267 PlacementLParen =
T.getOpenLocation();
3268 if (ParseExpressionListOrTypeId(PlacementArgs, DeclaratorInfo)) {
3274 PlacementRParen =
T.getCloseLocation();
3280 if (PlacementArgs.empty()) {
3282 TypeIdParens =
T.getRange();
3286 if (Tok.
is(tok::l_paren)) {
3289 MaybeParseGNUAttributes(DeclaratorInfo);
3290 ParseSpecifierQualifierList(DS);
3292 ParseDeclarator(DeclaratorInfo);
3294 TypeIdParens =
T.getRange();
3296 MaybeParseGNUAttributes(DeclaratorInfo);
3297 if (ParseCXXTypeSpecifierSeq(DS))
3298 DeclaratorInfo.setInvalidType(
true);
3301 ParseDeclaratorInternal(DeclaratorInfo,
3302 &Parser::ParseDirectNewDeclarator);
3309 MaybeParseGNUAttributes(DeclaratorInfo);
3311 DeclaratorInfo.setInvalidType(
true);
3314 ParseDeclaratorInternal(DeclaratorInfo,
3315 &Parser::ParseDirectNewDeclarator);
3318 if (DeclaratorInfo.isInvalidType()) {
3325 if (Tok.
is(tok::l_paren)) {
3327 ExprVector ConstructorArgs;
3330 ConstructorLParen =
T.getOpenLocation();
3331 if (Tok.
isNot(tok::r_paren)) {
3332 auto RunSignatureHelp = [&]() {
3341 DeclaratorInfo.getEndLoc(), ConstructorArgs, ConstructorLParen,
3343 CalledSignatureHelp =
true;
3344 return PreferredType;
3346 if (ParseExpressionList(ConstructorArgs, [&] {
3347 PreferredType.enterFunctionArgument(Tok.
getLocation(),
3357 ConstructorRParen =
T.getCloseLocation();
3367 diag::warn_cxx98_compat_generalized_initializer_lists);
3373 return Actions.
ActOnCXXNew(Start, UseGlobal, PlacementLParen,
3374 PlacementArgs, PlacementRParen,
3385void Parser::ParseDirectNewDeclarator(
Declarator &D) {
3388 while (Tok.
is(tok::l_square)) {
3390 if (CheckProhibitedCXX11Attribute())
3399 if (
Size.isInvalid()) {
3410 MaybeParseCXX11Attributes(Attrs);
3414 Size.get(),
T.getOpenLocation(),
3415 T.getCloseLocation()),
3416 std::move(Attrs),
T.getCloseLocation());
3418 if (
T.getCloseLocation().isInvalid())
3433bool Parser::ParseExpressionListOrTypeId(
3437 if (isTypeIdInParens()) {
3445 return ParseExpressionList(PlacementArgs);
3460Parser::ParseCXXDeleteExpression(
bool UseGlobal,
SourceLocation Start) {
3461 assert(Tok.
is(tok::kw_delete) &&
"Expected 'delete' keyword");
3465 bool ArrayDelete =
false;
3466 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::r_square)) {
3474 const Token Next = GetLookAheadToken(2);
3477 if (Next.isOneOf(tok::l_brace, tok::less) ||
3478 (Next.is(tok::l_paren) &&
3479 (GetLookAheadToken(3).is(tok::r_paren) ||
3480 (GetLookAheadToken(3).is(tok::identifier) &&
3481 GetLookAheadToken(4).is(tok::identifier))))) {
3482 TentativeParsingAction TPA(*
this);
3490 bool EmitFixIt =
false;
3491 if (Tok.
is(tok::l_brace)) {
3501 Diag(Start, diag::err_lambda_after_delete)
3509 Diag(Start, diag::err_lambda_after_delete)
3519 Lambda = ParsePostfixExpressionSuffix(Lambda);
3531 if (
T.getCloseLocation().isInvalid())
3566ExprResult Parser::ParseRequiresExpression() {
3567 assert(Tok.
is(tok::kw_requires) &&
"Expected 'requires' keyword");
3572 if (Tok.
is(tok::l_paren)) {
3577 if (!Tok.
is(tok::r_paren)) {
3582 FirstArgAttrs, LocalParameters,
3585 Diag(EllipsisLoc, diag::err_requires_expr_parameter_list_ellipsis);
3586 for (
auto &ParamInfo : LocalParameters)
3587 LocalParameterDecls.push_back(cast<ParmVarDecl>(ParamInfo.Param));
3593 if (
Braces.expectAndConsume())
3610 RequiresKWLoc, LocalParameterDecls,
getCurScope());
3612 if (Tok.
is(tok::r_brace)) {
3619 Diag(Tok, diag::err_empty_requires_expr);
3622 while (!Tok.
is(tok::r_brace)) {
3624 case tok::l_brace: {
3635 ExprBraces.consumeOpen();
3639 ExprBraces.skipToEnd();
3643 if (ExprBraces.consumeClose())
3644 ExprBraces.skipToEnd();
3649 if (Tok.
is(tok::semi)) {
3652 Requirements.push_back(Req);
3657 Diag(Tok, diag::err_requires_expr_missing_arrow)
3660 if (TryAnnotateTypeConstraint()) {
3664 if (!isTypeConstraintAnnotation()) {
3665 Diag(Tok, diag::err_requires_expr_expected_type_constraint);
3670 if (Tok.
is(tok::annot_cxxscope)) {
3674 ConsumeAnnotationToken();
3678 Expression.get(), NoexceptLoc, SS, takeTemplateIdAnnotation(Tok),
3679 TemplateParameterDepth);
3680 ConsumeAnnotationToken();
3682 Requirements.push_back(Req);
3686 bool PossibleRequiresExprInSimpleRequirement =
false;
3687 if (Tok.
is(tok::kw_requires)) {
3688 auto IsNestedRequirement = [&] {
3689 RevertingTentativeParsingAction TPA(*
this);
3691 if (Tok.
is(tok::l_brace))
3698 if (Tok.
is(tok::l_paren)) {
3701 auto Res = TryParseParameterDeclarationClause();
3702 if (Res != TPResult::False) {
3705 while (Depth != 0) {
3706 bool FoundParen =
SkipUntil(tok::l_paren, tok::r_paren,
3710 if (Tok.
is(tok::l_paren))
3712 else if (Tok.
is(tok::r_paren))
3723 if (Tok.
is(tok::l_brace))
3732 if (IsNestedRequirement()) {
3747 Requirements.push_back(Req);
3755 PossibleRequiresExprInSimpleRequirement =
true;
3756 }
else if (Tok.
is(tok::kw_typename)) {
3759 TentativeParsingAction TPA(*
this);
3769 if (Tok.
is(tok::annot_cxxscope)) {
3772 ConsumeAnnotationToken();
3775 if (Tok.
isOneOf(tok::identifier, tok::annot_template_id) &&
3781 if (Tok.
is(tok::identifier)) {
3785 TemplateId = takeTemplateIdAnnotation(Tok);
3786 ConsumeAnnotationToken();
3794 Requirements.push_back(Req);
3811 if (!
Expression.isInvalid() && PossibleRequiresExprInSimpleRequirement)
3812 Diag(StartLoc, diag::err_requires_expr_in_simple_requirement)
3815 Requirements.push_back(Req);
3821 if (Tok.
is(tok::kw_noexcept)) {
3822 Diag(Tok, diag::err_requires_expr_simple_requirement_noexcept)
3831 if (ExpectAndConsumeSemi(diag::err_expected_semi_requirement)) {
3837 if (Requirements.empty()) {
3848 ParsingBodyDecl.complete(Body);
3850 RequiresKWLoc, Body,
Parens.getOpenLocation(), LocalParameterDecls,
3851 Parens.getCloseLocation(), Requirements,
Braces.getCloseLocation());
3856 default: llvm_unreachable(
"Not a known type trait");
3857#define TYPE_TRAIT_1(Spelling, Name, Key) \
3858case tok::kw_ ## Spelling: return UTT_ ## Name;
3859#define TYPE_TRAIT_2(Spelling, Name, Key) \
3860case tok::kw_ ## Spelling: return BTT_ ## Name;
3861#include "clang/Basic/TokenKinds.def"
3862#define TYPE_TRAIT_N(Spelling, Name, Key) \
3863 case tok::kw_ ## Spelling: return TT_ ## Name;
3864#include "clang/Basic/TokenKinds.def"
3871 llvm_unreachable(
"Not a known array type trait");
3872#define ARRAY_TYPE_TRAIT(Spelling, Name, Key) \
3873 case tok::kw_##Spelling: \
3875#include "clang/Basic/TokenKinds.def"
3882 llvm_unreachable(
"Not a known unary expression trait.");
3883#define EXPRESSION_TRAIT(Spelling, Name, Key) \
3884 case tok::kw_##Spelling: \
3886#include "clang/Basic/TokenKinds.def"
3907 if (
Parens.expectAndConsume())
3923 if (Tok.
is(tok::ellipsis)) {
3932 Args.push_back(Ty.
get());
3935 if (
Parens.consumeClose())
3955 if (
T.expectAndConsume())
3967 case ATT_ArrayRank: {
3970 T.getCloseLocation());
3972 case ATT_ArrayExtent: {
3973 if (ExpectAndConsume(tok::comma)) {
3982 T.getCloseLocation());
3985 llvm_unreachable(
"Invalid ArrayTypeTrait!");
3999 if (
T.expectAndConsume())
4007 T.getCloseLocation());
4015Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
4020 assert(ExprType ==
CastExpr &&
"Compound literals are not ambiguous!");
4021 assert(isTypeIdInParens() &&
"Not a type-id!");
4045 ParenParseOption ParseAs;
4050 if (!ConsumeAndStoreUntil(tok::r_paren, Toks)) {
4056 if (Tok.
is(tok::l_brace)) {
4057 ParseAs = CompoundLiteral;
4060 if (Tok.
is(tok::l_paren) &&
NextToken().is(tok::r_paren)) {
4067 Result = ParseCastExpression(AnyCastExpr,
4076 ParseAs = NotCastExpr ? SimpleExpr :
CastExpr;
4085 Toks.push_back(AttrEnd);
4088 Toks.push_back(Tok);
4091 PP.EnterTokenStream(Toks,
true,
4097 if (ParseAs >= CompoundLiteral) {
4104 ParseSpecifierQualifierList(DS);
4105 ParseDeclarator(DeclaratorInfo);
4116 if (ParseAs == CompoundLiteral) {
4117 ExprType = CompoundLiteral;
4118 if (DeclaratorInfo.isInvalidType())
4122 return ParseCompoundLiteralExpression(Ty.
get(),
4130 if (DeclaratorInfo.isInvalidType())
4136 DeclaratorInfo, CastTy,
4142 assert(ParseAs == SimpleExpr);
4144 ExprType = SimpleExpr;
4146 if (!
Result.isInvalid() && Tok.
is(tok::r_paren))
4151 if (
Result.isInvalid()) {
4152 while (Tok.
isNot(tok::eof))
4171 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"__builtin_bit_cast"))
4176 ParseSpecifierQualifierList(DS);
4181 ParseDeclarator(DeclaratorInfo);
4183 if (ExpectAndConsume(tok::comma)) {
4191 if (
T.consumeClose())
4194 if (
Operand.isInvalid() || DeclaratorInfo.isInvalidType())
4198 T.getCloseLocation());
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
Defines the clang::Expr interface and subclasses for C++ expressions.
static void addConstexprToLambdaDeclSpecifier(Parser &P, SourceLocation ConstexprLoc, DeclSpec &DS)
static void FixDigraph(Parser &P, Preprocessor &PP, Token &DigraphToken, Token &ColonToken, tok::TokenKind Kind, bool AtDigraph)
static ArrayTypeTrait ArrayTypeTraitFromTokKind(tok::TokenKind kind)
static void tryConsumeLambdaSpecifierToken(Parser &P, SourceLocation &MutableLoc, SourceLocation &StaticLoc, SourceLocation &ConstexprLoc, SourceLocation &ConstevalLoc, SourceLocation &DeclEndLoc)
static ExpressionTrait ExpressionTraitFromTokKind(tok::TokenKind kind)
static void addConstevalToLambdaDeclSpecifier(Parser &P, SourceLocation ConstevalLoc, DeclSpec &DS)
static TypeTrait TypeTraitFromTokKind(tok::TokenKind kind)
static void DiagnoseStaticSpecifierRestrictions(Parser &P, SourceLocation StaticLoc, SourceLocation MutableLoc, const LambdaIntroducer &Intro)
static int SelectDigraphErrorMessage(tok::TokenKind Kind)
static void addStaticToLambdaDeclSpecifier(Parser &P, SourceLocation StaticLoc, DeclSpec &DS)
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
static constexpr bool isOneOf()
Defines the clang::TokenKind enum and support functions.
const clang::PrintingPolicy & getPrintingPolicy() const
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
SourceLocation getOpenLocation() const
SourceLocation getCloseLocation() const
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
void setEndLoc(SourceLocation Loc)
void SetInvalid(SourceRange R)
Indicate that this nested-name-specifier is invalid.
bool isEmpty() const
No scope specifier.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
void restore()
restore - This can be used to restore the state early, before the dtor is run.
Captures information about "declaration specifiers".
static const TST TST_typename
SourceLocation getEndLoc() const LLVM_READONLY
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
static const TST TST_char8
static const TST TST_BFloat16
bool SetConstexprSpec(ConstexprSpecKind ConstexprKind, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool SetTypeSpecWidth(TypeSpecifierWidth W, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec, but return true and ignore the request if ...
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceRange getSourceRange() const LLVM_READONLY
void SetRangeEnd(SourceLocation Loc)
bool SetBitIntType(SourceLocation KWLoc, Expr *BitWidth, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
static const TST TST_double
void SetRangeStart(SourceLocation Loc)
static const TST TST_char
static const TST TST_bool
static const TST TST_char16
static const TST TST_accum
static const TST TST_half
static const TST TST_ibm128
static const TST TST_float128
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Imaginary" (...
static const TST TST_wchar
static const TST TST_void
static const TST TST_float
static const TST TST_fract
static const TST TST_float16
static const TST TST_decltype_auto
static const TST TST_error
static const TST TST_char32
static const TST TST_int128
bool SetTypeSpecSign(TypeSpecifierSign S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_auto
Decl - This represents one declaration (or definition), e.g.
SourceLocation getLocation() const
Information about one declarator, including the parsed type information and the identifier.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
void SetSourceRange(SourceRange R)
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
bool isInvalidType() const
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
RAII object that enters a new expression evaluation context.
This represents one expression.
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.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Characters, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token,...
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
This represents a decl that may have a name.
static OpaquePtr make(QualType P)
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing,...
ParsedAttr - Represents a syntactic attribute.
static const ParsedAttributesView & none()
ParsedAttributes - A collection of parsed attributes.
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 type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
AttributeFactory & getAttrFactory()
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
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.
bool TryAnnotateOptionalCXXScopeToken(bool EnteringContext=false)
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
ExprResult ParseConstantExpression()
bool TryConsumeToken(tok::TokenKind Expected)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Scope * getCurScope() const
OpaquePtr< TemplateName > TemplateTy
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 ...
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
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.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
RAII object used to inform the actions that we're currently parsing a declaration.
void enterTypeCast(SourceLocation Tok, QualType CastType)
Handles all type casts, including C-style cast, C++ casts, etc.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
void Lex(Token &Result)
Lex the next token for this preprocessor.
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
SourceManager & getSourceManager() const
void RevertCachedTokens(unsigned N)
When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens...
IdentifierTable & getIdentifierTable()
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
SourceLocation getLastCachedTokenLocation() const
Get the location of the last cached token, suitable for setting the end location of an annotation tok...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
If a crash happens while one of these objects are live, the message is printed out along with the spe...
A (possibly-)qualified type.
Represents the body of a requires-expression.
Scope - A scope is a transient data structure that is used while parsing the program.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ LambdaScope
This is the scope for a lambda, after the lambda introducer.
@ BlockScope
This is a scope that corresponds to a block/closure object.
@ ContinueScope
This is a while, do, for, which can have continue statements embedded into it.
@ BreakScope
This is a while, do, switch, for, etc that can have break statements embedded into it.
@ CompoundStmtScope
This is a compound statement scope.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
@ 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.
ExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXTypeid - Parse typeid( something ).
ExprResult ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXUuidof - Parse __uuidof( something ).
ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body)
ActOnLambdaExpr - This is called when the body of a lambda expression was successfully completed.
void CodeCompleteObjCMessageReceiver(Scope *S)
TypeResult ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, const IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
QualType ProduceConstructorSignatureHelp(QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args, SourceLocation OpenParLoc, bool Braced)
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
ActOnExpressionTrait - Parsed one of the unary type trait support pseudo-functions.
@ Switch
An integral condition for a 'switch' statement.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
void ActOnLambdaExpressionAfterIntroducer(LambdaIntroducer &Intro, Scope *CurContext)
Once the Lambdas capture are known, we can start to create the closure, call operator method,...
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
concepts::Requirement * ActOnCompoundRequirement(Expr *E, SourceLocation NoexceptLoc)
bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc)
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression.
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization, bool Disambiguation=false)
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E)
ParsedType getDestructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
ASTContext & getASTContext() const
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc, SourceLocation TildeLoc, UnqualifiedId &SecondTypeName)
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, ParsedType LhsTy, Expr *DimExpr, SourceLocation RParen)
ActOnArrayTypeTrait - Parsed one of the binary type trait support pseudo-functions.
void ActOnFinishRequiresExpr()
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
ActOnCXXThrow - Parse throw expressions.
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
ExprResult ActOnNameClassifiedAsNonType(Scope *S, const CXXScopeSpec &SS, NamedDecl *Found, SourceLocation NameLoc, const Token &NextToken)
Act on the result of classifying a name as a specific non-type declaration.
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS)
The parser has parsed a global nested-name-specifier '::'.
bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, bool EnteringContext, CXXScopeSpec &SS, bool *IsCorrectedToColon=nullptr, bool OnlyNamespace=false)
The parser has parsed a nested-name-specifier 'identifier::'.
bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id, bool IsUDSuffix)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK, bool MissingOK=false)
sema::LambdaScopeInfo * PushLambdaScope()
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, bool IsUsingDeclaration, QualType BaseType, QualType PreferredType)
void ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, Declarator &ParamInfo, const DeclSpec &DS)
ActOnStartOfLambdaDefinition - This is called just before we start parsing the body of a lambda; it a...
void ActOnLambdaClosureParameters(Scope *LambdaScope, MutableArrayRef< DeclaratorChunk::ParamInfo > ParamInfo)
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep, SourceLocation LParenOrBraceLoc, MultiExprArg Exprs, SourceLocation RParenOrBraceLoc, bool ListInitialization)
ActOnCXXTypeConstructExpr - Parse construction of a specified type.
ConditionResult ActOnConditionVariable(Decl *ConditionVar, SourceLocation StmtLoc, ConditionKind CK)
bool ActOnSuperScopeSpecifier(SourceLocation SuperLoc, SourceLocation ColonColonLoc, CXXScopeSpec &SS)
The parser has parsed a '__super' nested-name-specifier.
ExprResult ActOnRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, SourceLocation LParenLoc, ArrayRef< ParmVarDecl * > LocalParameters, SourceLocation RParenLoc, ArrayRef< concepts::Requirement * > Requirements, SourceLocation ClosingBraceLoc)
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
void CodeCompleteOperatorName(Scope *S)
ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, SourceLocation LAngleBracketLoc, Declarator &D, SourceLocation RAngleBracketLoc, SourceLocation LParenLoc, Expr *E, SourceLocation RParenLoc)
ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const,addrspace}_cast's.
ExprResult ActOnPackIndexingExpr(Scope *S, Expr *PackExpression, SourceLocation EllipsisLoc, SourceLocation LSquareLoc, Expr *IndexExpr, SourceLocation RSquareLoc)
ParsedType getDestructorTypeForDecltype(const DeclSpec &DS, ParsedType ObjectType)
ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer)
ActOnCXXNew - Parsed a C++ 'new' expression.
@ PCC_Condition
Code completion occurs within the condition of an if, while, switch, or for statement.
void RestoreNestedNameSpecifierAnnotation(void *Annotation, SourceRange AnnotationRange, CXXScopeSpec &SS)
Given an annotation pointer for a nested-name-specifier, restore the nested-name-specifier structure.
TemplateNameKind ActOnTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a template name from a name that is syntactically required to name a template,...
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
SourceManager & getSourceManager() const
void ActOnLambdaExplicitTemplateParameterList(LambdaIntroducer &Intro, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > TParams, SourceLocation RAngleLoc, ExprResult RequiresClause)
This is called after parsing the explicit template parameter list on a lambda (if it exists) in C++2a...
bool ActOnCXXNestedNameSpecifierIndexedPack(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc, QualType Type)
ParsedType actOnLambdaInitCaptureInitialization(SourceLocation Loc, bool ByRef, SourceLocation EllipsisLoc, IdentifierInfo *Id, LambdaCaptureInitKind InitKind, Expr *&Init)
Perform initialization analysis of the init-capture and perform any implicit conversions such as an l...
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
TypeResult ActOnTypeName(Declarator &D)
void ActOnLambdaClosureQualifiers(LambdaIntroducer &Intro, SourceLocation MutableLoc)
void ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope, bool IsInstantiation=false)
ActOnLambdaError - If there is an error parsing a lambda, this callback is invoked to pop the informa...
concepts::Requirement * ActOnTypeRequirement(SourceLocation TypenameKWLoc, CXXScopeSpec &SS, SourceLocation NameLoc, const IdentifierInfo *TypeName, TemplateIdAnnotation *TemplateId)
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
ExprResult ActOnRequiresClause(ExprResult ConstraintExpr)
RequiresExprBodyDecl * ActOnStartRequiresExpr(SourceLocation RequiresKWLoc, ArrayRef< ParmVarDecl * > LocalParameters, Scope *BodyScope)
@ 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),...
void RecordParsingTemplateParameterDepth(unsigned Depth)
This is used to inform Sema what the current TemplateParameterDepth is during Parsing.
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, CXXScopeSpec &SS, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration.
ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< ParsedType > Args, SourceLocation RParenLoc)
Parsed one of the type trait support pseudo-functions.
QualType ActOnPackIndexingType(QualType Pattern, Expr *IndexExpr, SourceLocation Loc, SourceLocation EllipsisLoc)
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
ParsedType getConstructorName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, bool EnteringContext)
ExprResult ActOnNameClassifiedAsDependentNonType(const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, bool IsAddressOfOperand)
Act on the result of classifying a name as an undeclared member of a dependent base class.
concepts::Requirement * ActOnNestedRequirement(Expr *Constraint)
static ConditionResult ConditionError()
bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo, bool EnteringContext)
IsInvalidUnlessNestedName - This method is used for error recovery purposes to determine whether the ...
ExprResult ActOnCXXThis(SourceLocation Loc)
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, 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...
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.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getEnd() const
SourceLocation getBegin() const
void setEnd(SourceLocation e)
Stmt - This represents one statement.
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
Represents a C++ template name within the type system.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
void setAnnotationEndLoc(SourceLocation L)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
const char * getName() const
unsigned getLength() const
void setLength(unsigned Len)
void setKind(tok::TokenKind K)
SourceLocation getAnnotationEndLoc() 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)) {....
void * getAnnotationValue() const
tok::TokenKind getKind() const
bool isRegularKeywordAttribute() const
Return true if the token is a keyword that is parsed in the same position as a standard attribute,...
void setEofData(const void *D)
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
void setLocation(SourceLocation L)
bool hasLeadingEmptyMacro() const
Return true if this token has an empty macro before it.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
const void * getEofData() const
void startToken()
Reset all flags to cleared.
The base class of the type hierarchy.
QualType getCanonicalTypeInternal() const
Represents a C++ unqualified-id that has been parsed.
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.
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
A static requirement that can be used in a requires-expression to check properties of types and expre...
uint32_t Literal
Literals are represented as positive integers.
@ After
Like System, but searched after the system directories.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
The JSON file list parser is used to communicate input to InstallAPI.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
@ OO_None
Not an overloaded operator.
ArrayTypeTrait
Names for the array type traits.
LambdaCaptureKind
The different capture forms in a lambda introducer.
@ LCK_ByCopy
Capturing by copy (a.k.a., by value)
@ LCK_ByRef
Capturing by reference.
@ LCK_StarThis
Capturing the *this object by copy.
@ LCK_This
Capturing the *this object by reference.
@ IK_ConstructorName
A constructor name.
@ IK_LiteralOperatorId
A user-defined literal name, e.g., operator "" _i.
@ IK_Identifier
An identifier.
@ IK_DestructorName
A destructor name.
@ IK_OperatorFunctionId
An overloaded operator name, e.g., operator+.
@ CopyInit
[a = b], [a = {b}]
@ Result
The result type of a method or function.
ActionResult< Expr * > ExprResult
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
@ TNK_Non_template
The name does not refer to a template.
@ TNK_Undeclared_template
Lookup for the name failed, but we're assuming it was a template name anyway.
const FunctionProtoType * T
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword.
TypeTrait
Names for traits that operate specifically on types.
@ Parens
New-expression has a C++98 paren-delimited initializer.
@ Braces
New-expression has a C++11 list-initializer.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_None
no exception specification
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.
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
Represents a complete lambda introducer.
bool hasLambdaCapture() const
void addCapture(LambdaCaptureKind Kind, SourceLocation Loc, IdentifierInfo *Id, SourceLocation EllipsisLoc, LambdaCaptureInitKind InitKind, ExprResult Init, ParsedType InitCaptureType, SourceRange ExplicitRange)
Append a capture in a lambda introducer.
SourceLocation DefaultLoc
LambdaCaptureDefault Default
Describes how types, statements, expressions, and declarations should be printed.
Keeps information about an identifier in a nested-name-spec.
Information about a template-id annotation token.
const IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
unsigned NumArgs
NumArgs - The number of template arguments.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
static TemplateIdAnnotation * Create(SourceLocation TemplateKWLoc, SourceLocation TemplateNameLoc, const IdentifierInfo *Name, OverloadedOperatorKind OperatorKind, ParsedTemplateTy OpaqueTemplateName, TemplateNameKind TemplateKind, SourceLocation LAngleLoc, SourceLocation RAngleLoc, ArrayRef< ParsedTemplateArgument > TemplateArgs, bool ArgsInvalid, SmallVectorImpl< TemplateIdAnnotation * > &CleanupList)
Creates a new TemplateIdAnnotation with NumArgs arguments and appends it to List.