27#include "llvm/Support/Compiler.h"
28#include "llvm/Support/ErrorHandling.h"
36 case tok::unknown:
return 0;
38 case tok::kw_addrspace_cast:
return 1;
39 case tok::kw_const_cast:
return 2;
40 case tok::kw_dynamic_cast:
return 3;
41 case tok::kw_reinterpret_cast:
return 4;
42 case tok::kw_static_cast:
return 5;
44 llvm_unreachable(
"Unknown type for digraph error message.");
49bool Parser::areTokensAdjacent(
const Token &
First,
const Token &Second) {
67 P.Diag(DigraphToken.
getLocation(), diag::err_missing_whitespace_digraph)
72 ColonToken.
setKind(tok::coloncolon);
75 DigraphToken.
setKind(tok::less);
86void Parser::CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectType,
89 if (!Next.is(tok::l_square) || Next.getLength() != 2)
92 Token SecondToken = GetLookAheadToken(2);
93 if (!SecondToken.
is(tok::colon) || !areTokensAdjacent(Next, SecondToken))
99 bool MemberOfUnknownSpecialization;
102 Template, MemberOfUnknownSpecialization))
105 FixDigraph(*
this, PP, Next, SecondToken, tok::unknown,
158bool Parser::ParseOptionalCXXScopeSpecifier(
160 bool EnteringContext,
bool *MayBePseudoDestructor,
bool IsTypename,
162 bool InUsingDeclaration) {
164 "Call sites of this function should be guarded by checking for C++");
166 if (Tok.
is(tok::annot_cxxscope)) {
167 assert(!LastII &&
"want last identifier but have already annotated scope");
168 assert(!MayBePseudoDestructor &&
"unexpected annot_cxxscope");
172 ConsumeAnnotationToken();
177 bool CheckForDestructor =
false;
178 if (MayBePseudoDestructor && *MayBePseudoDestructor) {
179 CheckForDestructor =
true;
180 *MayBePseudoDestructor =
false;
186 bool HasScopeSpecifier =
false;
188 if (Tok.
is(tok::coloncolon)) {
191 if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
194 if (NextKind == tok::l_brace) {
203 HasScopeSpecifier =
true;
207 if (Tok.
is(tok::kw___super)) {
209 if (!Tok.
is(tok::coloncolon)) {
217 if (!HasScopeSpecifier &&
218 Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
228 AnnotateExistingDecltypeSpecifier(DS, DeclLoc, EndLoc);
235 HasScopeSpecifier =
true;
238 else if (!HasScopeSpecifier && Tok.
is(tok::identifier) &&
239 GetLookAheadToken(1).is(tok::ellipsis) &&
240 GetLookAheadToken(2).is(tok::l_square)) {
249 DS.getRepAsType().get(), DS.getPackIndexingExpr(), DS.getBeginLoc(),
250 DS.getEllipsisLoc());
263 HasScopeSpecifier =
true;
267 auto SavedType = PreferredType;
269 if (HasScopeSpecifier) {
270 if (Tok.
is(tok::code_completion)) {
275 getCurScope(), SS, EnteringContext, InUsingDeclaration,
295 ObjectType =
nullptr;
303 if (Tok.
is(tok::kw_template)) {
307 if (!HasScopeSpecifier && !ObjectType)
310 TentativeParsingAction TPA(*
this);
314 if (Tok.
is(tok::identifier)) {
318 }
else if (Tok.
is(tok::kw_operator)) {
323 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
332 diag::err_id_after_template_in_nested_name_spec)
345 if (Tok.
isNot(tok::less)) {
355 EnteringContext, Template,
true);
356 if (AnnotateTemplateIdToken(Template, TNK, SS, TemplateKWLoc,
363 if (Tok.
is(tok::annot_template_id) &&
NextToken().is(tok::coloncolon)) {
372 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
373 *MayBePseudoDestructor =
true;
378 *LastII = TemplateId->
Name;
381 ConsumeAnnotationToken();
383 assert(Tok.
is(tok::coloncolon) &&
"NextToken() not working properly!");
386 HasScopeSpecifier =
true;
412#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
413#include "clang/Basic/TransformTypeTraits.def"
416 Diag(Tok, diag::ext_keyword_as_ident)
427 if (Tok.
isNot(tok::identifier))
442 if (Next.is(tok::colon) && !ColonIsSacred) {
449 Diag(Next, diag::err_unexpected_colon_in_nested_name_spec)
452 Next.setKind(tok::coloncolon);
456 if (Next.is(tok::coloncolon) && GetLookAheadToken(2).is(tok::l_brace)) {
467 if (Next.is(tok::coloncolon)) {
468 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
469 *MayBePseudoDestructor =
true;
474 const Token &Next2 = GetLookAheadToken(2);
475 if (Next2.
is(tok::kw_private) || Next2.
is(tok::kw_protected) ||
476 Next2.
is(tok::kw_public) || Next2.
is(tok::kw_virtual)) {
477 Diag(Next2, diag::err_unexpected_token_in_nested_name_spec)
482 ColonColon.
setKind(tok::colon);
495 assert(Tok.
isOneOf(tok::coloncolon, tok::colon) &&
496 "NextToken() not working properly!");
497 Token ColonColon = Tok;
500 bool IsCorrectedToColon =
false;
501 bool *CorrectionFlagPtr = ColonIsSacred ? &IsCorrectedToColon :
nullptr;
503 getCurScope(), IdInfo, EnteringContext, SS, CorrectionFlagPtr,
507 if (CorrectionFlagPtr && IsCorrectedToColon) {
508 ColonColon.
setKind(tok::colon);
516 HasScopeSpecifier =
true;
520 CheckForTemplateAndDigraph(Next, ObjectType, EnteringContext, II, SS);
524 if (Next.is(tok::less)) {
529 bool MemberOfUnknownSpecialization;
536 MemberOfUnknownSpecialization)) {
542 isTemplateArgumentList(1) == TPResult::False)
559 if (MemberOfUnknownSpecialization && (ObjectType || SS.
isSet()) &&
560 (IsTypename || isTemplateArgumentList(1) == TPResult::True)) {
563 if (!ObjectHadErrors) {
568 unsigned DiagID = diag::err_missing_dependent_template_keyword;
570 DiagID = diag::warn_missing_dependent_template_keyword;
581 EnteringContext, Template,
true);
598 if (CheckForDestructor && !HasScopeSpecifier && Tok.
is(tok::tilde))
599 *MayBePseudoDestructor =
true;
605 bool isAddressOfOperand,
606 Token &Replacement) {
611 case tok::annot_non_type: {
612 NamedDecl *ND = getNonTypeAnnotation(Tok);
618 case tok::annot_non_type_dependent: {
624 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
625 isAddressOfOperand =
false;
632 case tok::annot_non_type_undeclared: {
634 "undeclared non-type annotation should be unqualified");
649 false, &TemplateKWLoc, Name))
654 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
655 isAddressOfOperand =
false;
658 getCurScope(), SS, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
659 isAddressOfOperand,
nullptr,
false,
665 E = tryParseCXXPackIndexingExpression(E);
668 checkPotentialAngleBracket(E);
673 assert(Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square) &&
679 if (
T.consumeClose() || IndexExpr.
isInvalid())
682 EllipsisLoc,
T.getOpenLocation(),
683 IndexExpr.
get(),
T.getCloseLocation());
687Parser::tryParseCXXPackIndexingExpression(
ExprResult PackIdExpression) {
690 Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square)) {
691 E = ParseCXXPackIndexingExpression(E);
738ExprResult Parser::ParseCXXIdExpression(
bool isAddressOfOperand) {
744 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
750 tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
754 UnconsumeToken(Replacement);
755 Result = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
757 assert(!
Result.isUnset() &&
"Typo correction suggested a keyword replacement "
758 "for a previous keyword suggestion");
810 if (ParseLambdaIntroducer(Intro)) {
817 return ParseLambdaExpressionAfterIntroducer(Intro);
824ExprResult Parser::TryParseLambdaExpression() {
826 "Not at the start of a possible lambda expression.");
829 if (Next.is(tok::eof))
834 if (Next.is(tok::r_square) ||
835 Next.is(tok::equal) ||
836 (Next.is(tok::amp) &&
837 After.isOneOf(tok::r_square, tok::comma)) ||
838 (Next.is(tok::identifier) &&
839 After.is(tok::r_square)) ||
840 Next.is(tok::ellipsis)) {
841 return ParseLambdaExpression();
846 if (Next.is(tok::identifier) &&
After.is(tok::identifier))
856 TentativeParsingAction TPA(*
this);
857 LambdaIntroducerTentativeParse Tentative;
858 if (ParseLambdaIntroducer(Intro, &Tentative)) {
864 case LambdaIntroducerTentativeParse::Success:
868 case LambdaIntroducerTentativeParse::Incomplete:
873 if (ParseLambdaIntroducer(Intro))
877 case LambdaIntroducerTentativeParse::MessageSend:
878 case LambdaIntroducerTentativeParse::Invalid:
885 return ParseLambdaExpressionAfterIntroducer(Intro);
898 LambdaIntroducerTentativeParse *Tentative) {
900 *Tentative = LambdaIntroducerTentativeParse::Success;
902 assert(Tok.
is(tok::l_square) &&
"Lambda expressions begin with '['.");
912 auto Invalid = [&](llvm::function_ref<void()> Action) {
914 *Tentative = LambdaIntroducerTentativeParse::Invalid;
923 auto NonTentativeAction = [&](llvm::function_ref<void()> Action) {
925 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
931 if (Tok.
is(tok::amp) &&
941 }
else if (Tok.
is(tok::equal)) {
948 while (Tok.
isNot(tok::r_square)) {
950 if (Tok.
isNot(tok::comma)) {
955 if (Tok.
is(tok::code_completion) &&
971 if (Tok.
is(tok::code_completion)) {
995 if (Tok.
is(tok::star)) {
997 if (Tok.
is(tok::kw_this)) {
1005 }
else if (Tok.
is(tok::kw_this)) {
1008 }
else if (Tok.
isOneOf(tok::amp, tok::equal) &&
1020 if (Tok.
is(tok::amp)) {
1024 if (Tok.
is(tok::code_completion)) {
1035 if (Tok.
is(tok::identifier)) {
1038 }
else if (Tok.
is(tok::kw_this)) {
1051 if (Tok.
is(tok::l_paren)) {
1060 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
1061 }
else if (ParseExpressionList(Exprs)) {
1067 Parens.getCloseLocation(),
1070 }
else if (Tok.
isOneOf(tok::l_brace, tok::equal)) {
1083 Init = ParseInitializer();
1084 }
else if (Tok.
is(tok::l_brace)) {
1088 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
1112 Init = ParseInitializer();
1113 if (!
Init.isInvalid())
1122 Tok.
setKind(tok::annot_primary_expr);
1123 setExprAnnotation(Tok,
Init);
1128 ConsumeAnnotationToken();
1137 if (Tentative && Tok.
is(tok::identifier) &&
1140 *Tentative = LambdaIntroducerTentativeParse::MessageSend;
1146 if (llvm::any_of(EllipsisLocs,
1152 !InitCapture ? &EllipsisLocs[2] :
1155 EllipsisLoc = *ExpectedEllipsisLoc;
1157 unsigned DiagID = 0;
1159 DiagID = diag::err_lambda_capture_misplaced_ellipsis;
1165 unsigned NumEllipses = std::accumulate(
1166 std::begin(EllipsisLocs), std::end(EllipsisLocs), 0,
1168 if (NumEllipses > 1)
1169 DiagID = diag::err_lambda_capture_multiple_ellipses;
1172 NonTentativeAction([&] {
1181 assert(DiagLoc.
isValid() &&
"no location for diagnostic");
1185 auto &&D =
Diag(DiagLoc, DiagID);
1186 if (DiagID == diag::err_lambda_capture_misplaced_ellipsis) {
1206 if (
Init.isUsable())
1208 if (
Init.isUsable()) {
1209 NonTentativeAction([&] {
1246 auto ConsumeLocation = [&
P, &DeclEndLoc](
SourceLocation &SpecifierLoc,
1248 if (SpecifierLoc.isValid()) {
1249 P.Diag(
P.getCurToken().getLocation(),
1250 diag::err_lambda_decl_specifier_repeated)
1254 SpecifierLoc =
P.ConsumeToken();
1255 DeclEndLoc = SpecifierLoc;
1259 switch (
P.getCurToken().getKind()) {
1260 case tok::kw_mutable:
1261 ConsumeLocation(MutableLoc, 0);
1263 case tok::kw_static:
1264 ConsumeLocation(StaticLoc, 1);
1266 case tok::kw_constexpr:
1267 ConsumeLocation(ConstexprLoc, 2);
1269 case tok::kw_consteval:
1270 ConsumeLocation(ConstevalLoc, 3);
1281 P.Diag(StaticLoc, !
P.getLangOpts().CPlusPlus23
1282 ? diag::err_static_lambda
1283 : diag::warn_cxx20_compat_static_lambda);
1284 const char *PrevSpec =
nullptr;
1285 unsigned DiagID = 0;
1288 P.getActions().getASTContext().getPrintingPolicy());
1289 assert(PrevSpec ==
nullptr && DiagID == 0 &&
1290 "Static cannot have been set previously!");
1298 P.Diag(ConstexprLoc, !
P.getLangOpts().CPlusPlus17
1299 ? diag::ext_constexpr_on_lambda_cxx17
1300 : diag::warn_cxx14_compat_constexpr_on_lambda);
1301 const char *PrevSpec =
nullptr;
1302 unsigned DiagID = 0;
1305 assert(PrevSpec ==
nullptr && DiagID == 0 &&
1306 "Constexpr cannot have been set previously!");
1314 P.Diag(ConstevalLoc, diag::warn_cxx20_compat_consteval);
1315 const char *PrevSpec =
nullptr;
1316 unsigned DiagID = 0;
1320 P.Diag(ConstevalLoc, DiagID) << PrevSpec;
1336 P.Diag(StaticLoc, diag::err_static_mutable_lambda);
1338 P.Diag(StaticLoc, diag::err_static_lambda_captures);
1344ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
1348 ? diag::warn_cxx98_compat_lambda
1349 : diag::ext_lambda);
1352 "lambda expression parsing");
1357 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1374 if (Tok.
is(tok::kw___noinline__)) {
1377 Attributes.addNew(AttrName, AttrNameLoc,
nullptr,
1378 AttrNameLoc,
nullptr,
1379 0, tok::kw___noinline__);
1380 }
else if (Tok.
is(tok::kw___attribute))
1381 ParseGNUAttributes(Attributes,
nullptr, &D);
1386 D.takeAttributes(Attributes);
1389 MultiParseScope TemplateParamScope(*
this);
1390 if (Tok.
is(tok::less)) {
1392 ? diag::warn_cxx17_compat_lambda_template_parameter_list
1393 : diag::ext_lambda_template_parameter_list);
1397 if (ParseTemplateParameters(TemplateParamScope,
1398 CurTemplateDepthTracker.getDepth(),
1399 TemplateParams, LAngleLoc, RAngleLoc)) {
1404 if (TemplateParams.empty()) {
1406 diag::err_lambda_template_parameter_list_empty);
1417 ++CurTemplateDepthTracker;
1428 Intro, LAngleLoc, TemplateParams, RAngleLoc, RequiresClause);
1436 if (isCXX11AttributeSpecifier()) {
1438 ? diag::warn_cxx20_compat_decl_attrs_on_lambda
1439 : diag::ext_decl_attrs_on_lambda)
1441 MaybeParseCXX11Attributes(D);
1448 bool HasParentheses =
false;
1449 bool HasSpecifiers =
false;
1460 if (Tok.
is(tok::l_paren)) {
1463 LParenLoc =
T.getOpenLocation();
1465 if (Tok.
isNot(tok::r_paren)) {
1467 CurTemplateDepthTracker.getOriginalDepth());
1469 ParseParameterDeclarationClause(D, Attributes, ParamInfo, EllipsisLoc);
1476 CurTemplateDepthTracker.setAddedDepth(1);
1480 DeclEndLoc = RParenLoc =
T.getCloseLocation();
1481 HasParentheses =
true;
1485 Tok.
isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute,
1486 tok::kw_constexpr, tok::kw_consteval, tok::kw_static,
1487 tok::kw___private, tok::kw___global, tok::kw___local,
1488 tok::kw___constant, tok::kw___generic, tok::kw_groupshared,
1489 tok::kw_requires, tok::kw_noexcept) ||
1493 if (HasSpecifiers && !HasParentheses && !
getLangOpts().CPlusPlus23) {
1497 Diag(Tok, diag::ext_lambda_missing_parens)
1501 if (HasParentheses || HasSpecifiers) {
1505 MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attributes);
1513 ConstevalLoc, DeclEndLoc);
1524 if (!HasParentheses)
1527 if (HasSpecifiers || HasParentheses) {
1536 ESpecType = tryParseExceptionSpecification(
1537 false, ESpecRange, DynamicExceptions,
1538 DynamicExceptionRanges, NoexceptExpr, ExceptionSpecTokens);
1541 DeclEndLoc = ESpecRange.
getEnd();
1544 if (MaybeParseCXX11Attributes(Attributes))
1545 DeclEndLoc = Attributes.Range.getEnd();
1548 if (Tok.
isOneOf(tok::kw___private, tok::kw___global, tok::kw___local,
1549 tok::kw___constant, tok::kw___generic)) {
1550 ParseOpenCLQualifiers(DS.getAttributes());
1557 if (Tok.
is(tok::arrow)) {
1560 TrailingReturnType =
1561 ParseTrailingReturnType(
Range,
false);
1570 false, LParenLoc, ParamInfo.data(),
1571 ParamInfo.size(), EllipsisLoc, RParenLoc,
1573 NoLoc, MutableLoc, ESpecType,
1574 ESpecRange, DynamicExceptions.data(),
1575 DynamicExceptionRanges.data(), DynamicExceptions.size(),
1576 NoexceptExpr.
isUsable() ? NoexceptExpr.
get() :
nullptr,
1578 std::nullopt, LParenLoc,
1579 FunLocalRangeEnd, D, TrailingReturnType,
1580 TrailingReturnTypeLoc, &DS),
1581 std::move(Attributes), DeclEndLoc);
1585 if (HasParentheses && Tok.
is(tok::kw_requires))
1586 ParseTrailingRequiresClause(D);
1593 if (A.getKind() == ParsedAttr::AT_CUDADevice ||
1594 A.getKind() == ParsedAttr::AT_CUDAHost ||
1595 A.getKind() == ParsedAttr::AT_CUDAGlobal)
1596 Diag(A.getLoc(), diag::warn_cuda_attr_lambda_position)
1597 << A.getAttrName()->getName();
1606 ParseScope BodyScope(
this, ScopeFlags);
1611 if (!Tok.
is(tok::l_brace)) {
1612 Diag(Tok, diag::err_expected_lambda_body);
1619 TemplateParamScope.Exit();
1643 const char *CastName =
nullptr;
1646 default: llvm_unreachable(
"Unknown C++ cast!");
1647 case tok::kw_addrspace_cast: CastName =
"addrspace_cast";
break;
1648 case tok::kw_const_cast: CastName =
"const_cast";
break;
1649 case tok::kw_dynamic_cast: CastName =
"dynamic_cast";
break;
1650 case tok::kw_reinterpret_cast: CastName =
"reinterpret_cast";
break;
1651 case tok::kw_static_cast: CastName =
"static_cast";
break;
1659 if (Tok.
is(tok::l_square) && Tok.
getLength() == 2) {
1661 if (Next.is(tok::colon) && areTokensAdjacent(Tok, Next))
1662 FixDigraph(*
this, PP, Tok, Next, Kind,
true);
1665 if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
1670 ParseSpecifierQualifierList(DS,
AS_none,
1671 DeclSpecContext::DSC_type_specifier);
1676 ParseDeclarator(DeclaratorInfo);
1680 if (ExpectAndConsume(tok::greater))
1681 return ExprError(
Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
1685 if (
T.expectAndConsume(diag::err_expected_lparen_after, CastName))
1693 if (!
Result.isInvalid() && !DeclaratorInfo.isInvalidType())
1695 LAngleBracketLoc, DeclaratorInfo,
1697 T.getOpenLocation(),
Result.get(),
1698 T.getCloseLocation());
1710 assert(Tok.
is(tok::kw_typeid) &&
"Not 'typeid'!");
1717 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"typeid"))
1719 LParenLoc =
T.getOpenLocation();
1740 if (isTypeIdInParens()) {
1745 RParenLoc =
T.getCloseLocation();
1750 Ty.
get().getAsOpaquePtr(), RParenLoc);
1759 RParenLoc =
T.getCloseLocation();
1764 Result.get(), RParenLoc);
1777 assert(Tok.
is(tok::kw___uuidof) &&
"Not '__uuidof'!");
1783 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"__uuidof"))
1788 if (isTypeIdInParens()) {
1798 Ty.
get().getAsOpaquePtr(),
1799 T.getCloseLocation());
1813 Result.get(),
T.getCloseLocation());
1860 if (Tok.
is(tok::identifier)) {
1863 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1865 }
else if (Tok.
is(tok::annot_template_id)) {
1871 ConsumeAnnotationToken();
1872 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1875 assert(SS.
isEmpty() &&
"missing last component of nested name specifier");
1880 assert(Tok.
is(tok::tilde) &&
"ParseOptionalCXXScopeSpecifier fail");
1883 if (Tok.
is(tok::kw_decltype) && !FirstTypeName.
isValid()) {
1885 ParseDecltypeSpecifier(DS);
1892 if (!Tok.
is(tok::identifier)) {
1893 Diag(Tok, diag::err_destructor_tilde_identifier);
1898 if (GetLookAheadToken(1).is(tok::ellipsis) &&
1899 GetLookAheadToken(2).is(tok::l_square)) {
1901 ParsePackIndexingType(DS);
1920 if (Tok.
is(tok::less) &&
1921 ParseUnqualifiedIdTemplateId(
1923 Name, NameLoc,
false, SecondTypeName,
1928 SS, FirstTypeName, CCLoc, TildeLoc,
1947 assert(Tok.
is(tok::kw_throw) &&
"Not throw!");
1974 assert(Tok.
is(tok::kw_co_yield) &&
"Not co_yield!");
1979 if (!
Expr.isInvalid())
1990 assert(Tok.
is(tok::kw_this) &&
"Not 'this'!");
2009Parser::ParseCXXTypeConstructExpression(
const DeclSpec &DS) {
2014 assert((Tok.
is(tok::l_paren) ||
2016 &&
"Expected '(' or '{'!");
2018 if (Tok.
is(tok::l_brace)) {
2021 if (
Init.isInvalid())
2035 auto RunSignatureHelp = [&]() {
2041 Exprs,
T.getOpenLocation(),
false);
2042 CalledSignatureHelp =
true;
2043 return PreferredType;
2046 if (Tok.
isNot(tok::r_paren)) {
2047 if (ParseExpressionList(Exprs, [&] {
2048 PreferredType.enterFunctionArgument(Tok.
getLocation(),
2066 Exprs,
T.getCloseLocation(),
2074 assert(Tok.
is(tok::kw_using) &&
"Expected using");
2077 "Unexpected Declarator Context");
2081 DG = ParseUsingDeclaration(Context, {}, DeclStart, DeclEnd, Attrs,
AS_none);
2086 ? diag::ext_alias_in_init_statement
2087 : diag::warn_cxx20_alias_in_init_statement)
2127 ForRangeInfo *FRI,
bool EnterForConditionScope) {
2129 struct ForConditionScopeRAII {
2131 void enter(
bool IsConditionVariable) {
2134 S->setIsConditionVarScope(IsConditionVariable);
2137 ~ForConditionScopeRAII() {
2139 S->setIsConditionVarScope(
false);
2141 } ForConditionScope{EnterForConditionScope ?
getCurScope() : nullptr};
2144 PreferredType.enterCondition(Actions, Tok.
getLocation());
2146 if (Tok.
is(tok::code_completion)) {
2154 MaybeParseCXX11Attributes(attrs);
2156 const auto WarnOnInit = [
this, &CK] {
2158 ? diag::warn_cxx14_compat_init_statement
2159 : diag::ext_init_statement)
2164 switch (isCXXConditionDeclarationOrInitStatement(InitStmt, FRI)) {
2165 case ConditionOrInitStatement::Expression: {
2167 ForConditionScope.enter(
false);
2169 ProhibitAttributes(attrs);
2173 if (InitStmt && Tok.
is(tok::semi)) {
2177 Diag(SemiLoc, diag::warn_empty_init_statement)
2183 return ParseCXXCondition(
nullptr,
Loc, CK, MissingOK);
2188 if (
Expr.isInvalid())
2191 if (InitStmt && Tok.
is(tok::semi)) {
2195 return ParseCXXCondition(
nullptr,
Loc, CK, MissingOK);
2202 case ConditionOrInitStatement::InitStmtDecl: {
2206 if (Tok.
is(tok::kw_using))
2207 DG = ParseAliasDeclarationInInitStatement(
2212 attrs, DeclSpecAttrs,
true);
2215 return ParseCXXCondition(
nullptr,
Loc, CK, MissingOK);
2218 case ConditionOrInitStatement::ForRangeDecl: {
2222 assert(FRI &&
"should not parse a for range declaration here");
2231 case ConditionOrInitStatement::ConditionDecl:
2232 case ConditionOrInitStatement::Error:
2237 ForConditionScope.enter(
true);
2241 ParseSpecifierQualifierList(DS,
AS_none, DeclSpecContext::DSC_condition);
2245 ParseDeclarator(DeclaratorInfo);
2248 if (Tok.
is(tok::kw_asm)) {
2251 if (AsmLabel.isInvalid()) {
2255 DeclaratorInfo.setAsmLabel(AsmLabel.get());
2256 DeclaratorInfo.SetRangeEnd(
Loc);
2260 MaybeParseGNUAttributes(DeclaratorInfo);
2271 bool CopyInitialization = isTokenEqualOrEqualTypo();
2272 if (CopyInitialization)
2278 diag::warn_cxx98_compat_generalized_initializer_lists);
2279 InitExpr = ParseBraceInitializer();
2280 }
else if (CopyInitialization) {
2281 PreferredType.enterVariableInit(Tok.
getLocation(), DeclOut);
2283 }
else if (Tok.
is(tok::l_paren)) {
2287 RParen = ConsumeParen();
2289 diag::err_expected_init_in_condition_lparen)
2330void Parser::ParseCXXSimpleTypeSpecifier(
DeclSpec &DS) {
2332 const char *PrevSpec;
2339 case tok::identifier:
2340 case tok::coloncolon:
2341 llvm_unreachable(
"Annotation token should already be formed!");
2343 llvm_unreachable(
"Not a simple-type-specifier token!");
2346 case tok::annot_typename: {
2350 ConsumeAnnotationToken();
2351 DS.
Finish(Actions, Policy);
2355 case tok::kw__ExtInt:
2356 case tok::kw__BitInt: {
2357 DiagnoseBitIntUse(Tok);
2366 DS.
Finish(Actions, Policy);
2379 case tok::kw___int64:
2383 case tok::kw_signed:
2386 case tok::kw_unsigned:
2401 case tok::kw___int128:
2404 case tok::kw___bf16:
2413 case tok::kw_double:
2416 case tok::kw__Float16:
2419 case tok::kw___float128:
2422 case tok::kw___ibm128:
2425 case tok::kw_wchar_t:
2428 case tok::kw_char8_t:
2431 case tok::kw_char16_t:
2434 case tok::kw_char32_t:
2440 case tok::kw__Accum:
2443 case tok::kw__Fract:
2449#define GENERIC_IMAGE_TYPE(ImgType, Id) \
2450 case tok::kw_##ImgType##_t: \
2451 DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, DiagID, \
2454#include "clang/Basic/OpenCLImageTypes.def"
2456 case tok::annot_decltype:
2457 case tok::kw_decltype:
2459 return DS.
Finish(Actions, Policy);
2461 case tok::annot_pack_indexing_type:
2463 return DS.
Finish(Actions, Policy);
2466 case tok::kw_typeof:
2467 ParseTypeofSpecifier(DS);
2468 DS.
Finish(Actions, Policy);
2473 DS.
Finish(Actions, Policy);
2488 ParseSpecifierQualifierList(DS,
AS_none,
2489 getDeclSpecContextFromDeclaratorContext(Context));
2529bool Parser::ParseUnqualifiedIdTemplateId(
2533 assert(Tok.
is(tok::less) &&
"Expected '<' to finish parsing a template-id");
2537 switch (
Id.getKind()) {
2541 if (AssumeTemplateId) {
2545 ObjectType, EnteringContext, Template,
2548 bool MemberOfUnknownSpecialization;
2551 ObjectType, EnteringContext, Template,
2552 MemberOfUnknownSpecialization);
2557 isTemplateArgumentList(0) == TPResult::False)
2561 ObjectType && isTemplateArgumentList(0) == TPResult::True) {
2564 if (!ObjectHadErrors) {
2571 Name = std::string(
Id.Identifier->getName());
2577 Name +=
Id.Identifier->getName();
2579 Diag(
Id.StartLocation, diag::err_missing_dependent_template_keyword)
2584 getCurScope(), SS, TemplateKWLoc,
Id, ObjectType, EnteringContext,
2594 bool MemberOfUnknownSpecialization;
2598 EnteringContext, Template,
2599 MemberOfUnknownSpecialization);
2607 bool MemberOfUnknownSpecialization;
2612 EnteringContext, Template,
true);
2616 EnteringContext, Template,
2617 MemberOfUnknownSpecialization);
2620 Diag(NameLoc, diag::err_destructor_template_id)
2634 TemplateArgList TemplateArgs;
2635 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs, RAngleLoc,
2656 :
Id.OperatorFunctionId.Operator;
2659 TemplateKWLoc,
Id.StartLocation, TemplateII, OpKind, Template, TNK,
2660 LAngleLoc, RAngleLoc, TemplateArgs,
false, TemplateIds);
2662 Id.setTemplateId(TemplateId);
2671 getCurScope(), SS, TemplateKWLoc, Template, Name, NameLoc, LAngleLoc,
2672 TemplateArgsPtr, RAngleLoc,
true);
2673 if (
Type.isInvalid())
2677 Id.setConstructorName(
Type.get(), NameLoc, RAngleLoc);
2679 Id.setDestructorName(
Id.StartLocation,
Type.get(), RAngleLoc);
2724bool Parser::ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2727 assert(Tok.
is(tok::kw_operator) &&
"Expected 'operator' keyword");
2733 unsigned SymbolIdx = 0;
2738 case tok::kw_delete: {
2739 bool isNew = Tok.
getKind() == tok::kw_new;
2743 if (Tok.
is(tok::l_square) &&
2749 if (
T.getCloseLocation().isInvalid())
2752 SymbolLocations[SymbolIdx++] =
T.getOpenLocation();
2753 SymbolLocations[SymbolIdx++] =
T.getCloseLocation();
2754 Op = isNew? OO_Array_New : OO_Array_Delete;
2756 Op = isNew? OO_New : OO_Delete;
2761#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2763 SymbolLocations[SymbolIdx++] = ConsumeToken(); \
2766#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2767#include "clang/Basic/OperatorKinds.def"
2769 case tok::l_paren: {
2774 if (
T.getCloseLocation().isInvalid())
2777 SymbolLocations[SymbolIdx++] =
T.getOpenLocation();
2778 SymbolLocations[SymbolIdx++] =
T.getCloseLocation();
2783 case tok::l_square: {
2788 if (
T.getCloseLocation().isInvalid())
2791 SymbolLocations[SymbolIdx++] =
T.getOpenLocation();
2792 SymbolLocations[SymbolIdx++] =
T.getCloseLocation();
2797 case tok::code_completion: {
2811 Result.setOperatorFunctionId(KeywordLoc, Op, SymbolLocations);
2825 unsigned DiagId = 0;
2831 while (isTokenStringLiteral()) {
2832 if (!Tok.
is(tok::string_literal) && !DiagId) {
2837 DiagId = diag::err_literal_operator_string_prefix;
2839 Toks.push_back(Tok);
2840 TokLocs.push_back(ConsumeStringToken());
2849 bool IsUDSuffix = !
Literal.getUDSuffix().empty();
2858 }
else if (Tok.
is(tok::identifier)) {
2861 TokLocs.push_back(SuffixLoc);
2873 DiagLoc = TokLocs.front();
2874 DiagId = diag::err_literal_operator_string_not_empty;
2884 SourceRange(TokLocs.front(), TokLocs.back()), Str);
2887 Result.setLiteralOperatorId(II, KeywordLoc, SuffixLoc);
2905 if (ParseCXXTypeSpecifierSeq(
2913 ParseDeclaratorInternal(D,
nullptr);
2921 Result.setConversionFunctionId(KeywordLoc, Ty.
get(),
2922 D.getSourceRange().getEnd());
2963 bool ObjectHadErrors,
bool EnteringContext,
2964 bool AllowDestructorName,
2965 bool AllowConstructorName,
2966 bool AllowDeductionGuide,
2974 bool TemplateSpecified =
false;
2975 if (Tok.
is(tok::kw_template)) {
2976 if (TemplateKWLoc && (ObjectType || SS.
isSet())) {
2977 TemplateSpecified =
true;
2981 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
2989 if (Tok.
is(tok::identifier)) {
3003 if (AllowConstructorName &&
3010 Result.setConstructorName(Ty, IdLoc, IdLoc);
3024 if (Tok.
is(tok::less))
3025 return ParseUnqualifiedIdTemplateId(
3026 SS, ObjectType, ObjectHadErrors,
3028 EnteringContext,
Result, TemplateSpecified);
3029 else if (TemplateSpecified &&
3032 EnteringContext, Template,
3041 if (Tok.
is(tok::annot_template_id)) {
3047 ConsumeAnnotationToken();
3052 if (AllowConstructorName && TemplateId->
Name &&
3060 diag::err_out_of_line_constructor_template_id)
3071 ConsumeAnnotationToken();
3075 Result.setConstructorTemplateId(TemplateId);
3076 ConsumeAnnotationToken();
3082 Result.setTemplateId(TemplateId);
3085 if (TemplateKWLoc && (ObjectType || SS.
isSet()))
3086 *TemplateKWLoc = TemplateLoc;
3088 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
3091 ConsumeAnnotationToken();
3098 if (Tok.
is(tok::kw_operator)) {
3099 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
Result))
3111 return ParseUnqualifiedIdTemplateId(
3112 SS, ObjectType, ObjectHadErrors,
3115 else if (TemplateSpecified &&
3118 EnteringContext, Template,
3126 (AllowDestructorName || SS.
isSet()) && Tok.
is(tok::tilde)) {
3135 if (TemplateSpecified) {
3146 Diag(*TemplateKWLoc, diag::err_unexpected_template_in_destructor_name)
3151 if (SS.
isEmpty() && Tok.
is(tok::kw_decltype)) {
3156 Result.setDestructorName(TildeLoc,
Type, EndLoc);
3163 if (Tok.
isNot(tok::identifier)) {
3164 Diag(Tok, diag::err_destructor_tilde_identifier);
3169 DeclaratorScopeObj DeclScopeObj(*
this, SS);
3177 AnnotateScopeToken(SS,
true);
3180 if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, ObjectHadErrors,
3184 ObjectType =
nullptr;
3185 if (Tok.
isNot(tok::identifier) ||
NextToken().is(tok::coloncolon) ||
3187 Diag(TildeLoc, diag::err_destructor_tilde_scope);
3192 Diag(TildeLoc, diag::err_destructor_tilde_scope)
3198 DeclScopeObj.EnterDeclaratorScope();
3205 if (Tok.
is(tok::less)) {
3206 Result.setDestructorName(TildeLoc,
nullptr, ClassNameLoc);
3207 return ParseUnqualifiedIdTemplateId(
3208 SS, ObjectType, ObjectHadErrors,
3210 ClassNameLoc, EnteringContext,
Result, TemplateSpecified);
3216 ObjectType, EnteringContext);
3220 Result.setDestructorName(TildeLoc, Ty, ClassNameLoc);
3225#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
3226#include "clang/Basic/TransformTypeTraits.def"
3229 Diag(Tok, diag::ext_keyword_as_ident)
3231 goto ParseIdentifier;
3235 Diag(Tok, diag::err_expected_unqualified_id) <<
getLangOpts().CPlusPlus;
3269Parser::ParseCXXNewExpression(
bool UseGlobal,
SourceLocation Start) {
3270 assert(Tok.
is(tok::kw_new) &&
"expected 'new' token");
3276 ExprVector PlacementArgs;
3283 if (Tok.
is(tok::l_paren)) {
3287 PlacementLParen =
T.getOpenLocation();
3288 if (ParseExpressionListOrTypeId(PlacementArgs, DeclaratorInfo)) {
3294 PlacementRParen =
T.getCloseLocation();
3300 if (PlacementArgs.empty()) {
3302 TypeIdParens =
T.getRange();
3306 if (Tok.
is(tok::l_paren)) {
3309 MaybeParseGNUAttributes(DeclaratorInfo);
3310 ParseSpecifierQualifierList(DS);
3312 ParseDeclarator(DeclaratorInfo);
3314 TypeIdParens =
T.getRange();
3316 MaybeParseGNUAttributes(DeclaratorInfo);
3317 if (ParseCXXTypeSpecifierSeq(DS))
3318 DeclaratorInfo.setInvalidType(
true);
3321 ParseDeclaratorInternal(DeclaratorInfo,
3322 &Parser::ParseDirectNewDeclarator);
3329 MaybeParseGNUAttributes(DeclaratorInfo);
3331 DeclaratorInfo.setInvalidType(
true);
3334 ParseDeclaratorInternal(DeclaratorInfo,
3335 &Parser::ParseDirectNewDeclarator);
3338 if (DeclaratorInfo.isInvalidType()) {
3345 if (Tok.
is(tok::l_paren)) {
3347 ExprVector ConstructorArgs;
3350 ConstructorLParen =
T.getOpenLocation();
3351 if (Tok.
isNot(tok::r_paren)) {
3352 auto RunSignatureHelp = [&]() {
3362 DeclaratorInfo.getEndLoc(), ConstructorArgs,
3365 CalledSignatureHelp =
true;
3366 return PreferredType;
3368 if (ParseExpressionList(ConstructorArgs, [&] {
3369 PreferredType.enterFunctionArgument(Tok.
getLocation(),
3379 ConstructorRParen =
T.getCloseLocation();
3389 diag::warn_cxx98_compat_generalized_initializer_lists);
3395 return Actions.
ActOnCXXNew(Start, UseGlobal, PlacementLParen,
3396 PlacementArgs, PlacementRParen,
3407void Parser::ParseDirectNewDeclarator(
Declarator &D) {
3410 while (Tok.
is(tok::l_square)) {
3412 if (CheckProhibitedCXX11Attribute())
3421 if (
Size.isInvalid()) {
3432 MaybeParseCXX11Attributes(Attrs);
3436 Size.get(),
T.getOpenLocation(),
3437 T.getCloseLocation()),
3438 std::move(Attrs),
T.getCloseLocation());
3440 if (
T.getCloseLocation().isInvalid())
3455bool Parser::ParseExpressionListOrTypeId(
3459 if (isTypeIdInParens()) {
3467 return ParseExpressionList(PlacementArgs);
3482Parser::ParseCXXDeleteExpression(
bool UseGlobal,
SourceLocation Start) {
3483 assert(Tok.
is(tok::kw_delete) &&
"Expected 'delete' keyword");
3487 bool ArrayDelete =
false;
3488 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::r_square)) {
3496 const Token Next = GetLookAheadToken(2);
3499 if (Next.isOneOf(tok::l_brace, tok::less) ||
3500 (Next.is(tok::l_paren) &&
3501 (GetLookAheadToken(3).is(tok::r_paren) ||
3502 (GetLookAheadToken(3).is(tok::identifier) &&
3503 GetLookAheadToken(4).is(tok::identifier))))) {
3504 TentativeParsingAction TPA(*
this);
3512 bool EmitFixIt =
false;
3513 if (Tok.
is(tok::l_brace)) {
3523 Diag(Start, diag::err_lambda_after_delete)
3531 Diag(Start, diag::err_lambda_after_delete)
3541 Lambda = ParsePostfixExpressionSuffix(Lambda);
3553 if (
T.getCloseLocation().isInvalid())
3588ExprResult Parser::ParseRequiresExpression() {
3589 assert(Tok.
is(tok::kw_requires) &&
"Expected 'requires' keyword");
3594 if (Tok.
is(tok::l_paren)) {
3599 if (!Tok.
is(tok::r_paren)) {
3604 FirstArgAttrs, LocalParameters,
3607 Diag(EllipsisLoc, diag::err_requires_expr_parameter_list_ellipsis);
3608 for (
auto &ParamInfo : LocalParameters)
3609 LocalParameterDecls.push_back(cast<ParmVarDecl>(ParamInfo.Param));
3615 if (
Braces.expectAndConsume())
3632 RequiresKWLoc, LocalParameterDecls,
getCurScope());
3634 if (Tok.
is(tok::r_brace)) {
3641 Diag(Tok, diag::err_empty_requires_expr);
3644 while (!Tok.
is(tok::r_brace)) {
3646 case tok::l_brace: {
3657 ExprBraces.consumeOpen();
3661 ExprBraces.skipToEnd();
3665 if (ExprBraces.consumeClose())
3666 ExprBraces.skipToEnd();
3671 if (Tok.
is(tok::semi)) {
3674 Requirements.push_back(Req);
3679 Diag(Tok, diag::err_requires_expr_missing_arrow)
3682 if (TryAnnotateTypeConstraint()) {
3686 if (!isTypeConstraintAnnotation()) {
3687 Diag(Tok, diag::err_requires_expr_expected_type_constraint);
3692 if (Tok.
is(tok::annot_cxxscope)) {
3696 ConsumeAnnotationToken();
3700 Expression.get(), NoexceptLoc, SS, takeTemplateIdAnnotation(Tok),
3701 TemplateParameterDepth);
3702 ConsumeAnnotationToken();
3704 Requirements.push_back(Req);
3708 bool PossibleRequiresExprInSimpleRequirement =
false;
3709 if (Tok.
is(tok::kw_requires)) {
3710 auto IsNestedRequirement = [&] {
3711 RevertingTentativeParsingAction TPA(*
this);
3713 if (Tok.
is(tok::l_brace))
3720 if (Tok.
is(tok::l_paren)) {
3723 auto Res = TryParseParameterDeclarationClause();
3724 if (Res != TPResult::False) {
3727 while (Depth != 0) {
3728 bool FoundParen =
SkipUntil(tok::l_paren, tok::r_paren,
3732 if (Tok.
is(tok::l_paren))
3734 else if (Tok.
is(tok::r_paren))
3745 if (Tok.
is(tok::l_brace))
3754 if (IsNestedRequirement()) {
3769 Requirements.push_back(Req);
3777 PossibleRequiresExprInSimpleRequirement =
true;
3778 }
else if (Tok.
is(tok::kw_typename)) {
3781 TentativeParsingAction TPA(*
this);
3791 if (Tok.
is(tok::annot_cxxscope)) {
3794 ConsumeAnnotationToken();
3797 if (Tok.
isOneOf(tok::identifier, tok::annot_template_id) &&
3803 if (Tok.
is(tok::identifier)) {
3807 TemplateId = takeTemplateIdAnnotation(Tok);
3808 ConsumeAnnotationToken();
3816 Requirements.push_back(Req);
3833 if (!
Expression.isInvalid() && PossibleRequiresExprInSimpleRequirement)
3834 Diag(StartLoc, diag::err_requires_expr_in_simple_requirement)
3837 Requirements.push_back(Req);
3843 if (Tok.
is(tok::kw_noexcept)) {
3844 Diag(Tok, diag::err_requires_expr_simple_requirement_noexcept)
3853 if (ExpectAndConsumeSemi(diag::err_expected_semi_requirement)) {
3859 if (Requirements.empty()) {
3870 ParsingBodyDecl.complete(Body);
3872 RequiresKWLoc, Body,
Parens.getOpenLocation(), LocalParameterDecls,
3873 Parens.getCloseLocation(), Requirements,
Braces.getCloseLocation());
3878 default: llvm_unreachable(
"Not a known type trait");
3879#define TYPE_TRAIT_1(Spelling, Name, Key) \
3880case tok::kw_ ## Spelling: return UTT_ ## Name;
3881#define TYPE_TRAIT_2(Spelling, Name, Key) \
3882case tok::kw_ ## Spelling: return BTT_ ## Name;
3883#include "clang/Basic/TokenKinds.def"
3884#define TYPE_TRAIT_N(Spelling, Name, Key) \
3885 case tok::kw_ ## Spelling: return TT_ ## Name;
3886#include "clang/Basic/TokenKinds.def"
3893 llvm_unreachable(
"Not a known array type trait");
3894#define ARRAY_TYPE_TRAIT(Spelling, Name, Key) \
3895 case tok::kw_##Spelling: \
3897#include "clang/Basic/TokenKinds.def"
3904 llvm_unreachable(
"Not a known unary expression trait.");
3905#define EXPRESSION_TRAIT(Spelling, Name, Key) \
3906 case tok::kw_##Spelling: \
3908#include "clang/Basic/TokenKinds.def"
3929 if (
Parens.expectAndConsume())
3945 if (Tok.
is(tok::ellipsis)) {
3954 Args.push_back(Ty.
get());
3957 if (
Parens.consumeClose())
3977 if (
T.expectAndConsume())
3989 case ATT_ArrayRank: {
3992 T.getCloseLocation());
3994 case ATT_ArrayExtent: {
3995 if (ExpectAndConsume(tok::comma)) {
4004 T.getCloseLocation());
4007 llvm_unreachable(
"Invalid ArrayTypeTrait!");
4021 if (
T.expectAndConsume())
4029 T.getCloseLocation());
4037Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
4042 assert(ExprType ==
CastExpr &&
"Compound literals are not ambiguous!");
4043 assert(isTypeIdInParens() &&
"Not a type-id!");
4067 ParenParseOption ParseAs;
4072 if (!ConsumeAndStoreUntil(tok::r_paren, Toks)) {
4078 if (Tok.
is(tok::l_brace)) {
4079 ParseAs = CompoundLiteral;
4082 if (Tok.
is(tok::l_paren) &&
NextToken().is(tok::r_paren)) {
4089 Result = ParseCastExpression(AnyCastExpr,
4098 ParseAs = NotCastExpr ? SimpleExpr :
CastExpr;
4107 Toks.push_back(AttrEnd);
4110 Toks.push_back(Tok);
4113 PP.EnterTokenStream(Toks,
true,
4119 if (ParseAs >= CompoundLiteral) {
4126 ParseSpecifierQualifierList(DS);
4127 ParseDeclarator(DeclaratorInfo);
4138 if (ParseAs == CompoundLiteral) {
4139 ExprType = CompoundLiteral;
4140 if (DeclaratorInfo.isInvalidType())
4144 return ParseCompoundLiteralExpression(Ty.
get(),
4152 if (DeclaratorInfo.isInvalidType())
4158 DeclaratorInfo, CastTy,
4164 assert(ParseAs == SimpleExpr);
4166 ExprType = SimpleExpr;
4168 if (!
Result.isInvalid() && Tok.
is(tok::r_paren))
4173 if (
Result.isInvalid()) {
4174 while (Tok.
isNot(tok::eof))
4193 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"__builtin_bit_cast"))
4198 ParseSpecifierQualifierList(DS);
4203 ParseDeclarator(DeclaratorInfo);
4205 if (ExpectAndConsume(tok::comma)) {
4213 if (
T.consumeClose())
4216 if (
Operand.isInvalid() || DeclaratorInfo.isInvalidType())
4220 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()
This file declares facilities that support code completion.
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.
void CodeCompleteObjCMessageReceiver(Scope *S)
void CodeCompleteOperatorName(Scope *S)
@ PCC_Condition
Code completion occurs within the condition of an if, while, switch, or for statement.
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
QualType ProduceConstructorSignatureHelp(QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args, SourceLocation OpenParLoc, bool Braced)
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, bool IsUsingDeclaration, QualType BaseType, QualType PreferredType)
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
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.
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)
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)
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()
SemaCodeCompletion & CodeCompletion()
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)
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.
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)
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.