31#include "llvm/ADT/SmallString.h"
32#include "llvm/Support/TimeProfiler.h"
67 assert(Tok.
is(tok::kw_namespace) &&
"Not a namespace!");
71 if (Tok.
is(tok::code_completion)) {
79 InnerNamespaceInfoList ExtraNSs;
84 auto ReadAttributes = [&] {
88 if (Tok.
is(tok::kw___attribute)) {
89 ParseGNUAttributes(attrs);
94 ? diag::warn_cxx14_compat_ns_enum_attribute
95 : diag::ext_ns_enum_attribute)
97 ParseCXX11Attributes(attrs);
100 }
while (MoreToParse);
105 if (Tok.
is(tok::identifier)) {
108 while (Tok.
is(tok::coloncolon) &&
111 GetLookAheadToken(2).is(tok::identifier)))) {
113 InnerNamespaceInfo Info;
116 if (Tok.
is(tok::kw_inline)) {
119 FirstNestedInlineLoc = Info.InlineLoc;
125 ExtraNSs.push_back(Info);
134 if (!ExtraNSs.empty() && attrLoc.
isValid())
135 Diag(attrLoc, diag::err_unexpected_nested_namespace_attribute);
137 if (Tok.
is(tok::equal)) {
139 Diag(Tok, diag::err_expected) << tok::identifier;
144 if (!ExtraNSs.empty()) {
145 Diag(ExtraNSs.front().NamespaceLoc,
146 diag::err_unexpected_qualified_namespace_alias)
148 ExtraNSs.back().IdentLoc);
153 Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
155 Diag(InlineLoc, diag::err_inline_namespace_alias)
157 Decl *NSAlias = ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd);
162 if (
T.consumeOpen()) {
164 Diag(Tok, diag::err_expected) << tok::l_brace;
166 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
173 Diag(
T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
178 if (ExtraNSs.empty()) {
180 }
else if (InlineLoc.
isValid()) {
181 Diag(InlineLoc, diag::err_inline_nested_namespace_definition);
183 Diag(ExtraNSs[0].NamespaceLoc,
184 diag::warn_cxx14_compat_nested_namespace_definition);
185 if (FirstNestedInlineLoc.
isValid())
186 Diag(FirstNestedInlineLoc,
187 diag::warn_cxx17_compat_inline_nested_namespace_definition);
189 Diag(ExtraNSs[0].NamespaceLoc,
190 diag::warn_cxx14_compat_nested_namespace_definition);
191 if (FirstNestedInlineLoc.
isValid())
192 Diag(FirstNestedInlineLoc, diag::ext_inline_nested_namespace_definition);
194 TentativeParsingAction TPA(*
this);
196 Token rBraceToken = Tok;
199 if (!rBraceToken.
is(tok::r_brace)) {
200 Diag(ExtraNSs[0].NamespaceLoc, diag::ext_nested_namespace_definition)
202 ExtraNSs.back().IdentLoc);
204 std::string NamespaceFix;
205 for (
const auto &ExtraNS : ExtraNSs) {
206 NamespaceFix +=
" { ";
207 if (ExtraNS.InlineLoc.isValid())
208 NamespaceFix +=
"inline ";
209 NamespaceFix +=
"namespace ";
210 NamespaceFix += ExtraNS.Ident->getName();
214 for (
unsigned i = 0, e = ExtraNSs.size(); i != e; ++i)
217 Diag(ExtraNSs[0].NamespaceLoc, diag::ext_nested_namespace_definition)
220 ExtraNSs.back().IdentLoc),
226 if (FirstNestedInlineLoc.
isValid())
227 Diag(FirstNestedInlineLoc, diag::ext_inline_nested_namespace_definition);
233 ? diag::warn_cxx98_compat_inline_namespace
234 : diag::ext_inline_namespace);
241 getCurScope(), InlineLoc, NamespaceLoc, IdentLoc, Ident,
242 T.getOpenLocation(), attrs, ImplicitUsingDirectiveDecl,
false);
245 NamespaceLoc,
"parsing namespace");
249 ParseInnerNamespace(ExtraNSs, 0, InlineLoc, attrs,
T);
252 NamespaceScope.Exit();
254 DeclEnd =
T.getCloseLocation();
258 ImplicitUsingDirectiveDecl);
262void Parser::ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
266 if (index == InnerNSs.size()) {
267 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
268 Tok.
isNot(tok::eof)) {
270 MaybeParseCXX11Attributes(DeclAttrs);
272 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
288 getCurScope(), InnerNSs[index].InlineLoc, InnerNSs[index].NamespaceLoc,
289 InnerNSs[index].IdentLoc, InnerNSs[index].Ident,
291 assert(!ImplicitUsingDirectiveDecl &&
292 "nested namespace definition cannot define anonymous namespace");
294 ParseInnerNamespace(InnerNSs, ++index, InlineLoc, attrs, Tracker);
296 NamespaceScope.Exit();
307 assert(Tok.
is(tok::equal) &&
"Not equal token");
311 if (Tok.
is(tok::code_completion)) {
319 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
327 if (Tok.
isNot(tok::identifier)) {
328 Diag(Tok, diag::err_expected_namespace_name);
347 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name))
351 Alias, SS, IdentLoc, Ident);
362 assert(isTokenStringLiteral() &&
"Not a string literal!");
376 while (MaybeParseCXX11Attributes(DeclAttrs) ||
377 MaybeParseGNUAttributes(DeclSpecAttrs))
380 if (Tok.
isNot(tok::l_brace)) {
387 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs, &DS);
395 ProhibitAttributes(DeclAttrs);
400 unsigned NestedModules = 0;
403 case tok::annot_module_begin:
408 case tok::annot_module_end:
415 case tok::annot_module_include:
429 while (MaybeParseCXX11Attributes(DeclAttrs) ||
430 MaybeParseGNUAttributes(DeclSpecAttrs))
432 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
459Decl *Parser::ParseExportDeclaration() {
460 assert(Tok.
is(tok::kw_export));
468 if (Tok.
isNot(tok::l_brace)) {
471 MaybeParseCXX11Attributes(DeclAttrs);
473 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
481 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
482 Tok.
isNot(tok::eof)) {
484 MaybeParseCXX11Attributes(DeclAttrs);
486 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
491 T.getCloseLocation());
499 assert(Tok.
is(tok::kw_using) &&
"Not using token");
505 if (Tok.
is(tok::code_completion)) {
512 while (Tok.
is(tok::kw_template)) {
514 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
519 if (Tok.
is(tok::kw_namespace)) {
521 if (TemplateInfo.Kind) {
523 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
527 Decl *UsingDir = ParseUsingDirective(Context, UsingLoc, DeclEnd, Attrs);
532 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, Attrs,
550 assert(Tok.
is(tok::kw_namespace) &&
"Not 'namespace' token");
555 if (Tok.
is(tok::code_completion)) {
563 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
575 if (Tok.
isNot(tok::identifier)) {
576 Diag(Tok, diag::err_expected_namespace_name);
595 bool GNUAttr =
false;
596 if (Tok.
is(tok::kw___attribute)) {
598 ParseGNUAttributes(attrs);
603 if (ExpectAndConsume(tok::semi,
604 GNUAttr ? diag::err_expected_semi_after_attribute_list
605 : diag::err_expected_semi_after_namespace_name))
609 IdentLoc, NamespcName, attrs);
618 UsingDeclarator &
D) {
625 if (Tok.
is(tok::kw___super)) {
632 if (ParseOptionalCXXScopeSpecifier(
D.SS,
nullptr,
642 if (
D.SS.isInvalid())
656 Tok.
is(tok::identifier) &&
662 !
D.SS.getScopeRep()->getAsNamespace() &&
663 !
D.SS.getScopeRep()->getAsNamespaceAlias()) {
667 D.Name.setConstructorName(
Type, IdLoc, IdLoc);
674 !(Tok.
is(tok::identifier) &&
NextToken().is(tok::equal)),
675 false,
nullptr,
D.Name))
681 ? diag::warn_cxx17_compat_using_declaration_pack
682 : diag::ext_using_declaration_pack);
721 ? diag::warn_cxx17_compat_using_enum_declaration
722 : diag::ext_using_enum_declaration);
724 DiagnoseCXX11AttributeExtension(PrefixAttrs);
726 if (TemplateInfo.Kind) {
728 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
734 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
746 if (Tok.
is(tok::code_completion)) {
756 if (Tok.
is(tok::identifier)) {
768 }
else if (Tok.
is(tok::annot_template_id)) {
775 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
778 ConsumeAnnotationToken();
790 << Tok.
is(tok::kw_enum);
801 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
802 "using-enum declaration"))
811 MaybeParseCXX11Attributes(MisplacedAttrs);
813 if (InInitStatement && Tok.
isNot(tok::identifier))
817 bool InvalidDeclarator = ParseUsingDeclarator(Context,
D);
820 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
824 if (MisplacedAttrs.Range.isValid()) {
826 MisplacedAttrs.empty() ? nullptr : &MisplacedAttrs.front();
827 auto &
Range = MisplacedAttrs.Range;
828 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
838 if (Tok.
is(tok::equal) || InInitStatement) {
839 if (InvalidDeclarator) {
844 ProhibitAttributes(PrefixAttrs);
846 Decl *DeclFromDeclSpec =
nullptr;
852 Decl *AD = ParseAliasDeclarationAfterDeclarator(
853 TemplateInfo, UsingLoc,
D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
857 DiagnoseCXX11AttributeExtension(PrefixAttrs);
862 if (TemplateInfo.Kind) {
864 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
876 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
877 DiagnoseCXX11AttributeExtension(Attrs);
880 if (InvalidDeclarator)
885 if (
D.TypenameLoc.isValid() &&
888 diag::err_typename_identifiers_only)
895 D.TypenameLoc,
D.SS,
D.Name,
896 D.EllipsisLoc, Attrs);
898 DeclsInGroup.push_back(UD);
906 InvalidDeclarator = ParseUsingDeclarator(Context,
D);
909 if (DeclsInGroup.size() > 1)
912 ? diag::warn_cxx17_compat_multi_using_declaration
913 : diag::ext_multi_using_declaration);
917 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
918 !Attrs.
empty() ?
"attributes list"
919 : UELoc.
isValid() ?
"using-enum declaration"
920 :
"using declaration"))
926Decl *Parser::ParseAliasDeclarationAfterDeclarator(
930 if (ExpectAndConsume(tok::equal)) {
936 ? diag::warn_cxx98_compat_alias_declaration
937 : diag::ext_alias_declaration);
941 if (TemplateInfo.Kind == ParsedTemplateInfo::Template &&
944 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization)
946 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
948 if (SpecKind != -1) {
952 D.Name.TemplateId->RAngleLoc);
954 Range = TemplateInfo.getSourceRange();
956 << SpecKind <<
Range;
963 Diag(
D.Name.StartLocation, diag::err_alias_declaration_not_identifier);
967 }
else if (
D.TypenameLoc.isValid())
968 Diag(
D.TypenameLoc, diag::err_alias_declaration_not_identifier)
972 else if (
D.SS.isNotEmpty())
975 if (
D.EllipsisLoc.isValid())
976 Diag(
D.EllipsisLoc, diag::err_alias_declaration_pack_expansion)
979 Decl *DeclFromDeclSpec =
nullptr;
984 AS, &DeclFromDeclSpec, &Attrs);
986 *OwnedType = DeclFromDeclSpec;
990 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
991 !Attrs.
empty() ?
"attributes list"
992 :
"alias declaration"))
997 TemplateParams ? TemplateParams->data() :
nullptr,
998 TemplateParams ? TemplateParams->size() : 0);
1000 UsingLoc,
D.Name, Attrs, TypeAlias,
1006 if (
const auto *BO = dyn_cast_or_null<BinaryOperator>(AssertExpr)) {
1007 if (BO->getOpcode() == BO_LAnd &&
1008 isa<StringLiteral>(BO->getRHS()->IgnoreImpCasts()))
1023 assert(Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
1024 "Not a static_assert declaration");
1027 const char *TokName = Tok.
getName();
1029 if (Tok.
is(tok::kw__Static_assert))
1030 diagnoseUseOfC11Keyword(Tok);
1031 else if (Tok.
is(tok::kw_static_assert)) {
1034 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
1039 Diag(Tok, diag::warn_cxx98_compat_static_assert);
1045 if (
T.consumeOpen()) {
1046 Diag(Tok, diag::err_expected) << tok::l_paren;
1054 if (AssertExpr.isInvalid()) {
1060 if (Tok.
is(tok::r_paren)) {
1063 DiagVal = diag::warn_cxx14_compat_static_assert_no_message;
1065 DiagVal = diag::ext_cxx_static_assert_no_message;
1067 DiagVal = diag::warn_c17_compat_static_assert_no_message;
1069 DiagVal = diag::ext_c_static_assert_no_message;
1073 if (ExpectAndConsume(tok::comma)) {
1078 bool ParseAsExpression =
false;
1080 for (
unsigned I = 0;; ++I) {
1081 const Token &
T = GetLookAheadToken(I);
1082 if (
T.is(tok::r_paren))
1085 ParseAsExpression =
true;
1091 if (ParseAsExpression)
1096 Diag(Tok, diag::err_expected_string_literal)
1111 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
1114 AssertMessage.
get(),
1115 T.getCloseLocation());
1124 assert(Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype) &&
1125 "Not a decltype specifier");
1131 if (Tok.
is(tok::annot_decltype)) {
1132 Result = getExprAnnotation(Tok);
1137 ConsumeAnnotationToken();
1138 if (
Result.isInvalid()) {
1144 Diag(Tok, diag::warn_cxx98_compat_decltype);
1149 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"decltype",
1152 return T.getOpenLocation() == Tok.
getLocation() ? StartLoc
1153 :
T.getOpenLocation();
1157 if (Tok.
is(tok::kw_auto) &&
NextToken().is(tok::r_paren)) {
1162 ? diag::warn_cxx11_compat_decltype_auto_type_specifier
1163 : diag::ext_decltype_auto_type_specifier);
1177 if (
Result.isInvalid()) {
1180 EndLoc = ConsumeParen();
1187 assert(Tok.
is(tok::semi));
1201 if (
T.getCloseLocation().isInvalid()) {
1205 return T.getCloseLocation();
1208 if (
Result.isInvalid()) {
1210 return T.getCloseLocation();
1213 EndLoc =
T.getCloseLocation();
1215 assert(!
Result.isInvalid());
1217 const char *PrevSpec =
nullptr;
1222 PrevSpec, DiagID,
Result.get(), Policy)
1224 PrevSpec, DiagID, Policy)) {
1225 Diag(StartLoc, DiagID) << PrevSpec;
1231void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
1247 Tok.
setKind(tok::annot_decltype);
1248 setExprAnnotation(Tok,
1258 assert(Tok.
isOneOf(tok::annot_pack_indexing_type, tok::identifier) &&
1259 "Expected an identifier");
1264 const char *PrevSpec;
1268 if (Tok.
is(tok::annot_pack_indexing_type)) {
1276 ConsumeAnnotationToken();
1277 if (
Type.isInvalid()) {
1282 DiagID,
Type, Policy);
1286 !GetLookAheadToken(2).is(tok::l_square)) {
1318 return T.getCloseLocation();
1321void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1337 Tok.
setKind(tok::annot_pack_indexing_type);
1338 setTypeAnnotation(Tok,
T);
1346#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1347 case tok::kw___##Trait: \
1348 return DeclSpec::TST_##Trait;
1349#include "clang/Basic/TransformTypeTraits.def"
1351 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1355bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1360 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1364 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.
getName(),
1369 if (
Result.isInvalid()) {
1375 if (
T.getCloseLocation().isInvalid())
1378 const char *PrevSpec =
nullptr;
1383 Diag(StartLoc, DiagID) << PrevSpec;
1409 if (Tok.
is(tok::kw_typename)) {
1410 Diag(Tok, diag::err_expected_class_name_not_template)
1417 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1427 if (Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1434 EndLocation = ParseDecltypeSpecifier(DS);
1441 if (Tok.
is(tok::annot_pack_indexing_type)) {
1443 ParsePackIndexingType(DS);
1452 if (Tok.
is(tok::annot_template_id)) {
1458 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
1461 ConsumeAnnotationToken();
1468 if (Tok.
isNot(tok::identifier)) {
1469 Diag(Tok, diag::err_expected_class_name);
1476 if (Tok.
is(tok::less)) {
1485 Diag(IdLoc, diag::err_unknown_template_name) <<
Id;
1496 if (Tok.
is(tok::annot_template_id) &&
1497 takeTemplateIdAnnotation(Tok)->mightBeType())
1503 if (Tok.
isNot(tok::annot_typename))
1510 ConsumeAnnotationToken();
1523 Diag(IdLoc, diag::err_expected_class_name);
1528 EndLocation = IdLoc;
1536 const char *PrevSpec =
nullptr;
1546void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1547 while (Tok.
isOneOf(tok::kw___single_inheritance,
1548 tok::kw___multiple_inheritance,
1549 tok::kw___virtual_inheritance)) {
1553 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1558 while (Tok.
is(tok::kw__Nullable)) {
1562 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1569bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1580 case tok::identifier:
1582 case tok::coloncolon:
1583 case tok::annot_cxxscope:
1584 case tok::annot_typename:
1585 case tok::annot_template_id:
1586 case tok::kw_decltype:
1589 case tok::kw_operator:
1590 case tok::kw___declspec:
1595 case tok::kw___attribute:
1596 case tok::annot_pragma_pack:
1598 case tok::annot_pragma_ms_pragma:
1600 case tok::annot_pragma_ms_vtordisp:
1602 case tok::annot_pragma_ms_pointers_to_members:
1605 return CouldBeBitfield ||
1608 case tok::kw___cdecl:
1609 case tok::kw___fastcall:
1610 case tok::kw___stdcall:
1611 case tok::kw___thiscall:
1612 case tok::kw___vectorcall:
1618 case tok::kw_volatile:
1619 case tok::kw_restrict:
1620 case tok::kw__Atomic:
1621 case tok::kw___unaligned:
1625 case tok::kw_inline:
1626 case tok::kw_virtual:
1627 case tok::kw_friend:
1629 case tok::kw_static:
1630 case tok::kw_extern:
1631 case tok::kw_typedef:
1632 case tok::kw_register:
1634 case tok::kw_mutable:
1635 case tok::kw_thread_local:
1636 case tok::kw_constexpr:
1637 case tok::kw_consteval:
1638 case tok::kw_constinit:
1654 if (!isKnownToBeTypeSpecifier(
NextToken()))
1711 ParsedTemplateInfo &TemplateInfo,
1713 DeclSpecContext DSC,
1716 if (TagTokKind == tok::kw_struct)
1718 else if (TagTokKind == tok::kw___interface)
1720 else if (TagTokKind == tok::kw_class)
1723 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1727 if (Tok.
is(tok::code_completion)) {
1741 const bool shouldDelayDiagsInTag =
1742 (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate);
1748 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1750 if (Tok.
isOneOf(tok::kw___single_inheritance,
1751 tok::kw___multiple_inheritance,
1752 tok::kw___virtual_inheritance)) {
1753 ParseMicrosoftInheritanceClassAttributes(attrs);
1756 if (Tok.
is(tok::kw__Nullable)) {
1757 ParseNullabilityClassAttributes(attrs);
1771#include
"clang/Basic/TransformTypeTraits.def"
1772 tok::kw___is_abstract,
1773 tok::kw___is_aggregate,
1774 tok::kw___is_arithmetic,
1776 tok::kw___is_assignable,
1777 tok::kw___is_base_of,
1778 tok::kw___is_bounded_array,
1780 tok::kw___is_complete_type,
1781 tok::kw___is_compound,
1783 tok::kw___is_constructible,
1784 tok::kw___is_convertible,
1785 tok::kw___is_convertible_to,
1786 tok::kw___is_destructible,
1789 tok::kw___is_floating_point,
1791 tok::kw___is_function,
1792 tok::kw___is_fundamental,
1793 tok::kw___is_integral,
1794 tok::kw___is_interface_class,
1795 tok::kw___is_literal,
1796 tok::kw___is_lvalue_expr,
1797 tok::kw___is_lvalue_reference,
1798 tok::kw___is_member_function_pointer,
1799 tok::kw___is_member_object_pointer,
1800 tok::kw___is_member_pointer,
1801 tok::kw___is_nothrow_assignable,
1802 tok::kw___is_nothrow_constructible,
1803 tok::kw___is_nothrow_convertible,
1804 tok::kw___is_nothrow_destructible,
1805 tok::kw___is_object,
1807 tok::kw___is_pointer,
1808 tok::kw___is_polymorphic,
1809 tok::kw___is_reference,
1810 tok::kw___is_referenceable,
1811 tok::kw___is_rvalue_expr,
1812 tok::kw___is_rvalue_reference,
1814 tok::kw___is_scalar,
1815 tok::kw___is_scoped_enum,
1816 tok::kw___is_sealed,
1817 tok::kw___is_signed,
1818 tok::kw___is_standard_layout,
1819 tok::kw___is_trivial,
1820 tok::kw___is_trivially_equality_comparable,
1821 tok::kw___is_trivially_assignable,
1822 tok::kw___is_trivially_constructible,
1823 tok::kw___is_trivially_copyable,
1824 tok::kw___is_unbounded_array,
1826 tok::kw___is_unsigned,
1828 tok::kw___is_volatile
1835 TryKeywordIdentFallback(
true);
1837 struct PreserveAtomicIdentifierInfoRAII {
1838 PreserveAtomicIdentifierInfoRAII(
Token &Tok,
bool Enabled)
1839 : AtomicII(nullptr) {
1842 assert(Tok.
is(tok::kw__Atomic));
1847 ~PreserveAtomicIdentifierInfoRAII() {
1850 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1860 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1861 Tok.
is(tok::kw__Atomic) &&
1863 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1864 Tok, ShouldChangeAtomicToIdentifier);
1874 if (TemplateInfo.TemplateParams)
1877 bool HasValidSpec =
true;
1878 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1882 HasValidSpec =
false;
1885 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::annot_template_id)) {
1886 Diag(Tok, diag::err_expected) << tok::identifier;
1887 HasValidSpec =
false;
1895 auto RecoverFromUndeclaredTemplateName = [&](
IdentifierInfo *Name,
1898 bool KnownUndeclared) {
1899 Diag(NameLoc, diag::err_explicit_spec_non_template)
1900 << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
1901 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1905 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1906 if (TemplateParams->size() > 1) {
1907 TemplateParams->pop_back();
1909 TemplateParams =
nullptr;
1910 TemplateInfo.Kind = ParsedTemplateInfo::NonTemplate;
1912 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1914 TemplateParams =
nullptr;
1915 TemplateInfo.Kind = ParsedTemplateInfo::NonTemplate;
1925 if (Tok.
is(tok::identifier)) {
1934 TemplateArgList TemplateArgs;
1936 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1942 RecoverFromUndeclaredTemplateName(
1943 Name, NameLoc,
SourceRange(LAngleLoc, RAngleLoc),
false);
1945 }
else if (Tok.
is(tok::annot_template_id)) {
1946 TemplateId = takeTemplateIdAnnotation(Tok);
1947 NameLoc = ConsumeAnnotationToken();
1954 RecoverFromUndeclaredTemplateName(
1957 TemplateId =
nullptr;
1970 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1971 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) <<
Range;
2006 MaybeParseCXX11Attributes(Attributes);
2015 Tok.
isOneOf(tok::comma, tok::ellipsis))
2018 AllowDefiningTypeSpec::No ||
2021 else if (Tok.
is(tok::l_brace) ||
2022 (DSC != DeclSpecContext::DSC_association &&
2024 (isClassCompatibleKeyword() &&
2040 }
else if (isClassCompatibleKeyword() &&
2047 TentativeParsingAction PA(*
this);
2050 while (isClassCompatibleKeyword()) {
2056 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square)) {
2060 }
else if (Tok.
is(tok::kw_alignas) &&
NextToken().is(tok::l_paren)) {
2070 if (!
T.consumeOpen())
2078 if (Tok.
isOneOf(tok::l_brace, tok::colon))
2084 }
else if (!isTypeSpecifier(DSC) &&
2085 (Tok.
is(tok::semi) ||
2088 if (Tok.
isNot(tok::semi)) {
2091 ExpectAndConsume(tok::semi, diag::err_expected_after,
2109 auto *FirstAttr = Attributes.
empty() ? nullptr : &Attributes.
front();
2111 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2112 ?
Diag(
Loc, diag::err_keyword_not_allowed) << FirstAttr
2113 :
Diag(
Loc, diag::err_attributes_not_allowed))
2125 if (!Name && !TemplateId &&
2130 Diag(StartLoc, diag::err_anon_type_definition)
2157 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2160 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2161 diag::err_keyword_not_allowed,
2165 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2176 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
2177 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2178 diag::err_keyword_not_allowed,
2188 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2201 "Expected a definition here");
2205 TemplateParams =
nullptr;
2210 diag::err_explicit_instantiation_with_definition)
2219 std::nullopt, LAngleLoc,
nullptr));
2220 TemplateParams = &FakedParamLists;
2227 SS, *TemplateId, attrs,
2230 TemplateParams ? TemplateParams->size() : 0),
2233 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2240 ProhibitAttributes(attrs);
2243 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2244 TagType, StartLoc, SS, Name, NameLoc, attrs);
2246 TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
2247 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2248 diag::err_keyword_not_allowed,
2264 if (Tok.
is(tok::comma)) {
2266 diag::err_friend_template_decl_multiple_specifiers);
2272 NameLoc, EllipsisLoc, attrs,
2274 TemplateParams ? TemplateParams->size() : 0));
2277 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2278 diag::err_keyword_not_allowed,
2282 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2285 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2287 TemplateParams =
nullptr;
2290 bool IsDependent =
false;
2300 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2303 TagOrTempResult = Actions.
ActOnTag(
2307 DSC == DeclSpecContext::DSC_type_specifier,
2308 DSC == DeclSpecContext::DSC_template_param ||
2309 DSC == DeclSpecContext::DSC_template_type_arg,
2310 OffsetOfState, &SkipBody);
2317 Name, StartLoc, NameLoc);
2324 if (shouldDelayDiagsInTag) {
2325 diagsFromTag.done();
2327 TemplateInfo.Kind == ParsedTemplateInfo::Template)
2328 diagsFromTag.redelay();
2333 assert(Tok.
is(tok::l_brace) ||
2335 isClassCompatibleKeyword());
2337 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc,
TagType,
2338 TagOrTempResult.
get());
2340 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs,
TagType,
2341 TagOrTempResult.
get());
2346 ParseStructUnionBody(StartLoc,
TagType, cast<RecordDecl>(
D));
2359 const char *PrevSpec =
nullptr;
2364 NameLoc.
isValid() ? NameLoc : StartLoc,
2366 }
else if (!TagOrTempResult.
isInvalid()) {
2368 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2369 DiagID, TagOrTempResult.
get(), Owned, Policy);
2376 Diag(StartLoc, DiagID) << PrevSpec;
2392 (TemplateInfo.Kind || !isValidAfterTypeSpecifier(
false))) {
2393 if (Tok.
isNot(tok::semi)) {
2395 ExpectAndConsume(tok::semi, diag::err_expected_after,
2413void Parser::ParseBaseClause(
Decl *ClassDecl) {
2414 assert(Tok.
is(tok::colon) &&
"Not a base clause");
2423 if (
Result.isInvalid()) {
2429 BaseInfo.push_back(
Result.get());
2454 bool IsVirtual =
false;
2458 MaybeParseCXX11Attributes(Attributes);
2464 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2474 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2478 if (Tok.
is(tok::kw_virtual)) {
2482 Diag(VirtualLoc, diag::err_dup_virtual)
2489 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2503 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2519 Access, BaseType.
get(), BaseLoc,
2534 case tok::kw_private:
2536 case tok::kw_protected:
2538 case tok::kw_public:
2547void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2554 if (!NeedLateParse) {
2558 if (Param->hasUnparsedDefaultArg()) {
2559 NeedLateParse =
true;
2565 if (NeedLateParse) {
2568 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2569 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2574 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2576 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2613 if (II == Ident_override)
2616 if (II == Ident_sealed)
2619 if (II == Ident_abstract)
2622 if (II == Ident_final)
2625 if (II == Ident_GNU_final)
2636void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2655 const char *PrevSpec =
nullptr;
2673 ? diag::warn_cxx98_compat_override_control_keyword
2674 : diag::ext_override_control_keyword)
2683bool Parser::isCXX11FinalKeyword()
const {
2692bool Parser::isClassCompatibleKeyword()
const {
2702bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2704 LateParsedAttrList &LateParsedAttrs) {
2715 if (Tok.
isNot(tok::colon))
2716 ParseDeclarator(DeclaratorInfo);
2721 MaybeParseHLSLAnnotations(DeclaratorInfo,
nullptr,
2726 "don't know where identifier would go yet?");
2730 }
else if (Tok.
is(tok::kw_requires)) {
2731 ParseTrailingRequiresClause(DeclaratorInfo);
2733 ParseOptionalCXX11VirtSpecifierSeq(
2734 VS, getCurrentClass().IsInterface,
2737 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2742 if (Tok.
is(tok::kw_asm)) {
2745 if (AsmLabel.isInvalid())
2755 DiagnoseAndSkipCXX11Attributes();
2756 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2757 DiagnoseAndSkipCXX11Attributes();
2762 ParseOptionalCXX11VirtSpecifierSeq(
2763 VS, getCurrentClass().IsInterface,
2769 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2770 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2772 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2789void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2795 ParseTypeQualifierListOpt(
2796 DS, AR_NoAttributesParsed,
false,
2797 false, llvm::function_ref<
void()>([&]() {
2800 D.ExtendWithDeclSpec(DS);
2802 if (
D.isFunctionDeclarator()) {
2803 auto &
Function =
D.getFunctionTypeInfo();
2805 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2808 auto &MQ =
Function.getOrCreateMethodQualifiers();
2809 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2810 std::string Name(FixItName.data());
2813 MQ.SetTypeQual(TypeQual, SpecLoc);
2815 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2824 bool RefQualifierIsLValueRef =
true;
2826 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2827 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2830 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2831 Function.RefQualifierLoc = RefQualifierLoc;
2833 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2834 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2837 D.SetRangeEnd(RefQualifierLoc);
2896 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2897 if (Tok.
is(tok::at)) {
2899 Diag(Tok, diag::err_at_defs_cxx);
2901 Diag(Tok, diag::err_at_in_class);
2917 bool MalformedTypeSpec =
false;
2918 if (!TemplateInfo.Kind &&
2919 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2921 MalformedTypeSpec =
true;
2924 if (Tok.
isNot(tok::annot_cxxscope))
2925 isAccessDecl =
false;
2926 else if (
NextToken().is(tok::identifier))
2927 isAccessDecl = GetLookAheadToken(2).
is(tok::semi);
2934 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2947 false,
false,
true,
true,
2948 false, &TemplateKWLoc, Name)) {
2954 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2955 "access declaration")) {
2971 if (!TemplateInfo.Kind &&
2972 Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2978 if (Tok.
is(tok::kw_template)) {
2979 assert(!TemplateInfo.TemplateParams &&
2980 "Nested template improperly parsed?");
2984 DeclEnd, AccessAttrs, AS);
2988 if (Tok.
is(tok::kw___extension__)) {
2992 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2998 MaybeParseCXX11Attributes(DeclAttrs);
3003 if (Tok.
is(tok::annot_attr_openmp))
3004 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
3006 if (Tok.
is(tok::kw_using)) {
3011 while (Tok.
is(tok::kw_template)) {
3013 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
3017 if (Tok.
is(tok::kw_namespace)) {
3018 Diag(UsingLoc, diag::err_using_namespace_in_class);
3025 UsingLoc, DeclEnd, DeclAttrs, AS);
3029 MaybeParseMicrosoftAttributes(DeclSpecAttrs);
3032 LateParsedAttrList CommonLateParsedAttrs;
3039 if (MalformedTypeSpec)
3047 bool IsTemplateSpecOrInst =
3048 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
3049 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
3052 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
3053 &CommonLateParsedAttrs);
3055 if (IsTemplateSpecOrInst)
3056 diagsFromTag.done();
3064 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate &&
3065 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
3066 &CommonLateParsedAttrs))
3070 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
3072 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
3076 ProhibitAttributes(DeclAttrs);
3080 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
3082 DS.complete(TheDecl);
3084 Decl *decls[] = {AnonRecord, TheDecl};
3097 ? diag::warn_cxx23_variadic_friends
3098 : diag::ext_variadic_friends);
3111 AnonRecord, VariadicLoc);
3122 if (ParsedFriendDecl(DS))
3127 const char *PrevSpec =
nullptr;
3128 unsigned DiagId = 0;
3130 ParseDeclarationSpecifiers(
DeclSpec, TemplateInfo, AS,
3131 DeclSpecContext::DSC_class,
nullptr);
3136 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_stmt,
3137 "friend declaration");
3144 if (TemplateInfo.TemplateParams)
3149 LateParsedAttrList LateParsedAttrs;
3154 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
3155 if (Tok.
isNot(tok::equal))
3160 if (
Zero.isNot(tok::numeric_constant) ||
3164 auto &
After = GetLookAheadToken(2);
3165 if (!
After.isOneOf(tok::semi, tok::comma) &&
3166 !(AllowDefinition &&
3167 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3178 bool ExpectSemi =
true;
3186 if (ParseCXXMemberDeclaratorBeforeInitializer(
3187 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3192 if (IsTemplateSpecOrInst)
3200 TryConsumePureSpecifier(
true);
3211 if (Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3213 }
else if (Tok.
is(tok::equal)) {
3215 if (KW.
is(tok::kw_default))
3217 else if (KW.
is(tok::kw_delete))
3219 else if (KW.
is(tok::code_completion)) {
3236 ProhibitAttributes(DeclAttrs);
3253 diag::err_function_declared_typedef);
3259 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3260 TemplateInfo, VS, PureSpecLoc);
3263 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3264 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3266 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3267 LateParsedAttrs[i]->addDecl(FunDecl);
3270 LateParsedAttrs.clear();
3273 if (Tok.
is(tok::semi))
3274 ConsumeExtraSemi(AfterMemberFunctionDefinition);
3286 bool HasStaticInitializer =
false;
3291 Diag(Tok, diag::err_anon_bitfield_member_init);
3295 if (!TryConsumePureSpecifier(
false))
3297 HasStaticInitializer =
true;
3303 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate) {
3305 if (BitfieldSize.
get())
3307 ? diag::warn_cxx17_compat_bitfield_member_init
3308 : diag::ext_bitfield_member_init);
3311 HasStaticInitializer =
true;
3327 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3328 auto Loc = AL.getRange().getBegin();
3329 (AL.isRegularKeywordAttribute()
3330 ?
Diag(
Loc, diag::err_keyword_not_allowed) << AL
3331 :
Diag(
Loc, diag::err_attributes_not_allowed))
3339 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3340 VS, HasInClassInit);
3343 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3346 ThisDecl = VT->getTemplatedDecl();
3355 DeclaratorInfo.getDeclSpec().getStorageClassSpec() ==
3358 HasStaticInitializer =
true;
3362 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3364 if (ThisDecl && PureSpecLoc.
isValid())
3373 ? diag::warn_cxx98_compat_nonstatic_member_init
3374 : diag::ext_nonstatic_member_init);
3376 if (DeclaratorInfo.isArrayOfUnknownBound()) {
3382 Diag(Tok, diag::err_incomplete_array_member_init);
3389 ParseCXXNonStaticMemberInitializer(ThisDecl);
3390 }
else if (HasStaticInitializer) {
3393 ThisDecl, DeclaratorInfo.isDeclarationOfFunction(), EqualLoc);
3395 if (
Init.isInvalid()) {
3399 }
else if (ThisDecl)
3402 }
else if (ThisDecl && DeclaratorInfo.isStaticMember())
3409 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3410 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3412 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3413 LateParsedAttrs[i]->addDecl(ThisDecl);
3416 DeclsInGroup.push_back(ThisDecl);
3418 if (DeclaratorInfo.isFunctionDeclarator() &&
3419 DeclaratorInfo.getDeclSpec().getStorageClassSpec() !=
3421 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3423 LateParsedAttrs.clear();
3425 DeclaratorInfo.complete(ThisDecl);
3438 Diag(CommaLoc, diag::err_expected_semi_declaration)
3448 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
3449 DeclaratorInfo.isFirstDeclarator()) {
3450 Diag(CommaLoc, diag::err_multiple_template_declarators)
3451 << TemplateInfo.Kind;
3455 DeclaratorInfo.clear();
3459 DeclaratorInfo.setCommaLoc(CommaLoc);
3464 DiagnoseAndSkipCXX11Attributes();
3465 MaybeParseGNUAttributes(DeclaratorInfo);
3466 DiagnoseAndSkipCXX11Attributes();
3468 if (ParseCXXMemberDeclaratorBeforeInitializer(
3469 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3474 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
3507 assert(Tok.
isOneOf(tok::equal, tok::l_brace) &&
3508 "Data member initializer not starting with '=' or '{'");
3510 bool IsFieldInitialization = isa_and_present<FieldDecl>(
D);
3514 IsFieldInitialization
3523 IsFieldInitialization;
3526 if (Tok.
is(tok::kw_delete)) {
3533 if (IsFunction || Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3539 SkipDeletedFunctionBody();
3542 }
else if (Tok.
is(tok::kw_default)) {
3544 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3552 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(
D)) {
3553 Diag(Tok, diag::err_ms_property_initializer) << PD;
3556 return ParseInitializer();
3564 assert(isCXX11FinalKeyword() &&
"not a class definition");
3570 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3575 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_brace))
3582 if (Tok.
is(tok::colon)) {
3585 ParsingClassDefinition ParsingDef(*
this,
TagDecl,
true,
3591 ParseBaseClause(
nullptr);
3595 if (!Tok.
is(tok::l_brace)) {
3597 diag::err_expected_lbrace_after_base_specifiers);
3603 assert(Tok.
is(tok::l_brace));
3609 if (Tok.
is(tok::kw___attribute)) {
3611 MaybeParseGNUAttributes(Attrs);
3621 case tok::kw___if_exists:
3622 case tok::kw___if_not_exists:
3623 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, AS);
3628 ConsumeExtraSemi(InsideStruct,
TagType);
3632 case tok::annot_pragma_vis:
3633 HandlePragmaVisibility();
3635 case tok::annot_pragma_pack:
3638 case tok::annot_pragma_align:
3639 HandlePragmaAlign();
3641 case tok::annot_pragma_ms_pointers_to_members:
3642 HandlePragmaMSPointersToMembers();
3644 case tok::annot_pragma_ms_pragma:
3645 HandlePragmaMSPragma();
3647 case tok::annot_pragma_ms_vtordisp:
3648 HandlePragmaMSVtorDisp();
3650 case tok::annot_pragma_dump:
3654 case tok::kw_namespace:
3656 DiagnoseUnexpectedNamespace(cast<NamedDecl>(
TagDecl));
3659 case tok::kw_private:
3663 ParsedTemplateInfo TemplateInfo;
3664 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3667 case tok::kw_public:
3668 case tok::kw_protected: {
3678 AccessAttrs.
clear();
3679 MaybeParseGNUAttributes(AccessAttrs);
3684 Diag(EndLoc, diag::err_expected)
3688 Diag(EndLoc, diag::err_expected)
3700 AccessAttrs.
clear();
3706 case tok::annot_attr_openmp:
3707 case tok::annot_pragma_openmp:
3708 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3710 case tok::annot_pragma_openacc:
3718 ConsumeAnnotationToken();
3721 ParsedTemplateInfo TemplateInfo;
3722 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3739 "Invalid TagType!");
3741 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3742 if (
auto *TD = dyn_cast_or_null<NamedDecl>(
TagDecl))
3743 return TD->getQualifiedNameAsString();
3744 return std::string(
"<anonymous>");
3748 "parsing struct/union/class body");
3752 bool NonNestedClass =
true;
3753 if (!ClassStack.empty()) {
3755 if (S->isClassScope()) {
3757 NonNestedClass =
false;
3760 if (getCurrentClass().IsInterface) {
3764 ? cast<NamedDecl>(
TagDecl)->getQualifiedNameAsString()
3770 if (S->isFunctionScope())
3781 ParsingClassDefinition ParsingDef(*
this,
TagDecl, NonNestedClass,
3789 bool IsFinalSpelledSealed =
false;
3790 bool IsAbstract =
false;
3798 if (isCXX11FinalKeyword()) {
3801 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3806 IsFinalSpelledSealed =
true;
3811 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3819 Diag(FinalLoc, diag::err_override_control_interface)
3823 ? diag::warn_cxx98_compat_override_control_keyword
3824 : diag::ext_override_control_keyword)
3827 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3829 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3831 Diag(FinalLoc, diag::ext_warn_gnu_final);
3834 "not a class definition");
3840 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3849 if (!Tok.
is(tok::colon) && !Tok.
is(tok::l_brace)) {
3856 if (Tok.
is(tok::colon)) {
3857 ParseScope InheritanceScope(
this,
getCurScope()->getFlags() |
3861 if (!Tok.
is(tok::l_brace)) {
3862 bool SuggestFixIt =
false;
3866 case tok::kw_private:
3867 case tok::kw_protected:
3868 case tok::kw_public:
3871 case tok::kw_static_assert:
3875 case tok::kw_template:
3876 SuggestFixIt =
true;
3878 case tok::identifier:
3879 SuggestFixIt = isConstructorDeclarator(
true);
3882 SuggestFixIt = isCXXSimpleDeclaration(
false);
3887 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3901 assert(Tok.
is(tok::l_brace));
3907 IsFinalSpelledSealed, IsAbstract,
3908 T.getOpenLocation());
3923 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3924 Tok.
isNot(tok::eof)) {
3926 ParseCXXClassMemberDeclarationWithPragmas(
3928 MaybeDestroyTemplateIds();
3937 MaybeParseGNUAttributes(attrs);
3941 T.getOpenLocation(),
3942 T.getCloseLocation(), attrs);
3949 if (
TagDecl && NonNestedClass) {
3956 ParseLexedPragmas(getCurrentClass());
3957 ParseLexedAttributes(getCurrentClass());
3958 ParseLexedMethodDeclarations(getCurrentClass());
3963 ParseLexedMemberInitializers(getCurrentClass());
3964 ParseLexedMethodDefs(getCurrentClass());
3965 PrevTokLocation = SavedPrevTokLocation;
3980void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *
D) {
3981 assert(Tok.
is(tok::kw_namespace));
4020void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
4021 assert(Tok.
is(tok::colon) &&
4022 "Constructor initializer always starts with ':'");
4030 bool AnyErrors =
false;
4033 if (Tok.
is(tok::code_completion)) {
4036 ConstructorDecl, MemInitializers);
4040 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
4042 MemInitializers.push_back(MemInit.
get());
4046 if (Tok.
is(tok::comma))
4048 else if (Tok.
is(tok::l_brace))
4053 Tok.
isOneOf(tok::identifier, tok::coloncolon)) {
4055 Diag(
Loc, diag::err_ctor_init_missing_comma)
4061 << tok::l_brace << tok::comma;
4086 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
4099 if (Tok.
is(tok::identifier)) {
4104 }
else if (Tok.
is(tok::annot_decltype)) {
4109 ParseDecltypeSpecifier(DS);
4110 }
else if (Tok.
is(tok::annot_pack_indexing_type)) {
4113 ParsePackIndexingType(DS);
4116 ? takeTemplateIdAnnotation(Tok)
4121 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
4123 ConsumeAnnotationToken();
4125 Diag(Tok, diag::err_expected_member_or_base_name);
4132 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
4135 ExprResult InitList = ParseBraceInitializer();
4145 TemplateTypeTy.
get(), DS, IdLoc,
4146 InitList.
get(), EllipsisLoc);
4147 }
else if (Tok.
is(tok::l_paren)) {
4152 ExprVector ArgExprs;
4153 auto RunSignatureHelp = [&] {
4158 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
4159 T.getOpenLocation(),
false);
4160 CalledSignatureHelp =
true;
4161 return PreferredType;
4163 if (Tok.
isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
4164 PreferredType.enterFunctionArgument(Tok.
getLocation(),
4181 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
4182 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
4189 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
4191 return Diag(Tok, diag::err_expected) << tok::l_paren;
4209 ExceptionSpecTokens =
nullptr;
4213 if (Tok.
isNot(tok::kw_throw) && Tok.
isNot(tok::kw_noexcept))
4217 bool IsNoexcept = Tok.
is(tok::kw_noexcept);
4218 Token StartTok = Tok;
4222 if (!Tok.
is(tok::l_paren)) {
4225 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4226 NoexceptExpr =
nullptr;
4230 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4236 ExceptionSpecTokens->push_back(StartTok);
4237 ExceptionSpecTokens->push_back(Tok);
4238 SpecificationRange.
setEnd(ConsumeParen());
4240 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4243 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4249 if (Tok.
is(tok::kw_throw)) {
4250 Result = ParseDynamicExceptionSpecification(
4251 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4252 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4253 "Produced different number of exception types and ranges.");
4257 if (Tok.
isNot(tok::kw_noexcept))
4260 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4268 if (Tok.
is(tok::l_paren)) {
4281 NoexceptRange =
SourceRange(KeywordLoc,
T.getCloseLocation());
4288 NoexceptRange =
SourceRange(KeywordLoc, KeywordLoc);
4292 SpecificationRange = NoexceptRange;
4297 if (Tok.
is(tok::kw_throw)) {
4298 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4299 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4300 DynamicExceptionRanges);
4303 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4311 if (
P.getLangOpts().CPlusPlus11) {
4312 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4314 ? diag::ext_dynamic_exception_spec
4315 : diag::warn_exception_spec_deprecated)
4336 assert(Tok.
is(tok::kw_throw) &&
"expected throw");
4340 if (
T.consumeOpen()) {
4341 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4348 if (Tok.
is(tok::ellipsis)) {
4351 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4353 SpecificationRange.
setEnd(
T.getCloseLocation());
4360 while (Tok.
isNot(tok::r_paren)) {
4363 if (Tok.
is(tok::ellipsis)) {
4369 if (!Res.isInvalid())
4373 if (!Res.isInvalid()) {
4374 Exceptions.push_back(Res.get());
4375 Ranges.push_back(
Range);
4383 SpecificationRange.
setEnd(
T.getCloseLocation());
4385 Exceptions.empty());
4392 bool MayBeFollowedByDirectInit) {
4393 assert(Tok.
is(tok::arrow) &&
"expected arrow");
4403void Parser::ParseTrailingRequiresClause(
Declarator &
D) {
4404 assert(Tok.
is(tok::kw_requires) &&
"expected requires");
4422 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4424 DeclScopeObj.EnterDeclaratorScope();
4433 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4434 InitCXXThisScopeForDeclaratorIfRelevant(
D,
D.getDeclSpec(), ThisScope);
4436 TrailingRequiresClause =
4439 TrailingRequiresClause =
4442 if (!
D.isDeclarationOfFunction()) {
4444 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4449 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4452 D.setTrailingRequiresClause(TrailingRequiresClause.
get());
4455 if (
D.isFunctionDeclarator() && Tok.
is(tok::arrow) &&
4456 D.getDeclSpec().getTypeSpecType() ==
TST_auto) {
4460 ParseTrailingReturnType(
Range,
false);
4464 diag::err_requires_clause_must_appear_after_trailing_return)
4466 auto &FunctionChunk =
D.getFunctionTypeInfo();
4467 FunctionChunk.HasTrailingReturnType = TrailingReturnType.
isUsable();
4468 FunctionChunk.TrailingReturnType = TrailingReturnType.
get();
4471 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4480 bool NonNestedClass,
4482 assert((NonNestedClass || !ClassStack.empty()) &&
4483 "Nested class without outer class");
4484 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4490void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4491 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4492 delete Class->LateParsedDeclarations[I];
4503 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4507 ParsingClass *Victim = ClassStack.top();
4509 if (Victim->TopLevelClass) {
4512 DeallocateParsedClasses(Victim);
4515 assert(!ClassStack.empty() &&
"Missing top-level class?");
4517 if (Victim->LateParsedDeclarations.empty()) {
4522 DeallocateParsedClasses(Victim);
4530 "Nested class outside of class scope?");
4531 ClassStack.top()->LateParsedDeclarations.push_back(
4532 new LateParsedClass(
this, Victim));
4558 case tok::code_completion:
4565 case tok::numeric_constant: {
4573 StringRef Spelling = PP.
getSpelling(ExpansionLoc, ExpansionBuf);
4574 if (Spelling ==
"__clang__") {
4578 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4594 case tok::pipeequal:
4595 case tok::caretequal:
4597 case tok::exclaimequal:
4603 StringRef Spelling = PP.
getSpelling(SpellingLoc, SpellingBuf);
4612void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4617 if (
T.consumeOpen()) {
4618 Diag(Tok, diag::err_expected) << tok::l_paren;
4622 if (AttrName->
isStr(
"directive")) {
4628 OMPBeginTok.
setKind(tok::annot_attr_openmp);
4630 OpenMPTokens.push_back(OMPBeginTok);
4632 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4636 OMPEndTok.
setKind(tok::annot_pragma_openmp_end);
4638 OpenMPTokens.push_back(OMPEndTok);
4640 assert(AttrName->
isStr(
"sequence") &&
4641 "Expected either 'directive' or 'sequence'");
4650 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4654 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4655 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4659 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4666 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4680 case ParsedAttr::AT_CarriesDependency:
4681 case ParsedAttr::AT_Deprecated:
4682 case ParsedAttr::AT_FallThrough:
4683 case ParsedAttr::AT_CXX11NoReturn:
4684 case ParsedAttr::AT_NoUniqueAddress:
4685 case ParsedAttr::AT_Likely:
4686 case ParsedAttr::AT_Unlikely:
4688 case ParsedAttr::AT_WarnUnusedResult:
4689 return !ScopeName && AttrName->
getName() ==
"nodiscard";
4690 case ParsedAttr::AT_Unused:
4691 return !ScopeName && AttrName->
getName() ==
"maybe_unused";
4703 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4711 TentativeParsingAction TPA(*
this);
4714 if (Res.isInvalid()) {
4717 if (Tok.
is(tok::r_paren))
4722 if (!Tok.
isOneOf(tok::r_paren, tok::r_square)) {
4727 if (!Res.isInvalid()) {
4728 auto *
E = Res.get();
4767bool Parser::ParseCXX11AttributeArgs(
4771 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4775 LO.CPlusPlus ? ParsedAttr::Form::CXX11() :
ParsedAttr::Form::
C23();
4781 Form = ParsedAttr::Form::Microsoft();
4796 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4799 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4800 ScopeLoc, Form,
nullptr);
4805 if (ScopeName && ScopeName->
isStr(
"omp") &&
4806 (AttrName->
isStr(
"directive") || AttrName->
isStr(
"sequence"))) {
4808 ? diag::warn_omp51_compat_attributes
4809 : diag::ext_omp_attributes);
4811 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4820 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4821 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4822 ScopeName, ScopeLoc, Form);
4824 else if (!ScopeName && AttrName->
isStr(
"assume")) {
4825 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form))
4829 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4830 ScopeName, ScopeLoc, Form);
4832 if (!Attrs.
empty() &&
4838 Diag(LParenLoc, diag::warn_unknown_attribute_ignored) << AttrName;
4839 Attr.setInvalid(
true);
4847 if (
Attr.getMaxArgs() && !NumArgs) {
4850 Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
4851 Attr.setInvalid(
true);
4852 }
else if (!
Attr.getMaxArgs()) {
4856 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4859 Attr.setInvalid(
true);
4892 if (Tok.
is(tok::kw_alignas)) {
4899 ParseAlignmentSpecifier(Attrs, EndLoc);
4910 if (!Tok.
is(tok::l_paren))
4913 ParseAttributeArgsCommon(AttrName,
Loc, Attrs, EndLoc,
4917 Attrs.
addNew(AttrName,
Loc,
nullptr,
Loc,
nullptr, 0, Form);
4921 assert(Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square) &&
4922 "Not a double square bracket attribute list");
4927 : diag::warn_ext_cxx11_attributes);
4930 : diag::warn_ext_c23_attributes);
4934 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4939 if (Tok.
is(tok::kw_using)) {
4941 ? diag::warn_cxx14_compat_using_attribute_ns
4942 : diag::ext_using_attribute_ns);
4945 CommonScopeName = TryParseCXX11AttributeIdentifier(
4947 if (!CommonScopeName) {
4955 bool AttrParsed =
false;
4956 while (!Tok.
isOneOf(tok::r_square, tok::semi, tok::eof)) {
4960 if (ExpectAndConsume(tok::comma)) {
4974 AttrName = TryParseCXX11AttributeIdentifier(
4983 ScopeName = AttrName;
4986 AttrName = TryParseCXX11AttributeIdentifier(
4996 if (CommonScopeName) {
4998 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
5001 ScopeName = CommonScopeName;
5002 ScopeLoc = CommonScopeLoc;
5007 if (Tok.
is(tok::l_paren))
5008 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
5009 ScopeName, ScopeLoc, OpenMPTokens);
5015 ScopeName, ScopeLoc,
nullptr, 0,
5017 : ParsedAttr::Form::C23());
5022 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) << AttrName;
5027 if (Tok.
is(tok::semi)) {
5033 if (ExpectAndConsume(tok::r_square))
5035 else if (Tok.
is(tok::r_square))
5036 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
5039 if (ExpectAndConsume(tok::r_square))
5052 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
5053 }
while (isAllowedCXX11AttributeSpecifier());
5058void Parser::DiagnoseAndSkipCXX11Attributes() {
5067 (Keyword ?
Diag(StartLoc, diag::err_keyword_not_allowed) << Keyword
5068 :
Diag(StartLoc, diag::err_attributes_not_allowed))
5076 if (!isCXX11AttributeSpecifier())
5080 if (Tok.
is(tok::l_square)) {
5084 EndLoc =
T.getCloseLocation();
5091 "not an attribute specifier");
5094 if (!
T.consumeOpen())
5096 EndLoc =
T.getCloseLocation();
5098 }
while (isCXX11AttributeSpecifier());
5105 assert(Tok.
is(tok::identifier) &&
"Not a Microsoft attribute list");
5107 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
5114 if (
T.consumeOpen()) {
5115 Diag(Tok, diag::err_expected) << tok::l_paren;
5120 if (isTokenStringLiteral()) {
5125 ArgExprs.push_back(StringResult.
get());
5142 while (Tok.
isNot(tok::r_paren)) {
5144 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5149 SpellingBuffer.resize(Tok.
getLength() + 1);
5151 StringRef TokSpelling = PP.
getSpelling(Tok, SpellingBuffer, &Invalid);
5156 StrBuffer += TokSpelling;
5162 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5172 Toks[0].
setKind(tok::string_literal);
5178 ArgExprs.push_back(UuidString);
5181 if (!
T.consumeClose()) {
5184 ParsedAttr::Form::Microsoft());
5197 assert(Tok.
is(tok::l_square) &&
"Not a Microsoft attribute list");
5208 SkipUntil(tok::r_square, tok::identifier,
5210 if (Tok.
is(tok::code_completion)) {
5218 if (Tok.
isNot(tok::identifier))
5221 ParseMicrosoftUuidAttributeArgs(Attrs);
5231 bool AttrParsed =
false;
5232 if (Tok.
is(tok::l_paren)) {
5235 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5237 ReplayOpenMPAttributeTokens(OpenMPTokens);
5241 ParsedAttr::Form::Microsoft());
5248 EndLoc =
T.getCloseLocation();
5249 }
while (Tok.
is(tok::l_square));
5254void Parser::ParseMicrosoftIfExistsClassDeclaration(
5257 IfExistsCondition
Result;
5258 if (ParseMicrosoftIfExistsCondition(
Result))
5262 if (
Braces.consumeOpen()) {
5263 Diag(Tok, diag::err_expected) << tok::l_brace;
5267 switch (
Result.Behavior) {
5273 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5283 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
5285 if (Tok.
isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5286 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, CurAS);
5291 if (Tok.
is(tok::semi)) {
5292 ConsumeExtraSemi(InsideStruct,
TagType);
5302 if (Tok.
is(tok::colon))
5306 Diag(Tok, diag::err_expected) << tok::colon;
5311 ParsedTemplateInfo TemplateInfo;
5313 ParseCXXClassMemberDeclaration(CurAS, AccessAttrs, TemplateInfo);
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)
This file declares facilities that support code completion.
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)
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_union
static const TST TST_typename_pack_indexing
SourceLocation getFriendSpecLoc() const
SourceLocation getModulePrivateSpecLoc() const
bool isFriendSpecifiedFirst() 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.
SourceLocation getEndLoc() const LLVM_READONLY
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInvalidDecl() const
SourceLocation getLocation() const
SourceLocation getBeginLoc() const LLVM_READONLY
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
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 setTemplateParameterLists(ArrayRef< TemplateParameterList * > TPLs)
Sets the template parameter lists that preceded the declarator.
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
void setAsmLabel(Expr *E)
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.
void CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax, AttributeCompletion Completion=AttributeCompletion::Attribute, const IdentifierInfo *Scope=nullptr)
QualType ProduceCtorInitMemberSignatureHelp(Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy, ArrayRef< Expr * > ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc, bool Braced)
void CodeCompleteNamespaceAliasDecl(Scope *S)
void CodeCompleteUsing(Scope *S)
void CodeCompleteUsingDirective(Scope *S)
void CodeCompleteAfterFunctionEquals(Declarator &D)
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
void CodeCompleteNamespaceDecl(Scope *S)
void CodeCompleteTag(Scope *S, unsigned TagSpec)
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 ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS=nullptr)
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)
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, SourceLocation EllipsisLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
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...
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()
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.
SemaCodeCompletion & CodeCompletion()
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...
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...
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)
Helper for delayed processing TransparentUnion or BPFPreserveAccessIndexAttr attribute.
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
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...
bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
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...
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 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)
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.
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
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.
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.