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));
463 if (Tok.
is(tok::code_completion)) {
477 if (Tok.
isNot(tok::l_brace)) {
480 MaybeParseCXX11Attributes(DeclAttrs);
482 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
490 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
491 Tok.
isNot(tok::eof)) {
493 MaybeParseCXX11Attributes(DeclAttrs);
495 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
500 T.getCloseLocation());
508 assert(Tok.
is(tok::kw_using) &&
"Not using token");
514 if (Tok.
is(tok::code_completion)) {
521 while (Tok.
is(tok::kw_template)) {
523 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
528 if (Tok.
is(tok::kw_namespace)) {
530 if (TemplateInfo.Kind) {
532 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
536 Decl *UsingDir = ParseUsingDirective(Context, UsingLoc, DeclEnd, Attrs);
541 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, Attrs,
559 assert(Tok.
is(tok::kw_namespace) &&
"Not 'namespace' token");
564 if (Tok.
is(tok::code_completion)) {
572 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
584 if (Tok.
isNot(tok::identifier)) {
585 Diag(Tok, diag::err_expected_namespace_name);
604 bool GNUAttr =
false;
605 if (Tok.
is(tok::kw___attribute)) {
607 ParseGNUAttributes(attrs);
612 if (ExpectAndConsume(tok::semi,
613 GNUAttr ? diag::err_expected_semi_after_attribute_list
614 : diag::err_expected_semi_after_namespace_name))
618 IdentLoc, NamespcName, attrs);
627 UsingDeclarator &
D) {
634 if (Tok.
is(tok::kw___super)) {
641 if (ParseOptionalCXXScopeSpecifier(
D.SS,
nullptr,
651 if (
D.SS.isInvalid())
665 Tok.
is(tok::identifier) &&
671 !
D.SS.getScopeRep()->getAsNamespace() &&
672 !
D.SS.getScopeRep()->getAsNamespaceAlias()) {
676 D.Name.setConstructorName(
Type, IdLoc, IdLoc);
683 !(Tok.
is(tok::identifier) &&
NextToken().is(tok::equal)),
684 false,
nullptr,
D.Name))
690 ? diag::warn_cxx17_compat_using_declaration_pack
691 : diag::ext_using_declaration_pack);
730 ? diag::warn_cxx17_compat_using_enum_declaration
731 : diag::ext_using_enum_declaration);
733 DiagnoseCXX11AttributeExtension(PrefixAttrs);
735 if (TemplateInfo.Kind) {
737 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
743 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
755 if (Tok.
is(tok::code_completion)) {
765 if (Tok.
is(tok::identifier)) {
777 }
else if (Tok.
is(tok::annot_template_id)) {
784 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
787 ConsumeAnnotationToken();
799 << Tok.
is(tok::kw_enum);
810 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
811 "using-enum declaration"))
820 MaybeParseCXX11Attributes(MisplacedAttrs);
822 if (InInitStatement && Tok.
isNot(tok::identifier))
826 bool InvalidDeclarator = ParseUsingDeclarator(Context,
D);
829 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
833 if (MisplacedAttrs.Range.isValid()) {
835 MisplacedAttrs.empty() ? nullptr : &MisplacedAttrs.front();
836 auto &
Range = MisplacedAttrs.Range;
837 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
847 if (Tok.
is(tok::equal) || InInitStatement) {
848 if (InvalidDeclarator) {
853 ProhibitAttributes(PrefixAttrs);
855 Decl *DeclFromDeclSpec =
nullptr;
861 Decl *AD = ParseAliasDeclarationAfterDeclarator(
862 TemplateInfo, UsingLoc,
D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
866 DiagnoseCXX11AttributeExtension(PrefixAttrs);
871 if (TemplateInfo.Kind) {
873 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
885 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
886 DiagnoseCXX11AttributeExtension(Attrs);
889 if (InvalidDeclarator)
894 if (
D.TypenameLoc.isValid() &&
897 diag::err_typename_identifiers_only)
904 D.TypenameLoc,
D.SS,
D.Name,
905 D.EllipsisLoc, Attrs);
907 DeclsInGroup.push_back(UD);
915 InvalidDeclarator = ParseUsingDeclarator(Context,
D);
918 if (DeclsInGroup.size() > 1)
921 ? diag::warn_cxx17_compat_multi_using_declaration
922 : diag::ext_multi_using_declaration);
926 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
927 !Attrs.
empty() ?
"attributes list"
928 : UELoc.
isValid() ?
"using-enum declaration"
929 :
"using declaration"))
935Decl *Parser::ParseAliasDeclarationAfterDeclarator(
939 if (ExpectAndConsume(tok::equal)) {
945 ? diag::warn_cxx98_compat_alias_declaration
946 : diag::ext_alias_declaration);
950 if (TemplateInfo.Kind == ParsedTemplateInfo::Template &&
953 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization)
955 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
957 if (SpecKind != -1) {
961 D.Name.TemplateId->RAngleLoc);
963 Range = TemplateInfo.getSourceRange();
965 << SpecKind <<
Range;
972 Diag(
D.Name.StartLocation, diag::err_alias_declaration_not_identifier);
976 }
else if (
D.TypenameLoc.isValid())
977 Diag(
D.TypenameLoc, diag::err_alias_declaration_not_identifier)
981 else if (
D.SS.isNotEmpty())
984 if (
D.EllipsisLoc.isValid())
985 Diag(
D.EllipsisLoc, diag::err_alias_declaration_pack_expansion)
988 Decl *DeclFromDeclSpec =
nullptr;
993 AS, &DeclFromDeclSpec, &Attrs);
995 *OwnedType = DeclFromDeclSpec;
999 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
1000 !Attrs.
empty() ?
"attributes list"
1001 :
"alias declaration"))
1006 TemplateParams ? TemplateParams->data() :
nullptr,
1007 TemplateParams ? TemplateParams->size() : 0);
1009 UsingLoc,
D.Name, Attrs, TypeAlias,
1015 if (
const auto *BO = dyn_cast_or_null<BinaryOperator>(AssertExpr)) {
1016 if (BO->getOpcode() == BO_LAnd &&
1017 isa<StringLiteral>(BO->getRHS()->IgnoreImpCasts()))
1032 assert(Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
1033 "Not a static_assert declaration");
1036 const char *TokName = Tok.
getName();
1038 if (Tok.
is(tok::kw__Static_assert))
1039 diagnoseUseOfC11Keyword(Tok);
1040 else if (Tok.
is(tok::kw_static_assert)) {
1043 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
1048 Diag(Tok, diag::warn_cxx98_compat_static_assert);
1054 if (
T.consumeOpen()) {
1055 Diag(Tok, diag::err_expected) << tok::l_paren;
1063 if (AssertExpr.isInvalid()) {
1069 if (Tok.
is(tok::r_paren)) {
1072 DiagVal = diag::warn_cxx14_compat_static_assert_no_message;
1074 DiagVal = diag::ext_cxx_static_assert_no_message;
1076 DiagVal = diag::warn_c17_compat_static_assert_no_message;
1078 DiagVal = diag::ext_c_static_assert_no_message;
1082 if (ExpectAndConsume(tok::comma)) {
1087 bool ParseAsExpression =
false;
1089 for (
unsigned I = 0;; ++I) {
1090 const Token &
T = GetLookAheadToken(I);
1091 if (
T.is(tok::r_paren))
1094 ParseAsExpression =
true;
1100 if (ParseAsExpression) {
1103 ? diag::warn_cxx20_compat_static_assert_user_generated_message
1104 : diag::ext_cxx_static_assert_user_generated_message);
1109 Diag(Tok, diag::err_expected_string_literal)
1121 if (
T.consumeClose())
1125 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
1128 AssertMessage.
get(),
1129 T.getCloseLocation());
1138 assert(Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype) &&
1139 "Not a decltype specifier");
1145 if (Tok.
is(tok::annot_decltype)) {
1146 Result = getExprAnnotation(Tok);
1151 ConsumeAnnotationToken();
1152 if (
Result.isInvalid()) {
1158 Diag(Tok, diag::warn_cxx98_compat_decltype);
1163 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"decltype",
1166 return T.getOpenLocation() == Tok.
getLocation() ? StartLoc
1167 :
T.getOpenLocation();
1171 if (Tok.
is(tok::kw_auto) &&
NextToken().is(tok::r_paren)) {
1176 ? diag::warn_cxx11_compat_decltype_auto_type_specifier
1177 : diag::ext_decltype_auto_type_specifier);
1191 if (
Result.isInvalid()) {
1194 EndLoc = ConsumeParen();
1201 assert(Tok.
is(tok::semi));
1215 if (
T.getCloseLocation().isInvalid()) {
1219 return T.getCloseLocation();
1222 if (
Result.isInvalid()) {
1224 return T.getCloseLocation();
1227 EndLoc =
T.getCloseLocation();
1229 assert(!
Result.isInvalid());
1231 const char *PrevSpec =
nullptr;
1236 PrevSpec, DiagID,
Result.get(), Policy)
1238 PrevSpec, DiagID, Policy)) {
1239 Diag(StartLoc, DiagID) << PrevSpec;
1245void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
1261 Tok.
setKind(tok::annot_decltype);
1262 setExprAnnotation(Tok,
1272 assert(Tok.
isOneOf(tok::annot_pack_indexing_type, tok::identifier) &&
1273 "Expected an identifier");
1278 const char *PrevSpec;
1282 if (Tok.
is(tok::annot_pack_indexing_type)) {
1290 ConsumeAnnotationToken();
1291 if (
Type.isInvalid()) {
1296 DiagID,
Type, Policy);
1300 !GetLookAheadToken(2).is(tok::l_square)) {
1332 return T.getCloseLocation();
1335void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1351 Tok.
setKind(tok::annot_pack_indexing_type);
1352 setTypeAnnotation(Tok,
T);
1360#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1361 case tok::kw___##Trait: \
1362 return DeclSpec::TST_##Trait;
1363#include "clang/Basic/TransformTypeTraits.def"
1365 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1369bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1374 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1378 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.
getName(),
1383 if (
Result.isInvalid()) {
1389 if (
T.getCloseLocation().isInvalid())
1392 const char *PrevSpec =
nullptr;
1397 Diag(StartLoc, DiagID) << PrevSpec;
1423 if (Tok.
is(tok::kw_typename)) {
1424 Diag(Tok, diag::err_expected_class_name_not_template)
1431 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1441 if (Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1448 EndLocation = ParseDecltypeSpecifier(DS);
1455 if (Tok.
is(tok::annot_pack_indexing_type)) {
1457 ParsePackIndexingType(DS);
1466 if (Tok.
is(tok::annot_template_id)) {
1472 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
1475 ConsumeAnnotationToken();
1482 if (Tok.
isNot(tok::identifier)) {
1483 Diag(Tok, diag::err_expected_class_name);
1490 if (Tok.
is(tok::less)) {
1499 Diag(IdLoc, diag::err_unknown_template_name) <<
Id;
1510 if (Tok.
is(tok::annot_template_id) &&
1511 takeTemplateIdAnnotation(Tok)->mightBeType())
1517 if (Tok.
isNot(tok::annot_typename))
1524 ConsumeAnnotationToken();
1537 Diag(IdLoc, diag::err_expected_class_name);
1542 EndLocation = IdLoc;
1550 const char *PrevSpec =
nullptr;
1560void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1561 while (Tok.
isOneOf(tok::kw___single_inheritance,
1562 tok::kw___multiple_inheritance,
1563 tok::kw___virtual_inheritance)) {
1567 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1572 while (Tok.
is(tok::kw__Nullable)) {
1576 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1583bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1594 case tok::identifier:
1596 case tok::coloncolon:
1597 case tok::annot_cxxscope:
1598 case tok::annot_typename:
1599 case tok::annot_template_id:
1600 case tok::kw_decltype:
1603 case tok::kw_operator:
1604 case tok::kw___declspec:
1609 case tok::kw___attribute:
1610 case tok::annot_pragma_pack:
1612 case tok::annot_pragma_ms_pragma:
1614 case tok::annot_pragma_ms_vtordisp:
1616 case tok::annot_pragma_ms_pointers_to_members:
1619 return CouldBeBitfield ||
1622 case tok::kw___cdecl:
1623 case tok::kw___fastcall:
1624 case tok::kw___stdcall:
1625 case tok::kw___thiscall:
1626 case tok::kw___vectorcall:
1632 case tok::kw_volatile:
1633 case tok::kw_restrict:
1634 case tok::kw__Atomic:
1635 case tok::kw___unaligned:
1639 case tok::kw_inline:
1640 case tok::kw_virtual:
1641 case tok::kw_friend:
1643 case tok::kw_static:
1644 case tok::kw_extern:
1645 case tok::kw_typedef:
1646 case tok::kw_register:
1648 case tok::kw_mutable:
1649 case tok::kw_thread_local:
1650 case tok::kw_constexpr:
1651 case tok::kw_consteval:
1652 case tok::kw_constinit:
1668 if (!isKnownToBeTypeSpecifier(
NextToken()))
1725 ParsedTemplateInfo &TemplateInfo,
1727 DeclSpecContext DSC,
1730 if (TagTokKind == tok::kw_struct)
1732 else if (TagTokKind == tok::kw___interface)
1734 else if (TagTokKind == tok::kw_class)
1737 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1741 if (Tok.
is(tok::code_completion)) {
1755 const bool shouldDelayDiagsInTag =
1756 (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate);
1762 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1764 if (Tok.
isOneOf(tok::kw___single_inheritance,
1765 tok::kw___multiple_inheritance,
1766 tok::kw___virtual_inheritance)) {
1767 ParseMicrosoftInheritanceClassAttributes(attrs);
1770 if (Tok.
is(tok::kw__Nullable)) {
1771 ParseNullabilityClassAttributes(attrs);
1785#include
"clang/Basic/TransformTypeTraits.def"
1786 tok::kw___is_abstract,
1787 tok::kw___is_aggregate,
1788 tok::kw___is_arithmetic,
1790 tok::kw___is_assignable,
1791 tok::kw___is_base_of,
1792 tok::kw___is_bounded_array,
1794 tok::kw___is_complete_type,
1795 tok::kw___is_compound,
1797 tok::kw___is_constructible,
1798 tok::kw___is_convertible,
1799 tok::kw___is_convertible_to,
1800 tok::kw___is_destructible,
1803 tok::kw___is_floating_point,
1805 tok::kw___is_function,
1806 tok::kw___is_fundamental,
1807 tok::kw___is_integral,
1808 tok::kw___is_interface_class,
1809 tok::kw___is_literal,
1810 tok::kw___is_lvalue_expr,
1811 tok::kw___is_lvalue_reference,
1812 tok::kw___is_member_function_pointer,
1813 tok::kw___is_member_object_pointer,
1814 tok::kw___is_member_pointer,
1815 tok::kw___is_nothrow_assignable,
1816 tok::kw___is_nothrow_constructible,
1817 tok::kw___is_nothrow_convertible,
1818 tok::kw___is_nothrow_destructible,
1819 tok::kw___is_object,
1821 tok::kw___is_pointer,
1822 tok::kw___is_polymorphic,
1823 tok::kw___is_reference,
1824 tok::kw___is_referenceable,
1825 tok::kw___is_rvalue_expr,
1826 tok::kw___is_rvalue_reference,
1828 tok::kw___is_scalar,
1829 tok::kw___is_scoped_enum,
1830 tok::kw___is_sealed,
1831 tok::kw___is_signed,
1832 tok::kw___is_standard_layout,
1833 tok::kw___is_trivial,
1834 tok::kw___is_trivially_equality_comparable,
1835 tok::kw___is_trivially_assignable,
1836 tok::kw___is_trivially_constructible,
1837 tok::kw___is_trivially_copyable,
1838 tok::kw___is_unbounded_array,
1840 tok::kw___is_unsigned,
1842 tok::kw___is_volatile
1849 TryKeywordIdentFallback(
true);
1851 struct PreserveAtomicIdentifierInfoRAII {
1852 PreserveAtomicIdentifierInfoRAII(
Token &Tok,
bool Enabled)
1853 : AtomicII(nullptr) {
1856 assert(Tok.
is(tok::kw__Atomic));
1861 ~PreserveAtomicIdentifierInfoRAII() {
1864 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1874 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1875 Tok.
is(tok::kw__Atomic) &&
1877 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1878 Tok, ShouldChangeAtomicToIdentifier);
1888 if (TemplateInfo.TemplateParams)
1891 bool HasValidSpec =
true;
1892 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1896 HasValidSpec =
false;
1899 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::annot_template_id)) {
1900 Diag(Tok, diag::err_expected) << tok::identifier;
1901 HasValidSpec =
false;
1909 auto RecoverFromUndeclaredTemplateName = [&](
IdentifierInfo *Name,
1912 bool KnownUndeclared) {
1913 Diag(NameLoc, diag::err_explicit_spec_non_template)
1914 << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
1915 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1919 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1920 if (TemplateParams->size() > 1) {
1921 TemplateParams->pop_back();
1923 TemplateParams =
nullptr;
1924 TemplateInfo.Kind = ParsedTemplateInfo::NonTemplate;
1926 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1928 TemplateParams =
nullptr;
1929 TemplateInfo.Kind = ParsedTemplateInfo::NonTemplate;
1939 if (Tok.
is(tok::identifier)) {
1948 TemplateArgList TemplateArgs;
1950 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1956 RecoverFromUndeclaredTemplateName(
1957 Name, NameLoc,
SourceRange(LAngleLoc, RAngleLoc),
false);
1959 }
else if (Tok.
is(tok::annot_template_id)) {
1960 TemplateId = takeTemplateIdAnnotation(Tok);
1961 NameLoc = ConsumeAnnotationToken();
1968 RecoverFromUndeclaredTemplateName(
1971 TemplateId =
nullptr;
1984 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1985 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) <<
Range;
2020 MaybeParseCXX11Attributes(Attributes);
2029 Tok.
isOneOf(tok::comma, tok::ellipsis))
2032 AllowDefiningTypeSpec::No ||
2035 else if (Tok.
is(tok::l_brace) ||
2036 (DSC != DeclSpecContext::DSC_association &&
2038 (isClassCompatibleKeyword() &&
2054 }
else if (isClassCompatibleKeyword() &&
2061 TentativeParsingAction PA(*
this);
2064 while (isClassCompatibleKeyword()) {
2070 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square)) {
2074 }
else if (Tok.
is(tok::kw_alignas) &&
NextToken().is(tok::l_paren)) {
2084 if (!
T.consumeOpen())
2092 if (Tok.
isOneOf(tok::l_brace, tok::colon))
2098 }
else if (!isTypeSpecifier(DSC) &&
2099 (Tok.
is(tok::semi) ||
2102 if (Tok.
isNot(tok::semi)) {
2105 ExpectAndConsume(tok::semi, diag::err_expected_after,
2123 auto *FirstAttr = Attributes.
empty() ? nullptr : &Attributes.
front();
2125 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2126 ?
Diag(
Loc, diag::err_keyword_not_allowed) << FirstAttr
2127 :
Diag(
Loc, diag::err_attributes_not_allowed))
2139 if (!Name && !TemplateId &&
2144 Diag(StartLoc, diag::err_anon_type_definition)
2171 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2174 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2175 diag::err_keyword_not_allowed,
2179 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2190 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
2191 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2192 diag::err_keyword_not_allowed,
2202 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2215 "Expected a definition here");
2219 TemplateParams =
nullptr;
2224 diag::err_explicit_instantiation_with_definition)
2233 LAngleLoc,
nullptr));
2234 TemplateParams = &FakedParamLists;
2241 SS, *TemplateId, attrs,
2244 TemplateParams ? TemplateParams->size() : 0),
2247 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2254 ProhibitAttributes(attrs);
2257 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2258 TagType, StartLoc, SS, Name, NameLoc, attrs);
2260 TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
2261 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2262 diag::err_keyword_not_allowed,
2278 if (Tok.
is(tok::comma)) {
2280 diag::err_friend_template_decl_multiple_specifiers);
2286 NameLoc, EllipsisLoc, attrs,
2288 TemplateParams ? TemplateParams->size() : 0));
2291 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2292 diag::err_keyword_not_allowed,
2296 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2299 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2301 TemplateParams =
nullptr;
2304 bool IsDependent =
false;
2314 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2317 TagOrTempResult = Actions.
ActOnTag(
2321 DSC == DeclSpecContext::DSC_type_specifier,
2322 DSC == DeclSpecContext::DSC_template_param ||
2323 DSC == DeclSpecContext::DSC_template_type_arg,
2324 OffsetOfState, &SkipBody);
2331 Name, StartLoc, NameLoc);
2338 if (shouldDelayDiagsInTag) {
2339 diagsFromTag.done();
2341 TemplateInfo.Kind == ParsedTemplateInfo::Template)
2342 diagsFromTag.redelay();
2347 assert(Tok.
is(tok::l_brace) ||
2349 isClassCompatibleKeyword());
2351 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc,
TagType,
2352 TagOrTempResult.
get());
2354 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs,
TagType,
2355 TagOrTempResult.
get());
2360 ParseStructUnionBody(StartLoc,
TagType, cast<RecordDecl>(
D));
2373 const char *PrevSpec =
nullptr;
2378 NameLoc.
isValid() ? NameLoc : StartLoc,
2380 }
else if (!TagOrTempResult.
isInvalid()) {
2382 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2383 DiagID, TagOrTempResult.
get(), Owned, Policy);
2390 Diag(StartLoc, DiagID) << PrevSpec;
2406 (TemplateInfo.Kind || !isValidAfterTypeSpecifier(
false))) {
2407 if (Tok.
isNot(tok::semi)) {
2409 ExpectAndConsume(tok::semi, diag::err_expected_after,
2427void Parser::ParseBaseClause(
Decl *ClassDecl) {
2428 assert(Tok.
is(tok::colon) &&
"Not a base clause");
2437 if (
Result.isInvalid()) {
2443 BaseInfo.push_back(
Result.get());
2468 bool IsVirtual =
false;
2472 MaybeParseCXX11Attributes(Attributes);
2478 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2488 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2492 if (Tok.
is(tok::kw_virtual)) {
2496 Diag(VirtualLoc, diag::err_dup_virtual)
2503 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2517 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2533 Access, BaseType.
get(), BaseLoc,
2548 case tok::kw_private:
2550 case tok::kw_protected:
2552 case tok::kw_public:
2561void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2568 if (!NeedLateParse) {
2572 if (Param->hasUnparsedDefaultArg()) {
2573 NeedLateParse =
true;
2579 if (NeedLateParse) {
2582 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2583 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2588 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2590 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2627 if (II == Ident_override)
2630 if (II == Ident_sealed)
2633 if (II == Ident_abstract)
2636 if (II == Ident_final)
2639 if (II == Ident_GNU_final)
2650void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2669 const char *PrevSpec =
nullptr;
2687 ? diag::warn_cxx98_compat_override_control_keyword
2688 : diag::ext_override_control_keyword)
2697bool Parser::isCXX11FinalKeyword()
const {
2706bool Parser::isClassCompatibleKeyword()
const {
2716bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2718 LateParsedAttrList &LateParsedAttrs) {
2729 if (Tok.
isNot(tok::colon))
2730 ParseDeclarator(DeclaratorInfo);
2735 MaybeParseHLSLAnnotations(DeclaratorInfo,
nullptr,
2740 "don't know where identifier would go yet?");
2744 }
else if (Tok.
is(tok::kw_requires)) {
2745 ParseTrailingRequiresClause(DeclaratorInfo);
2747 ParseOptionalCXX11VirtSpecifierSeq(
2748 VS, getCurrentClass().IsInterface,
2751 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2756 if (Tok.
is(tok::kw_asm)) {
2759 if (AsmLabel.isInvalid())
2769 DiagnoseAndSkipCXX11Attributes();
2770 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2771 DiagnoseAndSkipCXX11Attributes();
2776 ParseOptionalCXX11VirtSpecifierSeq(
2777 VS, getCurrentClass().IsInterface,
2783 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2784 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2786 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2803void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2809 ParseTypeQualifierListOpt(
2810 DS, AR_NoAttributesParsed,
false,
2811 false, llvm::function_ref<
void()>([&]() {
2814 D.ExtendWithDeclSpec(DS);
2816 if (
D.isFunctionDeclarator()) {
2817 auto &
Function =
D.getFunctionTypeInfo();
2819 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2822 auto &MQ =
Function.getOrCreateMethodQualifiers();
2823 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2824 std::string Name(FixItName.data());
2827 MQ.SetTypeQual(TypeQual, SpecLoc);
2829 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2838 bool RefQualifierIsLValueRef =
true;
2840 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2841 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2844 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2845 Function.RefQualifierLoc = RefQualifierLoc;
2847 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2848 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2851 D.SetRangeEnd(RefQualifierLoc);
2910 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2911 if (Tok.
is(tok::at)) {
2913 Diag(Tok, diag::err_at_defs_cxx);
2915 Diag(Tok, diag::err_at_in_class);
2931 bool MalformedTypeSpec =
false;
2932 if (!TemplateInfo.Kind &&
2933 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2935 MalformedTypeSpec =
true;
2938 if (Tok.
isNot(tok::annot_cxxscope))
2939 isAccessDecl =
false;
2940 else if (
NextToken().is(tok::identifier))
2941 isAccessDecl = GetLookAheadToken(2).
is(tok::semi);
2948 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2961 false,
false,
true,
true,
2962 false, &TemplateKWLoc, Name)) {
2968 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2969 "access declaration")) {
2985 if (!TemplateInfo.Kind &&
2986 Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2992 if (Tok.
is(tok::kw_template)) {
2993 assert(!TemplateInfo.TemplateParams &&
2994 "Nested template improperly parsed?");
2998 DeclEnd, AccessAttrs, AS);
3002 if (Tok.
is(tok::kw___extension__)) {
3006 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
3012 MaybeParseCXX11Attributes(DeclAttrs);
3017 if (Tok.
is(tok::annot_attr_openmp))
3018 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
3020 if (Tok.
is(tok::kw_using)) {
3025 while (Tok.
is(tok::kw_template)) {
3027 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
3031 if (Tok.
is(tok::kw_namespace)) {
3032 Diag(UsingLoc, diag::err_using_namespace_in_class);
3039 UsingLoc, DeclEnd, DeclAttrs, AS);
3043 MaybeParseMicrosoftAttributes(DeclSpecAttrs);
3046 LateParsedAttrList CommonLateParsedAttrs;
3053 if (MalformedTypeSpec)
3061 bool IsTemplateSpecOrInst =
3062 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
3063 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
3066 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
3067 &CommonLateParsedAttrs);
3069 if (IsTemplateSpecOrInst)
3070 diagsFromTag.done();
3078 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate &&
3079 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
3080 &CommonLateParsedAttrs))
3084 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
3086 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
3090 ProhibitAttributes(DeclAttrs);
3094 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
3096 DS.complete(TheDecl);
3098 Decl *decls[] = {AnonRecord, TheDecl};
3111 ? diag::warn_cxx23_variadic_friends
3112 : diag::ext_variadic_friends);
3125 AnonRecord, VariadicLoc);
3136 if (ParsedFriendDecl(DS))
3141 const char *PrevSpec =
nullptr;
3142 unsigned DiagId = 0;
3144 ParseDeclarationSpecifiers(
DeclSpec, TemplateInfo, AS,
3145 DeclSpecContext::DSC_class,
nullptr);
3150 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_stmt,
3151 "friend declaration");
3159 if (Tok.
is(tok::kw_concept)) {
3163 ? llvm::to_underlying(diag::err_friend_concept)
3164 : llvm::to_underlying(
3166 err_concept_decls_may_only_appear_in_global_namespace_scope));
3173 if (TemplateInfo.TemplateParams)
3178 LateParsedAttrList LateParsedAttrs;
3183 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
3184 if (Tok.
isNot(tok::equal))
3189 if (
Zero.isNot(tok::numeric_constant) ||
3193 auto &
After = GetLookAheadToken(2);
3194 if (!
After.isOneOf(tok::semi, tok::comma) &&
3195 !(AllowDefinition &&
3196 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3207 bool ExpectSemi =
true;
3215 if (ParseCXXMemberDeclaratorBeforeInitializer(
3216 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3221 if (IsTemplateSpecOrInst)
3229 TryConsumePureSpecifier(
true);
3240 if (Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3242 }
else if (Tok.
is(tok::equal)) {
3244 if (KW.
is(tok::kw_default))
3246 else if (KW.
is(tok::kw_delete))
3248 else if (KW.
is(tok::code_completion)) {
3265 ProhibitAttributes(DeclAttrs);
3282 diag::err_function_declared_typedef);
3288 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3289 TemplateInfo, VS, PureSpecLoc);
3292 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3293 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3295 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3296 LateParsedAttrs[i]->addDecl(FunDecl);
3299 LateParsedAttrs.clear();
3302 if (Tok.
is(tok::semi))
3303 ConsumeExtraSemi(AfterMemberFunctionDefinition);
3315 bool HasStaticInitializer =
false;
3320 Diag(Tok, diag::err_anon_bitfield_member_init);
3324 if (!TryConsumePureSpecifier(
false))
3326 HasStaticInitializer =
true;
3332 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate) {
3334 if (BitfieldSize.
get())
3336 ? diag::warn_cxx17_compat_bitfield_member_init
3337 : diag::ext_bitfield_member_init);
3340 HasStaticInitializer =
true;
3356 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3357 auto Loc = AL.getRange().getBegin();
3358 (AL.isRegularKeywordAttribute()
3359 ?
Diag(
Loc, diag::err_keyword_not_allowed) << AL
3360 :
Diag(
Loc, diag::err_attributes_not_allowed))
3368 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3369 VS, HasInClassInit);
3372 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3375 ThisDecl = VT->getTemplatedDecl();
3384 DeclaratorInfo.getDeclSpec().getStorageClassSpec() ==
3387 HasStaticInitializer =
true;
3391 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3393 if (ThisDecl && PureSpecLoc.
isValid())
3402 ? diag::warn_cxx98_compat_nonstatic_member_init
3403 : diag::ext_nonstatic_member_init);
3405 if (DeclaratorInfo.isArrayOfUnknownBound()) {
3411 Diag(Tok, diag::err_incomplete_array_member_init);
3418 ParseCXXNonStaticMemberInitializer(ThisDecl);
3419 }
else if (HasStaticInitializer) {
3422 ThisDecl, DeclaratorInfo.isDeclarationOfFunction(), EqualLoc);
3424 if (
Init.isInvalid()) {
3428 }
else if (ThisDecl)
3431 }
else if (ThisDecl && DeclaratorInfo.isStaticMember())
3438 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3439 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3441 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3442 LateParsedAttrs[i]->addDecl(ThisDecl);
3445 DeclsInGroup.push_back(ThisDecl);
3447 if (DeclaratorInfo.isFunctionDeclarator() &&
3448 DeclaratorInfo.getDeclSpec().getStorageClassSpec() !=
3450 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3452 LateParsedAttrs.clear();
3454 DeclaratorInfo.complete(ThisDecl);
3467 Diag(CommaLoc, diag::err_expected_semi_declaration)
3477 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
3478 DeclaratorInfo.isFirstDeclarator()) {
3479 Diag(CommaLoc, diag::err_multiple_template_declarators)
3480 << TemplateInfo.Kind;
3484 DeclaratorInfo.clear();
3488 DeclaratorInfo.setCommaLoc(CommaLoc);
3493 DiagnoseAndSkipCXX11Attributes();
3494 MaybeParseGNUAttributes(DeclaratorInfo);
3495 DiagnoseAndSkipCXX11Attributes();
3497 if (ParseCXXMemberDeclaratorBeforeInitializer(
3498 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3503 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
3536 assert(Tok.
isOneOf(tok::equal, tok::l_brace) &&
3537 "Data member initializer not starting with '=' or '{'");
3539 bool IsFieldInitialization = isa_and_present<FieldDecl>(
D);
3543 IsFieldInitialization
3552 IsFieldInitialization;
3555 if (Tok.
is(tok::kw_delete)) {
3562 if (IsFunction || Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3568 SkipDeletedFunctionBody();
3571 }
else if (Tok.
is(tok::kw_default)) {
3573 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3581 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(
D)) {
3582 Diag(Tok, diag::err_ms_property_initializer) << PD;
3585 return ParseInitializer();
3593 assert(isCXX11FinalKeyword() &&
"not a class definition");
3599 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3604 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_brace))
3611 if (Tok.
is(tok::colon)) {
3614 ParsingClassDefinition ParsingDef(*
this,
TagDecl,
true,
3620 ParseBaseClause(
nullptr);
3624 if (!Tok.
is(tok::l_brace)) {
3626 diag::err_expected_lbrace_after_base_specifiers);
3632 assert(Tok.
is(tok::l_brace));
3638 if (Tok.
is(tok::kw___attribute)) {
3640 MaybeParseGNUAttributes(Attrs);
3650 case tok::kw___if_exists:
3651 case tok::kw___if_not_exists:
3652 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, AS);
3657 ConsumeExtraSemi(InsideStruct,
TagType);
3661 case tok::annot_pragma_vis:
3662 HandlePragmaVisibility();
3664 case tok::annot_pragma_pack:
3667 case tok::annot_pragma_align:
3668 HandlePragmaAlign();
3670 case tok::annot_pragma_ms_pointers_to_members:
3671 HandlePragmaMSPointersToMembers();
3673 case tok::annot_pragma_ms_pragma:
3674 HandlePragmaMSPragma();
3676 case tok::annot_pragma_ms_vtordisp:
3677 HandlePragmaMSVtorDisp();
3679 case tok::annot_pragma_dump:
3683 case tok::kw_namespace:
3685 DiagnoseUnexpectedNamespace(cast<NamedDecl>(
TagDecl));
3688 case tok::kw_private:
3692 ParsedTemplateInfo TemplateInfo;
3693 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3696 case tok::kw_public:
3697 case tok::kw_protected: {
3707 AccessAttrs.
clear();
3708 MaybeParseGNUAttributes(AccessAttrs);
3713 Diag(EndLoc, diag::err_expected)
3717 Diag(EndLoc, diag::err_expected)
3729 AccessAttrs.
clear();
3735 case tok::annot_attr_openmp:
3736 case tok::annot_pragma_openmp:
3737 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3739 case tok::annot_pragma_openacc:
3747 ConsumeAnnotationToken();
3750 ParsedTemplateInfo TemplateInfo;
3751 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3768 "Invalid TagType!");
3770 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3771 if (
auto *TD = dyn_cast_or_null<NamedDecl>(
TagDecl))
3772 return TD->getQualifiedNameAsString();
3773 return std::string(
"<anonymous>");
3777 "parsing struct/union/class body");
3781 bool NonNestedClass =
true;
3782 if (!ClassStack.empty()) {
3784 if (S->isClassScope()) {
3786 NonNestedClass =
false;
3789 if (getCurrentClass().IsInterface) {
3793 ? cast<NamedDecl>(
TagDecl)->getQualifiedNameAsString()
3799 if (S->isFunctionScope())
3810 ParsingClassDefinition ParsingDef(*
this,
TagDecl, NonNestedClass,
3818 bool IsFinalSpelledSealed =
false;
3819 bool IsAbstract =
false;
3827 if (isCXX11FinalKeyword()) {
3830 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3835 IsFinalSpelledSealed =
true;
3840 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3848 Diag(FinalLoc, diag::err_override_control_interface)
3852 ? diag::warn_cxx98_compat_override_control_keyword
3853 : diag::ext_override_control_keyword)
3856 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3858 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3860 Diag(FinalLoc, diag::ext_warn_gnu_final);
3863 "not a class definition");
3869 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3878 if (!Tok.
is(tok::colon) && !Tok.
is(tok::l_brace)) {
3885 if (Tok.
is(tok::colon)) {
3886 ParseScope InheritanceScope(
this,
getCurScope()->getFlags() |
3890 if (!Tok.
is(tok::l_brace)) {
3891 bool SuggestFixIt =
false;
3895 case tok::kw_private:
3896 case tok::kw_protected:
3897 case tok::kw_public:
3900 case tok::kw_static_assert:
3904 case tok::kw_template:
3905 SuggestFixIt =
true;
3907 case tok::identifier:
3908 SuggestFixIt = isConstructorDeclarator(
true);
3911 SuggestFixIt = isCXXSimpleDeclaration(
false);
3916 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3930 assert(Tok.
is(tok::l_brace));
3936 IsFinalSpelledSealed, IsAbstract,
3937 T.getOpenLocation());
3952 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3953 Tok.
isNot(tok::eof)) {
3955 ParseCXXClassMemberDeclarationWithPragmas(
3957 MaybeDestroyTemplateIds();
3966 MaybeParseGNUAttributes(attrs);
3970 T.getOpenLocation(),
3971 T.getCloseLocation(), attrs);
3978 if (
TagDecl && NonNestedClass) {
3985 ParseLexedPragmas(getCurrentClass());
3986 ParseLexedAttributes(getCurrentClass());
3987 ParseLexedMethodDeclarations(getCurrentClass());
3992 ParseLexedMemberInitializers(getCurrentClass());
3993 ParseLexedMethodDefs(getCurrentClass());
3994 PrevTokLocation = SavedPrevTokLocation;
4009void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *
D) {
4010 assert(Tok.
is(tok::kw_namespace));
4049void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
4050 assert(Tok.
is(tok::colon) &&
4051 "Constructor initializer always starts with ':'");
4059 bool AnyErrors =
false;
4062 if (Tok.
is(tok::code_completion)) {
4065 ConstructorDecl, MemInitializers);
4069 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
4071 MemInitializers.push_back(MemInit.
get());
4075 if (Tok.
is(tok::comma))
4077 else if (Tok.
is(tok::l_brace))
4082 Tok.
isOneOf(tok::identifier, tok::coloncolon)) {
4084 Diag(
Loc, diag::err_ctor_init_missing_comma)
4090 << tok::l_brace << tok::comma;
4115 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
4128 if (Tok.
is(tok::identifier)) {
4133 }
else if (Tok.
is(tok::annot_decltype)) {
4138 ParseDecltypeSpecifier(DS);
4139 }
else if (Tok.
is(tok::annot_pack_indexing_type)) {
4142 ParsePackIndexingType(DS);
4145 ? takeTemplateIdAnnotation(Tok)
4150 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
4152 ConsumeAnnotationToken();
4154 Diag(Tok, diag::err_expected_member_or_base_name);
4161 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
4164 ExprResult InitList = ParseBraceInitializer();
4174 TemplateTypeTy.
get(), DS, IdLoc,
4175 InitList.
get(), EllipsisLoc);
4176 }
else if (Tok.
is(tok::l_paren)) {
4181 ExprVector ArgExprs;
4182 auto RunSignatureHelp = [&] {
4187 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
4188 T.getOpenLocation(),
false);
4189 CalledSignatureHelp =
true;
4190 return PreferredType;
4192 if (Tok.
isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
4193 PreferredType.enterFunctionArgument(Tok.
getLocation(),
4210 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
4211 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
4218 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
4220 return Diag(Tok, diag::err_expected) << tok::l_paren;
4238 ExceptionSpecTokens =
nullptr;
4242 if (Tok.
isNot(tok::kw_throw) && Tok.
isNot(tok::kw_noexcept))
4246 bool IsNoexcept = Tok.
is(tok::kw_noexcept);
4247 Token StartTok = Tok;
4251 if (!Tok.
is(tok::l_paren)) {
4254 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4255 NoexceptExpr =
nullptr;
4259 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4265 ExceptionSpecTokens->push_back(StartTok);
4266 ExceptionSpecTokens->push_back(Tok);
4267 SpecificationRange.
setEnd(ConsumeParen());
4269 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4272 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4278 if (Tok.
is(tok::kw_throw)) {
4279 Result = ParseDynamicExceptionSpecification(
4280 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4281 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4282 "Produced different number of exception types and ranges.");
4286 if (Tok.
isNot(tok::kw_noexcept))
4289 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4297 if (Tok.
is(tok::l_paren)) {
4310 NoexceptRange =
SourceRange(KeywordLoc,
T.getCloseLocation());
4317 NoexceptRange =
SourceRange(KeywordLoc, KeywordLoc);
4321 SpecificationRange = NoexceptRange;
4326 if (Tok.
is(tok::kw_throw)) {
4327 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4328 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4329 DynamicExceptionRanges);
4332 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4340 if (
P.getLangOpts().CPlusPlus11) {
4341 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4343 ? diag::ext_dynamic_exception_spec
4344 : diag::warn_exception_spec_deprecated)
4365 assert(Tok.
is(tok::kw_throw) &&
"expected throw");
4369 if (
T.consumeOpen()) {
4370 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4377 if (Tok.
is(tok::ellipsis)) {
4380 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4382 SpecificationRange.
setEnd(
T.getCloseLocation());
4389 while (Tok.
isNot(tok::r_paren)) {
4392 if (Tok.
is(tok::ellipsis)) {
4398 if (!Res.isInvalid())
4402 if (!Res.isInvalid()) {
4403 Exceptions.push_back(Res.get());
4404 Ranges.push_back(
Range);
4412 SpecificationRange.
setEnd(
T.getCloseLocation());
4414 Exceptions.empty());
4421 bool MayBeFollowedByDirectInit) {
4422 assert(Tok.
is(tok::arrow) &&
"expected arrow");
4432void Parser::ParseTrailingRequiresClause(
Declarator &
D) {
4433 assert(Tok.
is(tok::kw_requires) &&
"expected requires");
4451 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4453 DeclScopeObj.EnterDeclaratorScope();
4462 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4463 InitCXXThisScopeForDeclaratorIfRelevant(
D,
D.getDeclSpec(), ThisScope);
4465 TrailingRequiresClause =
4468 TrailingRequiresClause =
4471 if (!
D.isDeclarationOfFunction()) {
4473 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4478 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4481 D.setTrailingRequiresClause(TrailingRequiresClause.
get());
4484 if (
D.isFunctionDeclarator() && Tok.
is(tok::arrow) &&
4485 D.getDeclSpec().getTypeSpecType() ==
TST_auto) {
4489 ParseTrailingReturnType(
Range,
false);
4493 diag::err_requires_clause_must_appear_after_trailing_return)
4495 auto &FunctionChunk =
D.getFunctionTypeInfo();
4496 FunctionChunk.HasTrailingReturnType = TrailingReturnType.
isUsable();
4497 FunctionChunk.TrailingReturnType = TrailingReturnType.
get();
4500 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4509 bool NonNestedClass,
4511 assert((NonNestedClass || !ClassStack.empty()) &&
4512 "Nested class without outer class");
4513 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4519void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4520 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4521 delete Class->LateParsedDeclarations[I];
4532 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4536 ParsingClass *Victim = ClassStack.top();
4538 if (Victim->TopLevelClass) {
4541 DeallocateParsedClasses(Victim);
4544 assert(!ClassStack.empty() &&
"Missing top-level class?");
4546 if (Victim->LateParsedDeclarations.empty()) {
4551 DeallocateParsedClasses(Victim);
4559 "Nested class outside of class scope?");
4560 ClassStack.top()->LateParsedDeclarations.push_back(
4561 new LateParsedClass(
this, Victim));
4587 case tok::code_completion:
4594 case tok::numeric_constant: {
4602 StringRef Spelling = PP.
getSpelling(ExpansionLoc, ExpansionBuf);
4603 if (Spelling ==
"__clang__") {
4607 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4623 case tok::pipeequal:
4624 case tok::caretequal:
4626 case tok::exclaimequal:
4632 StringRef Spelling = PP.
getSpelling(SpellingLoc, SpellingBuf);
4641void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4646 if (
T.consumeOpen()) {
4647 Diag(Tok, diag::err_expected) << tok::l_paren;
4651 if (AttrName->
isStr(
"directive")) {
4657 OMPBeginTok.
setKind(tok::annot_attr_openmp);
4659 OpenMPTokens.push_back(OMPBeginTok);
4661 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4665 OMPEndTok.
setKind(tok::annot_pragma_openmp_end);
4667 OpenMPTokens.push_back(OMPEndTok);
4669 assert(AttrName->
isStr(
"sequence") &&
4670 "Expected either 'directive' or 'sequence'");
4679 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4683 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4684 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4688 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4695 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4709 case ParsedAttr::AT_CarriesDependency:
4710 case ParsedAttr::AT_Deprecated:
4711 case ParsedAttr::AT_FallThrough:
4712 case ParsedAttr::AT_CXX11NoReturn:
4713 case ParsedAttr::AT_NoUniqueAddress:
4714 case ParsedAttr::AT_Likely:
4715 case ParsedAttr::AT_Unlikely:
4717 case ParsedAttr::AT_WarnUnusedResult:
4718 return !ScopeName && AttrName->
getName() ==
"nodiscard";
4719 case ParsedAttr::AT_Unused:
4720 return !ScopeName && AttrName->
getName() ==
"maybe_unused";
4732 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4740 TentativeParsingAction TPA(*
this);
4743 if (Res.isInvalid()) {
4746 if (Tok.
is(tok::r_paren))
4751 if (!Tok.
isOneOf(tok::r_paren, tok::r_square)) {
4756 if (!Res.isInvalid()) {
4757 auto *
E = Res.get();
4796bool Parser::ParseCXX11AttributeArgs(
4800 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4804 LO.CPlusPlus ? ParsedAttr::Form::CXX11() :
ParsedAttr::Form::
C23();
4810 Form = ParsedAttr::Form::Microsoft();
4825 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4828 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4829 ScopeLoc, Form,
nullptr);
4834 if (ScopeName && ScopeName->
isStr(
"omp") &&
4835 (AttrName->
isStr(
"directive") || AttrName->
isStr(
"sequence"))) {
4837 ? diag::warn_omp51_compat_attributes
4838 : diag::ext_omp_attributes);
4840 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4849 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4850 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4851 ScopeName, ScopeLoc, Form);
4853 else if (!ScopeName && AttrName->
isStr(
"assume")) {
4854 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form))
4858 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4859 ScopeName, ScopeLoc, Form);
4861 if (!Attrs.
empty() &&
4867 Diag(LParenLoc, diag::warn_unknown_attribute_ignored) << AttrName;
4868 Attr.setInvalid(
true);
4876 if (
Attr.getMaxArgs() && !NumArgs) {
4879 Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
4880 Attr.setInvalid(
true);
4881 }
else if (!
Attr.getMaxArgs()) {
4885 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4888 Attr.setInvalid(
true);
4921 if (Tok.
is(tok::kw_alignas)) {
4928 ParseAlignmentSpecifier(Attrs, EndLoc);
4939 if (!Tok.
is(tok::l_paren))
4942 ParseAttributeArgsCommon(AttrName,
Loc, Attrs, EndLoc,
4946 Attrs.
addNew(AttrName,
Loc,
nullptr,
Loc,
nullptr, 0, Form);
4950 assert(Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square) &&
4951 "Not a double square bracket attribute list");
4956 : diag::warn_ext_cxx11_attributes);
4959 : diag::warn_ext_c23_attributes);
4963 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4968 if (Tok.
is(tok::kw_using)) {
4970 ? diag::warn_cxx14_compat_using_attribute_ns
4971 : diag::ext_using_attribute_ns);
4974 CommonScopeName = TryParseCXX11AttributeIdentifier(
4976 if (!CommonScopeName) {
4984 bool AttrParsed =
false;
4985 while (!Tok.
isOneOf(tok::r_square, tok::semi, tok::eof)) {
4989 if (ExpectAndConsume(tok::comma)) {
5003 AttrName = TryParseCXX11AttributeIdentifier(
5012 ScopeName = AttrName;
5015 AttrName = TryParseCXX11AttributeIdentifier(
5025 if (CommonScopeName) {
5027 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
5030 ScopeName = CommonScopeName;
5031 ScopeLoc = CommonScopeLoc;
5036 if (Tok.
is(tok::l_paren))
5037 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
5038 ScopeName, ScopeLoc, OpenMPTokens);
5044 ScopeName, ScopeLoc,
nullptr, 0,
5046 : ParsedAttr::Form::C23());
5051 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) << AttrName;
5056 if (Tok.
is(tok::semi)) {
5062 if (ExpectAndConsume(tok::r_square))
5064 else if (Tok.
is(tok::r_square))
5065 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
5068 if (ExpectAndConsume(tok::r_square))
5081 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
5082 }
while (isAllowedCXX11AttributeSpecifier());
5087void Parser::DiagnoseAndSkipCXX11Attributes() {
5096 (Keyword ?
Diag(StartLoc, diag::err_keyword_not_allowed) << Keyword
5097 :
Diag(StartLoc, diag::err_attributes_not_allowed))
5105 if (!isCXX11AttributeSpecifier())
5109 if (Tok.
is(tok::l_square)) {
5113 EndLoc =
T.getCloseLocation();
5120 "not an attribute specifier");
5123 if (!
T.consumeOpen())
5125 EndLoc =
T.getCloseLocation();
5127 }
while (isCXX11AttributeSpecifier());
5134 assert(Tok.
is(tok::identifier) &&
"Not a Microsoft attribute list");
5136 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
5143 if (
T.consumeOpen()) {
5144 Diag(Tok, diag::err_expected) << tok::l_paren;
5149 if (isTokenStringLiteral()) {
5154 ArgExprs.push_back(StringResult.
get());
5171 while (Tok.
isNot(tok::r_paren)) {
5173 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5178 SpellingBuffer.resize(Tok.
getLength() + 1);
5180 StringRef TokSpelling = PP.
getSpelling(Tok, SpellingBuffer, &Invalid);
5185 StrBuffer += TokSpelling;
5191 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5201 Toks[0].
setKind(tok::string_literal);
5207 ArgExprs.push_back(UuidString);
5210 if (!
T.consumeClose()) {
5213 ParsedAttr::Form::Microsoft());
5226 assert(Tok.
is(tok::l_square) &&
"Not a Microsoft attribute list");
5237 SkipUntil(tok::r_square, tok::identifier,
5239 if (Tok.
is(tok::code_completion)) {
5247 if (Tok.
isNot(tok::identifier))
5250 ParseMicrosoftUuidAttributeArgs(Attrs);
5260 bool AttrParsed =
false;
5261 if (Tok.
is(tok::l_paren)) {
5264 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5266 ReplayOpenMPAttributeTokens(OpenMPTokens);
5270 ParsedAttr::Form::Microsoft());
5277 EndLoc =
T.getCloseLocation();
5278 }
while (Tok.
is(tok::l_square));
5283void Parser::ParseMicrosoftIfExistsClassDeclaration(
5286 IfExistsCondition
Result;
5287 if (ParseMicrosoftIfExistsCondition(
Result))
5291 if (
Braces.consumeOpen()) {
5292 Diag(Tok, diag::err_expected) << tok::l_brace;
5296 switch (
Result.Behavior) {
5302 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5312 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
5314 if (Tok.
isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5315 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, CurAS);
5320 if (Tok.
is(tok::semi)) {
5321 ConsumeExtraSemi(InsideStruct,
TagType);
5331 if (Tok.
is(tok::colon))
5335 Diag(Tok, diag::err_expected) << tok::colon;
5340 ParsedTemplateInfo TemplateInfo;
5342 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.
bool isIncrementalProcessingEnabled() const
Returns true if incremental processing is enabled.
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)
@ PCC_TopLevelOrExpression
Code completion occurs at top-level in a REPL session.
@ PCC_Namespace
Code completion occurs at top-level or namespace context.
void CodeCompleteAfterFunctionEquals(Declarator &D)
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
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.