28#include "llvm/Support/Compiler.h"
29#include "llvm/Support/ErrorHandling.h"
37 case tok::unknown:
return 0;
39 case tok::kw_addrspace_cast:
return 1;
40 case tok::kw_const_cast:
return 2;
41 case tok::kw_dynamic_cast:
return 3;
42 case tok::kw_reinterpret_cast:
return 4;
43 case tok::kw_static_cast:
return 5;
45 llvm_unreachable(
"Unknown type for digraph error message.");
50bool Parser::areTokensAdjacent(
const Token &
First,
const Token &Second) {
68 P.Diag(DigraphToken.
getLocation(), diag::err_missing_whitespace_digraph)
73 ColonToken.
setKind(tok::coloncolon);
76 DigraphToken.
setKind(tok::less);
87void Parser::CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectType,
90 if (!Next.is(tok::l_square) || Next.getLength() != 2)
93 Token SecondToken = GetLookAheadToken(2);
94 if (!SecondToken.
is(tok::colon) || !areTokensAdjacent(Next, SecondToken))
100 bool MemberOfUnknownSpecialization;
103 Template, MemberOfUnknownSpecialization))
106 FixDigraph(*
this, PP, Next, SecondToken, tok::unknown,
159bool Parser::ParseOptionalCXXScopeSpecifier(
161 bool EnteringContext,
bool *MayBePseudoDestructor,
bool IsTypename,
163 bool InUsingDeclaration) {
165 "Call sites of this function should be guarded by checking for C++");
167 if (Tok.
is(tok::annot_cxxscope)) {
168 assert(!LastII &&
"want last identifier but have already annotated scope");
169 assert(!MayBePseudoDestructor &&
"unexpected annot_cxxscope");
173 ConsumeAnnotationToken();
178 bool CheckForDestructor =
false;
179 if (MayBePseudoDestructor && *MayBePseudoDestructor) {
180 CheckForDestructor =
true;
181 *MayBePseudoDestructor =
false;
187 bool HasScopeSpecifier =
false;
189 if (Tok.
is(tok::coloncolon)) {
192 if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
195 if (NextKind == tok::l_brace) {
204 HasScopeSpecifier =
true;
208 if (Tok.
is(tok::kw___super)) {
210 if (!Tok.
is(tok::coloncolon)) {
218 if (!HasScopeSpecifier &&
219 Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
229 AnnotateExistingDecltypeSpecifier(DS, DeclLoc, EndLoc);
236 HasScopeSpecifier =
true;
239 else if (!HasScopeSpecifier && Tok.
is(tok::identifier) &&
240 GetLookAheadToken(1).is(tok::ellipsis) &&
241 GetLookAheadToken(2).is(tok::l_square)) {
250 DS.getRepAsType().get(), DS.getPackIndexingExpr(), DS.getBeginLoc(),
251 DS.getEllipsisLoc());
264 HasScopeSpecifier =
true;
268 auto SavedType = PreferredType;
270 if (HasScopeSpecifier) {
271 if (Tok.
is(tok::code_completion)) {
276 getCurScope(), SS, EnteringContext, InUsingDeclaration,
296 ObjectType =
nullptr;
304 if (Tok.
is(tok::kw_template)) {
308 if (!HasScopeSpecifier && !ObjectType)
311 TentativeParsingAction TPA(*
this);
315 if (Tok.
is(tok::identifier)) {
319 }
else if (Tok.
is(tok::kw_operator)) {
324 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
333 diag::err_id_after_template_in_nested_name_spec)
346 if (Tok.
isNot(tok::less)) {
356 EnteringContext, Template,
true);
357 if (AnnotateTemplateIdToken(Template, TNK, SS, TemplateKWLoc,
364 if (Tok.
is(tok::annot_template_id) &&
NextToken().is(tok::coloncolon)) {
373 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
374 *MayBePseudoDestructor =
true;
379 *LastII = TemplateId->
Name;
382 ConsumeAnnotationToken();
384 assert(Tok.
is(tok::coloncolon) &&
"NextToken() not working properly!");
387 HasScopeSpecifier =
true;
413#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
414#include "clang/Basic/TransformTypeTraits.def"
417 Diag(Tok, diag::ext_keyword_as_ident)
428 if (Tok.
isNot(tok::identifier))
443 if (Next.is(tok::colon) && !ColonIsSacred) {
450 Diag(Next, diag::err_unexpected_colon_in_nested_name_spec)
453 Next.setKind(tok::coloncolon);
457 if (Next.is(tok::coloncolon) && GetLookAheadToken(2).is(tok::l_brace)) {
468 if (Next.is(tok::coloncolon)) {
469 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
470 *MayBePseudoDestructor =
true;
475 const Token &Next2 = GetLookAheadToken(2);
476 if (Next2.
is(tok::kw_private) || Next2.
is(tok::kw_protected) ||
477 Next2.
is(tok::kw_public) || Next2.
is(tok::kw_virtual)) {
478 Diag(Next2, diag::err_unexpected_token_in_nested_name_spec)
483 ColonColon.
setKind(tok::colon);
496 assert(Tok.
isOneOf(tok::coloncolon, tok::colon) &&
497 "NextToken() not working properly!");
498 Token ColonColon = Tok;
501 bool IsCorrectedToColon =
false;
502 bool *CorrectionFlagPtr = ColonIsSacred ? &IsCorrectedToColon :
nullptr;
504 getCurScope(), IdInfo, EnteringContext, SS, CorrectionFlagPtr,
508 if (CorrectionFlagPtr && IsCorrectedToColon) {
509 ColonColon.
setKind(tok::colon);
517 HasScopeSpecifier =
true;
521 CheckForTemplateAndDigraph(Next, ObjectType, EnteringContext, II, SS);
525 if (Next.is(tok::less)) {
530 bool MemberOfUnknownSpecialization;
537 MemberOfUnknownSpecialization)) {
543 isTemplateArgumentList(1) == TPResult::False)
560 if (MemberOfUnknownSpecialization && (ObjectType || SS.
isSet()) &&
561 (IsTypename || isTemplateArgumentList(1) == TPResult::True)) {
564 if (!ObjectHadErrors) {
569 unsigned DiagID = diag::err_missing_dependent_template_keyword;
571 DiagID = diag::warn_missing_dependent_template_keyword;
582 EnteringContext, Template,
true);
599 if (CheckForDestructor && !HasScopeSpecifier && Tok.
is(tok::tilde))
600 *MayBePseudoDestructor =
true;
606 bool isAddressOfOperand,
607 Token &Replacement) {
612 case tok::annot_non_type: {
613 NamedDecl *ND = getNonTypeAnnotation(Tok);
619 case tok::annot_non_type_dependent: {
625 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
626 isAddressOfOperand =
false;
633 case tok::annot_non_type_undeclared: {
635 "undeclared non-type annotation should be unqualified");
650 false, &TemplateKWLoc, Name))
655 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
656 isAddressOfOperand =
false;
659 getCurScope(), SS, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
660 isAddressOfOperand,
nullptr,
false,
666 E = tryParseCXXPackIndexingExpression(
E);
668 if (!
E.isInvalid() && !
E.isUnset() && Tok.
is(tok::less))
669 checkPotentialAngleBracket(
E);
674 assert(Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square) &&
680 if (
T.consumeClose() || IndexExpr.
isInvalid())
683 EllipsisLoc,
T.getOpenLocation(),
684 IndexExpr.
get(),
T.getCloseLocation());
688Parser::tryParseCXXPackIndexingExpression(
ExprResult PackIdExpression) {
691 Tok.
is(tok::ellipsis) &&
NextToken().is(tok::l_square)) {
692 E = ParseCXXPackIndexingExpression(
E);
739ExprResult Parser::ParseCXXIdExpression(
bool isAddressOfOperand) {
745 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
751 tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
755 UnconsumeToken(Replacement);
756 Result = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
758 assert(!
Result.isUnset() &&
"Typo correction suggested a keyword replacement "
759 "for a previous keyword suggestion");
811 if (ParseLambdaIntroducer(Intro)) {
818 return ParseLambdaExpressionAfterIntroducer(Intro);
825ExprResult Parser::TryParseLambdaExpression() {
827 "Not at the start of a possible lambda expression.");
830 if (Next.is(tok::eof))
835 if (Next.is(tok::r_square) ||
836 Next.is(tok::equal) ||
837 (Next.is(tok::amp) &&
838 After.isOneOf(tok::r_square, tok::comma)) ||
839 (Next.is(tok::identifier) &&
840 After.is(tok::r_square)) ||
841 Next.is(tok::ellipsis)) {
842 return ParseLambdaExpression();
847 if (Next.is(tok::identifier) &&
After.is(tok::identifier))
857 TentativeParsingAction TPA(*
this);
858 LambdaIntroducerTentativeParse Tentative;
859 if (ParseLambdaIntroducer(Intro, &Tentative)) {
865 case LambdaIntroducerTentativeParse::Success:
869 case LambdaIntroducerTentativeParse::Incomplete:
874 if (ParseLambdaIntroducer(Intro))
878 case LambdaIntroducerTentativeParse::MessageSend:
879 case LambdaIntroducerTentativeParse::Invalid:
886 return ParseLambdaExpressionAfterIntroducer(Intro);
899 LambdaIntroducerTentativeParse *Tentative) {
901 *Tentative = LambdaIntroducerTentativeParse::Success;
903 assert(Tok.
is(tok::l_square) &&
"Lambda expressions begin with '['.");
913 auto Invalid = [&](llvm::function_ref<void()> Action) {
915 *Tentative = LambdaIntroducerTentativeParse::Invalid;
924 auto NonTentativeAction = [&](llvm::function_ref<void()> Action) {
926 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
932 if (Tok.
is(tok::amp) &&
942 }
else if (Tok.
is(tok::equal)) {
949 while (Tok.
isNot(tok::r_square)) {
951 if (Tok.
isNot(tok::comma)) {
956 if (Tok.
is(tok::code_completion) &&
972 if (Tok.
is(tok::code_completion)) {
996 if (Tok.
is(tok::star)) {
998 if (Tok.
is(tok::kw_this)) {
1006 }
else if (Tok.
is(tok::kw_this)) {
1009 }
else if (Tok.
isOneOf(tok::amp, tok::equal) &&
1021 if (Tok.
is(tok::amp)) {
1025 if (Tok.
is(tok::code_completion)) {
1036 if (Tok.
is(tok::identifier)) {
1039 }
else if (Tok.
is(tok::kw_this)) {
1052 if (Tok.
is(tok::l_paren)) {
1061 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
1062 }
else if (ParseExpressionList(Exprs)) {
1068 Parens.getCloseLocation(),
1071 }
else if (Tok.
isOneOf(tok::l_brace, tok::equal)) {
1084 Init = ParseInitializer();
1085 }
else if (Tok.
is(tok::l_brace)) {
1089 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
1113 Init = ParseInitializer();
1114 if (!
Init.isInvalid())
1123 Tok.
setKind(tok::annot_primary_expr);
1124 setExprAnnotation(Tok,
Init);
1129 ConsumeAnnotationToken();
1138 if (Tentative && Tok.
is(tok::identifier) &&
1141 *Tentative = LambdaIntroducerTentativeParse::MessageSend;
1147 if (llvm::any_of(EllipsisLocs,
1153 !InitCapture ? &EllipsisLocs[2] :
1156 EllipsisLoc = *ExpectedEllipsisLoc;
1158 unsigned DiagID = 0;
1160 DiagID = diag::err_lambda_capture_misplaced_ellipsis;
1166 unsigned NumEllipses = std::accumulate(
1167 std::begin(EllipsisLocs), std::end(EllipsisLocs), 0,
1169 if (NumEllipses > 1)
1170 DiagID = diag::err_lambda_capture_multiple_ellipses;
1173 NonTentativeAction([&] {
1182 assert(DiagLoc.
isValid() &&
"no location for diagnostic");
1186 auto &&
D =
Diag(DiagLoc, DiagID);
1187 if (DiagID == diag::err_lambda_capture_misplaced_ellipsis) {
1207 if (
Init.isUsable())
1209 if (
Init.isUsable()) {
1210 NonTentativeAction([&] {
1247 auto ConsumeLocation = [&
P, &DeclEndLoc](
SourceLocation &SpecifierLoc,
1249 if (SpecifierLoc.isValid()) {
1250 P.Diag(
P.getCurToken().getLocation(),
1251 diag::err_lambda_decl_specifier_repeated)
1255 SpecifierLoc =
P.ConsumeToken();
1256 DeclEndLoc = SpecifierLoc;
1260 switch (
P.getCurToken().getKind()) {
1261 case tok::kw_mutable:
1262 ConsumeLocation(MutableLoc, 0);
1264 case tok::kw_static:
1265 ConsumeLocation(StaticLoc, 1);
1267 case tok::kw_constexpr:
1268 ConsumeLocation(ConstexprLoc, 2);
1270 case tok::kw_consteval:
1271 ConsumeLocation(ConstevalLoc, 3);
1282 P.Diag(StaticLoc, !
P.getLangOpts().CPlusPlus23
1283 ? diag::err_static_lambda
1284 : diag::warn_cxx20_compat_static_lambda);
1285 const char *PrevSpec =
nullptr;
1286 unsigned DiagID = 0;
1289 P.getActions().getASTContext().getPrintingPolicy());
1290 assert(PrevSpec ==
nullptr && DiagID == 0 &&
1291 "Static cannot have been set previously!");
1299 P.Diag(ConstexprLoc, !
P.getLangOpts().CPlusPlus17
1300 ? diag::ext_constexpr_on_lambda_cxx17
1301 : diag::warn_cxx14_compat_constexpr_on_lambda);
1302 const char *PrevSpec =
nullptr;
1303 unsigned DiagID = 0;
1306 assert(PrevSpec ==
nullptr && DiagID == 0 &&
1307 "Constexpr cannot have been set previously!");
1315 P.Diag(ConstevalLoc, diag::warn_cxx20_compat_consteval);
1316 const char *PrevSpec =
nullptr;
1317 unsigned DiagID = 0;
1321 P.Diag(ConstevalLoc, DiagID) << PrevSpec;
1337 P.Diag(StaticLoc, diag::err_static_mutable_lambda);
1339 P.Diag(StaticLoc, diag::err_static_lambda_captures);
1345ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
1349 ? diag::warn_cxx98_compat_lambda
1350 : diag::ext_lambda);
1353 "lambda expression parsing");
1358 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1375 if (Tok.
is(tok::kw___noinline__)) {
1378 Attributes.addNew(AttrName, AttrNameLoc,
nullptr,
1379 AttrNameLoc,
nullptr,
1380 0, tok::kw___noinline__);
1381 }
else if (Tok.
is(tok::kw___attribute))
1382 ParseGNUAttributes(Attributes,
nullptr, &
D);
1387 D.takeAttributes(Attributes);
1390 MultiParseScope TemplateParamScope(*
this);
1391 if (Tok.
is(tok::less)) {
1393 ? diag::warn_cxx17_compat_lambda_template_parameter_list
1394 : diag::ext_lambda_template_parameter_list);
1398 if (ParseTemplateParameters(TemplateParamScope,
1399 CurTemplateDepthTracker.getDepth(),
1400 TemplateParams, LAngleLoc, RAngleLoc)) {
1405 if (TemplateParams.empty()) {
1407 diag::err_lambda_template_parameter_list_empty);
1418 ++CurTemplateDepthTracker;
1429 Intro, LAngleLoc, TemplateParams, RAngleLoc, RequiresClause);
1437 if (isCXX11AttributeSpecifier()) {
1439 ? diag::warn_cxx20_compat_decl_attrs_on_lambda
1440 : diag::ext_decl_attrs_on_lambda)
1442 MaybeParseCXX11Attributes(
D);
1449 bool HasParentheses =
false;
1450 bool HasSpecifiers =
false;
1461 if (Tok.
is(tok::l_paren)) {
1464 LParenLoc =
T.getOpenLocation();
1466 if (Tok.
isNot(tok::r_paren)) {
1468 CurTemplateDepthTracker.getOriginalDepth());
1470 ParseParameterDeclarationClause(
D, Attributes, ParamInfo, EllipsisLoc);
1477 CurTemplateDepthTracker.setAddedDepth(1);
1481 DeclEndLoc = RParenLoc =
T.getCloseLocation();
1482 HasParentheses =
true;
1486 Tok.
isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute,
1487 tok::kw_constexpr, tok::kw_consteval, tok::kw_static,
1488 tok::kw___private, tok::kw___global, tok::kw___local,
1489 tok::kw___constant, tok::kw___generic, tok::kw_groupshared,
1490 tok::kw_requires, tok::kw_noexcept) ||
1494 if (HasSpecifiers && !HasParentheses && !
getLangOpts().CPlusPlus23) {
1498 Diag(Tok, diag::ext_lambda_missing_parens)
1502 if (HasParentheses || HasSpecifiers) {
1506 MaybeParseAttributes(PAKM_GNU | PAKM_Declspec, Attributes);
1514 ConstevalLoc, DeclEndLoc);
1525 if (!HasParentheses)
1528 if (HasSpecifiers || HasParentheses) {
1537 ESpecType = tryParseExceptionSpecification(
1538 false, ESpecRange, DynamicExceptions,
1539 DynamicExceptionRanges, NoexceptExpr, ExceptionSpecTokens);
1542 DeclEndLoc = ESpecRange.
getEnd();
1545 if (MaybeParseCXX11Attributes(Attributes))
1546 DeclEndLoc = Attributes.Range.getEnd();
1549 if (Tok.
isOneOf(tok::kw___private, tok::kw___global, tok::kw___local,
1550 tok::kw___constant, tok::kw___generic)) {
1551 ParseOpenCLQualifiers(DS.getAttributes());
1558 if (Tok.
is(tok::arrow)) {
1561 TrailingReturnType =
1562 ParseTrailingReturnType(
Range,
false);
1571 false, LParenLoc, ParamInfo.data(),
1572 ParamInfo.size(), EllipsisLoc, RParenLoc,
1574 NoLoc, MutableLoc, ESpecType,
1575 ESpecRange, DynamicExceptions.data(),
1576 DynamicExceptionRanges.data(), DynamicExceptions.size(),
1577 NoexceptExpr.
isUsable() ? NoexceptExpr.
get() :
nullptr,
1579 std::nullopt, LParenLoc,
1580 FunLocalRangeEnd,
D, TrailingReturnType,
1581 TrailingReturnTypeLoc, &DS),
1582 std::move(Attributes), DeclEndLoc);
1589 if (HasParentheses && Tok.
is(tok::kw_requires))
1590 ParseTrailingRequiresClause(
D);
1597 if (A.getKind() == ParsedAttr::AT_CUDADevice ||
1598 A.getKind() == ParsedAttr::AT_CUDAHost ||
1599 A.getKind() == ParsedAttr::AT_CUDAGlobal)
1600 Diag(A.getLoc(), diag::warn_cuda_attr_lambda_position)
1601 << A.getAttrName()->getName();
1610 ParseScope BodyScope(
this, ScopeFlags);
1615 if (!Tok.
is(tok::l_brace)) {
1616 Diag(Tok, diag::err_expected_lambda_body);
1623 TemplateParamScope.Exit();
1647 const char *CastName =
nullptr;
1650 default: llvm_unreachable(
"Unknown C++ cast!");
1651 case tok::kw_addrspace_cast: CastName =
"addrspace_cast";
break;
1652 case tok::kw_const_cast: CastName =
"const_cast";
break;
1653 case tok::kw_dynamic_cast: CastName =
"dynamic_cast";
break;
1654 case tok::kw_reinterpret_cast: CastName =
"reinterpret_cast";
break;
1655 case tok::kw_static_cast: CastName =
"static_cast";
break;
1663 if (Tok.
is(tok::l_square) && Tok.
getLength() == 2) {
1665 if (Next.is(tok::colon) && areTokensAdjacent(Tok, Next))
1666 FixDigraph(*
this, PP, Tok, Next, Kind,
true);
1669 if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
1674 ParseSpecifierQualifierList(DS,
AS_none,
1675 DeclSpecContext::DSC_type_specifier);
1680 ParseDeclarator(DeclaratorInfo);
1684 if (ExpectAndConsume(tok::greater))
1685 return ExprError(
Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
1689 if (
T.expectAndConsume(diag::err_expected_lparen_after, CastName))
1697 if (!
Result.isInvalid() && !DeclaratorInfo.isInvalidType())
1699 LAngleBracketLoc, DeclaratorInfo,
1701 T.getOpenLocation(),
Result.get(),
1702 T.getCloseLocation());
1714 assert(Tok.
is(tok::kw_typeid) &&
"Not 'typeid'!");
1721 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"typeid"))
1723 LParenLoc =
T.getOpenLocation();
1744 if (isTypeIdInParens()) {
1749 RParenLoc =
T.getCloseLocation();
1754 Ty.
get().getAsOpaquePtr(), RParenLoc);
1763 RParenLoc =
T.getCloseLocation();
1768 Result.get(), RParenLoc);
1781 assert(Tok.
is(tok::kw___uuidof) &&
"Not '__uuidof'!");
1787 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"__uuidof"))
1792 if (isTypeIdInParens()) {
1802 Ty.
get().getAsOpaquePtr(),
1803 T.getCloseLocation());
1817 Result.get(),
T.getCloseLocation());
1864 if (Tok.
is(tok::identifier)) {
1867 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1869 }
else if (Tok.
is(tok::annot_template_id)) {
1875 ConsumeAnnotationToken();
1876 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1879 assert(SS.
isEmpty() &&
"missing last component of nested name specifier");
1884 assert(Tok.
is(tok::tilde) &&
"ParseOptionalCXXScopeSpecifier fail");
1887 if (Tok.
is(tok::kw_decltype) && !FirstTypeName.
isValid()) {
1889 ParseDecltypeSpecifier(DS);
1896 if (!Tok.
is(tok::identifier)) {
1897 Diag(Tok, diag::err_destructor_tilde_identifier);
1902 if (GetLookAheadToken(1).is(tok::ellipsis) &&
1903 GetLookAheadToken(2).is(tok::l_square)) {
1905 ParsePackIndexingType(DS);
1924 if (Tok.
is(tok::less) &&
1925 ParseUnqualifiedIdTemplateId(
1927 Name, NameLoc,
false, SecondTypeName,
1932 SS, FirstTypeName, CCLoc, TildeLoc,
1951 assert(Tok.
is(tok::kw_throw) &&
"Not throw!");
1978 assert(Tok.
is(tok::kw_co_yield) &&
"Not co_yield!");
1983 if (!
Expr.isInvalid())
1994 assert(Tok.
is(tok::kw_this) &&
"Not 'this'!");
2013Parser::ParseCXXTypeConstructExpression(
const DeclSpec &DS) {
2018 assert((Tok.
is(tok::l_paren) ||
2020 &&
"Expected '(' or '{'!");
2022 if (Tok.
is(tok::l_brace)) {
2025 if (
Init.isInvalid())
2039 auto RunSignatureHelp = [&]() {
2045 Exprs,
T.getOpenLocation(),
false);
2046 CalledSignatureHelp =
true;
2047 return PreferredType;
2050 if (Tok.
isNot(tok::r_paren)) {
2051 if (ParseExpressionList(Exprs, [&] {
2052 PreferredType.enterFunctionArgument(Tok.
getLocation(),
2070 Exprs,
T.getCloseLocation(),
2078 assert(Tok.
is(tok::kw_using) &&
"Expected using");
2081 "Unexpected Declarator Context");
2085 DG = ParseUsingDeclaration(Context, {}, DeclStart, DeclEnd, Attrs,
AS_none);
2090 ? diag::ext_alias_in_init_statement
2091 : diag::warn_cxx20_alias_in_init_statement)
2131 ForRangeInfo *FRI,
bool EnterForConditionScope) {
2133 struct ForConditionScopeRAII {
2135 void enter(
bool IsConditionVariable) {
2138 S->setIsConditionVarScope(IsConditionVariable);
2141 ~ForConditionScopeRAII() {
2143 S->setIsConditionVarScope(
false);
2145 } ForConditionScope{EnterForConditionScope ?
getCurScope() : nullptr};
2148 PreferredType.enterCondition(Actions, Tok.
getLocation());
2150 if (Tok.
is(tok::code_completion)) {
2158 MaybeParseCXX11Attributes(attrs);
2160 const auto WarnOnInit = [
this, &CK] {
2162 ? diag::warn_cxx14_compat_init_statement
2163 : diag::ext_init_statement)
2168 switch (isCXXConditionDeclarationOrInitStatement(InitStmt, FRI)) {
2169 case ConditionOrInitStatement::Expression: {
2171 ForConditionScope.enter(
false);
2173 ProhibitAttributes(attrs);
2177 if (InitStmt && Tok.
is(tok::semi)) {
2181 Diag(SemiLoc, diag::warn_empty_init_statement)
2187 return ParseCXXCondition(
nullptr,
Loc, CK, MissingOK);
2192 if (
Expr.isInvalid())
2195 if (InitStmt && Tok.
is(tok::semi)) {
2199 return ParseCXXCondition(
nullptr,
Loc, CK, MissingOK);
2206 case ConditionOrInitStatement::InitStmtDecl: {
2210 if (Tok.
is(tok::kw_using))
2211 DG = ParseAliasDeclarationInInitStatement(
2216 attrs, DeclSpecAttrs,
true);
2219 return ParseCXXCondition(
nullptr,
Loc, CK, MissingOK);
2222 case ConditionOrInitStatement::ForRangeDecl: {
2226 assert(FRI &&
"should not parse a for range declaration here");
2235 case ConditionOrInitStatement::ConditionDecl:
2236 case ConditionOrInitStatement::Error:
2241 ForConditionScope.enter(
true);
2245 ParseSpecifierQualifierList(DS,
AS_none, DeclSpecContext::DSC_condition);
2249 ParseDeclarator(DeclaratorInfo);
2252 if (Tok.
is(tok::kw_asm)) {
2255 if (AsmLabel.isInvalid()) {
2259 DeclaratorInfo.setAsmLabel(AsmLabel.get());
2260 DeclaratorInfo.SetRangeEnd(
Loc);
2264 MaybeParseGNUAttributes(DeclaratorInfo);
2275 bool CopyInitialization = isTokenEqualOrEqualTypo();
2276 if (CopyInitialization)
2282 diag::warn_cxx98_compat_generalized_initializer_lists);
2283 InitExpr = ParseBraceInitializer();
2284 }
else if (CopyInitialization) {
2285 PreferredType.enterVariableInit(Tok.
getLocation(), DeclOut);
2287 }
else if (Tok.
is(tok::l_paren)) {
2291 RParen = ConsumeParen();
2293 diag::err_expected_init_in_condition_lparen)
2334void Parser::ParseCXXSimpleTypeSpecifier(
DeclSpec &DS) {
2336 const char *PrevSpec;
2343 case tok::identifier:
2344 case tok::coloncolon:
2345 llvm_unreachable(
"Annotation token should already be formed!");
2347 llvm_unreachable(
"Not a simple-type-specifier token!");
2350 case tok::annot_typename: {
2354 ConsumeAnnotationToken();
2355 DS.
Finish(Actions, Policy);
2359 case tok::kw__ExtInt:
2360 case tok::kw__BitInt: {
2361 DiagnoseBitIntUse(Tok);
2370 DS.
Finish(Actions, Policy);
2383 case tok::kw___int64:
2387 case tok::kw_signed:
2390 case tok::kw_unsigned:
2405 case tok::kw___int128:
2408 case tok::kw___bf16:
2417 case tok::kw_double:
2420 case tok::kw__Float16:
2423 case tok::kw___float128:
2426 case tok::kw___ibm128:
2429 case tok::kw_wchar_t:
2432 case tok::kw_char8_t:
2435 case tok::kw_char16_t:
2438 case tok::kw_char32_t:
2444 case tok::kw__Accum:
2447 case tok::kw__Fract:
2453#define GENERIC_IMAGE_TYPE(ImgType, Id) \
2454 case tok::kw_##ImgType##_t: \
2455 DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, DiagID, \
2458#include "clang/Basic/OpenCLImageTypes.def"
2460 case tok::annot_decltype:
2461 case tok::kw_decltype:
2463 return DS.
Finish(Actions, Policy);
2465 case tok::annot_pack_indexing_type:
2467 return DS.
Finish(Actions, Policy);
2470 case tok::kw_typeof:
2471 ParseTypeofSpecifier(DS);
2472 DS.
Finish(Actions, Policy);
2477 DS.
Finish(Actions, Policy);
2492 ParseSpecifierQualifierList(DS,
AS_none,
2493 getDeclSpecContextFromDeclaratorContext(Context));
2533bool Parser::ParseUnqualifiedIdTemplateId(
2537 assert(Tok.
is(tok::less) &&
"Expected '<' to finish parsing a template-id");
2541 switch (
Id.getKind()) {
2545 if (AssumeTemplateId) {
2549 ObjectType, EnteringContext, Template,
2552 bool MemberOfUnknownSpecialization;
2555 ObjectType, EnteringContext, Template,
2556 MemberOfUnknownSpecialization);
2561 isTemplateArgumentList(0) == TPResult::False)
2565 ObjectType && isTemplateArgumentList(0) == TPResult::True) {
2568 if (!ObjectHadErrors) {
2575 Name = std::string(
Id.Identifier->getName());
2581 Name +=
Id.Identifier->getName();
2583 Diag(
Id.StartLocation, diag::err_missing_dependent_template_keyword)
2588 getCurScope(), SS, TemplateKWLoc,
Id, ObjectType, EnteringContext,
2598 bool MemberOfUnknownSpecialization;
2602 EnteringContext, Template,
2603 MemberOfUnknownSpecialization);
2611 bool MemberOfUnknownSpecialization;
2616 EnteringContext, Template,
true);
2620 EnteringContext, Template,
2621 MemberOfUnknownSpecialization);
2624 Diag(NameLoc, diag::err_destructor_template_id)
2638 TemplateArgList TemplateArgs;
2639 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs, RAngleLoc,
2660 :
Id.OperatorFunctionId.Operator;
2663 TemplateKWLoc,
Id.StartLocation, TemplateII, OpKind, Template, TNK,
2664 LAngleLoc, RAngleLoc, TemplateArgs,
false, TemplateIds);
2666 Id.setTemplateId(TemplateId);
2675 getCurScope(), SS, TemplateKWLoc, Template, Name, NameLoc, LAngleLoc,
2676 TemplateArgsPtr, RAngleLoc,
true);
2677 if (
Type.isInvalid())
2681 Id.setConstructorName(
Type.get(), NameLoc, RAngleLoc);
2683 Id.setDestructorName(
Id.StartLocation,
Type.get(), RAngleLoc);
2728bool Parser::ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2731 assert(Tok.
is(tok::kw_operator) &&
"Expected 'operator' keyword");
2737 unsigned SymbolIdx = 0;
2742 case tok::kw_delete: {
2743 bool isNew = Tok.
getKind() == tok::kw_new;
2747 if (Tok.
is(tok::l_square) &&
2753 if (
T.getCloseLocation().isInvalid())
2756 SymbolLocations[SymbolIdx++] =
T.getOpenLocation();
2757 SymbolLocations[SymbolIdx++] =
T.getCloseLocation();
2758 Op = isNew? OO_Array_New : OO_Array_Delete;
2760 Op = isNew? OO_New : OO_Delete;
2765#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
2767 SymbolLocations[SymbolIdx++] = ConsumeToken(); \
2770#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
2771#include "clang/Basic/OperatorKinds.def"
2773 case tok::l_paren: {
2778 if (
T.getCloseLocation().isInvalid())
2781 SymbolLocations[SymbolIdx++] =
T.getOpenLocation();
2782 SymbolLocations[SymbolIdx++] =
T.getCloseLocation();
2787 case tok::l_square: {
2792 if (
T.getCloseLocation().isInvalid())
2795 SymbolLocations[SymbolIdx++] =
T.getOpenLocation();
2796 SymbolLocations[SymbolIdx++] =
T.getCloseLocation();
2801 case tok::code_completion: {
2815 Result.setOperatorFunctionId(KeywordLoc, Op, SymbolLocations);
2829 unsigned DiagId = 0;
2835 while (isTokenStringLiteral()) {
2836 if (!Tok.
is(tok::string_literal) && !DiagId) {
2841 DiagId = diag::err_literal_operator_string_prefix;
2843 Toks.push_back(Tok);
2844 TokLocs.push_back(ConsumeStringToken());
2853 bool IsUDSuffix = !
Literal.getUDSuffix().empty();
2862 }
else if (Tok.
is(tok::identifier)) {
2865 TokLocs.push_back(SuffixLoc);
2877 DiagLoc = TokLocs.front();
2878 DiagId = diag::err_literal_operator_string_not_empty;
2888 SourceRange(TokLocs.front(), TokLocs.back()), Str);
2891 Result.setLiteralOperatorId(II, KeywordLoc, SuffixLoc);
2909 if (ParseCXXTypeSpecifierSeq(
2917 ParseDeclaratorInternal(
D,
nullptr);
2925 Result.setConversionFunctionId(KeywordLoc, Ty.
get(),
2967 bool ObjectHadErrors,
bool EnteringContext,
2968 bool AllowDestructorName,
2969 bool AllowConstructorName,
2970 bool AllowDeductionGuide,
2978 bool TemplateSpecified =
false;
2979 if (Tok.
is(tok::kw_template)) {
2980 if (TemplateKWLoc && (ObjectType || SS.
isSet())) {
2981 TemplateSpecified =
true;
2985 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
2993 if (Tok.
is(tok::identifier)) {
3007 if (AllowConstructorName &&
3014 Result.setConstructorName(Ty, IdLoc, IdLoc);
3028 if (Tok.
is(tok::less))
3029 return ParseUnqualifiedIdTemplateId(
3030 SS, ObjectType, ObjectHadErrors,
3032 EnteringContext,
Result, TemplateSpecified);
3034 if (TemplateSpecified) {
3037 ObjectType, EnteringContext, Template,
3048 Diag(IdLoc, diag::missing_template_arg_list_after_template_kw);
3055 if (Tok.
is(tok::annot_template_id)) {
3061 ConsumeAnnotationToken();
3066 if (AllowConstructorName && TemplateId->
Name &&
3074 diag::err_out_of_line_constructor_template_id)
3085 ConsumeAnnotationToken();
3089 Result.setConstructorTemplateId(TemplateId);
3090 ConsumeAnnotationToken();
3096 Result.setTemplateId(TemplateId);
3099 if (TemplateKWLoc && (ObjectType || SS.
isSet()))
3100 *TemplateKWLoc = TemplateLoc;
3102 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
3105 ConsumeAnnotationToken();
3112 if (Tok.
is(tok::kw_operator)) {
3113 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
Result))
3125 return ParseUnqualifiedIdTemplateId(
3126 SS, ObjectType, ObjectHadErrors,
3129 else if (TemplateSpecified &&
3132 EnteringContext, Template,
3140 (AllowDestructorName || SS.
isSet()) && Tok.
is(tok::tilde)) {
3149 if (TemplateSpecified) {
3160 Diag(*TemplateKWLoc, diag::err_unexpected_template_in_destructor_name)
3165 if (SS.
isEmpty() && Tok.
is(tok::kw_decltype)) {
3170 Result.setDestructorName(TildeLoc,
Type, EndLoc);
3177 if (Tok.
isNot(tok::identifier)) {
3178 Diag(Tok, diag::err_destructor_tilde_identifier);
3183 DeclaratorScopeObj DeclScopeObj(*
this, SS);
3191 AnnotateScopeToken(SS,
true);
3194 if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, ObjectHadErrors,
3198 ObjectType =
nullptr;
3199 if (Tok.
isNot(tok::identifier) ||
NextToken().is(tok::coloncolon) ||
3201 Diag(TildeLoc, diag::err_destructor_tilde_scope);
3206 Diag(TildeLoc, diag::err_destructor_tilde_scope)
3212 DeclScopeObj.EnterDeclaratorScope();
3219 if (Tok.
is(tok::less)) {
3220 Result.setDestructorName(TildeLoc,
nullptr, ClassNameLoc);
3221 return ParseUnqualifiedIdTemplateId(
3222 SS, ObjectType, ObjectHadErrors,
3224 ClassNameLoc, EnteringContext,
Result, TemplateSpecified);
3230 ObjectType, EnteringContext);
3234 Result.setDestructorName(TildeLoc, Ty, ClassNameLoc);
3239#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
3240#include "clang/Basic/TransformTypeTraits.def"
3243 Diag(Tok, diag::ext_keyword_as_ident)
3245 goto ParseIdentifier;
3249 Diag(Tok, diag::err_expected_unqualified_id) <<
getLangOpts().CPlusPlus;
3283Parser::ParseCXXNewExpression(
bool UseGlobal,
SourceLocation Start) {
3284 assert(Tok.
is(tok::kw_new) &&
"expected 'new' token");
3290 ExprVector PlacementArgs;
3297 if (Tok.
is(tok::l_paren)) {
3301 PlacementLParen =
T.getOpenLocation();
3302 if (ParseExpressionListOrTypeId(PlacementArgs, DeclaratorInfo)) {
3308 PlacementRParen =
T.getCloseLocation();
3314 if (PlacementArgs.empty()) {
3316 TypeIdParens =
T.getRange();
3320 if (Tok.
is(tok::l_paren)) {
3323 MaybeParseGNUAttributes(DeclaratorInfo);
3324 ParseSpecifierQualifierList(DS);
3326 ParseDeclarator(DeclaratorInfo);
3328 TypeIdParens =
T.getRange();
3330 MaybeParseGNUAttributes(DeclaratorInfo);
3331 if (ParseCXXTypeSpecifierSeq(DS))
3332 DeclaratorInfo.setInvalidType(
true);
3335 ParseDeclaratorInternal(DeclaratorInfo,
3336 &Parser::ParseDirectNewDeclarator);
3343 MaybeParseGNUAttributes(DeclaratorInfo);
3345 DeclaratorInfo.setInvalidType(
true);
3348 ParseDeclaratorInternal(DeclaratorInfo,
3349 &Parser::ParseDirectNewDeclarator);
3352 if (DeclaratorInfo.isInvalidType()) {
3359 if (Tok.
is(tok::l_paren)) {
3361 ExprVector ConstructorArgs;
3364 ConstructorLParen =
T.getOpenLocation();
3365 if (Tok.
isNot(tok::r_paren)) {
3366 auto RunSignatureHelp = [&]() {
3376 DeclaratorInfo.getEndLoc(), ConstructorArgs,
3379 CalledSignatureHelp =
true;
3380 return PreferredType;
3382 if (ParseExpressionList(ConstructorArgs, [&] {
3383 PreferredType.enterFunctionArgument(Tok.
getLocation(),
3393 ConstructorRParen =
T.getCloseLocation();
3403 diag::warn_cxx98_compat_generalized_initializer_lists);
3409 return Actions.
ActOnCXXNew(Start, UseGlobal, PlacementLParen,
3410 PlacementArgs, PlacementRParen,
3421void Parser::ParseDirectNewDeclarator(
Declarator &
D) {
3424 while (Tok.
is(tok::l_square)) {
3426 if (CheckProhibitedCXX11Attribute())
3435 if (
Size.isInvalid()) {
3446 MaybeParseCXX11Attributes(Attrs);
3450 Size.get(),
T.getOpenLocation(),
3451 T.getCloseLocation()),
3452 std::move(Attrs),
T.getCloseLocation());
3454 if (
T.getCloseLocation().isInvalid())
3469bool Parser::ParseExpressionListOrTypeId(
3473 if (isTypeIdInParens()) {
3474 ParseSpecifierQualifierList(
D.getMutableDeclSpec());
3477 return D.isInvalidType();
3481 return ParseExpressionList(PlacementArgs);
3496Parser::ParseCXXDeleteExpression(
bool UseGlobal,
SourceLocation Start) {
3497 assert(Tok.
is(tok::kw_delete) &&
"Expected 'delete' keyword");
3501 bool ArrayDelete =
false;
3502 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::r_square)) {
3510 const Token Next = GetLookAheadToken(2);
3513 if (Next.isOneOf(tok::l_brace, tok::less) ||
3514 (Next.is(tok::l_paren) &&
3515 (GetLookAheadToken(3).is(tok::r_paren) ||
3516 (GetLookAheadToken(3).is(tok::identifier) &&
3517 GetLookAheadToken(4).is(tok::identifier))))) {
3518 TentativeParsingAction TPA(*
this);
3526 bool EmitFixIt =
false;
3527 if (Tok.
is(tok::l_brace)) {
3537 Diag(Start, diag::err_lambda_after_delete)
3545 Diag(Start, diag::err_lambda_after_delete)
3555 Lambda = ParsePostfixExpressionSuffix(Lambda);
3567 if (
T.getCloseLocation().isInvalid())
3602ExprResult Parser::ParseRequiresExpression() {
3603 assert(Tok.
is(tok::kw_requires) &&
"Expected 'requires' keyword");
3608 if (Tok.
is(tok::l_paren)) {
3613 if (!Tok.
is(tok::r_paren)) {
3618 FirstArgAttrs, LocalParameters,
3621 Diag(EllipsisLoc, diag::err_requires_expr_parameter_list_ellipsis);
3622 for (
auto &ParamInfo : LocalParameters)
3623 LocalParameterDecls.push_back(cast<ParmVarDecl>(ParamInfo.Param));
3629 if (
Braces.expectAndConsume())
3646 RequiresKWLoc, LocalParameterDecls,
getCurScope());
3648 if (Tok.
is(tok::r_brace)) {
3655 Diag(Tok, diag::err_empty_requires_expr);
3658 while (!Tok.
is(tok::r_brace)) {
3660 case tok::l_brace: {
3671 ExprBraces.consumeOpen();
3675 ExprBraces.skipToEnd();
3679 if (ExprBraces.consumeClose())
3680 ExprBraces.skipToEnd();
3685 if (Tok.
is(tok::semi)) {
3688 Requirements.push_back(Req);
3693 Diag(Tok, diag::err_requires_expr_missing_arrow)
3696 if (TryAnnotateTypeConstraint()) {
3700 if (!isTypeConstraintAnnotation()) {
3701 Diag(Tok, diag::err_requires_expr_expected_type_constraint);
3706 if (Tok.
is(tok::annot_cxxscope)) {
3710 ConsumeAnnotationToken();
3714 Expression.get(), NoexceptLoc, SS, takeTemplateIdAnnotation(Tok),
3715 TemplateParameterDepth);
3716 ConsumeAnnotationToken();
3718 Requirements.push_back(Req);
3722 bool PossibleRequiresExprInSimpleRequirement =
false;
3723 if (Tok.
is(tok::kw_requires)) {
3724 auto IsNestedRequirement = [&] {
3725 RevertingTentativeParsingAction TPA(*
this);
3727 if (Tok.
is(tok::l_brace))
3734 if (Tok.
is(tok::l_paren)) {
3737 auto Res = TryParseParameterDeclarationClause();
3738 if (Res != TPResult::False) {
3741 while (Depth != 0) {
3742 bool FoundParen =
SkipUntil(tok::l_paren, tok::r_paren,
3746 if (Tok.
is(tok::l_paren))
3748 else if (Tok.
is(tok::r_paren))
3759 if (Tok.
is(tok::l_brace))
3768 if (IsNestedRequirement()) {
3783 Requirements.push_back(Req);
3791 PossibleRequiresExprInSimpleRequirement =
true;
3792 }
else if (Tok.
is(tok::kw_typename)) {
3795 TentativeParsingAction TPA(*
this);
3805 if (Tok.
is(tok::annot_cxxscope)) {
3808 ConsumeAnnotationToken();
3811 if (Tok.
isOneOf(tok::identifier, tok::annot_template_id) &&
3817 if (Tok.
is(tok::identifier)) {
3821 TemplateId = takeTemplateIdAnnotation(Tok);
3822 ConsumeAnnotationToken();
3830 Requirements.push_back(Req);
3847 if (!
Expression.isInvalid() && PossibleRequiresExprInSimpleRequirement)
3848 Diag(StartLoc, diag::err_requires_expr_in_simple_requirement)
3851 Requirements.push_back(Req);
3857 if (Tok.
is(tok::kw_noexcept)) {
3858 Diag(Tok, diag::err_requires_expr_simple_requirement_noexcept)
3867 if (ExpectAndConsumeSemi(diag::err_expected_semi_requirement)) {
3873 if (Requirements.empty()) {
3884 ParsingBodyDecl.complete(Body);
3886 RequiresKWLoc, Body,
Parens.getOpenLocation(), LocalParameterDecls,
3887 Parens.getCloseLocation(), Requirements,
Braces.getCloseLocation());
3892 default: llvm_unreachable(
"Not a known type trait");
3893#define TYPE_TRAIT_1(Spelling, Name, Key) \
3894case tok::kw_ ## Spelling: return UTT_ ## Name;
3895#define TYPE_TRAIT_2(Spelling, Name, Key) \
3896case tok::kw_ ## Spelling: return BTT_ ## Name;
3897#include "clang/Basic/TokenKinds.def"
3898#define TYPE_TRAIT_N(Spelling, Name, Key) \
3899 case tok::kw_ ## Spelling: return TT_ ## Name;
3900#include "clang/Basic/TokenKinds.def"
3907 llvm_unreachable(
"Not a known array type trait");
3908#define ARRAY_TYPE_TRAIT(Spelling, Name, Key) \
3909 case tok::kw_##Spelling: \
3911#include "clang/Basic/TokenKinds.def"
3918 llvm_unreachable(
"Not a known unary expression trait.");
3919#define EXPRESSION_TRAIT(Spelling, Name, Key) \
3920 case tok::kw_##Spelling: \
3922#include "clang/Basic/TokenKinds.def"
3943 if (
Parens.expectAndConsume())
3959 if (Tok.
is(tok::ellipsis)) {
3968 Args.push_back(Ty.
get());
3971 if (
Parens.consumeClose())
3991 if (
T.expectAndConsume())
4003 case ATT_ArrayRank: {
4006 T.getCloseLocation());
4008 case ATT_ArrayExtent: {
4009 if (ExpectAndConsume(tok::comma)) {
4021 T.getCloseLocation());
4024 llvm_unreachable(
"Invalid ArrayTypeTrait!");
4038 if (
T.expectAndConsume())
4046 T.getCloseLocation());
4054Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
4059 assert(ExprType ==
CastExpr &&
"Compound literals are not ambiguous!");
4060 assert(isTypeIdInParens() &&
"Not a type-id!");
4084 ParenParseOption ParseAs;
4089 if (!ConsumeAndStoreUntil(tok::r_paren, Toks)) {
4095 if (Tok.
is(tok::l_brace)) {
4096 ParseAs = CompoundLiteral;
4099 if (Tok.
is(tok::l_paren) &&
NextToken().is(tok::r_paren)) {
4106 Result = ParseCastExpression(AnyCastExpr,
4115 ParseAs = NotCastExpr ? SimpleExpr :
CastExpr;
4124 Toks.push_back(AttrEnd);
4127 Toks.push_back(Tok);
4130 PP.EnterTokenStream(Toks,
true,
4136 if (ParseAs >= CompoundLiteral) {
4143 ParseSpecifierQualifierList(DS);
4144 ParseDeclarator(DeclaratorInfo);
4155 if (ParseAs == CompoundLiteral) {
4156 ExprType = CompoundLiteral;
4157 if (DeclaratorInfo.isInvalidType())
4161 return ParseCompoundLiteralExpression(Ty.
get(),
4169 if (DeclaratorInfo.isInvalidType())
4175 DeclaratorInfo, CastTy,
4181 assert(ParseAs == SimpleExpr);
4183 ExprType = SimpleExpr;
4185 if (!
Result.isInvalid() && Tok.
is(tok::r_paren))
4190 if (
Result.isInvalid()) {
4191 while (Tok.
isNot(tok::eof))
4210 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"__builtin_bit_cast"))
4215 ParseSpecifierQualifierList(DS);
4220 ParseDeclarator(DeclaratorInfo);
4222 if (ExpectAndConsume(tok::comma)) {
4230 if (
T.consumeClose())
4233 if (
Operand.isInvalid() || DeclaratorInfo.isInvalidType())
4237 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::TemplateNameKind enum.
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 "_Complex" (la...
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
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Information about one declarator, including the parsed type information and the identifier.
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 (C++ 5.3.5), as in:
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)
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)
Parsed a C++ 'new' expression (C++ 5.3.4).
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_Var_template
The name refers to a variable template whose specialization produces a variable.
@ TNK_Dependent_template_name
The name refers to a dependent template name:
@ TNK_Function_template
The name refers to a function template or a set of overloaded functions that includes at least one fu...
@ 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.