30#include "llvm/ADT/SmallString.h"
31#include "llvm/Support/TimeProfiler.h"
66 assert(Tok.
is(tok::kw_namespace) &&
"Not a namespace!");
70 if (Tok.
is(tok::code_completion)) {
78 InnerNamespaceInfoList ExtraNSs;
83 auto ReadAttributes = [&] {
87 if (Tok.
is(tok::kw___attribute)) {
88 ParseGNUAttributes(attrs);
93 ? diag::warn_cxx14_compat_ns_enum_attribute
94 : diag::ext_ns_enum_attribute)
96 ParseCXX11Attributes(attrs);
99 }
while (MoreToParse);
104 if (Tok.
is(tok::identifier)) {
107 while (Tok.
is(tok::coloncolon) &&
110 GetLookAheadToken(2).is(tok::identifier)))) {
112 InnerNamespaceInfo Info;
115 if (Tok.
is(tok::kw_inline)) {
118 FirstNestedInlineLoc = Info.InlineLoc;
124 ExtraNSs.push_back(Info);
133 if (!ExtraNSs.empty() && attrLoc.
isValid())
134 Diag(attrLoc, diag::err_unexpected_nested_namespace_attribute);
136 if (Tok.
is(tok::equal)) {
138 Diag(Tok, diag::err_expected) << tok::identifier;
144 Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
146 Diag(InlineLoc, diag::err_inline_namespace_alias)
148 Decl *NSAlias = ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd);
153 if (T.consumeOpen()) {
155 Diag(Tok, diag::err_expected) << tok::l_brace;
157 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
164 Diag(T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
169 if (ExtraNSs.empty()) {
171 }
else if (InlineLoc.
isValid()) {
172 Diag(InlineLoc, diag::err_inline_nested_namespace_definition);
174 Diag(ExtraNSs[0].NamespaceLoc,
175 diag::warn_cxx14_compat_nested_namespace_definition);
176 if (FirstNestedInlineLoc.
isValid())
177 Diag(FirstNestedInlineLoc,
178 diag::warn_cxx17_compat_inline_nested_namespace_definition);
180 Diag(ExtraNSs[0].NamespaceLoc,
181 diag::warn_cxx14_compat_nested_namespace_definition);
182 if (FirstNestedInlineLoc.
isValid())
183 Diag(FirstNestedInlineLoc, diag::ext_inline_nested_namespace_definition);
185 TentativeParsingAction TPA(*
this);
187 Token rBraceToken = Tok;
190 if (!rBraceToken.
is(tok::r_brace)) {
191 Diag(ExtraNSs[0].NamespaceLoc, diag::ext_nested_namespace_definition)
193 ExtraNSs.back().IdentLoc);
195 std::string NamespaceFix;
196 for (
const auto &ExtraNS : ExtraNSs) {
197 NamespaceFix +=
" { ";
198 if (ExtraNS.InlineLoc.isValid())
199 NamespaceFix +=
"inline ";
200 NamespaceFix +=
"namespace ";
201 NamespaceFix += ExtraNS.Ident->getName();
205 for (
unsigned i = 0, e = ExtraNSs.size(); i != e; ++i)
208 Diag(ExtraNSs[0].NamespaceLoc, diag::ext_nested_namespace_definition)
211 ExtraNSs.back().IdentLoc),
217 if (FirstNestedInlineLoc.
isValid())
218 Diag(FirstNestedInlineLoc, diag::ext_inline_nested_namespace_definition);
224 ? diag::warn_cxx98_compat_inline_namespace
225 : diag::ext_inline_namespace);
232 getCurScope(), InlineLoc, NamespaceLoc, IdentLoc, Ident,
233 T.getOpenLocation(), attrs, ImplicitUsingDirectiveDecl,
false);
236 NamespaceLoc,
"parsing namespace");
240 ParseInnerNamespace(ExtraNSs, 0, InlineLoc, attrs, T);
243 NamespaceScope.Exit();
245 DeclEnd = T.getCloseLocation();
249 ImplicitUsingDirectiveDecl);
253void Parser::ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
257 if (index == InnerNSs.size()) {
258 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
259 Tok.
isNot(tok::eof)) {
261 MaybeParseCXX11Attributes(DeclAttrs);
263 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
279 getCurScope(), InnerNSs[index].InlineLoc, InnerNSs[index].NamespaceLoc,
280 InnerNSs[index].IdentLoc, InnerNSs[index].Ident,
282 assert(!ImplicitUsingDirectiveDecl &&
283 "nested namespace definition cannot define anonymous namespace");
285 ParseInnerNamespace(InnerNSs, ++index, InlineLoc, attrs, Tracker);
287 NamespaceScope.Exit();
298 assert(Tok.
is(tok::equal) &&
"Not equal token");
302 if (Tok.
is(tok::code_completion)) {
310 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
318 if (Tok.
isNot(tok::identifier)) {
319 Diag(Tok, diag::err_expected_namespace_name);
338 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name))
342 Alias, SS, IdentLoc, Ident);
353 assert(isTokenStringLiteral() &&
"Not a string literal!");
367 while (MaybeParseCXX11Attributes(DeclAttrs) ||
368 MaybeParseGNUAttributes(DeclSpecAttrs))
371 if (Tok.
isNot(tok::l_brace)) {
378 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs, &DS);
386 ProhibitAttributes(DeclAttrs);
391 unsigned NestedModules = 0;
394 case tok::annot_module_begin:
399 case tok::annot_module_end:
406 case tok::annot_module_include:
419 MaybeParseCXX11Attributes(DeclAttrs);
420 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
439Decl *Parser::ParseExportDeclaration() {
440 assert(Tok.
is(tok::kw_export));
448 if (Tok.
isNot(tok::l_brace)) {
451 MaybeParseCXX11Attributes(DeclAttrs);
453 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
461 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
462 Tok.
isNot(tok::eof)) {
464 MaybeParseCXX11Attributes(DeclAttrs);
466 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
471 T.getCloseLocation());
479 assert(Tok.
is(tok::kw_using) &&
"Not using token");
485 if (Tok.
is(tok::code_completion)) {
492 while (Tok.
is(tok::kw_template)) {
494 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
499 if (Tok.
is(tok::kw_namespace)) {
501 if (TemplateInfo.Kind) {
503 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
507 Decl *UsingDir = ParseUsingDirective(Context, UsingLoc, DeclEnd, Attrs);
512 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, Attrs,
530 assert(Tok.
is(tok::kw_namespace) &&
"Not 'namespace' token");
535 if (Tok.
is(tok::code_completion)) {
543 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
555 if (Tok.
isNot(tok::identifier)) {
556 Diag(Tok, diag::err_expected_namespace_name);
575 bool GNUAttr =
false;
576 if (Tok.
is(tok::kw___attribute)) {
578 ParseGNUAttributes(attrs);
583 if (ExpectAndConsume(tok::semi,
584 GNUAttr ? diag::err_expected_semi_after_attribute_list
585 : diag::err_expected_semi_after_namespace_name))
589 IdentLoc, NamespcName, attrs);
598 UsingDeclarator &D) {
605 if (Tok.
is(tok::kw___super)) {
612 if (ParseOptionalCXXScopeSpecifier(D.SS,
nullptr,
622 if (D.SS.isInvalid())
636 Tok.
is(tok::identifier) &&
642 !D.SS.getScopeRep()->getAsNamespace() &&
643 !D.SS.getScopeRep()->getAsNamespaceAlias()) {
647 D.Name.setConstructorName(
Type, IdLoc, IdLoc);
654 !(Tok.
is(tok::identifier) &&
NextToken().is(tok::equal)),
655 false,
nullptr, D.Name))
661 ? diag::warn_cxx17_compat_using_declaration_pack
662 : diag::ext_using_declaration_pack);
701 ? diag::warn_cxx17_compat_using_enum_declaration
702 : diag::ext_using_enum_declaration);
704 DiagnoseCXX11AttributeExtension(PrefixAttrs);
706 if (TemplateInfo.Kind) {
708 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
714 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
726 if (Tok.
is(tok::code_completion)) {
732 if (!Tok.
is(tok::identifier)) {
734 << Tok.
is(tok::kw_enum);
741 getCurScope(), AS, UsingLoc, UELoc, IdentLoc, *IdentInfo, &SS);
748 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
749 "using-enum declaration"))
758 MaybeParseCXX11Attributes(MisplacedAttrs);
760 if (InInitStatement && Tok.
isNot(tok::identifier))
764 bool InvalidDeclarator = ParseUsingDeclarator(Context, D);
767 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
771 if (MisplacedAttrs.Range.isValid()) {
773 MisplacedAttrs.empty() ? nullptr : &MisplacedAttrs.front();
774 auto &
Range = MisplacedAttrs.Range;
775 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
776 ?
Diag(
Range.getBegin(), diag::err_keyword_not_allowed) << FirstAttr
777 :
Diag(
Range.getBegin(), diag::err_attributes_not_allowed))
785 if (Tok.
is(tok::equal) || InInitStatement) {
786 if (InvalidDeclarator) {
791 ProhibitAttributes(PrefixAttrs);
793 Decl *DeclFromDeclSpec =
nullptr;
794 Decl *AD = ParseAliasDeclarationAfterDeclarator(
795 TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
799 DiagnoseCXX11AttributeExtension(PrefixAttrs);
804 if (TemplateInfo.Kind) {
806 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
818 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
819 DiagnoseCXX11AttributeExtension(Attrs);
822 if (InvalidDeclarator)
827 if (D.TypenameLoc.isValid() &&
829 Diag(D.Name.getSourceRange().getBegin(),
830 diag::err_typename_identifiers_only)
837 D.TypenameLoc, D.SS, D.Name,
838 D.EllipsisLoc, Attrs);
840 DeclsInGroup.push_back(UD);
848 InvalidDeclarator = ParseUsingDeclarator(Context, D);
851 if (DeclsInGroup.size() > 1)
854 ? diag::warn_cxx17_compat_multi_using_declaration
855 : diag::ext_multi_using_declaration);
859 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
860 !Attrs.
empty() ?
"attributes list"
861 : UELoc.
isValid() ?
"using-enum declaration"
862 :
"using declaration"))
868Decl *Parser::ParseAliasDeclarationAfterDeclarator(
872 if (ExpectAndConsume(tok::equal)) {
878 ? diag::warn_cxx98_compat_alias_declaration
879 : diag::ext_alias_declaration);
883 if (TemplateInfo.Kind == ParsedTemplateInfo::Template &&
886 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization)
888 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
890 if (SpecKind != -1) {
894 D.Name.TemplateId->RAngleLoc);
896 Range = TemplateInfo.getSourceRange();
897 Diag(
Range.getBegin(), diag::err_alias_declaration_specialization)
898 << SpecKind <<
Range;
905 Diag(D.Name.StartLocation, diag::err_alias_declaration_not_identifier);
909 }
else if (D.TypenameLoc.isValid())
910 Diag(D.TypenameLoc, diag::err_alias_declaration_not_identifier)
912 SourceRange(D.TypenameLoc, D.SS.isNotEmpty() ? D.SS.getEndLoc()
914 else if (D.SS.isNotEmpty())
915 Diag(D.SS.getBeginLoc(), diag::err_alias_declaration_not_identifier)
917 if (D.EllipsisLoc.isValid())
918 Diag(D.EllipsisLoc, diag::err_alias_declaration_pack_expansion)
921 Decl *DeclFromDeclSpec =
nullptr;
926 AS, &DeclFromDeclSpec, &Attrs);
928 *OwnedType = DeclFromDeclSpec;
932 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
933 !Attrs.
empty() ?
"attributes list"
934 :
"alias declaration"))
939 TemplateParams ? TemplateParams->data() :
nullptr,
940 TemplateParams ? TemplateParams->size() : 0);
942 UsingLoc, D.Name, Attrs, TypeAlias,
948 if (
const auto *BO = dyn_cast_or_null<BinaryOperator>(AssertExpr)) {
949 if (BO->getOpcode() == BO_LAnd &&
950 isa<StringLiteral>(BO->getRHS()->IgnoreImpCasts()))
965 assert(Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
966 "Not a static_assert declaration");
969 const char *TokName = Tok.
getName();
971 if (Tok.
is(tok::kw__Static_assert))
972 diagnoseUseOfC11Keyword(Tok);
973 else if (Tok.
is(tok::kw_static_assert)) {
976 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
981 Diag(Tok, diag::warn_cxx98_compat_static_assert);
987 if (T.consumeOpen()) {
988 Diag(Tok, diag::err_expected) << tok::l_paren;
996 if (AssertExpr.isInvalid()) {
1002 if (Tok.
is(tok::r_paren)) {
1005 DiagVal = diag::warn_cxx14_compat_static_assert_no_message;
1007 DiagVal = diag::ext_cxx_static_assert_no_message;
1009 DiagVal = diag::warn_c17_compat_static_assert_no_message;
1011 DiagVal = diag::ext_c_static_assert_no_message;
1015 if (ExpectAndConsume(tok::comma)) {
1020 bool ParseAsExpression =
false;
1022 for (
unsigned I = 0;; ++I) {
1023 const Token &T = GetLookAheadToken(I);
1024 if (T.
is(tok::r_paren))
1027 ParseAsExpression =
true;
1033 if (ParseAsExpression)
1038 Diag(Tok, diag::err_expected_string_literal)
1053 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
1056 AssertMessage.
get(),
1057 T.getCloseLocation());
1066 assert(Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype) &&
1067 "Not a decltype specifier");
1073 if (Tok.
is(tok::annot_decltype)) {
1074 Result = getExprAnnotation(Tok);
1079 ConsumeAnnotationToken();
1080 if (
Result.isInvalid()) {
1086 Diag(Tok, diag::warn_cxx98_compat_decltype);
1091 if (T.expectAndConsume(diag::err_expected_lparen_after,
"decltype",
1094 return T.getOpenLocation() == Tok.
getLocation() ? StartLoc
1095 : T.getOpenLocation();
1099 if (Tok.
is(tok::kw_auto) &&
NextToken().is(tok::r_paren)) {
1104 ? diag::warn_cxx11_compat_decltype_auto_type_specifier
1105 : diag::ext_decltype_auto_type_specifier);
1119 if (
Result.isInvalid()) {
1122 EndLoc = ConsumeParen();
1129 assert(Tok.
is(tok::semi));
1143 if (T.getCloseLocation().isInvalid()) {
1147 return T.getCloseLocation();
1150 if (
Result.isInvalid()) {
1152 return T.getCloseLocation();
1155 EndLoc = T.getCloseLocation();
1157 assert(!
Result.isInvalid());
1159 const char *PrevSpec =
nullptr;
1164 PrevSpec, DiagID,
Result.get(), Policy)
1166 PrevSpec, DiagID, Policy)) {
1167 Diag(StartLoc, DiagID) << PrevSpec;
1173void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
1189 Tok.
setKind(tok::annot_decltype);
1190 setExprAnnotation(Tok,
1200 assert(Tok.
isOneOf(tok::annot_pack_indexing_type, tok::identifier) &&
1201 "Expected an identifier");
1206 const char *PrevSpec;
1210 if (Tok.
is(tok::annot_pack_indexing_type)) {
1218 ConsumeAnnotationToken();
1219 if (
Type.isInvalid()) {
1224 DiagID,
Type, Policy);
1228 !GetLookAheadToken(2).is(tok::l_square)) {
1260 return T.getCloseLocation();
1263void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1279 Tok.
setKind(tok::annot_pack_indexing_type);
1280 setTypeAnnotation(Tok, T);
1288#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1289 case tok::kw___##Trait: \
1290 return DeclSpec::TST_##Trait;
1291#include "clang/Basic/TransformTypeTraits.def"
1293 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1297bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1302 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1306 if (T.expectAndConsume(diag::err_expected_lparen_after, Tok.
getName(),
1311 if (
Result.isInvalid()) {
1317 if (T.getCloseLocation().isInvalid())
1320 const char *PrevSpec =
nullptr;
1325 Diag(StartLoc, DiagID) << PrevSpec;
1351 if (Tok.
is(tok::kw_typename)) {
1352 Diag(Tok, diag::err_expected_class_name_not_template)
1359 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1369 if (Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1376 EndLocation = ParseDecltypeSpecifier(DS);
1383 if (Tok.
is(tok::annot_pack_indexing_type)) {
1385 ParsePackIndexingType(DS);
1392 if (Tok.
is(tok::annot_template_id)) {
1398 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
1401 ConsumeAnnotationToken();
1408 if (Tok.
isNot(tok::identifier)) {
1409 Diag(Tok, diag::err_expected_class_name);
1416 if (Tok.
is(tok::less)) {
1425 Diag(IdLoc, diag::err_unknown_template_name) <<
Id;
1436 if (Tok.
is(tok::annot_template_id) &&
1437 takeTemplateIdAnnotation(Tok)->mightBeType())
1443 if (Tok.
isNot(tok::annot_typename))
1450 ConsumeAnnotationToken();
1463 Diag(IdLoc, diag::err_expected_class_name);
1468 EndLocation = IdLoc;
1476 const char *PrevSpec =
nullptr;
1486void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1487 while (Tok.
isOneOf(tok::kw___single_inheritance,
1488 tok::kw___multiple_inheritance,
1489 tok::kw___virtual_inheritance)) {
1493 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1500bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1511 case tok::identifier:
1513 case tok::coloncolon:
1514 case tok::annot_cxxscope:
1515 case tok::annot_typename:
1516 case tok::annot_template_id:
1517 case tok::kw_decltype:
1520 case tok::kw_operator:
1521 case tok::kw___declspec:
1526 case tok::kw___attribute:
1527 case tok::annot_pragma_pack:
1529 case tok::annot_pragma_ms_pragma:
1531 case tok::annot_pragma_ms_vtordisp:
1533 case tok::annot_pragma_ms_pointers_to_members:
1536 return CouldBeBitfield ||
1539 case tok::kw___cdecl:
1540 case tok::kw___fastcall:
1541 case tok::kw___stdcall:
1542 case tok::kw___thiscall:
1543 case tok::kw___vectorcall:
1549 case tok::kw_volatile:
1550 case tok::kw_restrict:
1551 case tok::kw__Atomic:
1552 case tok::kw___unaligned:
1556 case tok::kw_inline:
1557 case tok::kw_virtual:
1558 case tok::kw_friend:
1560 case tok::kw_static:
1561 case tok::kw_extern:
1562 case tok::kw_typedef:
1563 case tok::kw_register:
1565 case tok::kw_mutable:
1566 case tok::kw_thread_local:
1567 case tok::kw_constexpr:
1568 case tok::kw_consteval:
1569 case tok::kw_constinit:
1585 if (!isKnownToBeTypeSpecifier(
NextToken()))
1642 const ParsedTemplateInfo &TemplateInfo,
1644 DeclSpecContext DSC,
1647 if (TagTokKind == tok::kw_struct)
1649 else if (TagTokKind == tok::kw___interface)
1651 else if (TagTokKind == tok::kw_class)
1654 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1658 if (Tok.
is(tok::code_completion)) {
1672 const bool shouldDelayDiagsInTag =
1673 (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate);
1678 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1681 if (Tok.
isOneOf(tok::kw___single_inheritance, tok::kw___multiple_inheritance,
1682 tok::kw___virtual_inheritance))
1683 ParseMicrosoftInheritanceClassAttributes(attrs);
1686 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1696#include
"clang/Basic/TransformTypeTraits.def"
1697 tok::kw___is_abstract,
1698 tok::kw___is_aggregate,
1699 tok::kw___is_arithmetic,
1701 tok::kw___is_assignable,
1702 tok::kw___is_base_of,
1703 tok::kw___is_bounded_array,
1705 tok::kw___is_complete_type,
1706 tok::kw___is_compound,
1708 tok::kw___is_constructible,
1709 tok::kw___is_convertible,
1710 tok::kw___is_convertible_to,
1711 tok::kw___is_destructible,
1714 tok::kw___is_floating_point,
1716 tok::kw___is_function,
1717 tok::kw___is_fundamental,
1718 tok::kw___is_integral,
1719 tok::kw___is_interface_class,
1720 tok::kw___is_literal,
1721 tok::kw___is_lvalue_expr,
1722 tok::kw___is_lvalue_reference,
1723 tok::kw___is_member_function_pointer,
1724 tok::kw___is_member_object_pointer,
1725 tok::kw___is_member_pointer,
1726 tok::kw___is_nothrow_assignable,
1727 tok::kw___is_nothrow_constructible,
1728 tok::kw___is_nothrow_convertible,
1729 tok::kw___is_nothrow_destructible,
1730 tok::kw___is_nullptr,
1731 tok::kw___is_object,
1733 tok::kw___is_pointer,
1734 tok::kw___is_polymorphic,
1735 tok::kw___is_reference,
1736 tok::kw___is_referenceable,
1737 tok::kw___is_rvalue_expr,
1738 tok::kw___is_rvalue_reference,
1740 tok::kw___is_scalar,
1741 tok::kw___is_scoped_enum,
1742 tok::kw___is_sealed,
1743 tok::kw___is_signed,
1744 tok::kw___is_standard_layout,
1745 tok::kw___is_trivial,
1746 tok::kw___is_trivially_equality_comparable,
1747 tok::kw___is_trivially_assignable,
1748 tok::kw___is_trivially_constructible,
1749 tok::kw___is_trivially_copyable,
1750 tok::kw___is_unbounded_array,
1752 tok::kw___is_unsigned,
1754 tok::kw___is_volatile,
1755 tok::kw___reference_binds_to_temporary,
1756 tok::kw___reference_constructs_from_temporary))
1762 TryKeywordIdentFallback(
true);
1764 struct PreserveAtomicIdentifierInfoRAII {
1765 PreserveAtomicIdentifierInfoRAII(
Token &Tok,
bool Enabled)
1766 : AtomicII(nullptr) {
1769 assert(Tok.
is(tok::kw__Atomic));
1774 ~PreserveAtomicIdentifierInfoRAII() {
1777 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1787 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1788 Tok.
is(tok::kw__Atomic) &&
1790 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1791 Tok, ShouldChangeAtomicToIdentifier);
1801 if (TemplateInfo.TemplateParams)
1804 bool HasValidSpec =
true;
1805 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1809 HasValidSpec =
false;
1812 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::annot_template_id)) {
1813 Diag(Tok, diag::err_expected) << tok::identifier;
1814 HasValidSpec =
false;
1822 auto RecoverFromUndeclaredTemplateName = [&](
IdentifierInfo *Name,
1825 bool KnownUndeclared) {
1826 Diag(NameLoc, diag::err_explicit_spec_non_template)
1827 << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
1828 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1832 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1833 if (TemplateParams->size() > 1) {
1834 TemplateParams->pop_back();
1836 TemplateParams =
nullptr;
1837 const_cast<ParsedTemplateInfo &
>(TemplateInfo).Kind =
1838 ParsedTemplateInfo::NonTemplate;
1840 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1842 TemplateParams =
nullptr;
1843 const_cast<ParsedTemplateInfo &
>(TemplateInfo).Kind =
1844 ParsedTemplateInfo::NonTemplate;
1845 const_cast<ParsedTemplateInfo &
>(TemplateInfo).TemplateLoc =
1847 const_cast<ParsedTemplateInfo &
>(TemplateInfo).ExternLoc =
1856 if (Tok.
is(tok::identifier)) {
1864 TemplateArgList TemplateArgs;
1866 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1872 RecoverFromUndeclaredTemplateName(
1873 Name, NameLoc,
SourceRange(LAngleLoc, RAngleLoc),
false);
1875 }
else if (Tok.
is(tok::annot_template_id)) {
1876 TemplateId = takeTemplateIdAnnotation(Tok);
1877 NameLoc = ConsumeAnnotationToken();
1884 RecoverFromUndeclaredTemplateName(
1887 TemplateId =
nullptr;
1900 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1901 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1936 MaybeParseCXX11Attributes(Attributes);
1941 AllowDefiningTypeSpec::No ||
1944 else if (Tok.
is(tok::l_brace) ||
1945 (DSC != DeclSpecContext::DSC_association &&
1947 (isClassCompatibleKeyword() &&
1963 }
else if (isClassCompatibleKeyword() &&
1970 TentativeParsingAction PA(*
this);
1973 while (isClassCompatibleKeyword()) {
1979 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square)) {
1983 }
else if (Tok.
is(tok::kw_alignas) &&
NextToken().is(tok::l_paren)) {
1993 if (!T.consumeOpen())
2001 if (Tok.
isOneOf(tok::l_brace, tok::colon))
2007 }
else if (!isTypeSpecifier(DSC) &&
2008 (Tok.
is(tok::semi) ||
2011 if (Tok.
isNot(tok::semi)) {
2014 ExpectAndConsume(tok::semi, diag::err_expected_after,
2032 auto *FirstAttr = Attributes.
empty() ? nullptr : &Attributes.
front();
2034 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2035 ?
Diag(Loc, diag::err_keyword_not_allowed) << FirstAttr
2036 :
Diag(Loc, diag::err_attributes_not_allowed))
2048 if (!Name && !TemplateId &&
2053 Diag(StartLoc, diag::err_anon_type_definition)
2080 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2083 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2084 diag::err_keyword_not_allowed,
2088 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2099 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
2100 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2101 diag::err_keyword_not_allowed,
2111 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2124 "Expected a definition here");
2128 TemplateParams =
nullptr;
2133 diag::err_explicit_instantiation_with_definition)
2142 std::nullopt, LAngleLoc,
nullptr));
2143 TemplateParams = &FakedParamLists;
2150 SS, *TemplateId, attrs,
2153 TemplateParams ? TemplateParams->size() : 0),
2156 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2163 ProhibitAttributes(attrs);
2166 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2167 TagType, StartLoc, SS, Name, NameLoc, attrs);
2169 TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
2170 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2171 diag::err_keyword_not_allowed,
2178 TemplateParams ? TemplateParams->size() : 0));
2181 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2182 diag::err_keyword_not_allowed,
2186 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2189 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2191 TemplateParams =
nullptr;
2194 bool IsDependent =
false;
2204 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2207 TagOrTempResult = Actions.
ActOnTag(
2211 DSC == DeclSpecContext::DSC_type_specifier,
2212 DSC == DeclSpecContext::DSC_template_param ||
2213 DSC == DeclSpecContext::DSC_template_type_arg,
2214 OffsetOfState, &SkipBody);
2221 Name, StartLoc, NameLoc);
2228 if (shouldDelayDiagsInTag) {
2229 diagsFromTag.done();
2231 TemplateInfo.Kind == ParsedTemplateInfo::Template)
2232 diagsFromTag.redelay();
2237 assert(Tok.
is(tok::l_brace) ||
2239 isClassCompatibleKeyword());
2241 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc,
TagType,
2242 TagOrTempResult.
get());
2244 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs,
TagType,
2245 TagOrTempResult.
get());
2250 ParseStructUnionBody(StartLoc,
TagType, cast<RecordDecl>(D));
2263 const char *PrevSpec =
nullptr;
2268 NameLoc.
isValid() ? NameLoc : StartLoc,
2270 }
else if (!TagOrTempResult.
isInvalid()) {
2272 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2273 DiagID, TagOrTempResult.
get(), Owned, Policy);
2280 Diag(StartLoc, DiagID) << PrevSpec;
2296 (TemplateInfo.Kind || !isValidAfterTypeSpecifier(
false))) {
2297 if (Tok.
isNot(tok::semi)) {
2299 ExpectAndConsume(tok::semi, diag::err_expected_after,
2317void Parser::ParseBaseClause(
Decl *ClassDecl) {
2318 assert(Tok.
is(tok::colon) &&
"Not a base clause");
2327 if (
Result.isInvalid()) {
2333 BaseInfo.push_back(
Result.get());
2358 bool IsVirtual =
false;
2362 MaybeParseCXX11Attributes(Attributes);
2368 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2378 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2382 if (Tok.
is(tok::kw_virtual)) {
2386 Diag(VirtualLoc, diag::err_dup_virtual)
2393 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2407 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2423 Access, BaseType.
get(), BaseLoc,
2438 case tok::kw_private:
2440 case tok::kw_protected:
2442 case tok::kw_public:
2451void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2458 if (!NeedLateParse) {
2462 if (Param->hasUnparsedDefaultArg()) {
2463 NeedLateParse =
true;
2469 if (NeedLateParse) {
2472 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2473 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2478 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2480 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2517 if (II == Ident_override)
2520 if (II == Ident_sealed)
2523 if (II == Ident_abstract)
2526 if (II == Ident_final)
2529 if (II == Ident_GNU_final)
2540void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2559 const char *PrevSpec =
nullptr;
2577 ? diag::warn_cxx98_compat_override_control_keyword
2578 : diag::ext_override_control_keyword)
2587bool Parser::isCXX11FinalKeyword()
const {
2596bool Parser::isClassCompatibleKeyword()
const {
2606bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2608 LateParsedAttrList &LateParsedAttrs) {
2619 if (Tok.
isNot(tok::colon))
2620 ParseDeclarator(DeclaratorInfo);
2626 "don't know where identifier would go yet?");
2630 }
else if (Tok.
is(tok::kw_requires)) {
2631 ParseTrailingRequiresClause(DeclaratorInfo);
2633 ParseOptionalCXX11VirtSpecifierSeq(
2634 VS, getCurrentClass().IsInterface,
2637 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2642 if (Tok.
is(tok::kw_asm)) {
2644 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2645 if (AsmLabel.isInvalid())
2655 DiagnoseAndSkipCXX11Attributes();
2656 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2657 DiagnoseAndSkipCXX11Attributes();
2662 ParseOptionalCXX11VirtSpecifierSeq(
2663 VS, getCurrentClass().IsInterface,
2669 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2670 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2672 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2689void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2695 ParseTypeQualifierListOpt(
2696 DS, AR_NoAttributesParsed,
false,
2697 false, llvm::function_ref<
void()>([&]() {
2705 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2708 auto &MQ =
Function.getOrCreateMethodQualifiers();
2709 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2710 std::string Name(FixItName.data());
2713 MQ.SetTypeQual(TypeQual, SpecLoc);
2715 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2724 bool RefQualifierIsLValueRef =
true;
2726 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2727 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2730 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2731 Function.RefQualifierLoc = RefQualifierLoc;
2733 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2734 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2782 const ParsedTemplateInfo &TemplateInfo,
2785 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2786 if (Tok.
is(tok::at)) {
2788 Diag(Tok, diag::err_at_defs_cxx);
2790 Diag(Tok, diag::err_at_in_class);
2806 bool MalformedTypeSpec =
false;
2807 if (!TemplateInfo.Kind &&
2808 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2810 MalformedTypeSpec =
true;
2813 if (Tok.
isNot(tok::annot_cxxscope))
2814 isAccessDecl =
false;
2815 else if (
NextToken().is(tok::identifier))
2816 isAccessDecl = GetLookAheadToken(2).
is(tok::semi);
2823 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2836 false,
false,
true,
true,
2837 false, &TemplateKWLoc, Name)) {
2843 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2844 "access declaration")) {
2860 if (!TemplateInfo.Kind &&
2861 Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2867 if (Tok.
is(tok::kw_template)) {
2868 assert(!TemplateInfo.TemplateParams &&
2869 "Nested template improperly parsed?");
2873 DeclEnd, AccessAttrs, AS);
2877 if (Tok.
is(tok::kw___extension__)) {
2881 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2887 MaybeParseCXX11Attributes(DeclAttrs);
2892 if (Tok.
is(tok::annot_attr_openmp))
2893 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
2895 if (Tok.
is(tok::kw_using)) {
2900 while (Tok.
is(tok::kw_template)) {
2902 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
2906 if (Tok.
is(tok::kw_namespace)) {
2907 Diag(UsingLoc, diag::err_using_namespace_in_class);
2914 UsingLoc, DeclEnd, DeclAttrs, AS);
2918 MaybeParseMicrosoftAttributes(DeclSpecAttrs);
2921 LateParsedAttrList CommonLateParsedAttrs;
2928 if (MalformedTypeSpec)
2936 bool IsTemplateSpecOrInst =
2937 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
2938 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
2941 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
2942 &CommonLateParsedAttrs);
2944 if (IsTemplateSpecOrInst)
2945 diagsFromTag.done();
2953 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate &&
2954 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
2955 &CommonLateParsedAttrs))
2959 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
2961 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
2965 ProhibitAttributes(DeclAttrs);
2969 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
2971 DS.complete(TheDecl);
2973 Decl *decls[] = {AnonRecord, TheDecl};
2984 if (TemplateInfo.TemplateParams)
2989 LateParsedAttrList LateParsedAttrs;
2994 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
2995 if (Tok.
isNot(tok::equal))
3000 if (
Zero.isNot(tok::numeric_constant) ||
3004 auto &
After = GetLookAheadToken(2);
3005 if (!
After.isOneOf(tok::semi, tok::comma) &&
3006 !(AllowDefinition &&
3007 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3018 bool ExpectSemi =
true;
3026 if (ParseCXXMemberDeclaratorBeforeInitializer(
3027 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3032 if (IsTemplateSpecOrInst)
3040 TryConsumePureSpecifier(
true);
3051 if (Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3053 }
else if (Tok.
is(tok::equal)) {
3055 if (KW.
is(tok::kw_default))
3057 else if (KW.
is(tok::kw_delete))
3059 else if (KW.
is(tok::code_completion)) {
3075 ProhibitAttributes(DeclAttrs);
3092 diag::err_function_declared_typedef);
3098 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3099 TemplateInfo, VS, PureSpecLoc);
3102 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3103 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3105 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3106 LateParsedAttrs[i]->addDecl(FunDecl);
3109 LateParsedAttrs.clear();
3112 if (Tok.
is(tok::semi))
3113 ConsumeExtraSemi(AfterMemberFunctionDefinition);
3125 bool HasStaticInitializer =
false;
3130 Diag(Tok, diag::err_anon_bitfield_member_init);
3134 if (!TryConsumePureSpecifier(
false))
3136 HasStaticInitializer =
true;
3143 if (BitfieldSize.
get())
3145 ? diag::warn_cxx17_compat_bitfield_member_init
3146 : diag::ext_bitfield_member_init);
3149 HasStaticInitializer =
true;
3165 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3166 auto Loc = AL.getRange().getBegin();
3167 (AL.isRegularKeywordAttribute()
3168 ?
Diag(Loc, diag::err_keyword_not_allowed) << AL
3169 :
Diag(Loc, diag::err_attributes_not_allowed))
3177 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3178 VS, HasInClassInit);
3181 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3184 ThisDecl = VT->getTemplatedDecl();
3193 DeclaratorInfo.getDeclSpec().getStorageClassSpec() ==
3196 HasStaticInitializer =
true;
3200 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3202 if (ThisDecl && PureSpecLoc.
isValid())
3211 ? diag::warn_cxx98_compat_nonstatic_member_init
3212 : diag::ext_nonstatic_member_init);
3214 if (DeclaratorInfo.isArrayOfUnknownBound()) {
3220 Diag(Tok, diag::err_incomplete_array_member_init);
3227 ParseCXXNonStaticMemberInitializer(ThisDecl);
3228 }
else if (HasStaticInitializer) {
3231 ThisDecl, DeclaratorInfo.isDeclarationOfFunction(), EqualLoc);
3233 if (
Init.isInvalid()) {
3237 }
else if (ThisDecl)
3247 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3248 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3250 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3251 LateParsedAttrs[i]->addDecl(ThisDecl);
3254 DeclsInGroup.push_back(ThisDecl);
3256 if (DeclaratorInfo.isFunctionDeclarator() &&
3257 DeclaratorInfo.getDeclSpec().getStorageClassSpec() !=
3259 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3261 LateParsedAttrs.clear();
3263 DeclaratorInfo.complete(ThisDecl);
3276 Diag(CommaLoc, diag::err_expected_semi_declaration)
3286 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
3287 DeclaratorInfo.isFirstDeclarator()) {
3288 Diag(CommaLoc, diag::err_multiple_template_declarators)
3289 << TemplateInfo.Kind;
3293 DeclaratorInfo.clear();
3297 DeclaratorInfo.setCommaLoc(CommaLoc);
3302 DiagnoseAndSkipCXX11Attributes();
3303 MaybeParseGNUAttributes(DeclaratorInfo);
3304 DiagnoseAndSkipCXX11Attributes();
3306 if (ParseCXXMemberDeclaratorBeforeInitializer(
3307 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3312 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
3343ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
3345 assert(Tok.
isOneOf(tok::equal, tok::l_brace) &&
3346 "Data member initializer not starting with '=' or '{'");
3348 bool IsFieldInitialization = isa_and_present<FieldDecl>(D);
3352 IsFieldInitialization
3361 IsFieldInitialization;
3364 if (Tok.
is(tok::kw_delete)) {
3371 if (IsFunction || Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3379 }
else if (Tok.
is(tok::kw_default)) {
3381 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3389 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
3390 Diag(Tok, diag::err_ms_property_initializer) << PD;
3393 return ParseInitializer();
3401 assert(isCXX11FinalKeyword() &&
"not a class definition");
3407 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3412 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_brace))
3419 if (Tok.
is(tok::colon)) {
3422 ParsingClassDefinition ParsingDef(*
this,
TagDecl,
true,
3428 ParseBaseClause(
nullptr);
3432 if (!Tok.
is(tok::l_brace)) {
3434 diag::err_expected_lbrace_after_base_specifiers);
3440 assert(Tok.
is(tok::l_brace));
3446 if (Tok.
is(tok::kw___attribute)) {
3448 MaybeParseGNUAttributes(Attrs);
3458 case tok::kw___if_exists:
3459 case tok::kw___if_not_exists:
3460 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, AS);
3465 ConsumeExtraSemi(InsideStruct,
TagType);
3469 case tok::annot_pragma_vis:
3470 HandlePragmaVisibility();
3472 case tok::annot_pragma_pack:
3475 case tok::annot_pragma_align:
3476 HandlePragmaAlign();
3478 case tok::annot_pragma_ms_pointers_to_members:
3479 HandlePragmaMSPointersToMembers();
3481 case tok::annot_pragma_ms_pragma:
3482 HandlePragmaMSPragma();
3484 case tok::annot_pragma_ms_vtordisp:
3485 HandlePragmaMSVtorDisp();
3487 case tok::annot_pragma_dump:
3491 case tok::kw_namespace:
3493 DiagnoseUnexpectedNamespace(cast<NamedDecl>(
TagDecl));
3496 case tok::kw_private:
3500 return ParseCXXClassMemberDeclaration(AS, AccessAttrs);
3502 case tok::kw_public:
3503 case tok::kw_protected: {
3513 AccessAttrs.
clear();
3514 MaybeParseGNUAttributes(AccessAttrs);
3519 Diag(EndLoc, diag::err_expected)
3523 Diag(EndLoc, diag::err_expected)
3535 AccessAttrs.
clear();
3541 case tok::annot_attr_openmp:
3542 case tok::annot_pragma_openmp:
3543 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3545 case tok::annot_pragma_openacc:
3553 ConsumeAnnotationToken();
3556 return ParseCXXClassMemberDeclaration(AS, AccessAttrs);
3566void Parser::ParseCXXMemberSpecification(
SourceLocation RecordLoc,
3573 "Invalid TagType!");
3575 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3576 if (
auto *TD = dyn_cast_or_null<NamedDecl>(
TagDecl))
3577 return TD->getQualifiedNameAsString();
3578 return std::string(
"<anonymous>");
3582 "parsing struct/union/class body");
3586 bool NonNestedClass =
true;
3587 if (!ClassStack.empty()) {
3589 if (S->isClassScope()) {
3591 NonNestedClass =
false;
3594 if (getCurrentClass().IsInterface) {
3595 Diag(RecordLoc, diag::err_invalid_member_in_interface)
3598 ? cast<NamedDecl>(
TagDecl)->getQualifiedNameAsString()
3604 if (S->isFunctionScope())
3615 ParsingClassDefinition ParsingDef(*
this,
TagDecl, NonNestedClass,
3623 bool IsFinalSpelledSealed =
false;
3624 bool IsAbstract =
false;
3632 if (isCXX11FinalKeyword()) {
3635 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3640 IsFinalSpelledSealed =
true;
3645 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3653 Diag(FinalLoc, diag::err_override_control_interface)
3657 ? diag::warn_cxx98_compat_override_control_keyword
3658 : diag::ext_override_control_keyword)
3661 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3663 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3665 Diag(FinalLoc, diag::ext_warn_gnu_final);
3668 "not a class definition");
3674 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3683 if (!Tok.
is(tok::colon) && !Tok.
is(tok::l_brace)) {
3690 if (Tok.
is(tok::colon)) {
3691 ParseScope InheritanceScope(
this,
getCurScope()->getFlags() |
3695 if (!Tok.
is(tok::l_brace)) {
3696 bool SuggestFixIt =
false;
3700 case tok::kw_private:
3701 case tok::kw_protected:
3702 case tok::kw_public:
3705 case tok::kw_static_assert:
3709 case tok::kw_template:
3710 SuggestFixIt =
true;
3712 case tok::identifier:
3713 SuggestFixIt = isConstructorDeclarator(
true);
3716 SuggestFixIt = isCXXSimpleDeclaration(
false);
3721 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3735 assert(Tok.
is(tok::l_brace));
3741 IsFinalSpelledSealed, IsAbstract,
3742 T.getOpenLocation());
3757 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3758 Tok.
isNot(tok::eof)) {
3760 ParseCXXClassMemberDeclarationWithPragmas(
3762 MaybeDestroyTemplateIds();
3771 MaybeParseGNUAttributes(attrs);
3775 T.getOpenLocation(),
3776 T.getCloseLocation(), attrs);
3783 if (
TagDecl && NonNestedClass) {
3790 ParseLexedPragmas(getCurrentClass());
3791 ParseLexedAttributes(getCurrentClass());
3792 ParseLexedMethodDeclarations(getCurrentClass());
3797 ParseLexedMemberInitializers(getCurrentClass());
3798 ParseLexedMethodDefs(getCurrentClass());
3799 PrevTokLocation = SavedPrevTokLocation;
3814void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3815 assert(Tok.
is(tok::kw_namespace));
3820 Diag(Tok.
getLocation(), diag::note_missing_end_of_definition_before) << D;
3854void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3855 assert(Tok.
is(tok::colon) &&
3856 "Constructor initializer always starts with ':'");
3864 bool AnyErrors =
false;
3867 if (Tok.
is(tok::code_completion)) {
3874 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3876 MemInitializers.push_back(MemInit.
get());
3880 if (Tok.
is(tok::comma))
3882 else if (Tok.
is(tok::l_brace))
3887 Tok.
isOneOf(tok::identifier, tok::coloncolon)) {
3889 Diag(Loc, diag::err_ctor_init_missing_comma)
3895 << tok::l_brace << tok::comma;
3920 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
3933 if (Tok.
is(tok::identifier)) {
3938 }
else if (Tok.
is(tok::annot_decltype)) {
3943 ParseDecltypeSpecifier(DS);
3944 }
else if (Tok.
is(tok::annot_pack_indexing_type)) {
3947 ParsePackIndexingType(DS);
3950 ? takeTemplateIdAnnotation(Tok)
3955 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
3957 ConsumeAnnotationToken();
3959 Diag(Tok, diag::err_expected_member_or_base_name);
3966 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3969 ExprResult InitList = ParseBraceInitializer();
3979 TemplateTypeTy.
get(), DS, IdLoc,
3980 InitList.
get(), EllipsisLoc);
3981 }
else if (Tok.
is(tok::l_paren)) {
3986 ExprVector ArgExprs;
3987 auto RunSignatureHelp = [&] {
3991 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
3992 T.getOpenLocation(),
false);
3993 CalledSignatureHelp =
true;
3994 return PreferredType;
3996 if (Tok.
isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
3997 PreferredType.enterFunctionArgument(Tok.
getLocation(),
4014 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
4015 T.getOpenLocation(), ArgExprs, T.getCloseLocation(), EllipsisLoc);
4022 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
4024 return Diag(Tok, diag::err_expected) << tok::l_paren;
4042 ExceptionSpecTokens =
nullptr;
4046 if (Tok.
isNot(tok::kw_throw) && Tok.
isNot(tok::kw_noexcept))
4050 bool IsNoexcept = Tok.
is(tok::kw_noexcept);
4051 Token StartTok = Tok;
4055 if (!Tok.
is(tok::l_paren)) {
4058 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4059 NoexceptExpr =
nullptr;
4063 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4069 ExceptionSpecTokens->push_back(StartTok);
4070 ExceptionSpecTokens->push_back(Tok);
4071 SpecificationRange.
setEnd(ConsumeParen());
4073 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4076 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4082 if (Tok.
is(tok::kw_throw)) {
4083 Result = ParseDynamicExceptionSpecification(
4084 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4085 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4086 "Produced different number of exception types and ranges.");
4090 if (Tok.
isNot(tok::kw_noexcept))
4093 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4101 if (Tok.
is(tok::l_paren)) {
4114 NoexceptRange =
SourceRange(KeywordLoc, T.getCloseLocation());
4121 NoexceptRange =
SourceRange(KeywordLoc, KeywordLoc);
4125 SpecificationRange = NoexceptRange;
4130 if (Tok.
is(tok::kw_throw)) {
4131 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4132 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4133 DynamicExceptionRanges);
4136 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4144 if (
P.getLangOpts().CPlusPlus11) {
4145 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4146 P.Diag(Range.getBegin(),
P.getLangOpts().CPlusPlus17 && !IsNoexcept
4147 ? diag::ext_dynamic_exception_spec
4148 : diag::warn_exception_spec_deprecated)
4150 P.Diag(Range.getBegin(), diag::note_exception_spec_deprecated)
4169 assert(Tok.
is(tok::kw_throw) &&
"expected throw");
4173 if (T.consumeOpen()) {
4174 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4181 if (Tok.
is(tok::ellipsis)) {
4184 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4186 SpecificationRange.
setEnd(T.getCloseLocation());
4193 while (Tok.
isNot(tok::r_paren)) {
4196 if (Tok.
is(tok::ellipsis)) {
4201 Range.setEnd(Ellipsis);
4202 if (!Res.isInvalid())
4206 if (!Res.isInvalid()) {
4207 Exceptions.push_back(Res.get());
4208 Ranges.push_back(Range);
4216 SpecificationRange.
setEnd(T.getCloseLocation());
4218 Exceptions.empty());
4225 bool MayBeFollowedByDirectInit) {
4226 assert(Tok.
is(tok::arrow) &&
"expected arrow");
4236void Parser::ParseTrailingRequiresClause(
Declarator &D) {
4237 assert(Tok.
is(tok::kw_requires) &&
"expected requires");
4255 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4257 DeclScopeObj.EnterDeclaratorScope();
4266 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4267 InitCXXThisScopeForDeclaratorIfRelevant(D, D.
getDeclSpec(), ThisScope);
4269 TrailingRequiresClause =
4272 TrailingRequiresClause =
4277 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4282 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4293 ParseTrailingReturnType(Range,
false);
4297 diag::err_requires_clause_must_appear_after_trailing_return)
4301 FunctionChunk.TrailingReturnType = TrailingReturnType.
get();
4302 FunctionChunk.TrailingReturnTypeLoc =
Range.getBegin();
4304 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4313 bool NonNestedClass,
4315 assert((NonNestedClass || !ClassStack.empty()) &&
4316 "Nested class without outer class");
4317 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4323void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4324 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4325 delete Class->LateParsedDeclarations[I];
4336 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4340 ParsingClass *Victim = ClassStack.top();
4342 if (Victim->TopLevelClass) {
4345 DeallocateParsedClasses(Victim);
4348 assert(!ClassStack.empty() &&
"Missing top-level class?");
4350 if (Victim->LateParsedDeclarations.empty()) {
4355 DeallocateParsedClasses(Victim);
4363 "Nested class outside of class scope?");
4364 ClassStack.top()->LateParsedDeclarations.push_back(
4365 new LateParsedClass(
this, Victim));
4392 case tok::code_completion:
4399 case tok::numeric_constant: {
4407 StringRef Spelling = PP.
getSpelling(ExpansionLoc, ExpansionBuf);
4408 if (Spelling ==
"__clang__") {
4412 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4428 case tok::pipeequal:
4429 case tok::caretequal:
4431 case tok::exclaimequal:
4437 StringRef Spelling = PP.
getSpelling(SpellingLoc, SpellingBuf);
4446void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4451 if (T.consumeOpen()) {
4452 Diag(Tok, diag::err_expected) << tok::l_paren;
4456 if (AttrName->
isStr(
"directive")) {
4462 OMPBeginTok.
setKind(tok::annot_attr_openmp);
4464 OpenMPTokens.push_back(OMPBeginTok);
4466 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4470 OMPEndTok.
setKind(tok::annot_pragma_openmp_end);
4472 OpenMPTokens.push_back(OMPEndTok);
4474 assert(AttrName->
isStr(
"sequence") &&
4475 "Expected either 'directive' or 'sequence'");
4484 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4488 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4489 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4493 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4500 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4514 case ParsedAttr::AT_CarriesDependency:
4515 case ParsedAttr::AT_Deprecated:
4516 case ParsedAttr::AT_FallThrough:
4517 case ParsedAttr::AT_CXX11NoReturn:
4518 case ParsedAttr::AT_NoUniqueAddress:
4519 case ParsedAttr::AT_Likely:
4520 case ParsedAttr::AT_Unlikely:
4522 case ParsedAttr::AT_WarnUnusedResult:
4523 return !ScopeName && AttrName->
getName().equals(
"nodiscard");
4524 case ParsedAttr::AT_Unused:
4525 return !ScopeName && AttrName->
getName().equals(
"maybe_unused");
4536 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4544 TentativeParsingAction TPA(*
this);
4547 if (Res.isInvalid()) {
4550 if (Tok.
is(tok::r_paren))
4555 if (!Tok.
isOneOf(tok::r_paren, tok::r_square)) {
4560 if (!Res.isInvalid()) {
4561 auto *E = Res.get();
4600bool Parser::ParseCXX11AttributeArgs(
4604 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4608 LO.CPlusPlus ? ParsedAttr::Form::CXX11() :
ParsedAttr::Form::
C23();
4614 Form = ParsedAttr::Form::Microsoft();
4629 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4632 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4633 ScopeLoc, Form,
nullptr);
4638 if (ScopeName && ScopeName->
isStr(
"omp") &&
4639 (AttrName->
isStr(
"directive") || AttrName->
isStr(
"sequence"))) {
4641 ? diag::warn_omp51_compat_attributes
4642 : diag::ext_omp_attributes);
4644 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4653 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4654 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4655 ScopeName, ScopeLoc, Form);
4657 else if (!ScopeName && AttrName->
isStr(
"assume")) {
4658 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc))
4662 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4663 ScopeName, ScopeLoc, Form);
4665 if (!Attrs.
empty() &&
4671 Diag(LParenLoc, diag::warn_unknown_attribute_ignored) << AttrName;
4672 Attr.setInvalid(
true);
4680 if (
Attr.getMaxArgs() && !NumArgs) {
4683 Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
4684 Attr.setInvalid(
true);
4685 }
else if (!
Attr.getMaxArgs()) {
4689 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4692 Attr.setInvalid(
true);
4725 if (Tok.
is(tok::kw_alignas)) {
4732 ParseAlignmentSpecifier(Attrs, EndLoc);
4743 if (!Tok.
is(tok::l_paren))
4746 ParseAttributeArgsCommon(AttrName, Loc, Attrs, EndLoc,
4750 Attrs.
addNew(AttrName, Loc,
nullptr, Loc,
nullptr, 0, Form);
4754 assert(Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square) &&
4755 "Not a double square bracket attribute list");
4760 : diag::warn_ext_cxx11_attributes);
4763 : diag::warn_ext_c23_attributes);
4767 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4772 if (Tok.
is(tok::kw_using)) {
4774 ? diag::warn_cxx14_compat_using_attribute_ns
4775 : diag::ext_using_attribute_ns);
4778 CommonScopeName = TryParseCXX11AttributeIdentifier(
4780 if (!CommonScopeName) {
4788 bool AttrParsed =
false;
4789 while (!Tok.
isOneOf(tok::r_square, tok::semi, tok::eof)) {
4793 if (ExpectAndConsume(tok::comma)) {
4807 AttrName = TryParseCXX11AttributeIdentifier(
4815 ScopeName = AttrName;
4818 AttrName = TryParseCXX11AttributeIdentifier(
4827 if (CommonScopeName) {
4829 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4832 ScopeName = CommonScopeName;
4833 ScopeLoc = CommonScopeLoc;
4838 if (Tok.
is(tok::l_paren))
4839 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
4840 ScopeName, ScopeLoc, OpenMPTokens);
4846 ScopeName, ScopeLoc,
nullptr, 0,
4848 : ParsedAttr::Form::C23());
4853 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) << AttrName;
4858 if (Tok.
is(tok::semi)) {
4864 if (ExpectAndConsume(tok::r_square))
4866 else if (Tok.
is(tok::r_square))
4867 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
4870 if (ExpectAndConsume(tok::r_square))
4883 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
4884 }
while (isAllowedCXX11AttributeSpecifier());
4889void Parser::DiagnoseAndSkipCXX11Attributes() {
4898 (Keyword ?
Diag(StartLoc, diag::err_keyword_not_allowed) << Keyword
4899 :
Diag(StartLoc, diag::err_attributes_not_allowed))
4907 if (!isCXX11AttributeSpecifier())
4911 if (Tok.
is(tok::l_square)) {
4915 EndLoc = T.getCloseLocation();
4922 "not an attribute specifier");
4925 if (!T.consumeOpen())
4927 EndLoc = T.getCloseLocation();
4929 }
while (isCXX11AttributeSpecifier());
4936 assert(Tok.
is(tok::identifier) &&
"Not a Microsoft attribute list");
4938 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
4945 if (T.consumeOpen()) {
4946 Diag(Tok, diag::err_expected) << tok::l_paren;
4951 if (isTokenStringLiteral()) {
4956 ArgExprs.push_back(StringResult.
get());
4973 while (Tok.
isNot(tok::r_paren)) {
4975 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4980 SpellingBuffer.resize(Tok.
getLength() + 1);
4982 StringRef TokSpelling = PP.
getSpelling(Tok, SpellingBuffer, &Invalid);
4987 StrBuffer += TokSpelling;
4993 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5003 Toks[0].
setKind(tok::string_literal);
5009 ArgExprs.push_back(UuidString);
5012 if (!T.consumeClose()) {
5015 ParsedAttr::Form::Microsoft());
5028 assert(Tok.
is(tok::l_square) &&
"Not a Microsoft attribute list");
5039 SkipUntil(tok::r_square, tok::identifier,
5041 if (Tok.
is(tok::code_completion)) {
5048 if (Tok.
isNot(tok::identifier))
5051 ParseMicrosoftUuidAttributeArgs(Attrs);
5061 bool AttrParsed =
false;
5062 if (Tok.
is(tok::l_paren)) {
5065 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5067 ReplayOpenMPAttributeTokens(OpenMPTokens);
5071 ParsedAttr::Form::Microsoft());
5078 EndLoc = T.getCloseLocation();
5079 }
while (Tok.
is(tok::l_square));
5084void Parser::ParseMicrosoftIfExistsClassDeclaration(
5087 IfExistsCondition
Result;
5088 if (ParseMicrosoftIfExistsCondition(
Result))
5092 if (
Braces.consumeOpen()) {
5093 Diag(Tok, diag::err_expected) << tok::l_brace;
5097 switch (
Result.Behavior) {
5103 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5113 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
5115 if (Tok.
isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5116 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, CurAS);
5121 if (Tok.
is(tok::semi)) {
5122 ConsumeExtraSemi(InsideStruct,
TagType);
5132 if (Tok.
is(tok::colon))
5136 Diag(Tok, diag::err_expected) << tok::colon;
5142 ParseCXXClassMemberDeclaration(CurAS, AccessAttrs);
Defines the clang::ASTContext interface.
Defines the C++ template declaration subclasses.
Defines an enumeration for C++ overloaded operators.
static void diagnoseDynamicExceptionSpecification(Parser &P, SourceRange Range, bool IsNoexcept)
static bool IsBuiltInOrStandardCXX11Attribute(IdentifierInfo *AttrName, IdentifierInfo *ScopeName)
static FixItHint getStaticAssertNoMessageFixIt(const Expr *AssertExpr, SourceLocation EndExprLoc)
Defines the clang::TokenKind enum and support functions.
#define TRANSFORM_TYPE_TRAIT_DEF(Enum, _)
const NestedNameSpecifier * Specifier
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const clang::PrintingPolicy & getPrintingPolicy() const
Attr - This represents one attribute.
@ AS_Microsoft
[uuid("...")] class Foo
Kind getParsedKind() const
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
SourceLocation getOpenLocation() const
SourceLocation getCloseLocation() const
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
void setTemplateParamLists(ArrayRef< TemplateParameterList * > L)
Represents a character-granular source range.
static CharSourceRange getTokenRange(SourceRange R)
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
Captures information about "declaration specifiers".
void setTypeArgumentRange(SourceRange range)
static const TST TST_typename
void ClearStorageClassSpecs()
TST getTypeSpecType() const
SCS getStorageClassSpec() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
SourceRange getSourceRange() const LLVM_READONLY
void SetPackIndexingExpr(SourceLocation EllipsisLoc, Expr *Pack)
void SetRangeEnd(SourceLocation Loc)
static const TST TST_interface
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void SetRangeStart(SourceLocation Loc)
static const TST TST_union
static const TST TST_typename_pack_indexing
SourceLocation getFriendSpecLoc() const
SourceLocation getModulePrivateSpecLoc() const
Expr * getRepAsExpr() const
static const TST TST_decltype
static const TST TST_class
bool hasTagDefinition() const
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
Decl * getRepAsDecl() const
CXXScopeSpec & getTypeSpecScope()
static const TST TST_decltype_auto
void setExternInLinkageSpec(bool Value)
static const TST TST_error
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
FriendSpecified isFriendSpecified() const
void takeAttributesFrom(ParsedAttributes &attrs)
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInvalidDecl() const
SourceLocation getLocation() const
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear.
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
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 setTrailingRequiresClause(Expr *TRC)
Sets a trailing requires clause for this declarator.
void setTemplateParameterLists(ArrayRef< TemplateParameterList * > TPLs)
Sets the template parameter lists that preceded the declarator.
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
void setAsmLabel(Expr *E)
void ExtendWithDeclSpec(const DeclSpec &DS)
ExtendWithDeclSpec - Extend the declarator source range to include the given declspec,...
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
A little helper class used to produce diagnostics.
RAII object that enters a new expression evaluation context.
Represents a standard C++ module export declaration.
This represents one expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
This represents a decl that may have a name.
Wrapper for void* pointer.
static OpaquePtr make(PtrTy P)
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing,...
ParsedAttr - Represents a syntactic attribute.
static const ParsedAttributesView & none()
void addAll(iterator B, iterator E)
ParsedAttributes - A collection of parsed attributes.
ParsedAttr * addNew(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
void takeAllFrom(ParsedAttributes &Other)
Parser - This implements a parser for the C family of languages.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
DeclGroupPtrTy ParseOpenACCDirectiveDecl()
Placeholder for now, should just ignore the directives after emitting a diagnostic.
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
ExprResult ParseConstantExpression()
ExprResult ParseConditionalExpression()
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
const TargetInfo & getTargetInfo() const
OpaquePtr< TemplateName > TemplateTy
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
friend class ObjCDeclContextSwitch
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtCodeCompletion
Stop at code completion.
@ StopAtSemi
Stop skipping at semicolon.
ExprResult ParseUnevaluatedStringLiteralExpression()
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
RAII object used to inform the actions that we're currently parsing a declaration.
A class for parsing a DeclSpec.
A class for parsing a declarator.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
SourceManager & getSourceManager() const
bool isBacktrackEnabled() const
True if EnableBacktrackAtThisPos() was called and caching of tokens is on.
void RevertCachedTokens(unsigned N)
When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens...
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
IdentifierTable & getIdentifierTable()
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
SourceLocation getLastCachedTokenLocation() const
Get the location of the last cached token, suitable for setting the end location of an annotation tok...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
Represents a struct/union/class.
Scope - A scope is a transient data structure that is used while parsing the program.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ ClassInheritanceScope
We are between inheritance colon and the real class/struct definition scope.
@ ClassScope
The scope of a struct/union/class definition.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
@ DeclScope
This is a scope that can contain a declaration.
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, CXXScopeSpec &SS, TemplateIdAnnotation &TemplateId, const ParsedAttributesView &Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
void PopParsingClass(ParsingClassState state)
void CodeCompleteTag(Scope *S, unsigned TagSpec)
void CodeCompleteUsing(Scope *S)
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
void ActOnFinishCXXNonNestedClass()
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
ParsedType getInheritingConstructorName(CXXScopeSpec &SS, SourceLocation NameLoc, IdentifierInfo &Name)
Handle the result of the special case name lookup for inheriting constructor declarations.
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, const ParsedAttributesView &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation IdentLoc, IdentifierInfo &II, CXXScopeSpec *SS=nullptr)
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
ASTContext & getASTContext() const
Decl * ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, SourceLocation LBraceLoc)
We have parsed the start of an export declaration, including the '{' (if present).
ParsingClassState PushParsingClass()
void CodeCompleteUsingDirective(Scope *S)
ExprResult ActOnUnevaluatedStringLiteral(ArrayRef< Token > StringToks)
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, const ParsedAttributesView &AttrList, UsingDirectiveDecl *&UsingDecl, bool IsNested)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier * > Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
ExprResult ActOnNoexceptSpec(Expr *NoexceptExpr, ExceptionSpecificationType &EST)
Check the given noexcept-specifier, convert its expression, and compute the appropriate ExceptionSpec...
void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
void ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
void CodeCompleteNamespaceDecl(Scope *S)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
ExprResult ActOnFinishTrailingRequiresClause(ExprResult ConstraintExpr)
void CodeCompleteNamespaceAliasDecl(Scope *S)
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, bool IsAbstract, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
void CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax, AttributeCompletion Completion=AttributeCompletion::Attribute, const IdentifierInfo *Scope=nullptr)
bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
QualType ProduceCtorInitMemberSignatureHelp(Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy, ArrayRef< Expr * > ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc, bool Braced)
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification,...
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e....
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer * > MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
TypeResult ActOnTypeName(Declarator &D)
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
void ActOnUndeclaredTypeTemplateName(Scope *S, TemplateTy &Name, TemplateNameKind &TNK, SourceLocation NameLoc, IdentifierInfo *&II)
Try to resolve an undeclared template name as a type template.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, const ParsedAttributesView &Attr)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, const ParsedAttributesView &DeclAttrs, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e....
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
void CodeCompleteAfterFunctionEquals(Declarator &D)
void ActOnUninitializedDecl(Decl *dcl)
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
Decl * ActOnFinishExportDecl(Scope *S, Decl *ExportDecl, SourceLocation RBraceLoc)
Complete the definition of an export declaration.
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, const ParsedAttributesView &AttrList)
void ActOnStartTrailingRequiresClause(Scope *S, Declarator &D)
DeclResult ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, const ParsedAttributesView &AttrList)
ExprResult ActOnDecltypeExpression(Expr *E)
Process the expression contained within a decltype.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getBegin() const
void setEnd(SourceLocation e)
SourceLocation getEndLoc() const LLVM_READONLY
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
StringLiteral - This represents a string literal expression, e.g.
A RAII object used to temporarily suppress access-like checking.
Represents the declaration of a struct/union/class/enum.
Represents a C++ template name within the type system.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
void setLiteralData(const char *Ptr)
SourceLocation getEndLoc() const
void setAnnotationEndLoc(SourceLocation L)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
const char * getName() const
unsigned getLength() const
void setLength(unsigned Len)
void setKind(tok::TokenKind K)
SourceLocation getAnnotationEndLoc() const
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
tok::TokenKind getKind() const
bool isRegularKeywordAttribute() const
Return true if the token is a keyword that is parsed in the same position as a standard attribute,...
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
void setLocation(SourceLocation L)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
bool hasUDSuffix() const
Return true if this token is a string or character literal which has a ud-suffix.
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.
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Braces
New-expression has a C++11 list-initializer.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Unparsed
not parsed yet
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_Dynamic
throw(T1, T2)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
Describes how types, statements, expressions, and declarations should be printed.
Information about a template-id annotation token.
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.
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.