30#include "llvm/ADT/SmallString.h"
31#include "llvm/Support/TimeProfiler.h"
66 assert(Tok.
is(tok::kw_namespace) &&
"Not a namespace!");
70 if (Tok.
is(tok::code_completion)) {
78 InnerNamespaceInfoList ExtraNSs;
83 auto ReadAttributes = [&] {
87 if (Tok.
is(tok::kw___attribute)) {
88 ParseGNUAttributes(attrs);
93 ? diag::warn_cxx14_compat_ns_enum_attribute
94 : diag::ext_ns_enum_attribute)
96 ParseCXX11Attributes(attrs);
99 }
while (MoreToParse);
104 if (Tok.
is(tok::identifier)) {
107 while (Tok.
is(tok::coloncolon) &&
110 GetLookAheadToken(2).is(tok::identifier)))) {
112 InnerNamespaceInfo Info;
115 if (Tok.
is(tok::kw_inline)) {
118 FirstNestedInlineLoc = Info.InlineLoc;
124 ExtraNSs.push_back(Info);
133 if (!ExtraNSs.empty() && attrLoc.
isValid())
134 Diag(attrLoc, diag::err_unexpected_nested_namespace_attribute);
136 if (Tok.
is(tok::equal)) {
138 Diag(Tok, diag::err_expected) << tok::identifier;
143 if (!ExtraNSs.empty()) {
144 Diag(ExtraNSs.front().NamespaceLoc,
145 diag::err_unexpected_qualified_namespace_alias)
147 ExtraNSs.back().IdentLoc);
152 Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
154 Diag(InlineLoc, diag::err_inline_namespace_alias)
156 Decl *NSAlias = ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd);
161 if (
T.consumeOpen()) {
163 Diag(Tok, diag::err_expected) << tok::l_brace;
165 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
172 Diag(
T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
177 if (ExtraNSs.empty()) {
179 }
else if (InlineLoc.
isValid()) {
180 Diag(InlineLoc, diag::err_inline_nested_namespace_definition);
182 Diag(ExtraNSs[0].NamespaceLoc,
183 diag::warn_cxx14_compat_nested_namespace_definition);
184 if (FirstNestedInlineLoc.
isValid())
185 Diag(FirstNestedInlineLoc,
186 diag::warn_cxx17_compat_inline_nested_namespace_definition);
188 Diag(ExtraNSs[0].NamespaceLoc,
189 diag::warn_cxx14_compat_nested_namespace_definition);
190 if (FirstNestedInlineLoc.
isValid())
191 Diag(FirstNestedInlineLoc, diag::ext_inline_nested_namespace_definition);
193 TentativeParsingAction TPA(*
this);
195 Token rBraceToken = Tok;
198 if (!rBraceToken.
is(tok::r_brace)) {
199 Diag(ExtraNSs[0].NamespaceLoc, diag::ext_nested_namespace_definition)
201 ExtraNSs.back().IdentLoc);
203 std::string NamespaceFix;
204 for (
const auto &ExtraNS : ExtraNSs) {
205 NamespaceFix +=
" { ";
206 if (ExtraNS.InlineLoc.isValid())
207 NamespaceFix +=
"inline ";
208 NamespaceFix +=
"namespace ";
209 NamespaceFix += ExtraNS.Ident->getName();
213 for (
unsigned i = 0, e = ExtraNSs.size(); i != e; ++i)
216 Diag(ExtraNSs[0].NamespaceLoc, diag::ext_nested_namespace_definition)
219 ExtraNSs.back().IdentLoc),
225 if (FirstNestedInlineLoc.
isValid())
226 Diag(FirstNestedInlineLoc, diag::ext_inline_nested_namespace_definition);
232 ? diag::warn_cxx98_compat_inline_namespace
233 : diag::ext_inline_namespace);
240 getCurScope(), InlineLoc, NamespaceLoc, IdentLoc, Ident,
241 T.getOpenLocation(), attrs, ImplicitUsingDirectiveDecl,
false);
244 NamespaceLoc,
"parsing namespace");
248 ParseInnerNamespace(ExtraNSs, 0, InlineLoc, attrs,
T);
251 NamespaceScope.Exit();
253 DeclEnd =
T.getCloseLocation();
257 ImplicitUsingDirectiveDecl);
261void Parser::ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
265 if (index == InnerNSs.size()) {
266 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
267 Tok.
isNot(tok::eof)) {
269 MaybeParseCXX11Attributes(DeclAttrs);
271 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
287 getCurScope(), InnerNSs[index].InlineLoc, InnerNSs[index].NamespaceLoc,
288 InnerNSs[index].IdentLoc, InnerNSs[index].Ident,
290 assert(!ImplicitUsingDirectiveDecl &&
291 "nested namespace definition cannot define anonymous namespace");
293 ParseInnerNamespace(InnerNSs, ++index, InlineLoc, attrs, Tracker);
295 NamespaceScope.Exit();
306 assert(Tok.
is(tok::equal) &&
"Not equal token");
310 if (Tok.
is(tok::code_completion)) {
318 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
326 if (Tok.
isNot(tok::identifier)) {
327 Diag(Tok, diag::err_expected_namespace_name);
346 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name))
350 Alias, SS, IdentLoc, Ident);
361 assert(isTokenStringLiteral() &&
"Not a string literal!");
375 while (MaybeParseCXX11Attributes(DeclAttrs) ||
376 MaybeParseGNUAttributes(DeclSpecAttrs))
379 if (Tok.
isNot(tok::l_brace)) {
386 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs, &DS);
394 ProhibitAttributes(DeclAttrs);
399 unsigned NestedModules = 0;
402 case tok::annot_module_begin:
407 case tok::annot_module_end:
414 case tok::annot_module_include:
427 MaybeParseCXX11Attributes(DeclAttrs);
428 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
447Decl *Parser::ParseExportDeclaration() {
448 assert(Tok.
is(tok::kw_export));
456 if (Tok.
isNot(tok::l_brace)) {
459 MaybeParseCXX11Attributes(DeclAttrs);
461 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
469 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
470 Tok.
isNot(tok::eof)) {
472 MaybeParseCXX11Attributes(DeclAttrs);
474 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
479 T.getCloseLocation());
487 assert(Tok.
is(tok::kw_using) &&
"Not using token");
493 if (Tok.
is(tok::code_completion)) {
500 while (Tok.
is(tok::kw_template)) {
502 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
507 if (Tok.
is(tok::kw_namespace)) {
509 if (TemplateInfo.Kind) {
511 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
515 Decl *UsingDir = ParseUsingDirective(Context, UsingLoc, DeclEnd, Attrs);
520 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, Attrs,
538 assert(Tok.
is(tok::kw_namespace) &&
"Not 'namespace' token");
543 if (Tok.
is(tok::code_completion)) {
551 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
563 if (Tok.
isNot(tok::identifier)) {
564 Diag(Tok, diag::err_expected_namespace_name);
583 bool GNUAttr =
false;
584 if (Tok.
is(tok::kw___attribute)) {
586 ParseGNUAttributes(attrs);
591 if (ExpectAndConsume(tok::semi,
592 GNUAttr ? diag::err_expected_semi_after_attribute_list
593 : diag::err_expected_semi_after_namespace_name))
597 IdentLoc, NamespcName, attrs);
606 UsingDeclarator &D) {
613 if (Tok.
is(tok::kw___super)) {
620 if (ParseOptionalCXXScopeSpecifier(D.SS,
nullptr,
630 if (D.SS.isInvalid())
644 Tok.
is(tok::identifier) &&
650 !D.SS.getScopeRep()->getAsNamespace() &&
651 !D.SS.getScopeRep()->getAsNamespaceAlias()) {
655 D.Name.setConstructorName(
Type, IdLoc, IdLoc);
662 !(Tok.
is(tok::identifier) &&
NextToken().is(tok::equal)),
663 false,
nullptr, D.Name))
669 ? diag::warn_cxx17_compat_using_declaration_pack
670 : diag::ext_using_declaration_pack);
709 ? diag::warn_cxx17_compat_using_enum_declaration
710 : diag::ext_using_enum_declaration);
712 DiagnoseCXX11AttributeExtension(PrefixAttrs);
714 if (TemplateInfo.Kind) {
716 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
722 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
734 if (Tok.
is(tok::code_completion)) {
740 if (!Tok.
is(tok::identifier)) {
742 << Tok.
is(tok::kw_enum);
749 getCurScope(), AS, UsingLoc, UELoc, IdentLoc, *IdentInfo, &SS);
756 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
757 "using-enum declaration"))
766 MaybeParseCXX11Attributes(MisplacedAttrs);
768 if (InInitStatement && Tok.
isNot(tok::identifier))
772 bool InvalidDeclarator = ParseUsingDeclarator(Context, D);
775 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
779 if (MisplacedAttrs.Range.isValid()) {
781 MisplacedAttrs.empty() ? nullptr : &MisplacedAttrs.front();
782 auto &
Range = MisplacedAttrs.Range;
783 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
784 ?
Diag(
Range.getBegin(), diag::err_keyword_not_allowed) << FirstAttr
785 :
Diag(
Range.getBegin(), diag::err_attributes_not_allowed))
793 if (Tok.
is(tok::equal) || InInitStatement) {
794 if (InvalidDeclarator) {
799 ProhibitAttributes(PrefixAttrs);
801 Decl *DeclFromDeclSpec =
nullptr;
807 Decl *AD = ParseAliasDeclarationAfterDeclarator(
808 TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
812 DiagnoseCXX11AttributeExtension(PrefixAttrs);
817 if (TemplateInfo.Kind) {
819 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
831 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
832 DiagnoseCXX11AttributeExtension(Attrs);
835 if (InvalidDeclarator)
840 if (D.TypenameLoc.isValid() &&
842 Diag(D.Name.getSourceRange().getBegin(),
843 diag::err_typename_identifiers_only)
850 D.TypenameLoc, D.SS, D.Name,
851 D.EllipsisLoc, Attrs);
853 DeclsInGroup.push_back(UD);
861 InvalidDeclarator = ParseUsingDeclarator(Context, D);
864 if (DeclsInGroup.size() > 1)
867 ? diag::warn_cxx17_compat_multi_using_declaration
868 : diag::ext_multi_using_declaration);
872 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
873 !Attrs.
empty() ?
"attributes list"
874 : UELoc.
isValid() ?
"using-enum declaration"
875 :
"using declaration"))
881Decl *Parser::ParseAliasDeclarationAfterDeclarator(
885 if (ExpectAndConsume(tok::equal)) {
891 ? diag::warn_cxx98_compat_alias_declaration
892 : diag::ext_alias_declaration);
896 if (TemplateInfo.Kind == ParsedTemplateInfo::Template &&
899 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization)
901 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
903 if (SpecKind != -1) {
907 D.Name.TemplateId->RAngleLoc);
909 Range = TemplateInfo.getSourceRange();
910 Diag(
Range.getBegin(), diag::err_alias_declaration_specialization)
911 << SpecKind <<
Range;
918 Diag(D.Name.StartLocation, diag::err_alias_declaration_not_identifier);
922 }
else if (D.TypenameLoc.isValid())
923 Diag(D.TypenameLoc, diag::err_alias_declaration_not_identifier)
925 SourceRange(D.TypenameLoc, D.SS.isNotEmpty() ? D.SS.getEndLoc()
927 else if (D.SS.isNotEmpty())
928 Diag(D.SS.getBeginLoc(), diag::err_alias_declaration_not_identifier)
930 if (D.EllipsisLoc.isValid())
931 Diag(D.EllipsisLoc, diag::err_alias_declaration_pack_expansion)
934 Decl *DeclFromDeclSpec =
nullptr;
939 AS, &DeclFromDeclSpec, &Attrs);
941 *OwnedType = DeclFromDeclSpec;
945 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
946 !Attrs.
empty() ?
"attributes list"
947 :
"alias declaration"))
952 TemplateParams ? TemplateParams->data() :
nullptr,
953 TemplateParams ? TemplateParams->size() : 0);
955 UsingLoc, D.Name, Attrs, TypeAlias,
961 if (
const auto *BO = dyn_cast_or_null<BinaryOperator>(AssertExpr)) {
962 if (BO->getOpcode() == BO_LAnd &&
963 isa<StringLiteral>(BO->getRHS()->IgnoreImpCasts()))
978 assert(Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
979 "Not a static_assert declaration");
982 const char *TokName = Tok.
getName();
984 if (Tok.
is(tok::kw__Static_assert))
985 diagnoseUseOfC11Keyword(Tok);
986 else if (Tok.
is(tok::kw_static_assert)) {
989 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
994 Diag(Tok, diag::warn_cxx98_compat_static_assert);
1000 if (
T.consumeOpen()) {
1001 Diag(Tok, diag::err_expected) << tok::l_paren;
1009 if (AssertExpr.isInvalid()) {
1015 if (Tok.
is(tok::r_paren)) {
1018 DiagVal = diag::warn_cxx14_compat_static_assert_no_message;
1020 DiagVal = diag::ext_cxx_static_assert_no_message;
1022 DiagVal = diag::warn_c17_compat_static_assert_no_message;
1024 DiagVal = diag::ext_c_static_assert_no_message;
1028 if (ExpectAndConsume(tok::comma)) {
1033 bool ParseAsExpression =
false;
1035 for (
unsigned I = 0;; ++I) {
1036 const Token &
T = GetLookAheadToken(I);
1037 if (
T.is(tok::r_paren))
1040 ParseAsExpression =
true;
1046 if (ParseAsExpression)
1051 Diag(Tok, diag::err_expected_string_literal)
1066 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
1069 AssertMessage.
get(),
1070 T.getCloseLocation());
1079 assert(Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype) &&
1080 "Not a decltype specifier");
1086 if (Tok.
is(tok::annot_decltype)) {
1087 Result = getExprAnnotation(Tok);
1092 ConsumeAnnotationToken();
1093 if (
Result.isInvalid()) {
1099 Diag(Tok, diag::warn_cxx98_compat_decltype);
1104 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"decltype",
1107 return T.getOpenLocation() == Tok.
getLocation() ? StartLoc
1108 :
T.getOpenLocation();
1112 if (Tok.
is(tok::kw_auto) &&
NextToken().is(tok::r_paren)) {
1117 ? diag::warn_cxx11_compat_decltype_auto_type_specifier
1118 : diag::ext_decltype_auto_type_specifier);
1132 if (
Result.isInvalid()) {
1135 EndLoc = ConsumeParen();
1142 assert(Tok.
is(tok::semi));
1156 if (
T.getCloseLocation().isInvalid()) {
1160 return T.getCloseLocation();
1163 if (
Result.isInvalid()) {
1165 return T.getCloseLocation();
1168 EndLoc =
T.getCloseLocation();
1170 assert(!
Result.isInvalid());
1172 const char *PrevSpec =
nullptr;
1177 PrevSpec, DiagID,
Result.get(), Policy)
1179 PrevSpec, DiagID, Policy)) {
1180 Diag(StartLoc, DiagID) << PrevSpec;
1186void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
1202 Tok.
setKind(tok::annot_decltype);
1203 setExprAnnotation(Tok,
1213 assert(Tok.
isOneOf(tok::annot_pack_indexing_type, tok::identifier) &&
1214 "Expected an identifier");
1219 const char *PrevSpec;
1223 if (Tok.
is(tok::annot_pack_indexing_type)) {
1231 ConsumeAnnotationToken();
1232 if (
Type.isInvalid()) {
1237 DiagID,
Type, Policy);
1241 !GetLookAheadToken(2).is(tok::l_square)) {
1273 return T.getCloseLocation();
1276void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1292 Tok.
setKind(tok::annot_pack_indexing_type);
1293 setTypeAnnotation(Tok,
T);
1301#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1302 case tok::kw___##Trait: \
1303 return DeclSpec::TST_##Trait;
1304#include "clang/Basic/TransformTypeTraits.def"
1306 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1310bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1315 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1319 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.
getName(),
1324 if (
Result.isInvalid()) {
1330 if (
T.getCloseLocation().isInvalid())
1333 const char *PrevSpec =
nullptr;
1338 Diag(StartLoc, DiagID) << PrevSpec;
1364 if (Tok.
is(tok::kw_typename)) {
1365 Diag(Tok, diag::err_expected_class_name_not_template)
1372 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1382 if (Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1389 EndLocation = ParseDecltypeSpecifier(DS);
1396 if (Tok.
is(tok::annot_pack_indexing_type)) {
1398 ParsePackIndexingType(DS);
1405 if (Tok.
is(tok::annot_template_id)) {
1411 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
1414 ConsumeAnnotationToken();
1421 if (Tok.
isNot(tok::identifier)) {
1422 Diag(Tok, diag::err_expected_class_name);
1429 if (Tok.
is(tok::less)) {
1438 Diag(IdLoc, diag::err_unknown_template_name) <<
Id;
1449 if (Tok.
is(tok::annot_template_id) &&
1450 takeTemplateIdAnnotation(Tok)->mightBeType())
1456 if (Tok.
isNot(tok::annot_typename))
1463 ConsumeAnnotationToken();
1476 Diag(IdLoc, diag::err_expected_class_name);
1481 EndLocation = IdLoc;
1489 const char *PrevSpec =
nullptr;
1499void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1500 while (Tok.
isOneOf(tok::kw___single_inheritance,
1501 tok::kw___multiple_inheritance,
1502 tok::kw___virtual_inheritance)) {
1506 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1511 while (Tok.
is(tok::kw__Nullable)) {
1515 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1522bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1533 case tok::identifier:
1535 case tok::coloncolon:
1536 case tok::annot_cxxscope:
1537 case tok::annot_typename:
1538 case tok::annot_template_id:
1539 case tok::kw_decltype:
1542 case tok::kw_operator:
1543 case tok::kw___declspec:
1548 case tok::kw___attribute:
1549 case tok::annot_pragma_pack:
1551 case tok::annot_pragma_ms_pragma:
1553 case tok::annot_pragma_ms_vtordisp:
1555 case tok::annot_pragma_ms_pointers_to_members:
1558 return CouldBeBitfield ||
1561 case tok::kw___cdecl:
1562 case tok::kw___fastcall:
1563 case tok::kw___stdcall:
1564 case tok::kw___thiscall:
1565 case tok::kw___vectorcall:
1571 case tok::kw_volatile:
1572 case tok::kw_restrict:
1573 case tok::kw__Atomic:
1574 case tok::kw___unaligned:
1578 case tok::kw_inline:
1579 case tok::kw_virtual:
1580 case tok::kw_friend:
1582 case tok::kw_static:
1583 case tok::kw_extern:
1584 case tok::kw_typedef:
1585 case tok::kw_register:
1587 case tok::kw_mutable:
1588 case tok::kw_thread_local:
1589 case tok::kw_constexpr:
1590 case tok::kw_consteval:
1591 case tok::kw_constinit:
1607 if (!isKnownToBeTypeSpecifier(
NextToken()))
1664 const ParsedTemplateInfo &TemplateInfo,
1666 DeclSpecContext DSC,
1669 if (TagTokKind == tok::kw_struct)
1671 else if (TagTokKind == tok::kw___interface)
1673 else if (TagTokKind == tok::kw_class)
1676 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1680 if (Tok.
is(tok::code_completion)) {
1694 const bool shouldDelayDiagsInTag =
1695 (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate);
1701 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1703 if (Tok.
isOneOf(tok::kw___single_inheritance,
1704 tok::kw___multiple_inheritance,
1705 tok::kw___virtual_inheritance)) {
1706 ParseMicrosoftInheritanceClassAttributes(attrs);
1709 if (Tok.
is(tok::kw__Nullable)) {
1710 ParseNullabilityClassAttributes(attrs);
1724#include
"clang/Basic/TransformTypeTraits.def"
1725 tok::kw___is_abstract,
1726 tok::kw___is_aggregate,
1727 tok::kw___is_arithmetic,
1729 tok::kw___is_assignable,
1730 tok::kw___is_base_of,
1731 tok::kw___is_bounded_array,
1733 tok::kw___is_complete_type,
1734 tok::kw___is_compound,
1736 tok::kw___is_constructible,
1737 tok::kw___is_convertible,
1738 tok::kw___is_convertible_to,
1739 tok::kw___is_destructible,
1742 tok::kw___is_floating_point,
1744 tok::kw___is_function,
1745 tok::kw___is_fundamental,
1746 tok::kw___is_integral,
1747 tok::kw___is_interface_class,
1748 tok::kw___is_literal,
1749 tok::kw___is_lvalue_expr,
1750 tok::kw___is_lvalue_reference,
1751 tok::kw___is_member_function_pointer,
1752 tok::kw___is_member_object_pointer,
1753 tok::kw___is_member_pointer,
1754 tok::kw___is_nothrow_assignable,
1755 tok::kw___is_nothrow_constructible,
1756 tok::kw___is_nothrow_convertible,
1757 tok::kw___is_nothrow_destructible,
1758 tok::kw___is_nullptr,
1759 tok::kw___is_object,
1761 tok::kw___is_pointer,
1762 tok::kw___is_polymorphic,
1763 tok::kw___is_reference,
1764 tok::kw___is_referenceable,
1765 tok::kw___is_rvalue_expr,
1766 tok::kw___is_rvalue_reference,
1768 tok::kw___is_scalar,
1769 tok::kw___is_scoped_enum,
1770 tok::kw___is_sealed,
1771 tok::kw___is_signed,
1772 tok::kw___is_standard_layout,
1773 tok::kw___is_trivial,
1774 tok::kw___is_trivially_equality_comparable,
1775 tok::kw___is_trivially_assignable,
1776 tok::kw___is_trivially_constructible,
1777 tok::kw___is_trivially_copyable,
1778 tok::kw___is_unbounded_array,
1780 tok::kw___is_unsigned,
1782 tok::kw___is_volatile,
1783 tok::kw___reference_binds_to_temporary,
1784 tok::kw___reference_constructs_from_temporary))
1790 TryKeywordIdentFallback(
true);
1792 struct PreserveAtomicIdentifierInfoRAII {
1793 PreserveAtomicIdentifierInfoRAII(
Token &Tok,
bool Enabled)
1794 : AtomicII(nullptr) {
1797 assert(Tok.
is(tok::kw__Atomic));
1802 ~PreserveAtomicIdentifierInfoRAII() {
1805 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1815 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1816 Tok.
is(tok::kw__Atomic) &&
1818 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1819 Tok, ShouldChangeAtomicToIdentifier);
1829 if (TemplateInfo.TemplateParams)
1832 bool HasValidSpec =
true;
1833 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1837 HasValidSpec =
false;
1840 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::annot_template_id)) {
1841 Diag(Tok, diag::err_expected) << tok::identifier;
1842 HasValidSpec =
false;
1850 auto RecoverFromUndeclaredTemplateName = [&](
IdentifierInfo *Name,
1853 bool KnownUndeclared) {
1854 Diag(NameLoc, diag::err_explicit_spec_non_template)
1855 << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
1856 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1860 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1861 if (TemplateParams->size() > 1) {
1862 TemplateParams->pop_back();
1864 TemplateParams =
nullptr;
1865 const_cast<ParsedTemplateInfo &
>(TemplateInfo).Kind =
1866 ParsedTemplateInfo::NonTemplate;
1868 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1870 TemplateParams =
nullptr;
1871 const_cast<ParsedTemplateInfo &
>(TemplateInfo).Kind =
1872 ParsedTemplateInfo::NonTemplate;
1873 const_cast<ParsedTemplateInfo &
>(TemplateInfo).TemplateLoc =
1875 const_cast<ParsedTemplateInfo &
>(TemplateInfo).ExternLoc =
1884 if (Tok.
is(tok::identifier)) {
1892 TemplateArgList TemplateArgs;
1894 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1900 RecoverFromUndeclaredTemplateName(
1901 Name, NameLoc,
SourceRange(LAngleLoc, RAngleLoc),
false);
1903 }
else if (Tok.
is(tok::annot_template_id)) {
1904 TemplateId = takeTemplateIdAnnotation(Tok);
1905 NameLoc = ConsumeAnnotationToken();
1912 RecoverFromUndeclaredTemplateName(
1915 TemplateId =
nullptr;
1928 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1929 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1964 MaybeParseCXX11Attributes(Attributes);
1969 AllowDefiningTypeSpec::No ||
1972 else if (Tok.
is(tok::l_brace) ||
1973 (DSC != DeclSpecContext::DSC_association &&
1975 (isClassCompatibleKeyword() &&
1991 }
else if (isClassCompatibleKeyword() &&
1998 TentativeParsingAction PA(*
this);
2001 while (isClassCompatibleKeyword()) {
2007 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square)) {
2011 }
else if (Tok.
is(tok::kw_alignas) &&
NextToken().is(tok::l_paren)) {
2021 if (!
T.consumeOpen())
2029 if (Tok.
isOneOf(tok::l_brace, tok::colon))
2035 }
else if (!isTypeSpecifier(DSC) &&
2036 (Tok.
is(tok::semi) ||
2039 if (Tok.
isNot(tok::semi)) {
2042 ExpectAndConsume(tok::semi, diag::err_expected_after,
2060 auto *FirstAttr = Attributes.
empty() ? nullptr : &Attributes.
front();
2062 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2063 ?
Diag(Loc, diag::err_keyword_not_allowed) << FirstAttr
2064 :
Diag(Loc, diag::err_attributes_not_allowed))
2076 if (!Name && !TemplateId &&
2081 Diag(StartLoc, diag::err_anon_type_definition)
2108 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2111 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2112 diag::err_keyword_not_allowed,
2116 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2127 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
2128 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2129 diag::err_keyword_not_allowed,
2139 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2152 "Expected a definition here");
2156 TemplateParams =
nullptr;
2161 diag::err_explicit_instantiation_with_definition)
2170 std::nullopt, LAngleLoc,
nullptr));
2171 TemplateParams = &FakedParamLists;
2178 SS, *TemplateId, attrs,
2181 TemplateParams ? TemplateParams->size() : 0),
2184 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2191 ProhibitAttributes(attrs);
2194 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2195 TagType, StartLoc, SS, Name, NameLoc, attrs);
2197 TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
2198 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2199 diag::err_keyword_not_allowed,
2206 TemplateParams ? TemplateParams->size() : 0));
2209 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2210 diag::err_keyword_not_allowed,
2214 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2217 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2219 TemplateParams =
nullptr;
2222 bool IsDependent =
false;
2232 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2235 TagOrTempResult = Actions.
ActOnTag(
2239 DSC == DeclSpecContext::DSC_type_specifier,
2240 DSC == DeclSpecContext::DSC_template_param ||
2241 DSC == DeclSpecContext::DSC_template_type_arg,
2242 OffsetOfState, &SkipBody);
2249 Name, StartLoc, NameLoc);
2256 if (shouldDelayDiagsInTag) {
2257 diagsFromTag.done();
2259 TemplateInfo.Kind == ParsedTemplateInfo::Template)
2260 diagsFromTag.redelay();
2265 assert(Tok.
is(tok::l_brace) ||
2267 isClassCompatibleKeyword());
2269 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc,
TagType,
2270 TagOrTempResult.
get());
2272 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs,
TagType,
2273 TagOrTempResult.
get());
2278 ParseStructUnionBody(StartLoc,
TagType, cast<RecordDecl>(D));
2291 const char *PrevSpec =
nullptr;
2296 NameLoc.
isValid() ? NameLoc : StartLoc,
2298 }
else if (!TagOrTempResult.
isInvalid()) {
2300 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2301 DiagID, TagOrTempResult.
get(), Owned, Policy);
2308 Diag(StartLoc, DiagID) << PrevSpec;
2324 (TemplateInfo.Kind || !isValidAfterTypeSpecifier(
false))) {
2325 if (Tok.
isNot(tok::semi)) {
2327 ExpectAndConsume(tok::semi, diag::err_expected_after,
2345void Parser::ParseBaseClause(
Decl *ClassDecl) {
2346 assert(Tok.
is(tok::colon) &&
"Not a base clause");
2355 if (
Result.isInvalid()) {
2361 BaseInfo.push_back(
Result.get());
2386 bool IsVirtual =
false;
2390 MaybeParseCXX11Attributes(Attributes);
2396 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2406 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2410 if (Tok.
is(tok::kw_virtual)) {
2414 Diag(VirtualLoc, diag::err_dup_virtual)
2421 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2435 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2451 Access, BaseType.
get(), BaseLoc,
2466 case tok::kw_private:
2468 case tok::kw_protected:
2470 case tok::kw_public:
2479void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2486 if (!NeedLateParse) {
2490 if (Param->hasUnparsedDefaultArg()) {
2491 NeedLateParse =
true;
2497 if (NeedLateParse) {
2500 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2501 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2506 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2508 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2545 if (II == Ident_override)
2548 if (II == Ident_sealed)
2551 if (II == Ident_abstract)
2554 if (II == Ident_final)
2557 if (II == Ident_GNU_final)
2568void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2587 const char *PrevSpec =
nullptr;
2605 ? diag::warn_cxx98_compat_override_control_keyword
2606 : diag::ext_override_control_keyword)
2615bool Parser::isCXX11FinalKeyword()
const {
2624bool Parser::isClassCompatibleKeyword()
const {
2634bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2636 LateParsedAttrList &LateParsedAttrs) {
2647 if (Tok.
isNot(tok::colon))
2648 ParseDeclarator(DeclaratorInfo);
2654 "don't know where identifier would go yet?");
2658 }
else if (Tok.
is(tok::kw_requires)) {
2659 ParseTrailingRequiresClause(DeclaratorInfo);
2661 ParseOptionalCXX11VirtSpecifierSeq(
2662 VS, getCurrentClass().IsInterface,
2665 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2670 if (Tok.
is(tok::kw_asm)) {
2672 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2673 if (AsmLabel.isInvalid())
2683 DiagnoseAndSkipCXX11Attributes();
2684 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2685 DiagnoseAndSkipCXX11Attributes();
2690 ParseOptionalCXX11VirtSpecifierSeq(
2691 VS, getCurrentClass().IsInterface,
2697 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2698 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2700 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2717void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2723 ParseTypeQualifierListOpt(
2724 DS, AR_NoAttributesParsed,
false,
2725 false, llvm::function_ref<
void()>([&]() {
2733 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2736 auto &MQ =
Function.getOrCreateMethodQualifiers();
2737 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2738 std::string Name(FixItName.data());
2741 MQ.SetTypeQual(TypeQual, SpecLoc);
2743 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2752 bool RefQualifierIsLValueRef =
true;
2754 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2755 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2758 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2759 Function.RefQualifierLoc = RefQualifierLoc;
2761 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2762 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2810 const ParsedTemplateInfo &TemplateInfo,
2813 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2814 if (Tok.
is(tok::at)) {
2816 Diag(Tok, diag::err_at_defs_cxx);
2818 Diag(Tok, diag::err_at_in_class);
2834 bool MalformedTypeSpec =
false;
2835 if (!TemplateInfo.Kind &&
2836 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2838 MalformedTypeSpec =
true;
2841 if (Tok.
isNot(tok::annot_cxxscope))
2842 isAccessDecl =
false;
2843 else if (
NextToken().is(tok::identifier))
2844 isAccessDecl = GetLookAheadToken(2).
is(tok::semi);
2851 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2864 false,
false,
true,
true,
2865 false, &TemplateKWLoc, Name)) {
2871 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2872 "access declaration")) {
2888 if (!TemplateInfo.Kind &&
2889 Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2895 if (Tok.
is(tok::kw_template)) {
2896 assert(!TemplateInfo.TemplateParams &&
2897 "Nested template improperly parsed?");
2901 DeclEnd, AccessAttrs, AS);
2905 if (Tok.
is(tok::kw___extension__)) {
2909 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2915 MaybeParseCXX11Attributes(DeclAttrs);
2920 if (Tok.
is(tok::annot_attr_openmp))
2921 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
2923 if (Tok.
is(tok::kw_using)) {
2928 while (Tok.
is(tok::kw_template)) {
2930 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
2934 if (Tok.
is(tok::kw_namespace)) {
2935 Diag(UsingLoc, diag::err_using_namespace_in_class);
2942 UsingLoc, DeclEnd, DeclAttrs, AS);
2946 MaybeParseMicrosoftAttributes(DeclSpecAttrs);
2949 LateParsedAttrList CommonLateParsedAttrs;
2956 if (MalformedTypeSpec)
2964 bool IsTemplateSpecOrInst =
2965 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
2966 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
2969 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
2970 &CommonLateParsedAttrs);
2972 if (IsTemplateSpecOrInst)
2973 diagsFromTag.done();
2981 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate &&
2982 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
2983 &CommonLateParsedAttrs))
2987 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
2989 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
2993 ProhibitAttributes(DeclAttrs);
2997 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
2999 DS.complete(TheDecl);
3001 Decl *decls[] = {AnonRecord, TheDecl};
3012 if (TemplateInfo.TemplateParams)
3017 LateParsedAttrList LateParsedAttrs;
3022 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
3023 if (Tok.
isNot(tok::equal))
3028 if (
Zero.isNot(tok::numeric_constant) ||
3032 auto &
After = GetLookAheadToken(2);
3033 if (!
After.isOneOf(tok::semi, tok::comma) &&
3034 !(AllowDefinition &&
3035 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3046 bool ExpectSemi =
true;
3054 if (ParseCXXMemberDeclaratorBeforeInitializer(
3055 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3060 if (IsTemplateSpecOrInst)
3068 TryConsumePureSpecifier(
true);
3079 if (Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3081 }
else if (Tok.
is(tok::equal)) {
3083 if (KW.
is(tok::kw_default))
3085 else if (KW.
is(tok::kw_delete))
3087 else if (KW.
is(tok::code_completion)) {
3103 ProhibitAttributes(DeclAttrs);
3120 diag::err_function_declared_typedef);
3126 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3127 TemplateInfo, VS, PureSpecLoc);
3130 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3131 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3133 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3134 LateParsedAttrs[i]->addDecl(FunDecl);
3137 LateParsedAttrs.clear();
3140 if (Tok.
is(tok::semi))
3141 ConsumeExtraSemi(AfterMemberFunctionDefinition);
3153 bool HasStaticInitializer =
false;
3158 Diag(Tok, diag::err_anon_bitfield_member_init);
3162 if (!TryConsumePureSpecifier(
false))
3164 HasStaticInitializer =
true;
3171 if (BitfieldSize.
get())
3173 ? diag::warn_cxx17_compat_bitfield_member_init
3174 : diag::ext_bitfield_member_init);
3177 HasStaticInitializer =
true;
3193 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3194 auto Loc = AL.getRange().getBegin();
3195 (AL.isRegularKeywordAttribute()
3196 ?
Diag(Loc, diag::err_keyword_not_allowed) << AL
3197 :
Diag(Loc, diag::err_attributes_not_allowed))
3205 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3206 VS, HasInClassInit);
3209 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3212 ThisDecl = VT->getTemplatedDecl();
3221 DeclaratorInfo.getDeclSpec().getStorageClassSpec() ==
3224 HasStaticInitializer =
true;
3228 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3230 if (ThisDecl && PureSpecLoc.
isValid())
3239 ? diag::warn_cxx98_compat_nonstatic_member_init
3240 : diag::ext_nonstatic_member_init);
3242 if (DeclaratorInfo.isArrayOfUnknownBound()) {
3248 Diag(Tok, diag::err_incomplete_array_member_init);
3255 ParseCXXNonStaticMemberInitializer(ThisDecl);
3256 }
else if (HasStaticInitializer) {
3259 ThisDecl, DeclaratorInfo.isDeclarationOfFunction(), EqualLoc);
3261 if (
Init.isInvalid()) {
3265 }
else if (ThisDecl)
3275 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3276 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3278 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3279 LateParsedAttrs[i]->addDecl(ThisDecl);
3282 DeclsInGroup.push_back(ThisDecl);
3284 if (DeclaratorInfo.isFunctionDeclarator() &&
3285 DeclaratorInfo.getDeclSpec().getStorageClassSpec() !=
3287 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3289 LateParsedAttrs.clear();
3291 DeclaratorInfo.complete(ThisDecl);
3304 Diag(CommaLoc, diag::err_expected_semi_declaration)
3314 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
3315 DeclaratorInfo.isFirstDeclarator()) {
3316 Diag(CommaLoc, diag::err_multiple_template_declarators)
3317 << TemplateInfo.Kind;
3321 DeclaratorInfo.clear();
3325 DeclaratorInfo.setCommaLoc(CommaLoc);
3330 DiagnoseAndSkipCXX11Attributes();
3331 MaybeParseGNUAttributes(DeclaratorInfo);
3332 DiagnoseAndSkipCXX11Attributes();
3334 if (ParseCXXMemberDeclaratorBeforeInitializer(
3335 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3340 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
3371ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
3373 assert(Tok.
isOneOf(tok::equal, tok::l_brace) &&
3374 "Data member initializer not starting with '=' or '{'");
3376 bool IsFieldInitialization = isa_and_present<FieldDecl>(D);
3380 IsFieldInitialization
3389 IsFieldInitialization;
3392 if (Tok.
is(tok::kw_delete)) {
3399 if (IsFunction || Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3405 SkipDeletedFunctionBody();
3408 }
else if (Tok.
is(tok::kw_default)) {
3410 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3418 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
3419 Diag(Tok, diag::err_ms_property_initializer) << PD;
3422 return ParseInitializer();
3430 assert(isCXX11FinalKeyword() &&
"not a class definition");
3436 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3441 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_brace))
3448 if (Tok.
is(tok::colon)) {
3451 ParsingClassDefinition ParsingDef(*
this,
TagDecl,
true,
3457 ParseBaseClause(
nullptr);
3461 if (!Tok.
is(tok::l_brace)) {
3463 diag::err_expected_lbrace_after_base_specifiers);
3469 assert(Tok.
is(tok::l_brace));
3475 if (Tok.
is(tok::kw___attribute)) {
3477 MaybeParseGNUAttributes(Attrs);
3487 case tok::kw___if_exists:
3488 case tok::kw___if_not_exists:
3489 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, AS);
3494 ConsumeExtraSemi(InsideStruct,
TagType);
3498 case tok::annot_pragma_vis:
3499 HandlePragmaVisibility();
3501 case tok::annot_pragma_pack:
3504 case tok::annot_pragma_align:
3505 HandlePragmaAlign();
3507 case tok::annot_pragma_ms_pointers_to_members:
3508 HandlePragmaMSPointersToMembers();
3510 case tok::annot_pragma_ms_pragma:
3511 HandlePragmaMSPragma();
3513 case tok::annot_pragma_ms_vtordisp:
3514 HandlePragmaMSVtorDisp();
3516 case tok::annot_pragma_dump:
3520 case tok::kw_namespace:
3522 DiagnoseUnexpectedNamespace(cast<NamedDecl>(
TagDecl));
3525 case tok::kw_private:
3529 return ParseCXXClassMemberDeclaration(AS, AccessAttrs);
3531 case tok::kw_public:
3532 case tok::kw_protected: {
3542 AccessAttrs.
clear();
3543 MaybeParseGNUAttributes(AccessAttrs);
3548 Diag(EndLoc, diag::err_expected)
3552 Diag(EndLoc, diag::err_expected)
3564 AccessAttrs.
clear();
3570 case tok::annot_attr_openmp:
3571 case tok::annot_pragma_openmp:
3572 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3574 case tok::annot_pragma_openacc:
3582 ConsumeAnnotationToken();
3585 return ParseCXXClassMemberDeclaration(AS, AccessAttrs);
3602 "Invalid TagType!");
3604 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3605 if (
auto *TD = dyn_cast_or_null<NamedDecl>(
TagDecl))
3606 return TD->getQualifiedNameAsString();
3607 return std::string(
"<anonymous>");
3611 "parsing struct/union/class body");
3615 bool NonNestedClass =
true;
3616 if (!ClassStack.empty()) {
3618 if (S->isClassScope()) {
3620 NonNestedClass =
false;
3623 if (getCurrentClass().IsInterface) {
3627 ? cast<NamedDecl>(
TagDecl)->getQualifiedNameAsString()
3633 if (S->isFunctionScope())
3644 ParsingClassDefinition ParsingDef(*
this,
TagDecl, NonNestedClass,
3652 bool IsFinalSpelledSealed =
false;
3653 bool IsAbstract =
false;
3661 if (isCXX11FinalKeyword()) {
3664 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3669 IsFinalSpelledSealed =
true;
3674 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3682 Diag(FinalLoc, diag::err_override_control_interface)
3686 ? diag::warn_cxx98_compat_override_control_keyword
3687 : diag::ext_override_control_keyword)
3690 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3692 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3694 Diag(FinalLoc, diag::ext_warn_gnu_final);
3697 "not a class definition");
3703 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3712 if (!Tok.
is(tok::colon) && !Tok.
is(tok::l_brace)) {
3719 if (Tok.
is(tok::colon)) {
3720 ParseScope InheritanceScope(
this,
getCurScope()->getFlags() |
3724 if (!Tok.
is(tok::l_brace)) {
3725 bool SuggestFixIt =
false;
3729 case tok::kw_private:
3730 case tok::kw_protected:
3731 case tok::kw_public:
3734 case tok::kw_static_assert:
3738 case tok::kw_template:
3739 SuggestFixIt =
true;
3741 case tok::identifier:
3742 SuggestFixIt = isConstructorDeclarator(
true);
3745 SuggestFixIt = isCXXSimpleDeclaration(
false);
3750 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3764 assert(Tok.
is(tok::l_brace));
3770 IsFinalSpelledSealed, IsAbstract,
3771 T.getOpenLocation());
3786 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3787 Tok.
isNot(tok::eof)) {
3789 ParseCXXClassMemberDeclarationWithPragmas(
3791 MaybeDestroyTemplateIds();
3800 MaybeParseGNUAttributes(attrs);
3804 T.getOpenLocation(),
3805 T.getCloseLocation(), attrs);
3812 if (
TagDecl && NonNestedClass) {
3819 ParseLexedPragmas(getCurrentClass());
3820 ParseLexedAttributes(getCurrentClass());
3821 ParseLexedMethodDeclarations(getCurrentClass());
3826 ParseLexedMemberInitializers(getCurrentClass());
3827 ParseLexedMethodDefs(getCurrentClass());
3828 PrevTokLocation = SavedPrevTokLocation;
3843void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3844 assert(Tok.
is(tok::kw_namespace));
3849 Diag(Tok.
getLocation(), diag::note_missing_end_of_definition_before) << D;
3883void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3884 assert(Tok.
is(tok::colon) &&
3885 "Constructor initializer always starts with ':'");
3893 bool AnyErrors =
false;
3896 if (Tok.
is(tok::code_completion)) {
3903 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3905 MemInitializers.push_back(MemInit.
get());
3909 if (Tok.
is(tok::comma))
3911 else if (Tok.
is(tok::l_brace))
3916 Tok.
isOneOf(tok::identifier, tok::coloncolon)) {
3918 Diag(Loc, diag::err_ctor_init_missing_comma)
3924 << tok::l_brace << tok::comma;
3949 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
3962 if (Tok.
is(tok::identifier)) {
3967 }
else if (Tok.
is(tok::annot_decltype)) {
3972 ParseDecltypeSpecifier(DS);
3973 }
else if (Tok.
is(tok::annot_pack_indexing_type)) {
3976 ParsePackIndexingType(DS);
3979 ? takeTemplateIdAnnotation(Tok)
3984 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
3986 ConsumeAnnotationToken();
3988 Diag(Tok, diag::err_expected_member_or_base_name);
3995 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3998 ExprResult InitList = ParseBraceInitializer();
4008 TemplateTypeTy.
get(), DS, IdLoc,
4009 InitList.
get(), EllipsisLoc);
4010 }
else if (Tok.
is(tok::l_paren)) {
4015 ExprVector ArgExprs;
4016 auto RunSignatureHelp = [&] {
4020 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
4021 T.getOpenLocation(),
false);
4022 CalledSignatureHelp =
true;
4023 return PreferredType;
4025 if (Tok.
isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
4026 PreferredType.enterFunctionArgument(Tok.
getLocation(),
4043 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
4044 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
4051 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
4053 return Diag(Tok, diag::err_expected) << tok::l_paren;
4071 ExceptionSpecTokens =
nullptr;
4075 if (Tok.
isNot(tok::kw_throw) && Tok.
isNot(tok::kw_noexcept))
4079 bool IsNoexcept = Tok.
is(tok::kw_noexcept);
4080 Token StartTok = Tok;
4084 if (!Tok.
is(tok::l_paren)) {
4087 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4088 NoexceptExpr =
nullptr;
4092 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4098 ExceptionSpecTokens->push_back(StartTok);
4099 ExceptionSpecTokens->push_back(Tok);
4100 SpecificationRange.
setEnd(ConsumeParen());
4102 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4105 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4111 if (Tok.
is(tok::kw_throw)) {
4112 Result = ParseDynamicExceptionSpecification(
4113 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4114 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4115 "Produced different number of exception types and ranges.");
4119 if (Tok.
isNot(tok::kw_noexcept))
4122 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4130 if (Tok.
is(tok::l_paren)) {
4143 NoexceptRange =
SourceRange(KeywordLoc,
T.getCloseLocation());
4150 NoexceptRange =
SourceRange(KeywordLoc, KeywordLoc);
4154 SpecificationRange = NoexceptRange;
4159 if (Tok.
is(tok::kw_throw)) {
4160 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4161 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4162 DynamicExceptionRanges);
4165 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4173 if (
P.getLangOpts().CPlusPlus11) {
4174 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4175 P.Diag(Range.getBegin(),
P.getLangOpts().CPlusPlus17 && !IsNoexcept
4176 ? diag::ext_dynamic_exception_spec
4177 : diag::warn_exception_spec_deprecated)
4179 P.Diag(Range.getBegin(), diag::note_exception_spec_deprecated)
4198 assert(Tok.
is(tok::kw_throw) &&
"expected throw");
4202 if (
T.consumeOpen()) {
4203 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4210 if (Tok.
is(tok::ellipsis)) {
4213 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4215 SpecificationRange.
setEnd(
T.getCloseLocation());
4222 while (Tok.
isNot(tok::r_paren)) {
4225 if (Tok.
is(tok::ellipsis)) {
4230 Range.setEnd(Ellipsis);
4231 if (!Res.isInvalid())
4235 if (!Res.isInvalid()) {
4236 Exceptions.push_back(Res.get());
4237 Ranges.push_back(Range);
4245 SpecificationRange.
setEnd(
T.getCloseLocation());
4247 Exceptions.empty());
4254 bool MayBeFollowedByDirectInit) {
4255 assert(Tok.
is(tok::arrow) &&
"expected arrow");
4265void Parser::ParseTrailingRequiresClause(
Declarator &D) {
4266 assert(Tok.
is(tok::kw_requires) &&
"expected requires");
4284 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4286 DeclScopeObj.EnterDeclaratorScope();
4295 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4296 InitCXXThisScopeForDeclaratorIfRelevant(D, D.
getDeclSpec(), ThisScope);
4298 TrailingRequiresClause =
4301 TrailingRequiresClause =
4306 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4311 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4322 ParseTrailingReturnType(Range,
false);
4326 diag::err_requires_clause_must_appear_after_trailing_return)
4330 FunctionChunk.TrailingReturnType = TrailingReturnType.
get();
4331 FunctionChunk.TrailingReturnTypeLoc =
Range.getBegin();
4333 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4342 bool NonNestedClass,
4344 assert((NonNestedClass || !ClassStack.empty()) &&
4345 "Nested class without outer class");
4346 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4352void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4353 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4354 delete Class->LateParsedDeclarations[I];
4365 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4369 ParsingClass *Victim = ClassStack.top();
4371 if (Victim->TopLevelClass) {
4374 DeallocateParsedClasses(Victim);
4377 assert(!ClassStack.empty() &&
"Missing top-level class?");
4379 if (Victim->LateParsedDeclarations.empty()) {
4384 DeallocateParsedClasses(Victim);
4392 "Nested class outside of class scope?");
4393 ClassStack.top()->LateParsedDeclarations.push_back(
4394 new LateParsedClass(
this, Victim));
4421 case tok::code_completion:
4428 case tok::numeric_constant: {
4436 StringRef Spelling = PP.
getSpelling(ExpansionLoc, ExpansionBuf);
4437 if (Spelling ==
"__clang__") {
4441 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4457 case tok::pipeequal:
4458 case tok::caretequal:
4460 case tok::exclaimequal:
4466 StringRef Spelling = PP.
getSpelling(SpellingLoc, SpellingBuf);
4475void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4480 if (
T.consumeOpen()) {
4481 Diag(Tok, diag::err_expected) << tok::l_paren;
4485 if (AttrName->
isStr(
"directive")) {
4491 OMPBeginTok.
setKind(tok::annot_attr_openmp);
4493 OpenMPTokens.push_back(OMPBeginTok);
4495 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4499 OMPEndTok.
setKind(tok::annot_pragma_openmp_end);
4501 OpenMPTokens.push_back(OMPEndTok);
4503 assert(AttrName->
isStr(
"sequence") &&
4504 "Expected either 'directive' or 'sequence'");
4513 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4517 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4518 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4522 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4529 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4543 case ParsedAttr::AT_CarriesDependency:
4544 case ParsedAttr::AT_Deprecated:
4545 case ParsedAttr::AT_FallThrough:
4546 case ParsedAttr::AT_CXX11NoReturn:
4547 case ParsedAttr::AT_NoUniqueAddress:
4548 case ParsedAttr::AT_Likely:
4549 case ParsedAttr::AT_Unlikely:
4551 case ParsedAttr::AT_WarnUnusedResult:
4552 return !ScopeName && AttrName->
getName().equals(
"nodiscard");
4553 case ParsedAttr::AT_Unused:
4554 return !ScopeName && AttrName->
getName().equals(
"maybe_unused");
4565 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4573 TentativeParsingAction TPA(*
this);
4576 if (Res.isInvalid()) {
4579 if (Tok.
is(tok::r_paren))
4584 if (!Tok.
isOneOf(tok::r_paren, tok::r_square)) {
4589 if (!Res.isInvalid()) {
4590 auto *E = Res.get();
4629bool Parser::ParseCXX11AttributeArgs(
4633 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4637 LO.CPlusPlus ? ParsedAttr::Form::CXX11() :
ParsedAttr::Form::
C23();
4643 Form = ParsedAttr::Form::Microsoft();
4658 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4661 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4662 ScopeLoc, Form,
nullptr);
4667 if (ScopeName && ScopeName->
isStr(
"omp") &&
4668 (AttrName->
isStr(
"directive") || AttrName->
isStr(
"sequence"))) {
4670 ? diag::warn_omp51_compat_attributes
4671 : diag::ext_omp_attributes);
4673 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4682 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4683 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4684 ScopeName, ScopeLoc, Form);
4686 else if (!ScopeName && AttrName->
isStr(
"assume")) {
4687 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc))
4691 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4692 ScopeName, ScopeLoc, Form);
4694 if (!Attrs.
empty() &&
4700 Diag(LParenLoc, diag::warn_unknown_attribute_ignored) << AttrName;
4701 Attr.setInvalid(
true);
4709 if (
Attr.getMaxArgs() && !NumArgs) {
4712 Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
4713 Attr.setInvalid(
true);
4714 }
else if (!
Attr.getMaxArgs()) {
4718 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4721 Attr.setInvalid(
true);
4754 if (Tok.
is(tok::kw_alignas)) {
4761 ParseAlignmentSpecifier(Attrs, EndLoc);
4772 if (!Tok.
is(tok::l_paren))
4775 ParseAttributeArgsCommon(AttrName, Loc, Attrs, EndLoc,
4779 Attrs.
addNew(AttrName, Loc,
nullptr, Loc,
nullptr, 0, Form);
4783 assert(Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square) &&
4784 "Not a double square bracket attribute list");
4789 : diag::warn_ext_cxx11_attributes);
4792 : diag::warn_ext_c23_attributes);
4796 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4801 if (Tok.
is(tok::kw_using)) {
4803 ? diag::warn_cxx14_compat_using_attribute_ns
4804 : diag::ext_using_attribute_ns);
4807 CommonScopeName = TryParseCXX11AttributeIdentifier(
4809 if (!CommonScopeName) {
4817 bool AttrParsed =
false;
4818 while (!Tok.
isOneOf(tok::r_square, tok::semi, tok::eof)) {
4822 if (ExpectAndConsume(tok::comma)) {
4836 AttrName = TryParseCXX11AttributeIdentifier(
4844 ScopeName = AttrName;
4847 AttrName = TryParseCXX11AttributeIdentifier(
4856 if (CommonScopeName) {
4858 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4861 ScopeName = CommonScopeName;
4862 ScopeLoc = CommonScopeLoc;
4867 if (Tok.
is(tok::l_paren))
4868 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
4869 ScopeName, ScopeLoc, OpenMPTokens);
4875 ScopeName, ScopeLoc,
nullptr, 0,
4877 : ParsedAttr::Form::C23());
4882 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) << AttrName;
4887 if (Tok.
is(tok::semi)) {
4893 if (ExpectAndConsume(tok::r_square))
4895 else if (Tok.
is(tok::r_square))
4896 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
4899 if (ExpectAndConsume(tok::r_square))
4912 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
4913 }
while (isAllowedCXX11AttributeSpecifier());
4918void Parser::DiagnoseAndSkipCXX11Attributes() {
4927 (Keyword ?
Diag(StartLoc, diag::err_keyword_not_allowed) << Keyword
4928 :
Diag(StartLoc, diag::err_attributes_not_allowed))
4936 if (!isCXX11AttributeSpecifier())
4940 if (Tok.
is(tok::l_square)) {
4944 EndLoc =
T.getCloseLocation();
4951 "not an attribute specifier");
4954 if (!
T.consumeOpen())
4956 EndLoc =
T.getCloseLocation();
4958 }
while (isCXX11AttributeSpecifier());
4965 assert(Tok.
is(tok::identifier) &&
"Not a Microsoft attribute list");
4967 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
4974 if (
T.consumeOpen()) {
4975 Diag(Tok, diag::err_expected) << tok::l_paren;
4980 if (isTokenStringLiteral()) {
4985 ArgExprs.push_back(StringResult.
get());
5002 while (Tok.
isNot(tok::r_paren)) {
5004 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5009 SpellingBuffer.resize(Tok.
getLength() + 1);
5011 StringRef TokSpelling = PP.
getSpelling(Tok, SpellingBuffer, &Invalid);
5016 StrBuffer += TokSpelling;
5022 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5032 Toks[0].
setKind(tok::string_literal);
5038 ArgExprs.push_back(UuidString);
5041 if (!
T.consumeClose()) {
5044 ParsedAttr::Form::Microsoft());
5057 assert(Tok.
is(tok::l_square) &&
"Not a Microsoft attribute list");
5068 SkipUntil(tok::r_square, tok::identifier,
5070 if (Tok.
is(tok::code_completion)) {
5077 if (Tok.
isNot(tok::identifier))
5080 ParseMicrosoftUuidAttributeArgs(Attrs);
5090 bool AttrParsed =
false;
5091 if (Tok.
is(tok::l_paren)) {
5094 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5096 ReplayOpenMPAttributeTokens(OpenMPTokens);
5100 ParsedAttr::Form::Microsoft());
5107 EndLoc =
T.getCloseLocation();
5108 }
while (Tok.
is(tok::l_square));
5113void Parser::ParseMicrosoftIfExistsClassDeclaration(
5116 IfExistsCondition
Result;
5117 if (ParseMicrosoftIfExistsCondition(
Result))
5121 if (
Braces.consumeOpen()) {
5122 Diag(Tok, diag::err_expected) << tok::l_brace;
5126 switch (
Result.Behavior) {
5132 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5142 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
5144 if (Tok.
isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5145 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, CurAS);
5150 if (Tok.
is(tok::semi)) {
5151 ConsumeExtraSemi(InsideStruct,
TagType);
5161 if (Tok.
is(tok::colon))
5165 Diag(Tok, diag::err_expected) << tok::colon;
5171 ParseCXXClassMemberDeclaration(CurAS, AccessAttrs);
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
llvm::MachO::RecordLoc RecordLoc
Defines an enumeration for C++ overloaded operators.
static void diagnoseDynamicExceptionSpecification(Parser &P, SourceRange Range, bool IsNoexcept)
static bool IsBuiltInOrStandardCXX11Attribute(IdentifierInfo *AttrName, IdentifierInfo *ScopeName)
static FixItHint getStaticAssertNoMessageFixIt(const Expr *AssertExpr, SourceLocation EndExprLoc)
Defines the clang::TokenKind enum and support functions.
#define TRANSFORM_TYPE_TRAIT_DEF(Enum, _)
const NestedNameSpecifier * Specifier
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const clang::PrintingPolicy & getPrintingPolicy() const
Attr - This represents one attribute.
@ AS_Microsoft
[uuid("...")] class Foo
Kind getParsedKind() 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.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
void setTemplateParamLists(ArrayRef< TemplateParameterList * > L)
Represents a character-granular source range.
static CharSourceRange getTokenRange(SourceRange R)
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
Captures information about "declaration specifiers".
void setTypeArgumentRange(SourceRange range)
static const TST TST_typename
void ClearStorageClassSpecs()
TST getTypeSpecType() const
SCS getStorageClassSpec() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
SourceRange getSourceRange() const LLVM_READONLY
void SetPackIndexingExpr(SourceLocation EllipsisLoc, Expr *Pack)
void SetRangeEnd(SourceLocation Loc)
static const TST TST_interface
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void SetRangeStart(SourceLocation Loc)
static const TST TST_union
static const TST TST_typename_pack_indexing
SourceLocation getFriendSpecLoc() const
SourceLocation getModulePrivateSpecLoc() const
Expr * getRepAsExpr() const
static const TST TST_decltype
static const TST TST_class
bool hasTagDefinition() const
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
Decl * getRepAsDecl() const
CXXScopeSpec & getTypeSpecScope()
static const TST TST_decltype_auto
void setExternInLinkageSpec(bool Value)
static const TST TST_error
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
FriendSpecified isFriendSpecified() const
void takeAttributesFrom(ParsedAttributes &attrs)
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInvalidDecl() const
SourceLocation getLocation() const
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const ParsedAttributes & getAttributes() const
SourceLocation getIdentifierLoc() const
void SetIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
void setTrailingRequiresClause(Expr *TRC)
Sets a trailing requires clause for this declarator.
void setTemplateParameterLists(ArrayRef< TemplateParameterList * > TPLs)
Sets the template parameter lists that preceded the declarator.
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
void setAsmLabel(Expr *E)
void ExtendWithDeclSpec(const DeclSpec &DS)
ExtendWithDeclSpec - Extend the declarator source range to include the given declspec,...
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
A little helper class used to produce diagnostics.
RAII object that enters a new expression evaluation context.
Represents a standard C++ module export declaration.
This represents one expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location.
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.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
This represents a decl that may have a name.
Wrapper for void* pointer.
static OpaquePtr make(PtrTy P)
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing,...
ParsedAttr - Represents a syntactic attribute.
static const ParsedAttributesView & none()
void addAll(iterator B, iterator E)
ParsedAttributes - A collection of parsed attributes.
ParsedAttr * addNew(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
void takeAllFrom(ParsedAttributes &Other)
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.
DeclGroupPtrTy ParseOpenACCDirectiveDecl()
Placeholder for now, should just ignore the directives after emitting a diagnostic.
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.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
ExprResult ParseConstantExpression()
ExprResult ParseConditionalExpression()
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
const TargetInfo & getTargetInfo() 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 ...
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
friend class ObjCDeclContextSwitch
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
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.
@ StopAtCodeCompletion
Stop at code completion.
@ StopAtSemi
Stop skipping at semicolon.
ExprResult ParseUnevaluatedStringLiteralExpression()
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
RAII object used to inform the actions that we're currently parsing a declaration.
A class for parsing a DeclSpec.
A class for parsing a declarator.
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...
SourceManager & getSourceManager() const
bool isBacktrackEnabled() const
True if EnableBacktrackAtThisPos() was called and caching of tokens is on.
void RevertCachedTokens(unsigned N)
When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens...
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
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.
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
Represents a struct/union/class.
Scope - A scope is a transient data structure that is used while parsing the program.
unsigned getFlags() const
getFlags - Return the flags for this scope.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ TypeAliasScope
This is a scope of type alias declaration.
@ ClassInheritanceScope
We are between inheritance colon and the real class/struct definition scope.
@ ClassScope
The scope of a struct/union/class definition.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
@ DeclScope
This is a scope that can contain a declaration.
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, CXXScopeSpec &SS, TemplateIdAnnotation &TemplateId, const ParsedAttributesView &Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
void PopParsingClass(ParsingClassState state)
void CodeCompleteTag(Scope *S, unsigned TagSpec)
void CodeCompleteUsing(Scope *S)
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
void ActOnFinishCXXNonNestedClass()
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, const IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, const ParsedAttributesView &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation IdentLoc, IdentifierInfo &II, CXXScopeSpec *SS=nullptr)
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
ASTContext & getASTContext() const
Decl * ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, SourceLocation LBraceLoc)
We have parsed the start of an export declaration, including the '{' (if present).
ParsingClassState PushParsingClass()
void CodeCompleteUsingDirective(Scope *S)
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl, bool IsNested)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier * > Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr, ExceptionSpecificationType &EST)
Check the given noexcept-specifier, convert its expression, and compute the appropriate ExceptionSpec...
void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void CodeCompleteNamespaceDecl(Scope *S)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
void CodeCompleteNamespaceAliasDecl(Scope *S)
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
void CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax, AttributeCompletion Completion=AttributeCompletion::Attribute, const IdentifierInfo *Scope=nullptr)
bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
QualType ProduceCtorInitMemberSignatureHelp(Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy, ArrayRef< Expr * > ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc, bool Braced)
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e....
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer * > MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
TypeResult ActOnTypeName(Declarator &D)
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
void ActOnUndeclaredTypeTemplateName(Scope *S, TemplateTy &Name, TemplateNameKind &TNK, SourceLocation NameLoc, IdentifierInfo *&II)
Try to resolve an undeclared template name as a type template.
ParsedType getInheritingConstructorName(CXXScopeSpec &SS, SourceLocation NameLoc, const IdentifierInfo &Name)
Handle the result of the special case name lookup for inheriting constructor declarations.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, const ParsedAttributesView &Attr)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ 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),...
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, const ParsedAttributesView &DeclAttrs, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e....
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
void CodeCompleteAfterFunctionEquals(Declarator &D)
void ActOnUninitializedDecl(Decl *dcl)
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
Decl * ActOnFinishExportDecl(Scope *S, Decl *ExportDecl, SourceLocation RBraceLoc)
Complete the definition of an export declaration.
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
ExprResult ActOnDecltypeExpression(Expr *E)
Process the expression contained within a decltype.
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.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getBegin() const
void setEnd(SourceLocation e)
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
A RAII object used to temporarily suppress access-like checking.
Represents the declaration of a struct/union/class/enum.
Represents a C++ template name within the type system.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
void setLiteralData(const char *Ptr)
SourceLocation getEndLoc() 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)) {....
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,...
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
void setLocation(SourceLocation L)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void startToken()
Reset all flags to cleared.
The base class of the type hierarchy.
Represents a C++ unqualified-id that has been parsed.
Represents C++ using-directive.
Declaration of a variable template.
Represents a C++11 virt-specifier-seq.
Specifier getLastSpecifier() const
SourceLocation getFirstLocation() const
SourceLocation getAbstractLoc() const
static const char * getSpecifierName(Specifier VS)
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
Defines the clang::TargetInfo interface.
@ After
Like System, but searched after the system directories.
bool Zero(InterpState &S, CodePtr OpPC)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
constexpr bool isRegularKeywordAttribute(TokenKind K)
bool isPragmaAnnotation(TokenKind K)
Return true if this is an annotation token representing a pragma.
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
bool doesKeywordAttributeTakeArgs(tok::TokenKind Kind)
FunctionDefinitionKind
Described the kind of function definition (if any) provided for a function.
InClassInitStyle
In-class initialization styles for non-static data members.
@ ICIS_CopyInit
Copy initialization.
@ ICIS_ListInit
Direct list-initialization.
@ ICIS_NoInit
No in-class initializer.
bool tokenIsLikeStringLiteral(const Token &Tok, const LangOptions &LO)
Return true if the token is a string literal, or a function local predefined macro,...
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an ParsedAttr as an argument.
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_Identifier
An identifier.
LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
@ Result
The result type of a method or function.
ActionResult< Expr * > ExprResult
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
int hasAttribute(AttributeCommonInfo::Syntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
@ TNK_Non_template
The name does not refer to a template.
@ TNK_Undeclared_template
Lookup for the name failed, but we're assuming it was a template name anyway.
const FunctionProtoType * T
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Braces
New-expression has a C++11 list-initializer.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Unparsed
not parsed yet
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_Dynamic
throw(T1, T2)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
Describes how types, statements, expressions, and declarations should be printed.
Information about a template-id annotation token.
const IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
TemplateNameKind Kind
The kind of template that Template refers to.
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.
bool mightBeType() const
Determine whether this might be a type template.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.