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,
160 IdentifierInfo **LastII,
bool OnlyNamespace,
bool InUsingDeclaration) {
162 "Call sites of this function should be guarded by checking for C++");
164 if (Tok.
is(tok::annot_cxxscope)) {
165 assert(!LastII &&
"want last identifier but have already annotated scope");
166 assert(!MayBePseudoDestructor &&
"unexpected annot_cxxscope");
170 ConsumeAnnotationToken();
175 bool CheckForDestructor =
false;
176 if (MayBePseudoDestructor && *MayBePseudoDestructor) {
177 CheckForDestructor =
true;
178 *MayBePseudoDestructor =
false;
184 bool HasScopeSpecifier =
false;
186 if (Tok.
is(tok::coloncolon)) {
189 if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
192 if (NextKind == tok::l_brace) {
201 HasScopeSpecifier =
true;
205 if (Tok.
is(tok::kw___super)) {
207 if (!Tok.
is(tok::coloncolon)) {
215 if (!HasScopeSpecifier &&
216 Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
226 AnnotateExistingDecltypeSpecifier(DS, DeclLoc, EndLoc);
233 HasScopeSpecifier =
true;
236 else if (!HasScopeSpecifier && Tok.
is(tok::identifier) &&
237 GetLookAheadToken(1).is(tok::ellipsis) &&
238 GetLookAheadToken(2).is(tok::l_square)) {
247 DS.getRepAsType().get(), DS.getPackIndexingExpr(), DS.getBeginLoc(),
248 DS.getEllipsisLoc());
261 HasScopeSpecifier =
true;
265 auto SavedType = PreferredType;
267 if (HasScopeSpecifier) {
268 if (Tok.
is(tok::code_completion)) {
273 InUsingDeclaration, ObjectType.
get(),
293 ObjectType =
nullptr;
301 if (Tok.
is(tok::kw_template)) {
305 if (!HasScopeSpecifier && !ObjectType)
308 TentativeParsingAction TPA(*
this);
312 if (Tok.
is(tok::identifier)) {
316 }
else if (Tok.
is(tok::kw_operator)) {
321 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
330 diag::err_id_after_template_in_nested_name_spec)
343 if (Tok.
isNot(tok::less)) {
353 EnteringContext, Template,
true);
354 if (AnnotateTemplateIdToken(Template, TNK, SS, TemplateKWLoc,
361 if (Tok.
is(tok::annot_template_id) &&
NextToken().is(tok::coloncolon)) {
370 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
371 *MayBePseudoDestructor =
true;
376 *LastII = TemplateId->
Name;
379 ConsumeAnnotationToken();
381 assert(Tok.
is(tok::coloncolon) &&
"NextToken() not working properly!");
384 HasScopeSpecifier =
true;
411 if (Tok.
isNot(tok::identifier))
426 if (Next.is(tok::colon) && !ColonIsSacred) {
433 Diag(Next, diag::err_unexpected_colon_in_nested_name_spec)
436 Next.setKind(tok::coloncolon);
440 if (Next.is(tok::coloncolon) && GetLookAheadToken(2).is(tok::l_brace)) {
451 if (Next.is(tok::coloncolon)) {
452 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
453 *MayBePseudoDestructor =
true;
458 const Token &Next2 = GetLookAheadToken(2);
459 if (Next2.
is(tok::kw_private) || Next2.
is(tok::kw_protected) ||
460 Next2.
is(tok::kw_public) || Next2.
is(tok::kw_virtual)) {
461 Diag(Next2, diag::err_unexpected_token_in_nested_name_spec)
466 ColonColon.
setKind(tok::colon);
479 assert(Tok.
isOneOf(tok::coloncolon, tok::colon) &&
480 "NextToken() not working properly!");
481 Token ColonColon = Tok;
484 bool IsCorrectedToColon =
false;
485 bool *CorrectionFlagPtr = ColonIsSacred ? &IsCorrectedToColon :
nullptr;
487 getCurScope(), IdInfo, EnteringContext, SS, CorrectionFlagPtr,
491 if (CorrectionFlagPtr && IsCorrectedToColon) {
492 ColonColon.
setKind(tok::colon);
500 HasScopeSpecifier =
true;
504 CheckForTemplateAndDigraph(Next, ObjectType, EnteringContext, II, SS);
508 if (Next.is(tok::less)) {
513 bool MemberOfUnknownSpecialization;
520 MemberOfUnknownSpecialization)) {
526 isTemplateArgumentList(1) == TPResult::False)
543 if (MemberOfUnknownSpecialization && (ObjectType || SS.
isSet()) &&
544 (IsTypename || isTemplateArgumentList(1) == TPResult::True)) {
547 if (!ObjectHadErrors) {
552 unsigned DiagID = diag::err_missing_dependent_template_keyword;
554 DiagID = diag::warn_missing_dependent_template_keyword;
565 EnteringContext, Template,
true);
582 if (CheckForDestructor && !HasScopeSpecifier && Tok.
is(tok::tilde))
583 *MayBePseudoDestructor =
true;
589 bool isAddressOfOperand,
590 Token &Replacement) {
595 case tok::annot_non_type: {
596 NamedDecl *ND = getNonTypeAnnotation(Tok);
602 case tok::annot_non_type_dependent: {
608 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
609 isAddressOfOperand =
false;
616 case tok::annot_non_type_undeclared: {
618 "undeclared non-type annotation should be unqualified");
633 false, &TemplateKWLoc, Name))
638 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
639 isAddressOfOperand =
false;
642 getCurScope(), SS, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
643 isAddressOfOperand,
nullptr,
false,
649 E = tryParseCXXPackIndexingExpression(E);
652 checkPotentialAngleBracket(E);
657 assert(Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square) &&
663 if (T.consumeClose() || IndexExpr.
isInvalid())
666 EllipsisLoc, T.getOpenLocation(),
667 IndexExpr.
get(), T.getCloseLocation());
671Parser::tryParseCXXPackIndexingExpression(
ExprResult PackIdExpression) {
674 Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square)) {
675 E = ParseCXXPackIndexingExpression(E);
722ExprResult Parser::ParseCXXIdExpression(
bool isAddressOfOperand) {
728 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
734 tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
738 UnconsumeToken(Replacement);
739 Result = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
741 assert(!
Result.isUnset() &&
"Typo correction suggested a keyword replacement "
742 "for a previous keyword suggestion");
794 if (ParseLambdaIntroducer(Intro)) {
801 return ParseLambdaExpressionAfterIntroducer(Intro);
808ExprResult Parser::TryParseLambdaExpression() {
810 && Tok.
is(tok::l_square)
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(
1329 Diag(LambdaBeginLoc, diag::warn_cxx98_compat_lambda);
1332 "lambda expression parsing");
1337 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1354 if (Tok.
is(tok::kw___noinline__)) {
1357 Attributes.addNew(AttrName, AttrNameLoc,
nullptr,
1358 AttrNameLoc,
nullptr,
1359 0, tok::kw___noinline__);
1360 }
else if (Tok.
is(tok::kw___attribute))
1361 ParseGNUAttributes(Attributes,
nullptr, &D);
1366 D.takeAttributes(Attributes);
1369 MultiParseScope TemplateParamScope(*
this);
1370 if (Tok.
is(tok::less)) {
1372 ? diag::warn_cxx17_compat_lambda_template_parameter_list
1373 : diag::ext_lambda_template_parameter_list);
1377 if (ParseTemplateParameters(TemplateParamScope,
1378 CurTemplateDepthTracker.getDepth(),
1379 TemplateParams, LAngleLoc, RAngleLoc)) {
1384 if (TemplateParams.empty()) {
1386 diag::err_lambda_template_parameter_list_empty);
1397 ++CurTemplateDepthTracker;
1408 Intro, LAngleLoc, TemplateParams, RAngleLoc, RequiresClause);
1416 if (isCXX11AttributeSpecifier()) {
1418 ? diag::warn_cxx20_compat_decl_attrs_on_lambda
1419 : diag::ext_decl_attrs_on_lambda)
1421 MaybeParseCXX11Attributes(D);
1428 bool HasParentheses =
false;
1429 bool HasSpecifiers =
false;
1440 if (Tok.
is(tok::l_paren)) {
1443 LParenLoc = T.getOpenLocation();
1445 if (Tok.
isNot(tok::r_paren)) {
1447 CurTemplateDepthTracker.getOriginalDepth());
1449 ParseParameterDeclarationClause(D, Attributes, ParamInfo, EllipsisLoc);
1456 CurTemplateDepthTracker.setAddedDepth(1);
1460 DeclEndLoc = RParenLoc = T.getCloseLocation();
1461 HasParentheses =
true;
1465 Tok.
isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute,
1466 tok::kw_constexpr, tok::kw_consteval, tok::kw_static,
1467 tok::kw___private, tok::kw___global, tok::kw___local,
1468 tok::kw___constant, tok::kw___generic, tok::kw_groupshared,
1469 tok::kw_requires, tok::kw_noexcept) ||
1473 if (HasSpecifiers && !HasParentheses && !
getLangOpts().CPlusPlus23) {
1477 Diag(Tok, diag::ext_lambda_missing_parens)
1481 if (HasParentheses || HasSpecifiers) {
1485 MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attributes);
1493 ConstevalLoc, DeclEndLoc);
1504 if (!HasParentheses)
1507 if (HasSpecifiers || HasParentheses) {
1516 ESpecType = tryParseExceptionSpecification(
1517 false, ESpecRange, DynamicExceptions,
1518 DynamicExceptionRanges, NoexceptExpr, ExceptionSpecTokens);
1521 DeclEndLoc = ESpecRange.
getEnd();
1524 if (MaybeParseCXX11Attributes(Attributes))
1525 DeclEndLoc = Attributes.Range.getEnd();
1528 if (Tok.
isOneOf(tok::kw___private, tok::kw___global, tok::kw___local,
1529 tok::kw___constant, tok::kw___generic)) {
1530 ParseOpenCLQualifiers(DS.getAttributes());
1537 if (Tok.
is(tok::arrow)) {
1540 TrailingReturnType =
1541 ParseTrailingReturnType(Range,
false);
1542 TrailingReturnTypeLoc =
Range.getBegin();
1543 if (
Range.getEnd().isValid())
1544 DeclEndLoc =
Range.getEnd();
1550 false, LParenLoc, ParamInfo.data(),
1551 ParamInfo.size(), EllipsisLoc, RParenLoc,
1553 NoLoc, MutableLoc, ESpecType,
1554 ESpecRange, DynamicExceptions.data(),
1555 DynamicExceptionRanges.data(), DynamicExceptions.size(),
1556 NoexceptExpr.
isUsable() ? NoexceptExpr.
get() :
nullptr,
1558 std::nullopt, LParenLoc,
1559 FunLocalRangeEnd, D, TrailingReturnType,
1560 TrailingReturnTypeLoc, &DS),
1561 std::move(Attributes), DeclEndLoc);
1565 if (HasParentheses && Tok.
is(tok::kw_requires))
1566 ParseTrailingRequiresClause(D);
1573 if (A.getKind() == ParsedAttr::AT_CUDADevice ||
1574 A.getKind() == ParsedAttr::AT_CUDAHost ||
1575 A.getKind() == ParsedAttr::AT_CUDAGlobal)
1576 Diag(A.getLoc(), diag::warn_cuda_attr_lambda_position)
1577 << A.getAttrName()->getName();
1586 ParseScope BodyScope(
this, ScopeFlags);
1591 if (!Tok.
is(tok::l_brace)) {
1592 Diag(Tok, diag::err_expected_lambda_body);
1599 TemplateParamScope.Exit();
1623 const char *CastName =
nullptr;
1626 default: llvm_unreachable(
"Unknown C++ cast!");
1627 case tok::kw_addrspace_cast: CastName =
"addrspace_cast";
break;
1628 case tok::kw_const_cast: CastName =
"const_cast";
break;
1629 case tok::kw_dynamic_cast: CastName =
"dynamic_cast";
break;
1630 case tok::kw_reinterpret_cast: CastName =
"reinterpret_cast";
break;
1631 case tok::kw_static_cast: CastName =
"static_cast";
break;
1639 if (Tok.
is(tok::l_square) && Tok.
getLength() == 2) {
1641 if (Next.is(tok::colon) && areTokensAdjacent(Tok, Next))
1642 FixDigraph(*
this, PP, Tok, Next, Kind,
true);
1645 if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
1650 ParseSpecifierQualifierList(DS,
AS_none,
1651 DeclSpecContext::DSC_type_specifier);
1656 ParseDeclarator(DeclaratorInfo);
1660 if (ExpectAndConsume(tok::greater))
1661 return ExprError(
Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
1665 if (T.expectAndConsume(diag::err_expected_lparen_after, CastName))
1673 if (!
Result.isInvalid() && !DeclaratorInfo.isInvalidType())
1675 LAngleBracketLoc, DeclaratorInfo,
1677 T.getOpenLocation(),
Result.get(),
1678 T.getCloseLocation());
1690 assert(Tok.
is(tok::kw_typeid) &&
"Not 'typeid'!");
1697 if (T.expectAndConsume(diag::err_expected_lparen_after,
"typeid"))
1699 LParenLoc = T.getOpenLocation();
1720 if (isTypeIdInParens()) {
1725 RParenLoc = T.getCloseLocation();
1730 Ty.
get().getAsOpaquePtr(), RParenLoc);
1739 RParenLoc = T.getCloseLocation();
1744 Result.get(), RParenLoc);
1757 assert(Tok.
is(tok::kw___uuidof) &&
"Not '__uuidof'!");
1763 if (T.expectAndConsume(diag::err_expected_lparen_after,
"__uuidof"))
1768 if (isTypeIdInParens()) {
1778 Ty.
get().getAsOpaquePtr(),
1779 T.getCloseLocation());
1793 Result.get(), T.getCloseLocation());
1840 if (Tok.
is(tok::identifier)) {
1843 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1845 }
else if (Tok.
is(tok::annot_template_id)) {
1851 ConsumeAnnotationToken();
1852 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1855 assert(SS.
isEmpty() &&
"missing last component of nested name specifier");
1860 assert(Tok.
is(tok::tilde) &&
"ParseOptionalCXXScopeSpecifier fail");
1863 if (Tok.
is(tok::kw_decltype) && !FirstTypeName.
isValid()) {
1865 ParseDecltypeSpecifier(DS);
1872 if (!Tok.
is(tok::identifier)) {
1873 Diag(Tok, diag::err_destructor_tilde_identifier);
1878 if (GetLookAheadToken(1).is(tok::ellipsis) &&
1879 GetLookAheadToken(2).is(tok::l_square)) {
1881 ParsePackIndexingType(DS);
1900 if (Tok.
is(tok::less) &&
1901 ParseUnqualifiedIdTemplateId(
1903 Name, NameLoc,
false, SecondTypeName,
1908 SS, FirstTypeName, CCLoc, TildeLoc,
1927 assert(Tok.
is(tok::kw_throw) &&
"Not throw!");
1954 assert(Tok.
is(tok::kw_co_yield) &&
"Not co_yield!");
1959 if (!
Expr.isInvalid())
1970 assert(Tok.
is(tok::kw_this) &&
"Not 'this'!");
1989Parser::ParseCXXTypeConstructExpression(
const DeclSpec &DS) {
1994 assert((Tok.
is(tok::l_paren) ||
1996 &&
"Expected '(' or '{'!");
1998 if (Tok.
is(tok::l_brace)) {
2001 if (
Init.isInvalid())
2015 auto RunSignatureHelp = [&]() {
2020 T.getOpenLocation(),
false);
2021 CalledSignatureHelp =
true;
2022 return PreferredType;
2025 if (Tok.
isNot(tok::r_paren)) {
2026 if (ParseExpressionList(Exprs, [&] {
2027 PreferredType.enterFunctionArgument(Tok.
getLocation(),
2045 Exprs, T.getCloseLocation(),
2053 assert(Tok.
is(tok::kw_using) &&
"Expected using");
2056 "Unexpected Declarator Context");
2060 DG = ParseUsingDeclaration(Context, {}, DeclStart, DeclEnd, Attrs,
AS_none);
2065 ? diag::ext_alias_in_init_statement
2066 : diag::warn_cxx20_alias_in_init_statement)
2106 ForRangeInfo *FRI,
bool EnterForConditionScope) {
2108 struct ForConditionScopeRAII {
2110 void enter(
bool IsConditionVariable) {
2113 S->setIsConditionVarScope(IsConditionVariable);
2116 ~ForConditionScopeRAII() {
2118 S->setIsConditionVarScope(
false);
2120 } ForConditionScope{EnterForConditionScope ?
getCurScope() : nullptr};
2123 PreferredType.enterCondition(Actions, Tok.
getLocation());
2125 if (Tok.
is(tok::code_completion)) {
2132 MaybeParseCXX11Attributes(attrs);
2134 const auto WarnOnInit = [
this, &CK] {
2136 ? diag::warn_cxx14_compat_init_statement
2137 : diag::ext_init_statement)
2142 switch (isCXXConditionDeclarationOrInitStatement(InitStmt, FRI)) {
2143 case ConditionOrInitStatement::Expression: {
2145 ForConditionScope.enter(
false);
2147 ProhibitAttributes(attrs);
2151 if (InitStmt && Tok.
is(tok::semi)) {
2155 Diag(SemiLoc, diag::warn_empty_init_statement)
2161 return ParseCXXCondition(
nullptr, Loc, CK, MissingOK);
2166 if (
Expr.isInvalid())
2169 if (InitStmt && Tok.
is(tok::semi)) {
2173 return ParseCXXCondition(
nullptr, Loc, CK, MissingOK);
2180 case ConditionOrInitStatement::InitStmtDecl: {
2184 if (Tok.
is(tok::kw_using))
2185 DG = ParseAliasDeclarationInInitStatement(
2190 attrs, DeclSpecAttrs,
true);
2193 return ParseCXXCondition(
nullptr, Loc, CK, MissingOK);
2196 case ConditionOrInitStatement::ForRangeDecl: {
2200 assert(FRI &&
"should not parse a for range declaration here");
2209 case ConditionOrInitStatement::ConditionDecl:
2210 case ConditionOrInitStatement::Error:
2215 ForConditionScope.enter(
true);
2219 ParseSpecifierQualifierList(DS,
AS_none, DeclSpecContext::DSC_condition);
2223 ParseDeclarator(DeclaratorInfo);
2226 if (Tok.
is(tok::kw_asm)) {
2228 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2229 if (AsmLabel.isInvalid()) {
2233 DeclaratorInfo.setAsmLabel(AsmLabel.get());
2234 DeclaratorInfo.SetRangeEnd(Loc);
2238 MaybeParseGNUAttributes(DeclaratorInfo);
2249 bool CopyInitialization = isTokenEqualOrEqualTypo();
2250 if (CopyInitialization)
2256 diag::warn_cxx98_compat_generalized_initializer_lists);
2257 InitExpr = ParseBraceInitializer();
2258 }
else if (CopyInitialization) {
2259 PreferredType.enterVariableInit(Tok.
getLocation(), DeclOut);
2261 }
else if (Tok.
is(tok::l_paren)) {
2265 RParen = ConsumeParen();
2267 diag::err_expected_init_in_condition_lparen)
2308void Parser::ParseCXXSimpleTypeSpecifier(
DeclSpec &DS) {
2310 const char *PrevSpec;
2317 case tok::identifier:
2318 case tok::coloncolon:
2319 llvm_unreachable(
"Annotation token should already be formed!");
2321 llvm_unreachable(
"Not a simple-type-specifier token!");
2324 case tok::annot_typename: {
2328 ConsumeAnnotationToken();
2329 DS.
Finish(Actions, Policy);
2333 case tok::kw__ExtInt:
2334 case tok::kw__BitInt: {
2335 DiagnoseBitIntUse(Tok);
2344 DS.
Finish(Actions, Policy);
2357 case tok::kw___int64:
2361 case tok::kw_signed:
2364 case tok::kw_unsigned:
2379 case tok::kw___int128:
2382 case tok::kw___bf16:
2391 case tok::kw_double:
2394 case tok::kw__Float16:
2397 case tok::kw___float128:
2400 case tok::kw___ibm128:
2403 case tok::kw_wchar_t:
2406 case tok::kw_char8_t:
2409 case tok::kw_char16_t:
2412 case tok::kw_char32_t:
2418 case tok::kw__Accum:
2421 case tok::kw__Fract:
2427#define GENERIC_IMAGE_TYPE(ImgType, Id) \
2428 case tok::kw_##ImgType##_t: \
2429 DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, DiagID, \
2432#include "clang/Basic/OpenCLImageTypes.def"
2434 case tok::annot_decltype:
2435 case tok::kw_decltype:
2437 return DS.
Finish(Actions, Policy);
2439 case tok::annot_pack_indexing_type:
2441 return DS.
Finish(Actions, Policy);
2444 case tok::kw_typeof:
2445 ParseTypeofSpecifier(DS);
2446 DS.
Finish(Actions, Policy);
2451 DS.
Finish(Actions, Policy);
2466 ParseSpecifierQualifierList(DS,
AS_none,
2467 getDeclSpecContextFromDeclaratorContext(Context));
2507bool Parser::ParseUnqualifiedIdTemplateId(
2511 assert(Tok.
is(tok::less) &&
"Expected '<' to finish parsing a template-id");
2515 switch (
Id.getKind()) {
2519 if (AssumeTemplateId) {
2523 ObjectType, EnteringContext, Template,
2526 bool MemberOfUnknownSpecialization;
2529 ObjectType, EnteringContext, Template,
2530 MemberOfUnknownSpecialization);
2535 isTemplateArgumentList(0) == TPResult::False)
2539 ObjectType && isTemplateArgumentList(0) == TPResult::True) {
2542 if (!ObjectHadErrors) {
2549 Name = std::string(
Id.Identifier->getName());
2555 Name +=
Id.Identifier->getName();
2557 Diag(
Id.StartLocation, diag::err_missing_dependent_template_keyword)
2562 getCurScope(), SS, TemplateKWLoc,
Id, ObjectType, EnteringContext,
2572 bool MemberOfUnknownSpecialization;
2576 EnteringContext, Template,
2577 MemberOfUnknownSpecialization);
2585 bool MemberOfUnknownSpecialization;
2590 EnteringContext, Template,
true);
2594 EnteringContext, Template,
2595 MemberOfUnknownSpecialization);
2598 Diag(NameLoc, diag::err_destructor_template_id)
2612 TemplateArgList TemplateArgs;
2613 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs, RAngleLoc,
2634 :
Id.OperatorFunctionId.Operator;
2637 TemplateKWLoc,
Id.StartLocation, TemplateII, OpKind, Template, TNK,
2638 LAngleLoc, RAngleLoc, TemplateArgs,
false, TemplateIds);
2640 Id.setTemplateId(TemplateId);
2649 getCurScope(), SS, TemplateKWLoc, Template, Name, NameLoc, LAngleLoc,
2650 TemplateArgsPtr, RAngleLoc,
true);
2651 if (
Type.isInvalid())
2655 Id.setConstructorName(
Type.get(), NameLoc, RAngleLoc);
2657 Id.setDestructorName(
Id.StartLocation,
Type.get(), RAngleLoc);
2702bool Parser::ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2705 assert(Tok.
is(tok::kw_operator) &&
"Expected 'operator' keyword");
2711 unsigned SymbolIdx = 0;
2716 case tok::kw_delete: {
2717 bool isNew = Tok.
getKind() == tok::kw_new;
2721 if (Tok.
is(tok::l_square) &&
2727 if (T.getCloseLocation().isInvalid())
2730 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2731 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2732 Op = isNew? OO_Array_New : OO_Array_Delete;
2734 Op = isNew? OO_New : OO_Delete;
2739#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2741 SymbolLocations[SymbolIdx++] = ConsumeToken(); \
2744#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2745#include "clang/Basic/OperatorKinds.def"
2747 case tok::l_paren: {
2752 if (T.getCloseLocation().isInvalid())
2755 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2756 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2761 case tok::l_square: {
2766 if (T.getCloseLocation().isInvalid())
2769 SymbolLocations[SymbolIdx++] = T.getOpenLocation();
2770 SymbolLocations[SymbolIdx++] = T.getCloseLocation();
2775 case tok::code_completion: {
2789 Result.setOperatorFunctionId(KeywordLoc, Op, SymbolLocations);
2803 unsigned DiagId = 0;
2809 while (isTokenStringLiteral()) {
2810 if (!Tok.
is(tok::string_literal) && !DiagId) {
2815 DiagId = diag::err_literal_operator_string_prefix;
2817 Toks.push_back(Tok);
2818 TokLocs.push_back(ConsumeStringToken());
2827 bool IsUDSuffix = !
Literal.getUDSuffix().empty();
2836 }
else if (Tok.
is(tok::identifier)) {
2839 TokLocs.push_back(SuffixLoc);
2851 DiagLoc = TokLocs.front();
2852 DiagId = diag::err_literal_operator_string_not_empty;
2862 SourceRange(TokLocs.front(), TokLocs.back()), Str);
2865 Result.setLiteralOperatorId(II, KeywordLoc, SuffixLoc);
2883 if (ParseCXXTypeSpecifierSeq(
2891 ParseDeclaratorInternal(D,
nullptr);
2899 Result.setConversionFunctionId(KeywordLoc, Ty.
get(),
2900 D.getSourceRange().getEnd());
2941 bool ObjectHadErrors,
bool EnteringContext,
2942 bool AllowDestructorName,
2943 bool AllowConstructorName,
2944 bool AllowDeductionGuide,
2952 bool TemplateSpecified =
false;
2953 if (Tok.
is(tok::kw_template)) {
2954 if (TemplateKWLoc && (ObjectType || SS.
isSet())) {
2955 TemplateSpecified =
true;
2959 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
2967 if (Tok.
is(tok::identifier)) {
2981 if (AllowConstructorName &&
2988 Result.setConstructorName(Ty, IdLoc, IdLoc);
3002 if (Tok.
is(tok::less))
3003 return ParseUnqualifiedIdTemplateId(
3004 SS, ObjectType, ObjectHadErrors,
3006 EnteringContext,
Result, TemplateSpecified);
3007 else if (TemplateSpecified &&
3010 EnteringContext, Template,
3019 if (Tok.
is(tok::annot_template_id)) {
3025 ConsumeAnnotationToken();
3030 if (AllowConstructorName && TemplateId->
Name &&
3038 diag::err_out_of_line_constructor_template_id)
3049 ConsumeAnnotationToken();
3053 Result.setConstructorTemplateId(TemplateId);
3054 ConsumeAnnotationToken();
3060 Result.setTemplateId(TemplateId);
3063 if (TemplateKWLoc && (ObjectType || SS.
isSet()))
3064 *TemplateKWLoc = TemplateLoc;
3066 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
3069 ConsumeAnnotationToken();
3076 if (Tok.
is(tok::kw_operator)) {
3077 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
Result))
3089 return ParseUnqualifiedIdTemplateId(
3090 SS, ObjectType, ObjectHadErrors,
3093 else if (TemplateSpecified &&
3096 EnteringContext, Template,
3104 (AllowDestructorName || SS.
isSet()) && Tok.
is(tok::tilde)) {
3113 if (TemplateSpecified) {
3124 Diag(*TemplateKWLoc, diag::err_unexpected_template_in_destructor_name)
3129 if (SS.
isEmpty() && Tok.
is(tok::kw_decltype)) {
3134 Result.setDestructorName(TildeLoc,
Type, EndLoc);
3141 if (Tok.
isNot(tok::identifier)) {
3142 Diag(Tok, diag::err_destructor_tilde_identifier);
3147 DeclaratorScopeObj DeclScopeObj(*
this, SS);
3155 AnnotateScopeToken(SS,
true);
3158 if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, ObjectHadErrors,
3162 ObjectType =
nullptr;
3163 if (Tok.
isNot(tok::identifier) ||
NextToken().is(tok::coloncolon) ||
3165 Diag(TildeLoc, diag::err_destructor_tilde_scope);
3170 Diag(TildeLoc, diag::err_destructor_tilde_scope)
3176 DeclScopeObj.EnterDeclaratorScope();
3183 if (Tok.
is(tok::less)) {
3184 Result.setDestructorName(TildeLoc,
nullptr, ClassNameLoc);
3185 return ParseUnqualifiedIdTemplateId(
3186 SS, ObjectType, ObjectHadErrors,
3188 ClassNameLoc, EnteringContext,
Result, TemplateSpecified);
3194 ObjectType, EnteringContext);
3198 Result.setDestructorName(TildeLoc, Ty, ClassNameLoc);
3203#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
3204#include "clang/Basic/TransformTypeTraits.def"
3207 Diag(Tok, diag::ext_keyword_as_ident)
3209 goto ParseIdentifier;
3213 Diag(Tok, diag::err_expected_unqualified_id) <<
getLangOpts().CPlusPlus;
3247Parser::ParseCXXNewExpression(
bool UseGlobal,
SourceLocation Start) {
3248 assert(Tok.
is(tok::kw_new) &&
"expected 'new' token");
3254 ExprVector PlacementArgs;
3261 if (Tok.
is(tok::l_paren)) {
3265 PlacementLParen = T.getOpenLocation();
3266 if (ParseExpressionListOrTypeId(PlacementArgs, DeclaratorInfo)) {
3272 PlacementRParen = T.getCloseLocation();
3278 if (PlacementArgs.empty()) {
3280 TypeIdParens = T.getRange();
3284 if (Tok.
is(tok::l_paren)) {
3287 MaybeParseGNUAttributes(DeclaratorInfo);
3288 ParseSpecifierQualifierList(DS);
3290 ParseDeclarator(DeclaratorInfo);
3292 TypeIdParens = T.getRange();
3294 MaybeParseGNUAttributes(DeclaratorInfo);
3295 if (ParseCXXTypeSpecifierSeq(DS))
3296 DeclaratorInfo.setInvalidType(
true);
3299 ParseDeclaratorInternal(DeclaratorInfo,
3300 &Parser::ParseDirectNewDeclarator);
3307 MaybeParseGNUAttributes(DeclaratorInfo);
3309 DeclaratorInfo.setInvalidType(
true);
3312 ParseDeclaratorInternal(DeclaratorInfo,
3313 &Parser::ParseDirectNewDeclarator);
3316 if (DeclaratorInfo.isInvalidType()) {
3323 if (Tok.
is(tok::l_paren)) {
3325 ExprVector ConstructorArgs;
3328 ConstructorLParen = T.getOpenLocation();
3329 if (Tok.
isNot(tok::r_paren)) {
3330 auto RunSignatureHelp = [&]() {
3339 DeclaratorInfo.getEndLoc(), ConstructorArgs, ConstructorLParen,
3341 CalledSignatureHelp =
true;
3342 return PreferredType;
3344 if (ParseExpressionList(ConstructorArgs, [&] {
3345 PreferredType.enterFunctionArgument(Tok.
getLocation(),
3355 ConstructorRParen = T.getCloseLocation();
3365 diag::warn_cxx98_compat_generalized_initializer_lists);
3371 return Actions.
ActOnCXXNew(Start, UseGlobal, PlacementLParen,
3372 PlacementArgs, PlacementRParen,
3383void Parser::ParseDirectNewDeclarator(
Declarator &D) {
3386 while (Tok.
is(tok::l_square)) {
3388 if (CheckProhibitedCXX11Attribute())
3397 if (
Size.isInvalid()) {
3408 MaybeParseCXX11Attributes(Attrs);
3412 Size.get(), T.getOpenLocation(),
3413 T.getCloseLocation()),
3414 std::move(Attrs), T.getCloseLocation());
3416 if (T.getCloseLocation().isInvalid())
3431bool Parser::ParseExpressionListOrTypeId(
3435 if (isTypeIdInParens()) {
3443 return ParseExpressionList(PlacementArgs);
3458Parser::ParseCXXDeleteExpression(
bool UseGlobal,
SourceLocation Start) {
3459 assert(Tok.
is(tok::kw_delete) &&
"Expected 'delete' keyword");
3463 bool ArrayDelete =
false;
3464 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::r_square)) {
3472 const Token Next = GetLookAheadToken(2);
3475 if (Next.isOneOf(tok::l_brace, tok::less) ||
3476 (Next.is(tok::l_paren) &&
3477 (GetLookAheadToken(3).is(tok::r_paren) ||
3478 (GetLookAheadToken(3).is(tok::identifier) &&
3479 GetLookAheadToken(4).is(tok::identifier))))) {
3480 TentativeParsingAction TPA(*
this);
3488 bool EmitFixIt =
false;
3489 if (Tok.
is(tok::l_brace)) {
3499 Diag(Start, diag::err_lambda_after_delete)
3507 Diag(Start, diag::err_lambda_after_delete)
3517 Lambda = ParsePostfixExpressionSuffix(Lambda);
3529 if (T.getCloseLocation().isInvalid())
3564ExprResult Parser::ParseRequiresExpression() {
3565 assert(Tok.
is(tok::kw_requires) &&
"Expected 'requires' keyword");
3570 if (Tok.
is(tok::l_paren)) {
3575 if (!Tok.
is(tok::r_paren)) {
3580 FirstArgAttrs, LocalParameters,
3583 Diag(EllipsisLoc, diag::err_requires_expr_parameter_list_ellipsis);
3584 for (
auto &ParamInfo : LocalParameters)
3585 LocalParameterDecls.push_back(cast<ParmVarDecl>(ParamInfo.Param));
3591 if (
Braces.expectAndConsume())
3608 RequiresKWLoc, LocalParameterDecls,
getCurScope());
3610 if (Tok.
is(tok::r_brace)) {
3617 Diag(Tok, diag::err_empty_requires_expr);
3620 while (!Tok.
is(tok::r_brace)) {
3622 case tok::l_brace: {
3633 ExprBraces.consumeOpen();
3637 ExprBraces.skipToEnd();
3641 if (ExprBraces.consumeClose())
3642 ExprBraces.skipToEnd();
3647 if (Tok.
is(tok::semi)) {
3650 Requirements.push_back(Req);
3655 Diag(Tok, diag::err_requires_expr_missing_arrow)
3658 if (TryAnnotateTypeConstraint()) {
3662 if (!isTypeConstraintAnnotation()) {
3663 Diag(Tok, diag::err_requires_expr_expected_type_constraint);
3668 if (Tok.
is(tok::annot_cxxscope)) {
3672 ConsumeAnnotationToken();
3676 Expression.get(), NoexceptLoc, SS, takeTemplateIdAnnotation(Tok),
3677 TemplateParameterDepth);
3678 ConsumeAnnotationToken();
3680 Requirements.push_back(Req);
3684 bool PossibleRequiresExprInSimpleRequirement =
false;
3685 if (Tok.
is(tok::kw_requires)) {
3686 auto IsNestedRequirement = [&] {
3687 RevertingTentativeParsingAction TPA(*
this);
3689 if (Tok.
is(tok::l_brace))
3696 if (Tok.
is(tok::l_paren)) {
3699 auto Res = TryParseParameterDeclarationClause();
3700 if (Res != TPResult::False) {
3703 while (Depth != 0) {
3704 bool FoundParen =
SkipUntil(tok::l_paren, tok::r_paren,
3708 if (Tok.
is(tok::l_paren))
3710 else if (Tok.
is(tok::r_paren))
3721 if (Tok.
is(tok::l_brace))
3730 if (IsNestedRequirement()) {
3745 Requirements.push_back(Req);
3753 PossibleRequiresExprInSimpleRequirement =
true;
3754 }
else if (Tok.
is(tok::kw_typename)) {
3757 TentativeParsingAction TPA(*
this);
3767 if (Tok.
is(tok::annot_cxxscope)) {
3770 ConsumeAnnotationToken();
3773 if (Tok.
isOneOf(tok::identifier, tok::annot_template_id) &&
3779 if (Tok.
is(tok::identifier)) {
3783 TemplateId = takeTemplateIdAnnotation(Tok);
3784 ConsumeAnnotationToken();
3792 Requirements.push_back(Req);
3809 if (!
Expression.isInvalid() && PossibleRequiresExprInSimpleRequirement)
3810 Diag(StartLoc, diag::err_requires_expr_in_simple_requirement)
3813 Requirements.push_back(Req);
3819 if (Tok.
is(tok::kw_noexcept)) {
3820 Diag(Tok, diag::err_requires_expr_simple_requirement_noexcept)
3829 if (ExpectAndConsumeSemi(diag::err_expected_semi_requirement)) {
3835 if (Requirements.empty()) {
3846 ParsingBodyDecl.complete(Body);
3848 RequiresKWLoc, Body,
Parens.getOpenLocation(), LocalParameterDecls,
3849 Parens.getCloseLocation(), Requirements,
Braces.getCloseLocation());
3854 default: llvm_unreachable(
"Not a known type trait");
3855#define TYPE_TRAIT_1(Spelling, Name, Key) \
3856case tok::kw_ ## Spelling: return UTT_ ## Name;
3857#define TYPE_TRAIT_2(Spelling, Name, Key) \
3858case tok::kw_ ## Spelling: return BTT_ ## Name;
3859#include "clang/Basic/TokenKinds.def"
3860#define TYPE_TRAIT_N(Spelling, Name, Key) \
3861 case tok::kw_ ## Spelling: return TT_ ## Name;
3862#include "clang/Basic/TokenKinds.def"
3869 llvm_unreachable(
"Not a known array type trait");
3870#define ARRAY_TYPE_TRAIT(Spelling, Name, Key) \
3871 case tok::kw_##Spelling: \
3873#include "clang/Basic/TokenKinds.def"
3880 llvm_unreachable(
"Not a known unary expression trait.");
3881#define EXPRESSION_TRAIT(Spelling, Name, Key) \
3882 case tok::kw_##Spelling: \
3884#include "clang/Basic/TokenKinds.def"
3905 if (
Parens.expectAndConsume())
3921 if (Tok.
is(tok::ellipsis)) {
3930 Args.push_back(Ty.
get());
3933 if (
Parens.consumeClose())
3953 if (T.expectAndConsume())
3965 case ATT_ArrayRank: {
3968 T.getCloseLocation());
3970 case ATT_ArrayExtent: {
3971 if (ExpectAndConsume(tok::comma)) {
3980 T.getCloseLocation());
3983 llvm_unreachable(
"Invalid ArrayTypeTrait!");
3997 if (T.expectAndConsume())
4005 T.getCloseLocation());
4013Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
4018 assert(ExprType ==
CastExpr &&
"Compound literals are not ambiguous!");
4019 assert(isTypeIdInParens() &&
"Not a type-id!");
4043 ParenParseOption ParseAs;
4048 if (!ConsumeAndStoreUntil(tok::r_paren, Toks)) {
4054 if (Tok.
is(tok::l_brace)) {
4055 ParseAs = CompoundLiteral;
4058 if (Tok.
is(tok::l_paren) &&
NextToken().is(tok::r_paren)) {
4065 Result = ParseCastExpression(AnyCastExpr,
4074 ParseAs = NotCastExpr ? SimpleExpr :
CastExpr;
4083 Toks.push_back(AttrEnd);
4086 Toks.push_back(Tok);
4089 PP.EnterTokenStream(Toks,
true,
4095 if (ParseAs >= CompoundLiteral) {
4102 ParseSpecifierQualifierList(DS);
4103 ParseDeclarator(DeclaratorInfo);
4114 if (ParseAs == CompoundLiteral) {
4115 ExprType = CompoundLiteral;
4116 if (DeclaratorInfo.isInvalidType())
4120 return ParseCompoundLiteralExpression(Ty.
get(),
4128 if (DeclaratorInfo.isInvalidType())
4134 DeclaratorInfo, CastTy,
4140 assert(ParseAs == SimpleExpr);
4142 ExprType = SimpleExpr;
4144 if (!
Result.isInvalid() && Tok.
is(tok::r_paren))
4149 if (
Result.isInvalid()) {
4150 while (Tok.
isNot(tok::eof))
4169 if (T.expectAndConsume(diag::err_expected_lparen_after,
"__builtin_bit_cast"))
4174 ParseSpecifierQualifierList(DS);
4179 ParseDeclarator(DeclaratorInfo);
4181 if (ExpectAndConsume(tok::comma)) {
4189 if (T.consumeClose())
4192 if (
Operand.isInvalid() || DeclaratorInfo.isInvalidType())
4196 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 ).
ParsedType getConstructorName(IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, bool EnteringContext)
ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body)
ActOnLambdaExpr - This is called when the body of a lambda expression was successfully completed.
void CodeCompleteObjCMessageReceiver(Scope *S)
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...
concepts::Requirement * ActOnTypeRequirement(SourceLocation TypenameKWLoc, CXXScopeSpec &SS, SourceLocation NameLoc, IdentifierInfo *TypeName, TemplateIdAnnotation *TemplateId)
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)
ExprResult ActOnCXXThis(SourceLocation loc)
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)
TypeResult ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
ParsedType getDestructorName(IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
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...
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.
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 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 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.
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.
static TemplateIdAnnotation * Create(SourceLocation TemplateKWLoc, SourceLocation TemplateNameLoc, 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.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.