24 #include "llvm/Support/ErrorHandling.h" 27 using namespace clang;
32 case tok::unknown:
return 0;
34 case tok::kw_const_cast:
return 1;
35 case tok::kw_dynamic_cast:
return 2;
36 case tok::kw_reinterpret_cast:
return 3;
37 case tok::kw_static_cast:
return 4;
39 llvm_unreachable(
"Unknown type for digraph error message.");
44 bool Parser::areTokensAdjacent(
const Token &
First,
const Token &Second) {
62 P.
Diag(DigraphToken.
getLocation(), diag::err_missing_whitespace_digraph)
67 ColonToken.
setKind(tok::coloncolon);
70 DigraphToken.
setKind(tok::less);
81 void Parser::CheckForTemplateAndDigraph(
Token &Next,
ParsedType ObjectType,
84 if (!Next.
is(tok::l_square) || Next.
getLength() != 2)
87 Token SecondToken = GetLookAheadToken(2);
88 if (!SecondToken.
is(tok::colon) || !areTokensAdjacent(Next, SecondToken))
94 bool MemberOfUnknownSpecialization;
96 TemplateName, ObjectType, EnteringContext,
97 Template, MemberOfUnknownSpecialization))
100 FixDigraph(*
this, PP, Next, SecondToken, tok::unknown,
149 bool Parser::ParseOptionalCXXScopeSpecifier(
CXXScopeSpec &SS,
151 bool EnteringContext,
152 bool *MayBePseudoDestructor,
156 bool InUsingDeclaration) {
158 "Call sites of this function should be guarded by checking for C++");
160 if (Tok.
is(tok::annot_cxxscope)) {
161 assert(!LastII &&
"want last identifier but have already annotated scope");
162 assert(!MayBePseudoDestructor &&
"unexpected annot_cxxscope");
166 ConsumeAnnotationToken();
171 bool CheckForDestructor =
false;
172 if (MayBePseudoDestructor && *MayBePseudoDestructor) {
173 CheckForDestructor =
true;
174 *MayBePseudoDestructor =
false;
180 bool HasScopeSpecifier =
false;
182 if (Tok.
is(tok::coloncolon)) {
185 if (NextKind == tok::kw_new || NextKind == tok::kw_delete)
188 if (NextKind == tok::l_brace) {
197 HasScopeSpecifier =
true;
201 if (Tok.
is(tok::kw___super)) {
203 if (!Tok.
is(tok::coloncolon)) {
211 if (!HasScopeSpecifier &&
212 Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
222 AnnotateExistingDecltypeSpecifier(DS, DeclLoc, EndLoc);
229 HasScopeSpecifier =
true;
233 auto SavedType = PreferredType;
235 if (HasScopeSpecifier) {
236 if (Tok.
is(tok::code_completion)) {
240 InUsingDeclaration, ObjectType.
get(),
261 ObjectType =
nullptr;
269 if (Tok.
is(tok::kw_template)) {
273 if (!HasScopeSpecifier && !ObjectType)
276 TentativeParsingAction TPA(*
this);
280 if (Tok.
is(tok::identifier)) {
284 }
else if (Tok.
is(tok::kw_operator)) {
289 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType,
298 diag::err_id_after_template_in_nested_name_spec)
311 if (Tok.
isNot(tok::less)) {
320 getCurScope(), SS, TemplateKWLoc, TemplateName, ObjectType,
321 EnteringContext, Template,
true)) {
322 if (AnnotateTemplateIdToken(Template, TNK, SS, TemplateKWLoc,
323 TemplateName,
false))
331 if (Tok.
is(tok::annot_template_id) &&
NextToken().
is(tok::coloncolon)) {
340 if (CheckForDestructor && GetLookAheadToken(2).is(tok::tilde)) {
341 *MayBePseudoDestructor =
true;
346 *LastII = TemplateId->
Name;
349 ConsumeAnnotationToken();
351 assert(Tok.
is(tok::coloncolon) &&
"NextToken() not working properly!");
354 HasScopeSpecifier =
true;
380 if (Tok.
isNot(tok::identifier))
395 if (Next.
is(tok::colon) && !ColonIsSacred) {
402 Diag(Next, diag::err_unexpected_colon_in_nested_name_spec)
409 if (Next.
is(tok::coloncolon) && GetLookAheadToken(2).
is(tok::l_brace)) {
416 UnconsumeToken(Identifier);
420 if (Next.
is(tok::coloncolon)) {
421 if (CheckForDestructor && GetLookAheadToken(2).
is(tok::tilde) &&
423 *MayBePseudoDestructor =
true;
428 const Token &Next2 = GetLookAheadToken(2);
429 if (Next2.
is(tok::kw_private) || Next2.
is(tok::kw_protected) ||
430 Next2.
is(tok::kw_public) || Next2.
is(tok::kw_virtual)) {
431 Diag(Next2, diag::err_unexpected_token_in_nested_name_spec)
436 ColonColon.setKind(tok::colon);
449 assert(Tok.
isOneOf(tok::coloncolon, tok::colon) &&
450 "NextToken() not working properly!");
451 Token ColonColon = Tok;
454 bool IsCorrectedToColon =
false;
455 bool *CorrectionFlagPtr = ColonIsSacred ? &IsCorrectedToColon :
nullptr;
458 CorrectionFlagPtr, OnlyNamespace)) {
461 if (CorrectionFlagPtr && IsCorrectedToColon) {
462 ColonColon.setKind(tok::colon);
470 HasScopeSpecifier =
true;
474 CheckForTemplateAndDigraph(Next, ObjectType, EnteringContext, II, SS);
478 if (Next.
is(tok::less)) {
483 bool MemberOfUnknownSpecialization;
490 MemberOfUnknownSpecialization)) {
496 isTemplateArgumentList(1) == TPResult::False)
508 TemplateName,
false))
513 if (MemberOfUnknownSpecialization && (ObjectType || SS.
isSet()) &&
514 (IsTypename || isTemplateArgumentList(1) == TPResult::True)) {
519 unsigned DiagID = diag::err_missing_dependent_template_keyword;
521 DiagID = diag::warn_missing_dependent_template_keyword;
529 EnteringContext, Template,
true)) {
533 TemplateName,
false))
551 if (CheckForDestructor && Tok.
is(tok::tilde))
552 *MayBePseudoDestructor =
true;
558 bool isAddressOfOperand,
559 Token &Replacement) {
564 case tok::annot_non_type: {
565 NamedDecl *ND = getNonTypeAnnotation(Tok);
571 case tok::annot_non_type_dependent: {
577 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
578 isAddressOfOperand =
false;
585 case tok::annot_non_type_undeclared: {
587 "undeclared non-type annotation should be unqualified");
602 nullptr, &TemplateKWLoc, Name))
607 if (isAddressOfOperand && isPostfixExpressionSuffixStart())
608 isAddressOfOperand =
false;
611 getCurScope(), SS, TemplateKWLoc, Name, Tok.
is(tok::l_paren),
612 isAddressOfOperand,
nullptr,
false,
618 checkPotentialAngleBracket(E);
664 ExprResult Parser::ParseCXXIdExpression(
bool isAddressOfOperand) {
670 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false);
674 tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
678 UnconsumeToken(Replacement);
679 Result = tryParseCXXIdExpression(SS, isAddressOfOperand, Replacement);
681 assert(!Result.
isUnset() &&
"Typo correction suggested a keyword replacement " 682 "for a previous keyword suggestion");
730 if (ParseLambdaIntroducer(Intro)) {
737 return ParseLambdaExpressionAfterIntroducer(Intro);
744 ExprResult Parser::TryParseLambdaExpression() {
746 && Tok.
is(tok::l_square)
747 &&
"Not at the start of a possible lambda expression.");
755 if (Next.is(tok::r_square) ||
756 Next.is(tok::equal) ||
757 (Next.is(tok::amp) &&
758 After.
isOneOf(tok::r_square, tok::comma)) ||
759 (Next.is(tok::identifier) &&
760 After.
is(tok::r_square)) ||
761 Next.is(tok::ellipsis)) {
762 return ParseLambdaExpression();
767 if (Next.is(tok::identifier) && After.
is(tok::identifier))
777 TentativeParsingAction TPA(*
this);
778 LambdaIntroducerTentativeParse Tentative;
779 if (ParseLambdaIntroducer(Intro, &Tentative)) {
785 case LambdaIntroducerTentativeParse::Success:
789 case LambdaIntroducerTentativeParse::Incomplete:
794 if (ParseLambdaIntroducer(Intro))
798 case LambdaIntroducerTentativeParse::MessageSend:
799 case LambdaIntroducerTentativeParse::Invalid:
806 return ParseLambdaExpressionAfterIntroducer(Intro);
819 LambdaIntroducerTentativeParse *Tentative) {
821 *Tentative = LambdaIntroducerTentativeParse::Success;
823 assert(Tok.
is(tok::l_square) &&
"Lambda expressions begin with '['.");
833 auto Invalid = [&](llvm::function_ref<void()> Action) {
835 *Tentative = LambdaIntroducerTentativeParse::Invalid;
844 auto NonTentativeAction = [&](llvm::function_ref<void()> Action) {
846 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
852 if (Tok.
is(tok::amp) &&
862 }
else if (Tok.
is(tok::equal)) {
869 while (Tok.
isNot(tok::r_square)) {
871 if (Tok.
isNot(tok::comma)) {
876 if (Tok.
is(tok::code_completion) &&
891 if (Tok.
is(tok::code_completion)) {
914 if (Tok.
is(tok::star)) {
916 if (Tok.
is(tok::kw_this)) {
924 }
else if (Tok.
is(tok::kw_this)) {
930 if (Tok.
is(tok::amp)) {
934 if (Tok.
is(tok::code_completion)) {
944 if (Tok.
is(tok::identifier)) {
947 }
else if (Tok.
is(tok::kw_this)) {
960 if (Tok.
is(tok::l_paren)) {
970 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
971 }
else if (ParseExpressionList(Exprs, Commas)) {
980 }
else if (Tok.
isOneOf(tok::l_brace, tok::equal)) {
993 Init = ParseInitializer();
994 }
else if (Tok.
is(tok::l_brace)) {
998 *Tentative = LambdaIntroducerTentativeParse::Incomplete;
1022 Init = ParseInitializer();
1032 Tok.
setKind(tok::annot_primary_expr);
1033 setExprAnnotation(Tok, Init);
1038 ConsumeAnnotationToken();
1047 if (Tentative && Tok.
is(tok::identifier) &&
1050 *Tentative = LambdaIntroducerTentativeParse::MessageSend;
1056 if (std::any_of(std::begin(EllipsisLocs), std::end(EllipsisLocs),
1062 !InitCapture ? &EllipsisLocs[2] :
1065 EllipsisLoc = *ExpectedEllipsisLoc;
1067 unsigned DiagID = 0;
1069 DiagID = diag::err_lambda_capture_misplaced_ellipsis;
1075 unsigned NumEllipses = std::accumulate(
1076 std::begin(EllipsisLocs), std::end(EllipsisLocs), 0,
1078 if (NumEllipses > 1)
1079 DiagID = diag::err_lambda_capture_multiple_ellipses;
1082 NonTentativeAction([&] {
1086 if (&Loc != ExpectedEllipsisLoc && Loc.
isValid()) {
1091 assert(DiagLoc.
isValid() &&
"no location for diagnostic");
1095 auto &&D =
Diag(DiagLoc, DiagID);
1096 if (DiagID == diag::err_lambda_capture_misplaced_ellipsis) {
1104 if (&Loc != ExpectedEllipsisLoc && Loc.
isValid())
1119 NonTentativeAction([&] {
1126 Loc, Kind ==
LCK_ByRef, EllipsisLoc, Id, InitKind, InitExpr);
1133 Intro.
addCapture(Kind, Loc, Id, EllipsisLoc, InitKind, Init,
1155 case tok::kw_mutable: {
1158 diag::err_lambda_decl_specifier_repeated)
1162 DeclEndLoc = MutableLoc;
1165 case tok::kw_constexpr:
1168 diag::err_lambda_decl_specifier_repeated)
1172 DeclEndLoc = ConstexprLoc;
1174 case tok::kw_consteval:
1177 diag::err_lambda_decl_specifier_repeated)
1181 DeclEndLoc = ConstevalLoc;
1194 ? diag::ext_constexpr_on_lambda_cxx17
1195 : diag::warn_cxx14_compat_constexpr_on_lambda);
1196 const char *PrevSpec =
nullptr;
1197 unsigned DiagID = 0;
1199 assert(PrevSpec ==
nullptr && DiagID == 0 &&
1200 "Constexpr cannot have been set previously!");
1208 P.
Diag(ConstevalLoc, diag::warn_cxx20_compat_consteval);
1209 const char *PrevSpec =
nullptr;
1210 unsigned DiagID = 0;
1213 P.
Diag(ConstevalLoc, DiagID) << PrevSpec;
1219 ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
1222 Diag(LambdaBeginLoc, diag::warn_cxx98_compat_lambda);
1225 "lambda expression parsing");
1235 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
1243 MaybeParseGNUAttributes(D);
1248 auto WarnIfHasCUDATargetAttr = [&] {
1251 if (A.getKind() == ParsedAttr::AT_CUDADevice ||
1252 A.getKind() == ParsedAttr::AT_CUDAHost ||
1253 A.getKind() == ParsedAttr::AT_CUDAGlobal)
1254 Diag(A.getLoc(), diag::warn_cuda_attr_lambda_position)
1255 << A.getAttrName()->getName();
1259 const bool HasExplicitTemplateParams = Tok.
is(tok::less);
1261 HasExplicitTemplateParams);
1262 if (HasExplicitTemplateParams) {
1264 ? diag::warn_cxx17_compat_lambda_template_parameter_list
1265 : diag::ext_lambda_template_parameter_list);
1269 if (ParseTemplateParameters(CurTemplateDepthTracker.getDepth(),
1270 TemplateParams, LAngleLoc, RAngleLoc)) {
1275 if (TemplateParams.empty()) {
1277 diag::err_lambda_template_parameter_list_empty);
1280 LAngleLoc, TemplateParams, RAngleLoc);
1281 ++CurTemplateDepthTracker;
1286 if (Tok.
is(tok::l_paren)) {
1287 ParseScope PrototypeScope(
this,
1300 if (Tok.
isNot(tok::r_paren)) {
1302 CurTemplateDepthTracker.getOriginalDepth());
1304 ParseParameterDeclarationClause(D.
getContext(), Attr, ParamInfo,
1312 CurTemplateDepthTracker.setAddedDepth(1);
1321 MaybeParseGNUAttributes(Attr, &DeclEndLoc);
1325 MaybeParseMicrosoftDeclSpecs(Attr, &DeclEndLoc);
1333 ConstevalLoc, DeclEndLoc);
1344 ESpecType = tryParseExceptionSpecification(
false,
1347 DynamicExceptionRanges,
1349 ExceptionSpecTokens);
1352 DeclEndLoc = ESpecRange.
getEnd();
1355 MaybeParseCXX11Attributes(Attr, &DeclEndLoc);
1358 if (Tok.
isOneOf(tok::kw___private, tok::kw___global, tok::kw___local,
1359 tok::kw___constant, tok::kw___generic)) {
1360 ParseOpenCLQualifiers(DS.getAttributes());
1367 if (Tok.
is(tok::arrow)) {
1370 TrailingReturnType =
1371 ParseTrailingReturnType(Range,
false);
1373 DeclEndLoc = Range.
getEnd();
1379 false, LParenLoc, ParamInfo.data(),
1380 ParamInfo.size(), EllipsisLoc, RParenLoc,
1382 NoLoc, MutableLoc, ESpecType,
1383 ESpecRange, DynamicExceptions.data(),
1384 DynamicExceptionRanges.data(), DynamicExceptions.size(),
1385 NoexceptExpr.
isUsable() ? NoexceptExpr.
get() :
nullptr,
1387 None, LParenLoc, FunLocalRangeEnd, D,
1388 TrailingReturnType, &DS),
1389 std::move(Attr), DeclEndLoc);
1392 if (Tok.
is(tok::kw_requires))
1393 ParseTrailingRequiresClause(D);
1395 PrototypeScope.Exit();
1397 WarnIfHasCUDATargetAttr();
1398 }
else if (Tok.
isOneOf(tok::kw_mutable, tok::arrow, tok::kw___attribute,
1399 tok::kw_constexpr, tok::kw_consteval,
1400 tok::kw___private, tok::kw___global, tok::kw___local,
1401 tok::kw___constant, tok::kw___generic,
1402 tok::kw_requires) ||
1406 unsigned TokKind = 0;
1408 case tok::kw_mutable: TokKind = 0;
break;
1409 case tok::arrow: TokKind = 1;
break;
1410 case tok::kw___attribute:
1411 case tok::kw___private:
1412 case tok::kw___global:
1413 case tok::kw___local:
1414 case tok::kw___constant:
1415 case tok::kw___generic:
1416 case tok::l_square: TokKind = 2;
break;
1417 case tok::kw_constexpr: TokKind = 3;
break;
1418 case tok::kw_consteval: TokKind = 4;
break;
1419 case tok::kw_requires: TokKind = 5;
break;
1420 default: llvm_unreachable(
"Unknown token kind");
1423 Diag(Tok, diag::err_lambda_missing_parens)
1430 MaybeParseGNUAttributes(Attr, &DeclEndLoc);
1434 if (Tok.
is(tok::kw_mutable)) {
1436 DeclEndLoc = MutableLoc;
1440 MaybeParseCXX11Attributes(Attr, &DeclEndLoc);
1443 if (Tok.
is(tok::arrow)) {
1445 TrailingReturnType =
1446 ParseTrailingReturnType(Range,
false);
1448 DeclEndLoc = Range.
getEnd();
1468 None, DeclLoc, DeclEndLoc, D,
1469 TrailingReturnType),
1470 std::move(Attr), DeclEndLoc);
1473 if (Tok.
is(tok::kw_requires))
1474 ParseTrailingRequiresClause(D);
1476 WarnIfHasCUDATargetAttr();
1483 ParseScope BodyScope(
this, ScopeFlags);
1488 if (!Tok.
is(tok::l_brace)) {
1489 Diag(Tok, diag::err_expected_lambda_body);
1496 TemplateParamScope.Exit();
1498 if (!Stmt.isInvalid() && !TrailingReturnType.
isInvalid())
1516 const char *CastName =
nullptr;
1519 default: llvm_unreachable(
"Unknown C++ cast!");
1520 case tok::kw_const_cast: CastName =
"const_cast";
break;
1521 case tok::kw_dynamic_cast: CastName =
"dynamic_cast";
break;
1522 case tok::kw_reinterpret_cast: CastName =
"reinterpret_cast";
break;
1523 case tok::kw_static_cast: CastName =
"static_cast";
break;
1531 if (Tok.
is(tok::l_square) && Tok.
getLength() == 2) {
1533 if (Next.
is(tok::colon) && areTokensAdjacent(Tok, Next))
1534 FixDigraph(*
this, PP, Tok, Next, Kind,
true);
1537 if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
1542 ParseSpecifierQualifierList(DS);
1546 ParseDeclarator(DeclaratorInfo);
1550 if (ExpectAndConsume(tok::greater))
1551 return ExprError(
Diag(LAngleBracketLoc, diag::note_matching) << tok::less);
1565 LAngleBracketLoc, DeclaratorInfo,
1580 assert(Tok.
is(tok::kw_typeid) &&
"Not 'typeid'!");
1610 if (isTypeIdInParens()) {
1620 Ty.
get().getAsOpaquePtr(), RParenLoc);
1634 Result.
get(), RParenLoc);
1647 assert(Tok.
is(tok::kw___uuidof) &&
"Not '__uuidof'!");
1658 if (isTypeIdInParens()) {
1668 Ty.
get().getAsOpaquePtr(),
1719 if (Tok.
is(tok::identifier)) {
1722 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1724 }
else if (Tok.
is(tok::annot_template_id)) {
1729 ConsumeAnnotationToken();
1730 assert(Tok.
is(tok::coloncolon) &&
"ParseOptionalCXXScopeSpecifier fail");
1737 assert(Tok.
is(tok::tilde) &&
"ParseOptionalCXXScopeSpecifier fail");
1740 if (Tok.
is(tok::kw_decltype) && !FirstTypeName.
isValid() && SS.
isEmpty()) {
1742 ParseDecltypeSpecifier(DS);
1749 if (!Tok.
is(tok::identifier)) {
1750 Diag(Tok, diag::err_destructor_tilde_identifier);
1762 if (Tok.
is(tok::less) &&
1765 false, ObjectType, SecondTypeName,
1770 SS, FirstTypeName, CCLoc, TildeLoc,
1789 assert(Tok.
is(tok::kw_throw) &&
"Not throw!");
1815 ExprResult Parser::ParseCoyieldExpression() {
1816 assert(Tok.
is(tok::kw_co_yield) &&
"Not co_yield!");
1832 assert(Tok.
is(tok::kw_this) &&
"Not 'this'!");
1851 Parser::ParseCXXTypeConstructExpression(
const DeclSpec &DS) {
1855 assert((Tok.
is(tok::l_paren) ||
1857 &&
"Expected '(' or '{'!");
1859 if (Tok.
is(tok::l_brace)) {
1874 CommaLocsTy CommaLocs;
1876 auto RunSignatureHelp = [&]() {
1882 CalledSignatureHelp =
true;
1883 return PreferredType;
1886 if (Tok.
isNot(tok::r_paren)) {
1887 if (ParseExpressionList(Exprs, CommaLocs, [&] {
1905 assert((Exprs.size() == 0 || Exprs.size()-1 == CommaLocs.size())&&
1906 "Unexpected number of commas!");
1941 ForRangeInfo *FRI) {
1945 if (Tok.
is(tok::code_completion)) {
1951 ParsedAttributesWithRange attrs(AttrFactory);
1952 MaybeParseCXX11Attributes(attrs);
1954 const auto WarnOnInit = [
this, &CK] {
1956 ? diag::warn_cxx14_compat_init_statement
1957 : diag::ext_init_statement)
1962 switch (isCXXConditionDeclarationOrInitStatement(InitStmt, FRI)) {
1963 case ConditionOrInitStatement::Expression: {
1964 ProhibitAttributes(attrs);
1968 if (InitStmt && Tok.
is(tok::semi)) {
1972 Diag(SemiLoc, diag::warn_empty_init_statement)
1978 return ParseCXXCondition(
nullptr, Loc, CK);
1986 if (InitStmt && Tok.
is(tok::semi)) {
1990 return ParseCXXCondition(
nullptr, Loc, CK);
1996 case ConditionOrInitStatement::InitStmtDecl: {
2003 return ParseCXXCondition(
nullptr, Loc, CK);
2006 case ConditionOrInitStatement::ForRangeDecl: {
2007 assert(FRI &&
"should not parse a for range declaration here");
2015 case ConditionOrInitStatement::ConditionDecl:
2016 case ConditionOrInitStatement::Error:
2023 ParseSpecifierQualifierList(DS,
AS_none, DeclSpecContext::DSC_condition);
2027 ParseDeclarator(DeclaratorInfo);
2030 if (Tok.
is(tok::kw_asm)) {
2032 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2042 MaybeParseGNUAttributes(DeclaratorInfo);
2053 bool CopyInitialization = isTokenEqualOrEqualTypo();
2054 if (CopyInitialization)
2060 diag::warn_cxx98_compat_generalized_initializer_lists);
2061 InitExpr = ParseBraceInitializer();
2062 }
else if (CopyInitialization) {
2065 }
else if (Tok.
is(tok::l_paren)) {
2069 RParen = ConsumeParen();
2071 diag::err_expected_init_in_condition_lparen)
2112 void Parser::ParseCXXSimpleTypeSpecifier(
DeclSpec &DS) {
2114 const char *PrevSpec;
2121 case tok::identifier:
2122 case tok::coloncolon:
2123 llvm_unreachable(
"Annotation token should already be formed!");
2125 llvm_unreachable(
"Not a simple-type-specifier token!");
2128 case tok::annot_typename: {
2136 ConsumeAnnotationToken();
2138 DS.
Finish(Actions, Policy);
2149 case tok::kw___int64:
2152 case tok::kw_signed:
2155 case tok::kw_unsigned:
2167 case tok::kw___int128:
2176 case tok::kw_double:
2179 case tok::kw__Float16:
2182 case tok::kw___float128:
2185 case tok::kw_wchar_t:
2188 case tok::kw_char8_t:
2191 case tok::kw_char16_t:
2194 case tok::kw_char32_t:
2200 #define GENERIC_IMAGE_TYPE(ImgType, Id) \ 2201 case tok::kw_##ImgType##_t: \ 2202 DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, DiagID, \ 2205 #include "clang/Basic/OpenCLImageTypes.def" 2207 case tok::annot_decltype:
2208 case tok::kw_decltype:
2210 return DS.
Finish(Actions, Policy);
2213 case tok::kw_typeof:
2214 ParseTypeofSpecifier(DS);
2215 DS.
Finish(Actions, Policy);
2220 DS.
Finish(Actions, Policy);
2234 bool Parser::ParseCXXTypeSpecifierSeq(
DeclSpec &DS) {
2235 ParseSpecifierQualifierList(DS,
AS_none, DeclSpecContext::DSC_type_specifier);
2272 bool Parser::ParseUnqualifiedIdTemplateId(
CXXScopeSpec &SS,
2276 bool EnteringContext,
2279 bool AssumeTemplateId) {
2280 assert(Tok.
is(tok::less) &&
"Expected '<' to finish parsing a template-id");
2288 if (AssumeTemplateId) {
2292 getCurScope(), SS, TemplateKWLoc, Id, ObjectType, EnteringContext,
2297 bool MemberOfUnknownSpecialization;
2300 ObjectType, EnteringContext, Template,
2301 MemberOfUnknownSpecialization);
2306 isTemplateArgumentList(0) == TPResult::False)
2310 ObjectType && isTemplateArgumentList(0) == TPResult::True) {
2329 getCurScope(), SS, TemplateKWLoc, Id, ObjectType, EnteringContext,
2339 bool MemberOfUnknownSpecialization;
2342 TemplateName, ObjectType,
2343 EnteringContext, Template,
2344 MemberOfUnknownSpecialization);
2350 bool MemberOfUnknownSpecialization;
2354 getCurScope(), SS, TemplateKWLoc, TemplateName, ObjectType,
2355 EnteringContext, Template,
true);
2360 TemplateName, ObjectType,
2361 EnteringContext, Template,
2362 MemberOfUnknownSpecialization);
2365 Diag(NameLoc, diag::err_destructor_template_id)
2382 TemplateArgList TemplateArgs;
2383 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
2403 TemplateKWLoc, Id.
StartLocation, TemplateII, OpKind, Template, TNK,
2404 LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds);
2415 getCurScope(), SS, TemplateKWLoc, Template, Name, NameLoc, LAngleLoc,
2416 TemplateArgsPtr, RAngleLoc,
true);
2468 bool Parser::ParseUnqualifiedIdOperator(
CXXScopeSpec &SS,
bool EnteringContext,
2471 assert(Tok.
is(tok::kw_operator) &&
"Expected 'operator' keyword");
2477 unsigned SymbolIdx = 0;
2482 case tok::kw_delete: {
2483 bool isNew = Tok.
getKind() == tok::kw_new;
2487 if (Tok.
is(tok::l_square) &&
2498 Op = isNew? OO_Array_New : OO_Array_Delete;
2500 Op = isNew? OO_New : OO_Delete;
2505 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 2507 SymbolLocations[SymbolIdx++] = ConsumeToken(); \ 2510 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly) 2511 #include "clang/Basic/OperatorKinds.def" 2513 case tok::l_paren: {
2527 case tok::l_square: {
2541 case tok::code_completion: {
2569 unsigned DiagId = 0;
2575 while (isTokenStringLiteral()) {
2576 if (!Tok.
is(tok::string_literal) && !DiagId) {
2581 DiagId = diag::err_literal_operator_string_prefix;
2583 Toks.push_back(Tok);
2584 TokLocs.push_back(ConsumeStringToken());
2601 }
else if (Tok.
is(tok::identifier)) {
2604 TokLocs.push_back(SuffixLoc);
2616 DiagLoc = TokLocs.front();
2617 DiagId = diag::err_literal_operator_string_not_empty;
2627 SourceRange(TokLocs.front(), TokLocs.back()), Str);
2648 if (ParseCXXTypeSpecifierSeq(DS))
2654 ParseDeclaratorInternal(D,
nullptr);
2700 bool AllowDestructorName,
2701 bool AllowConstructorName,
2702 bool AllowDeductionGuide,
2711 bool TemplateSpecified =
false;
2712 if (Tok.
is(tok::kw_template)) {
2713 if (TemplateKWLoc && (ObjectType || SS.
isSet())) {
2714 TemplateSpecified =
true;
2718 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
2726 if (Tok.
is(tok::identifier)) {
2739 if (AllowConstructorName &&
2748 AllowDeductionGuide && SS.
isEmpty() &&
2760 if (Tok.
is(tok::less))
2761 return ParseUnqualifiedIdTemplateId(
2763 EnteringContext, ObjectType,
Result, TemplateSpecified);
2764 else if (TemplateSpecified &&
2766 getCurScope(), SS, *TemplateKWLoc, Result, ObjectType,
2767 EnteringContext, Template,
2776 if (Tok.
is(tok::annot_template_id)) {
2780 if (AllowConstructorName && TemplateId->
Name &&
2788 diag::err_out_of_line_constructor_template_id)
2799 ConsumeAnnotationToken();
2804 ConsumeAnnotationToken();
2813 if (TemplateKWLoc && (ObjectType || SS.
isSet()))
2814 *TemplateKWLoc = TemplateLoc;
2816 Diag(TemplateLoc, diag::err_unexpected_template_in_unqualified_id)
2819 ConsumeAnnotationToken();
2826 if (Tok.
is(tok::kw_operator)) {
2827 if (ParseUnqualifiedIdOperator(SS, EnteringContext, ObjectType, Result))
2839 return ParseUnqualifiedIdTemplateId(
2843 else if (TemplateSpecified &&
2845 getCurScope(), SS, *TemplateKWLoc, Result, ObjectType,
2846 EnteringContext, Template,
2854 (AllowDestructorName || SS.
isSet()) && Tok.
is(tok::tilde)) {
2863 if (SS.
isEmpty() && Tok.
is(tok::kw_decltype)) {
2875 if (Tok.
isNot(tok::identifier)) {
2876 Diag(Tok, diag::err_destructor_tilde_identifier);
2881 DeclaratorScopeObj DeclScopeObj(*
this, SS);
2882 if (!TemplateSpecified &&
NextToken().is(tok::coloncolon)) {
2889 AnnotateScopeToken(SS,
true);
2892 if (ParseOptionalCXXScopeSpecifier(SS, ObjectType, EnteringContext))
2895 ObjectType =
nullptr;
2898 Diag(TildeLoc, diag::err_destructor_tilde_scope);
2903 Diag(TildeLoc, diag::err_destructor_tilde_scope)
2909 DeclScopeObj.EnterDeclaratorScope();
2916 if (Tok.
is(tok::less)) {
2918 return ParseUnqualifiedIdTemplateId(
2919 SS, TemplateKWLoc ? *TemplateKWLoc :
SourceLocation(), ClassName,
2920 ClassNameLoc, EnteringContext, ObjectType, Result, TemplateSpecified);
2935 Diag(Tok, diag::err_expected_unqualified_id)
2969 Parser::ParseCXXNewExpression(
bool UseGlobal,
SourceLocation Start) {
2970 assert(Tok.
is(tok::kw_new) &&
"expected 'new' token");
2982 if (Tok.
is(tok::l_paren)) {
2987 if (ParseExpressionListOrTypeId(PlacementArgs, DeclaratorInfo)) {
2999 if (PlacementArgs.empty()) {
3005 if (Tok.
is(tok::l_paren)) {
3008 MaybeParseGNUAttributes(DeclaratorInfo);
3009 ParseSpecifierQualifierList(DS);
3011 ParseDeclarator(DeclaratorInfo);
3015 MaybeParseGNUAttributes(DeclaratorInfo);
3016 if (ParseCXXTypeSpecifierSeq(DS))
3020 ParseDeclaratorInternal(DeclaratorInfo,
3021 &Parser::ParseDirectNewDeclarator);
3028 MaybeParseGNUAttributes(DeclaratorInfo);
3029 if (ParseCXXTypeSpecifierSeq(DS))
3033 ParseDeclaratorInternal(DeclaratorInfo,
3034 &Parser::ParseDirectNewDeclarator);
3044 if (Tok.
is(tok::l_paren)) {
3050 if (Tok.
isNot(tok::r_paren)) {
3052 auto RunSignatureHelp = [&]() {
3055 assert(TypeRep &&
"invalid types should be handled before");
3058 DeclaratorInfo.
getEndLoc(), ConstructorArgs, ConstructorLParen);
3059 CalledSignatureHelp =
true;
3060 return PreferredType;
3062 if (ParseExpressionList(ConstructorArgs, CommaLocs, [&] {
3081 }
else if (Tok.
is(tok::l_brace) &&
getLangOpts().CPlusPlus11) {
3083 diag::warn_cxx98_compat_generalized_initializer_lists);
3084 Initializer = ParseBraceInitializer();
3089 return Actions.
ActOnCXXNew(Start, UseGlobal, PlacementLParen,
3090 PlacementArgs, PlacementRParen,
3091 TypeIdParens, DeclaratorInfo, Initializer.
get());
3101 void Parser::ParseDirectNewDeclarator(
Declarator &D) {
3104 while (Tok.
is(tok::l_square)) {
3106 if (CheckProhibitedCXX11Attribute())
3126 MaybeParseCXX11Attributes(Attrs);
3149 bool Parser::ParseExpressionListOrTypeId(
3153 if (isTypeIdInParens()) {
3163 return ParseExpressionList(PlacementArgs, CommaLocs);
3178 Parser::ParseCXXDeleteExpression(
bool UseGlobal,
SourceLocation Start) {
3179 assert(Tok.
is(tok::kw_delete) &&
"Expected 'delete' keyword");
3183 bool ArrayDelete =
false;
3184 if (Tok.
is(tok::l_square) &&
NextToken().
is(tok::r_square)) {
3192 const Token Next = GetLookAheadToken(2);
3195 if (Next.
isOneOf(tok::l_brace, tok::less) ||
3196 (Next.
is(tok::l_paren) &&
3197 (GetLookAheadToken(3).
is(tok::r_paren) ||
3198 (GetLookAheadToken(3).
is(tok::identifier) &&
3199 GetLookAheadToken(4).
is(tok::identifier))))) {
3200 TentativeParsingAction TPA(*
this);
3208 bool EmitFixIt =
false;
3209 if (Tok.
is(tok::l_brace)) {
3219 Diag(Start, diag::err_lambda_after_delete)
3227 Diag(Start, diag::err_lambda_after_delete)
3237 Lambda = ParsePostfixExpressionSuffix(Lambda);
3253 ExprResult Operand(ParseCastExpression(AnyCastExpr));
3284 ExprResult Parser::ParseRequiresExpression() {
3285 assert(Tok.
is(tok::kw_requires) &&
"Expected 'requires' keyword");
3289 if (Tok.
is(tok::l_paren)) {
3295 if (!Tok.
is(tok::r_paren)) {
3301 FirstArgAttrs, LocalParameters,
3304 Diag(EllipsisLoc, diag::err_requires_expr_parameter_list_ellipsis);
3305 for (
auto &ParamInfo : LocalParameters)
3306 LocalParameterDecls.push_back(cast<ParmVarDecl>(ParamInfo.Param));
3327 RequiresKWLoc, LocalParameterDecls,
getCurScope());
3329 if (Tok.
is(tok::r_brace)) {
3336 Diag(Tok, diag::err_empty_requires_expr);
3339 while (!Tok.
is(tok::r_brace)) {
3341 case tok::l_brace: {
3357 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3366 if (Tok.
is(tok::semi)) {
3369 Requirements.push_back(Req);
3374 Diag(Tok, diag::err_requires_expr_missing_arrow)
3377 if (TryAnnotateTypeConstraint()) {
3378 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3381 if (!isTypeConstraintAnnotation()) {
3382 Diag(Tok, diag::err_requires_expr_expected_type_constraint);
3383 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3387 if (Tok.
is(tok::annot_cxxscope)) {
3391 ConsumeAnnotationToken();
3395 Expression.
get(), NoexceptLoc, SS, takeTemplateIdAnnotation(Tok),
3396 TemplateParameterDepth);
3397 ConsumeAnnotationToken();
3399 Requirements.push_back(Req);
3403 bool PossibleRequiresExprInSimpleRequirement =
false;
3404 if (Tok.
is(tok::kw_requires)) {
3405 auto IsNestedRequirement = [&] {
3406 RevertingTentativeParsingAction TPA(*
this);
3408 if (Tok.
is(tok::l_brace))
3415 if (Tok.
is(tok::l_paren)) {
3418 auto Res = TryParseParameterDeclarationClause();
3419 if (Res != TPResult::False) {
3424 while (Depth != 0) {
3425 if (Tok.
is(tok::l_paren))
3427 else if (Tok.
is(tok::r_paren))
3438 if (Tok.
is(tok::l_brace))
3447 if (IsNestedRequirement()) {
3457 SkipUntilFlags::StopBeforeMatch);
3462 Requirements.push_back(Req);
3465 SkipUntilFlags::StopBeforeMatch);
3470 PossibleRequiresExprInSimpleRequirement =
true;
3471 }
else if (Tok.
is(tok::kw_typename)) {
3474 TentativeParsingAction TPA(*
this);
3480 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3484 if (Tok.
is(tok::annot_cxxscope)) {
3487 ConsumeAnnotationToken();
3490 if (Tok.
isOneOf(tok::identifier, tok::annot_template_id) &&
3496 if (Tok.
is(tok::identifier)) {
3500 TemplateId = takeTemplateIdAnnotation(Tok);
3501 ConsumeAnnotationToken();
3507 Requirements.push_back(Req);
3521 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3524 if (!Expression.
isInvalid() && PossibleRequiresExprInSimpleRequirement)
3525 Diag(StartLoc, diag::warn_requires_expr_in_simple_requirement)
3528 Requirements.push_back(Req);
3530 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3534 if (Tok.
is(tok::kw_noexcept)) {
3535 Diag(Tok, diag::err_requires_expr_simple_requirement_noexcept)
3538 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3544 if (ExpectAndConsumeSemi(diag::err_expected_semi_requirement)) {
3545 SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
3550 if (Requirements.empty()) {
3567 default: llvm_unreachable(
"Not a known type trait");
3568 #define TYPE_TRAIT_1(Spelling, Name, Key) \ 3569 case tok::kw_ ## Spelling: return UTT_ ## Name; 3570 #define TYPE_TRAIT_2(Spelling, Name, Key) \ 3571 case tok::kw_ ## Spelling: return BTT_ ## Name; 3572 #include "clang/Basic/TokenKinds.def" 3573 #define TYPE_TRAIT_N(Spelling, Name, Key) \ 3574 case tok::kw_ ## Spelling: return TT_ ## Name; 3575 #include "clang/Basic/TokenKinds.def" 3581 default: llvm_unreachable(
"Not a known binary type trait");
3589 default: llvm_unreachable(
"Not a known unary expression trait.");
3597 default: llvm_unreachable(
"Not a known type trait");
3598 #define TYPE_TRAIT(N,Spelling,K) case tok::kw_##Spelling: return N; 3599 #include "clang/Basic/TokenKinds.def" 3634 if (Tok.
is(tok::ellipsis)) {
3643 Args.push_back(Ty.
get());
3651 if (Arity && Args.size() != Arity) {
3652 Diag(EndLoc, diag::err_type_trait_arity)
3653 << Arity << 0 << (Arity > 1) << (
int)Args.size() <<
SourceRange(Loc);
3657 if (!Arity && Args.empty()) {
3658 Diag(EndLoc, diag::err_type_trait_arity)
3659 << 1 << 1 << 1 << (int)Args.size() <<
SourceRange(Loc);
3695 if (ExpectAndConsume(tok::comma)) {
3707 llvm_unreachable(
"Invalid ArrayTypeTrait!");
3737 Parser::ParseCXXAmbiguousParenExpression(ParenParseOption &ExprType,
3742 assert(ExprType ==
CastExpr &&
"Compound literals are not ambiguous!");
3743 assert(isTypeIdInParens() &&
"Not a type-id!");
3767 ParenParseOption ParseAs;
3772 if (!ConsumeAndStoreUntil(tok::r_paren, Toks)) {
3778 if (Tok.
is(tok::l_brace)) {
3779 ParseAs = CompoundLiteral;
3789 Result = ParseCastExpression(AnyCastExpr,
3798 ParseAs = NotCastExpr ? SimpleExpr :
CastExpr;
3807 Toks.push_back(AttrEnd);
3810 Toks.push_back(Tok);
3813 PP.EnterTokenStream(Toks,
true,
3819 if (ParseAs >= CompoundLiteral) {
3825 ParseSpecifierQualifierList(DS);
3826 ParseDeclarator(DeclaratorInfo);
3837 if (ParseAs == CompoundLiteral) {
3838 ExprType = CompoundLiteral;
3843 return ParseCompoundLiteralExpression(Ty.
get(),
3857 DeclaratorInfo, CastTy,
3863 assert(ParseAs == SimpleExpr);
3865 ExprType = SimpleExpr;
3892 if (T.
expectAndConsume(diag::err_expected_lparen_after,
"__builtin_bit_cast"))
3897 ParseSpecifierQualifierList(DS);
3901 ParseDeclarator(DeclaratorInfo);
3903 if (ExpectAndConsume(tok::comma)) {
static TypeTrait TypeTraitFromTokKind(tok::TokenKind kind)
Defines the clang::ASTContext interface.
void setConstructorName(ParsedType ClassType, SourceLocation ClassNameLoc, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a constructor name.
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, ParsedType LhsTy, Expr *DimExpr, SourceLocation RParen)
ActOnArrayTypeTrait - Parsed one of the binary type trait support pseudo-functions.
StringRef getUDSuffix() const
ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, Declarator &D, ParsedType &Ty, SourceLocation RParenLoc, Expr *CastExpr)
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
no exception specification
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
ParseScope - Introduces a new scope for parsing.
void restore()
restore - This can be used to restore the state early, before the dtor is run.
A (possibly-)qualified type.
Keeps information about an identifier in a nested-name-spec.
This is a scope that corresponds to the parameters within a function prototype.
ConditionResult ActOnConditionVariable(Decl *ConditionVar, SourceLocation StmtLoc, ConditionKind CK)
static void tryConsumeLambdaSpecifierToken(Parser &P, SourceLocation &MutableLoc, SourceLocation &ConstexprLoc, SourceLocation &ConstevalLoc, SourceLocation &DeclEndLoc)
bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id)
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
static const TSS TSS_unsigned
bool ActOnCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo, bool EnteringContext, CXXScopeSpec &SS, bool ErrorRecoveryLookup=false, bool *IsCorrectedToColon=nullptr, bool OnlyNamespace=false)
The parser has parsed a nested-name-specifier 'identifier::'.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
static const TST TST_wchar
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
static ConditionResult ConditionError()
const Token & LookAhead(unsigned N)
Peeks ahead N tokens and returns that token without consuming any tokens.
Stmt - This represents one statement.
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
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...
TemplateNameKind isTemplateName(Scope *S, CXXScopeSpec &SS, bool hasTemplateKeyword, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool &MemberOfUnknownSpecialization)
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
bool isEmpty() const
No scope specifier.
DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D)
ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a C++ if/switch/while/for statem...
void setEndLoc(SourceLocation Loc)
static const TST TST_char16
Decl - This represents one declaration (or definition), e.g.
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
Defines the PrettyStackTraceEntry class, which is used to make crashes give more contextual informati...
concepts::Requirement * ActOnNestedRequirement(Expr *Constraint)
Defines the C++ template declaration subclasses.
The base class of the type hierarchy.
concepts::Requirement * ActOnTypeRequirement(SourceLocation TypenameKWLoc, CXXScopeSpec &SS, SourceLocation NameLoc, IdentifierInfo *TypeName, TemplateIdAnnotation *TemplateId)
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
SourceLocation getCloseLocation() const
This indicates that the scope corresponds to a function, which means that labels are set here...
SourceLocation getEndLoc() const LLVM_READONLY
Parser - This implements a parser for the C family of languages.
An overloaded operator name, e.g., operator+.
bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo, bool EnteringContext)
IsInvalidUnlessNestedName - This method is used for error recovery purposes to determine whether the ...
ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
ActOnExpressionTrait - Parsed one of the unary type trait support pseudo-functions.
void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext, bool IsUsingDeclaration, QualType BaseType, QualType PreferredType)
void CodeCompleteObjCMessageReceiver(Scope *S)
RAII object that enters a new expression evaluation context.
ActionResult< Stmt * > StmtResult
Information about one declarator, including the parsed type information and the identifier.
RAII class that determines when any errors have occurred between the time the instance was created an...
static const TST TST_char
Like System, but searched after the system directories.
void setBegin(SourceLocation b)
Describes how types, statements, expressions, and declarations should be printed. ...
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing...
Defines the clang::Expr interface and subclasses for C++ expressions.
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
tok::TokenKind getKind() const
bool SetConstexprSpec(ConstexprSpecKind ConstexprKind, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
Information about a template-id annotation token.
void enterFunctionArgument(SourceLocation Tok, llvm::function_ref< QualType()> ComputeType)
Computing a type for the function argument may require running overloading, so we postpone its comput...
ExprResult ActOnRequiresExpr(SourceLocation RequiresKWLoc, RequiresExprBodyDecl *Body, ArrayRef< ParmVarDecl *> LocalParameters, ArrayRef< concepts::Requirement *> Requirements, SourceLocation ClosingBraceLoc)
void enterVariableInit(SourceLocation Tok, Decl *D)
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool TryConsumeToken(tok::TokenKind Expected)
bool ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS, const DeclSpec &DS, SourceLocation ColonColonLoc)
One of these records is kept for each identifier that is lexed.
void setConstructorTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id that names a constructor.
SourceLocation getAnnotationEndLoc() const
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
StmtResult ActOnExprStmt(ExprResult Arg, bool DiscardedValue=true)
static const TST TST_char8
Lookup for the name failed, but we're assuming it was a template name anyway.
void setConversionFunctionId(SourceLocation OperatorLoc, ParsedType Ty, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a conversion-function-id.
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...
SourceLocation getBeginLoc() const LLVM_READONLY
LambdaCaptureKind
The different capture forms in a lambda introducer.
The current expression is potentially evaluated at run time, which means that code may be generated t...
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
OverloadedOperatorKind Operator
The kind of overloaded operator.
static const TST TST_double
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
ExprResult ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXUuidof - Parse __uuidof( something ).
Token - This structure provides full information about a lexed token.
void setKind(tok::TokenKind K)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
ParsedType getDestructorName(SourceLocation TildeLoc, IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
A user-defined literal name, e.g., operator "" _i.
void SetSourceRange(SourceRange R)
bool isInvalidType() const
ExprResult ActOnBuiltinBitCastExpr(SourceLocation KWLoc, Declarator &Dcl, ExprResult Operand, SourceLocation RParenLoc)
void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro, bool AfterAmpersand)
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
This is a scope that corresponds to a block/closure object.
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
ActOnCXXThrow - Parse throw expressions.
Represents a C++ unqualified-id that has been parsed.
static ParsedType getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
< Capturing the *this object by copy
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
SourceRange getRange() const
QualType ProduceConstructorSignatureHelp(Scope *S, QualType Type, SourceLocation Loc, ArrayRef< Expr *> Args, SourceLocation OpenParLoc)
void enterCondition(Sema &S, SourceLocation Tok)
const clang::PrintingPolicy & getPrintingPolicy() const
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
If a crash happens while one of these objects are live, the message is printed out along with the spe...
void SetInvalid(SourceRange R)
Indicate that this nested-name-specifier is invalid.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, CorrectionCandidateCallback *CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
ExprResult ActOnCXXThis(SourceLocation loc)
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...
Represents a C++ nested-name-specifier or a global scope specifier.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
static TemplateIdAnnotation * Create(SourceLocation TemplateKWLoc, SourceLocation TemplateNameLoc, IdentifierInfo *Name, OverloadedOperatorKind OperatorKind, ParsedTemplateTy OpaqueTemplateName, TemplateNameKind TemplateKind, SourceLocation LAngleLoc, SourceLocation RAngleLoc, ArrayRef< ParsedTemplateArgument > TemplateArgs, SmallVectorImpl< TemplateIdAnnotation *> &CleanupList)
Creates a new TemplateIdAnnotation with NumArgs arguments and appends it to List. ...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
ArrayTypeTrait
Names for the array type traits.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type...
void setTemplateId(TemplateIdAnnotation *TemplateId)
Specify that this unqualified-id was parsed as a template-id.
AttributeFactory & getAttrFactory()
SourceRange getSourceRange() const LLVM_READONLY
const char * getName() const
bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, NestedNameSpecInfo &IdInfo)
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword.
static const TST TST_float
TypeTrait
Names for traits that operate specifically on types.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
ExprResult ActOnNameClassifiedAsUndeclaredNonType(IdentifierInfo *Name, SourceLocation NameLoc)
Act on the result of classifying a name as an undeclared (ADL-only) non-type declaration.
static const TSW TSW_long
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(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
concepts::Requirement * ActOnSimpleRequirement(Expr *E)
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, SourceLocation StartLoc, SourceLocation EndLoc)
void SetRangeStart(SourceLocation Loc)
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.
SourceRange getRange() const
TST getTypeSpecType() const
ExprResult ActOnLambdaExpr(SourceLocation StartLoc, Stmt *Body, Scope *CurScope)
ActOnLambdaExpr - This is called when the body of a lambda expression was successfully completed...
This represents one expression.
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.
bool ActOnCXXGlobalScopeSpecifier(SourceLocation CCLoc, CXXScopeSpec &SS)
The parser has parsed a global nested-name-specifier '::'.
void setDeductionGuideName(ParsedTemplateTy Template, SourceLocation TemplateLoc)
Specify that this unqualified-id was parsed as a template-name for a deduction-guide.
Represents the body of a requires-expression.
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
ParsedType getDestructorTypeForDecltype(const DeclSpec &DS, ParsedType ObjectType)
bool hasLeadingEmptyMacro() const
Return true if this token has an empty macro before it.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, ParsedType ObjectType, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
TypeResult ActOnTypeName(Scope *S, Declarator &D)
OpaquePtr< T > get() const
void setEofData(const void *D)
void RevertCachedTokens(unsigned N)
When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens...
ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc, SourceLocation TildeLoc, UnqualifiedId &SecondTypeName)
const Token & getCurToken() const
OpaquePtr< TemplateName > TemplateTy
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
void setAsmLabel(Expr *E)
SourceLocation getBeginLoc() const
Represents a C++ template name within the type system.
This is a compound statement scope.
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< ParsedType > Args, SourceLocation RParenLoc)
Parsed one of the type trait support pseudo-functions.
void setLiteralOperatorId(const IdentifierInfo *Id, SourceLocation OpLoc, SourceLocation IdLoc)
Specific that this unqualified-id was parsed as a literal-operator-id.
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
SourceLocation getEnd() const
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceLocation getOpenLocation() const
static const TST TST_half
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression.
sema::LambdaScopeInfo * PushLambdaScope()
The result type of a method or function.
static const TSW TSW_short
StringRef GetString() const
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion...
bool isValid() const
Determine whether this unqualified-id refers to a valid name.
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
SourceLocation getEndLoc() const LLVM_READONLY
const LangOptions & getLangOpts() const
bool SetTypeSpecWidth(TSW 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 ...
This is a scope that corresponds to the parameters within a function prototype for a function declara...
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
SourceManager & getSourceManager() const
static const TST TST_char32
unsigned getUDSuffixOffset() const
Get the spelling offset of the first byte of the ud-suffix.
SourceLocation DefaultLoc
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
unsigned getUDSuffixToken() const
Get the index of a token containing a ud-suffix.
ASTContext & getASTContext() const
static const TST TST_float16
concepts::Requirement * ActOnCompoundRequirement(Expr *E, SourceLocation NoexceptLoc)
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void setLength(unsigned Len)
bool hasErrorOccurred() const
Determine whether any errors have occurred since this object instance was created.
static void addConstexprToLambdaDeclSpecifier(Parser &P, SourceLocation ConstexprLoc, DeclSpec &DS)
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
MutableArrayRef< Expr * > MultiExprArg
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration...
SourceLocation getEndLoc() const LLVM_READONLY
IdentifierInfo * getIdentifierInfo() const
void setAnnotationEndLoc(SourceLocation L)
IdentifierTable & getIdentifierTable()
ParsedAttr - Represents a syntactic attribute.
static const TSS TSS_signed
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}_cast's.
void CodeCompleteOperatorName(Scope *S)
void Lex(Token &Result)
Lex the next token for this preprocessor.
ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep, SourceLocation LParenOrBraceLoc, MultiExprArg Exprs, SourceLocation RParenOrBraceLoc, bool ListInitialization)
ActOnCXXTypeConstructExpr - Parse construction of a specified type.
const void * getEofData() const
TemplateNameKind ActOnDependentTemplateName(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, const UnqualifiedId &Name, ParsedType ObjectType, bool EnteringContext, TemplateTy &Template, bool AllowInjectedClassName=false)
Form a dependent template name.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
Scope * getCurScope() const
RequiresExprBodyDecl * ActOnStartRequiresExpr(SourceLocation RequiresKWLoc, ArrayRef< ParmVarDecl *> LocalParameters, Scope *BodyScope)
A static requirement that can be used in a requires-expression to check properties of types and expre...
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer)
ActOnCXXNew - Parsed a C++ 'new' expression.
static void FixDigraph(Parser &P, Preprocessor &PP, Token &DigraphToken, Token &ColonToken, tok::TokenKind Kind, bool AtDigraph)
TypeResult ActOnTemplateIdType(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, IdentifierInfo *TemplateII, SourceLocation TemplateIILoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false, bool IsClassName=false)
StringRef getName() const
Return the actual identifier string.
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isNot(tok::TokenKind K) const
static const TST TST_decltype_auto
The name does not refer to a template.
Dataflow Directional Tag Classes.
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...
bool isValid() const
Return true if this is a valid SourceLocation object.
LambdaCaptureDefault Default
bool expectAndConsume(unsigned DiagID=diag::err_expected, const char *Msg="", tok::TokenKind SkipToTok=tok::unknown)
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
static const TST TST_void
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
static const TST TST_int128
void RecordParsingTemplateParameterDepth(unsigned Depth)
This is used to inform Sema what the current TemplateParameterDepth is during Parsing.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
void ActOnFinishRequiresExpr()
This is a scope that corresponds to the template parameters of a C++ template.
ExprResult ParseConstraintExpression()
Parse a constraint-expression.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
SourceLocation getLastCachedTokenLocation() const
Get the location of the last cached token, suitable for setting the end location of an annotation tok...
bool ActOnSuperScopeSpecifier(SourceLocation SuperLoc, SourceLocation ColonColonLoc, CXXScopeSpec &SS)
The parser has parsed a '__super' nested-name-specifier.
unsigned getLength() const
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
void ActOnLambdaExplicitTemplateParameterList(SourceLocation LAngleLoc, ArrayRef< NamedDecl *> TParams, SourceLocation RAngleLoc)
This is called after parsing the explicit template parameter list on a lambda (if it exists) in C++2a...
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...
ParsedType getConstructorName(IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, bool EnteringContext)
Not an overloaded operator.
void ActOnStartOfLambdaDefinition(LambdaIntroducer &Intro, Declarator &ParamInfo, Scope *CurScope)
ActOnStartOfLambdaDefinition - This is called just before we start parsing the body of a lambda; it a...
QualType getCanonicalTypeInternal() const
void takeAttributesFrom(ParsedAttributes &attrs)
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
void RestoreNestedNameSpecifierAnnotation(void *Annotation, SourceRange AnnotationRange, CXXScopeSpec &SS)
Given an annotation pointer for a nested-name-specifier, restore the nested-name-specifier structure...
const char * getOperatorSpelling(OverloadedOperatorKind Operator)
Retrieve the spelling of the given overloaded operator, without the preceding "operator" keyword...
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
void setOperatorFunctionId(SourceLocation OperatorLoc, OverloadedOperatorKind Op, SourceLocation SymbolLocations[3])
Specify that this unqualified-id was parsed as an operator-function-id.
static const TST TST_typename
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXTypeid - Parse typeid( something ).
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
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.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
ExprResult ActOnCoyieldExpr(Scope *S, SourceLocation KwLoc, Expr *E)
Capturing the *this object by reference.
This is a scope that can contain a declaration.
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool isSet() const
Deprecated.
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
void setInvalidType(bool Val=true)
An integral condition for a 'switch' statement.
Captures information about "declaration specifiers".
ActionResult< Expr * > ExprResult
void setEnd(SourceLocation e)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
static ExpressionTrait ExpressionTraitFromTokKind(tok::TokenKind kind)
static int SelectDigraphErrorMessage(tok::TokenKind Kind)
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
static const TST TST_float128
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
static const TST TST_bool
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
SourceManager & getSourceManager() const
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Imaginary" (...
Represents a complete lambda introducer.
static const TSW TSW_longlong
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.
void enterTypeCast(SourceLocation Tok, QualType CastType)
Handles all type casts, including C-style cast, C++ casts, etc.
Code completion occurs within the condition of an if, while, switch, or for statement.
static unsigned TypeTraitArity(tok::TokenKind kind)
static void addConstevalToLambdaDeclSpecifier(Parser &P, SourceLocation ConstevalLoc, DeclSpec &DS)
DeclaratorContext getContext() const
void setLocation(SourceLocation L)
A trivial tuple used to represent a source range.
This represents a decl that may have a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
unsigned NumArgs
NumArgs - The number of template arguments.
void * getAnnotationValue() const
void setDestructorName(SourceLocation TildeLoc, ParsedType ClassType, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a destructor name.
void SetRangeEnd(SourceLocation Loc)
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
This class handles loading and caching of source files into memory.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
static ArrayTypeTrait ArrayTypeTraitFromTokKind(tok::TokenKind kind)
Attr - This represents one attribute.
SourceLocation getLocation() const
void startToken()
Reset all flags to cleared.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Stop skipping at specified token, but don't skip the token itself.