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:
428 MaybeParseCXX11Attributes(DeclAttrs);
429 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
456Decl *Parser::ParseExportDeclaration() {
457 assert(Tok.
is(tok::kw_export));
465 if (Tok.
isNot(tok::l_brace)) {
468 MaybeParseCXX11Attributes(DeclAttrs);
470 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
478 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
479 Tok.
isNot(tok::eof)) {
481 MaybeParseCXX11Attributes(DeclAttrs);
483 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
488 T.getCloseLocation());
496 assert(Tok.
is(tok::kw_using) &&
"Not using token");
502 if (Tok.
is(tok::code_completion)) {
509 while (Tok.
is(tok::kw_template)) {
511 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
516 if (Tok.
is(tok::kw_namespace)) {
518 if (TemplateInfo.Kind) {
520 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
524 Decl *UsingDir = ParseUsingDirective(Context, UsingLoc, DeclEnd, Attrs);
529 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, Attrs,
547 assert(Tok.
is(tok::kw_namespace) &&
"Not 'namespace' token");
552 if (Tok.
is(tok::code_completion)) {
560 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
572 if (Tok.
isNot(tok::identifier)) {
573 Diag(Tok, diag::err_expected_namespace_name);
592 bool GNUAttr =
false;
593 if (Tok.
is(tok::kw___attribute)) {
595 ParseGNUAttributes(attrs);
600 if (ExpectAndConsume(tok::semi,
601 GNUAttr ? diag::err_expected_semi_after_attribute_list
602 : diag::err_expected_semi_after_namespace_name))
606 IdentLoc, NamespcName, attrs);
615 UsingDeclarator &
D) {
622 if (Tok.
is(tok::kw___super)) {
629 if (ParseOptionalCXXScopeSpecifier(
D.SS,
nullptr,
639 if (
D.SS.isInvalid())
653 Tok.
is(tok::identifier) &&
659 !
D.SS.getScopeRep()->getAsNamespace() &&
660 !
D.SS.getScopeRep()->getAsNamespaceAlias()) {
664 D.Name.setConstructorName(
Type, IdLoc, IdLoc);
671 !(Tok.
is(tok::identifier) &&
NextToken().is(tok::equal)),
672 false,
nullptr,
D.Name))
678 ? diag::warn_cxx17_compat_using_declaration_pack
679 : diag::ext_using_declaration_pack);
718 ? diag::warn_cxx17_compat_using_enum_declaration
719 : diag::ext_using_enum_declaration);
721 DiagnoseCXX11AttributeExtension(PrefixAttrs);
723 if (TemplateInfo.Kind) {
725 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
731 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
743 if (Tok.
is(tok::code_completion)) {
753 if (Tok.
is(tok::identifier)) {
765 }
else if (Tok.
is(tok::annot_template_id)) {
772 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
775 ConsumeAnnotationToken();
787 << Tok.
is(tok::kw_enum);
798 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
799 "using-enum declaration"))
808 MaybeParseCXX11Attributes(MisplacedAttrs);
810 if (InInitStatement && Tok.
isNot(tok::identifier))
814 bool InvalidDeclarator = ParseUsingDeclarator(Context,
D);
817 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
821 if (MisplacedAttrs.Range.isValid()) {
823 MisplacedAttrs.empty() ? nullptr : &MisplacedAttrs.front();
824 auto &
Range = MisplacedAttrs.Range;
825 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
835 if (Tok.
is(tok::equal) || InInitStatement) {
836 if (InvalidDeclarator) {
841 ProhibitAttributes(PrefixAttrs);
843 Decl *DeclFromDeclSpec =
nullptr;
849 Decl *AD = ParseAliasDeclarationAfterDeclarator(
850 TemplateInfo, UsingLoc,
D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
854 DiagnoseCXX11AttributeExtension(PrefixAttrs);
859 if (TemplateInfo.Kind) {
861 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
873 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
874 DiagnoseCXX11AttributeExtension(Attrs);
877 if (InvalidDeclarator)
882 if (
D.TypenameLoc.isValid() &&
885 diag::err_typename_identifiers_only)
892 D.TypenameLoc,
D.SS,
D.Name,
893 D.EllipsisLoc, Attrs);
895 DeclsInGroup.push_back(UD);
903 InvalidDeclarator = ParseUsingDeclarator(Context,
D);
906 if (DeclsInGroup.size() > 1)
909 ? diag::warn_cxx17_compat_multi_using_declaration
910 : diag::ext_multi_using_declaration);
914 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
915 !Attrs.
empty() ?
"attributes list"
916 : UELoc.
isValid() ?
"using-enum declaration"
917 :
"using declaration"))
923Decl *Parser::ParseAliasDeclarationAfterDeclarator(
927 if (ExpectAndConsume(tok::equal)) {
933 ? diag::warn_cxx98_compat_alias_declaration
934 : diag::ext_alias_declaration);
938 if (TemplateInfo.Kind == ParsedTemplateInfo::Template &&
941 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization)
943 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
945 if (SpecKind != -1) {
949 D.Name.TemplateId->RAngleLoc);
951 Range = TemplateInfo.getSourceRange();
953 << SpecKind <<
Range;
960 Diag(
D.Name.StartLocation, diag::err_alias_declaration_not_identifier);
964 }
else if (
D.TypenameLoc.isValid())
965 Diag(
D.TypenameLoc, diag::err_alias_declaration_not_identifier)
969 else if (
D.SS.isNotEmpty())
972 if (
D.EllipsisLoc.isValid())
973 Diag(
D.EllipsisLoc, diag::err_alias_declaration_pack_expansion)
976 Decl *DeclFromDeclSpec =
nullptr;
981 AS, &DeclFromDeclSpec, &Attrs);
983 *OwnedType = DeclFromDeclSpec;
987 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
988 !Attrs.
empty() ?
"attributes list"
989 :
"alias declaration"))
994 TemplateParams ? TemplateParams->data() :
nullptr,
995 TemplateParams ? TemplateParams->size() : 0);
997 UsingLoc,
D.Name, Attrs, TypeAlias,
1003 if (
const auto *BO = dyn_cast_or_null<BinaryOperator>(AssertExpr)) {
1004 if (BO->getOpcode() == BO_LAnd &&
1005 isa<StringLiteral>(BO->getRHS()->IgnoreImpCasts()))
1020 assert(Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
1021 "Not a static_assert declaration");
1024 const char *TokName = Tok.
getName();
1026 if (Tok.
is(tok::kw__Static_assert))
1027 diagnoseUseOfC11Keyword(Tok);
1028 else if (Tok.
is(tok::kw_static_assert)) {
1031 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
1036 Diag(Tok, diag::warn_cxx98_compat_static_assert);
1042 if (
T.consumeOpen()) {
1043 Diag(Tok, diag::err_expected) << tok::l_paren;
1051 if (AssertExpr.isInvalid()) {
1057 if (Tok.
is(tok::r_paren)) {
1060 DiagVal = diag::warn_cxx14_compat_static_assert_no_message;
1062 DiagVal = diag::ext_cxx_static_assert_no_message;
1064 DiagVal = diag::warn_c17_compat_static_assert_no_message;
1066 DiagVal = diag::ext_c_static_assert_no_message;
1070 if (ExpectAndConsume(tok::comma)) {
1075 bool ParseAsExpression =
false;
1077 for (
unsigned I = 0;; ++I) {
1078 const Token &
T = GetLookAheadToken(I);
1079 if (
T.is(tok::r_paren))
1082 ParseAsExpression =
true;
1088 if (ParseAsExpression)
1093 Diag(Tok, diag::err_expected_string_literal)
1108 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
1111 AssertMessage.
get(),
1112 T.getCloseLocation());
1121 assert(Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype) &&
1122 "Not a decltype specifier");
1128 if (Tok.
is(tok::annot_decltype)) {
1129 Result = getExprAnnotation(Tok);
1134 ConsumeAnnotationToken();
1135 if (
Result.isInvalid()) {
1141 Diag(Tok, diag::warn_cxx98_compat_decltype);
1146 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"decltype",
1149 return T.getOpenLocation() == Tok.
getLocation() ? StartLoc
1150 :
T.getOpenLocation();
1154 if (Tok.
is(tok::kw_auto) &&
NextToken().is(tok::r_paren)) {
1159 ? diag::warn_cxx11_compat_decltype_auto_type_specifier
1160 : diag::ext_decltype_auto_type_specifier);
1174 if (
Result.isInvalid()) {
1177 EndLoc = ConsumeParen();
1184 assert(Tok.
is(tok::semi));
1198 if (
T.getCloseLocation().isInvalid()) {
1202 return T.getCloseLocation();
1205 if (
Result.isInvalid()) {
1207 return T.getCloseLocation();
1210 EndLoc =
T.getCloseLocation();
1212 assert(!
Result.isInvalid());
1214 const char *PrevSpec =
nullptr;
1219 PrevSpec, DiagID,
Result.get(), Policy)
1221 PrevSpec, DiagID, Policy)) {
1222 Diag(StartLoc, DiagID) << PrevSpec;
1228void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
1244 Tok.
setKind(tok::annot_decltype);
1245 setExprAnnotation(Tok,
1255 assert(Tok.
isOneOf(tok::annot_pack_indexing_type, tok::identifier) &&
1256 "Expected an identifier");
1261 const char *PrevSpec;
1265 if (Tok.
is(tok::annot_pack_indexing_type)) {
1273 ConsumeAnnotationToken();
1274 if (
Type.isInvalid()) {
1279 DiagID,
Type, Policy);
1283 !GetLookAheadToken(2).is(tok::l_square)) {
1315 return T.getCloseLocation();
1318void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1334 Tok.
setKind(tok::annot_pack_indexing_type);
1335 setTypeAnnotation(Tok,
T);
1343#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1344 case tok::kw___##Trait: \
1345 return DeclSpec::TST_##Trait;
1346#include "clang/Basic/TransformTypeTraits.def"
1348 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1352bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1357 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1361 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.
getName(),
1366 if (
Result.isInvalid()) {
1372 if (
T.getCloseLocation().isInvalid())
1375 const char *PrevSpec =
nullptr;
1380 Diag(StartLoc, DiagID) << PrevSpec;
1406 if (Tok.
is(tok::kw_typename)) {
1407 Diag(Tok, diag::err_expected_class_name_not_template)
1414 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1424 if (Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1431 EndLocation = ParseDecltypeSpecifier(DS);
1438 if (Tok.
is(tok::annot_pack_indexing_type)) {
1440 ParsePackIndexingType(DS);
1449 if (Tok.
is(tok::annot_template_id)) {
1455 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
1458 ConsumeAnnotationToken();
1465 if (Tok.
isNot(tok::identifier)) {
1466 Diag(Tok, diag::err_expected_class_name);
1473 if (Tok.
is(tok::less)) {
1482 Diag(IdLoc, diag::err_unknown_template_name) <<
Id;
1493 if (Tok.
is(tok::annot_template_id) &&
1494 takeTemplateIdAnnotation(Tok)->mightBeType())
1500 if (Tok.
isNot(tok::annot_typename))
1507 ConsumeAnnotationToken();
1520 Diag(IdLoc, diag::err_expected_class_name);
1525 EndLocation = IdLoc;
1533 const char *PrevSpec =
nullptr;
1543void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1544 while (Tok.
isOneOf(tok::kw___single_inheritance,
1545 tok::kw___multiple_inheritance,
1546 tok::kw___virtual_inheritance)) {
1550 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1555 while (Tok.
is(tok::kw__Nullable)) {
1559 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1566bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1577 case tok::identifier:
1579 case tok::coloncolon:
1580 case tok::annot_cxxscope:
1581 case tok::annot_typename:
1582 case tok::annot_template_id:
1583 case tok::kw_decltype:
1586 case tok::kw_operator:
1587 case tok::kw___declspec:
1592 case tok::kw___attribute:
1593 case tok::annot_pragma_pack:
1595 case tok::annot_pragma_ms_pragma:
1597 case tok::annot_pragma_ms_vtordisp:
1599 case tok::annot_pragma_ms_pointers_to_members:
1602 return CouldBeBitfield ||
1605 case tok::kw___cdecl:
1606 case tok::kw___fastcall:
1607 case tok::kw___stdcall:
1608 case tok::kw___thiscall:
1609 case tok::kw___vectorcall:
1615 case tok::kw_volatile:
1616 case tok::kw_restrict:
1617 case tok::kw__Atomic:
1618 case tok::kw___unaligned:
1622 case tok::kw_inline:
1623 case tok::kw_virtual:
1624 case tok::kw_friend:
1626 case tok::kw_static:
1627 case tok::kw_extern:
1628 case tok::kw_typedef:
1629 case tok::kw_register:
1631 case tok::kw_mutable:
1632 case tok::kw_thread_local:
1633 case tok::kw_constexpr:
1634 case tok::kw_consteval:
1635 case tok::kw_constinit:
1651 if (!isKnownToBeTypeSpecifier(
NextToken()))
1708 ParsedTemplateInfo &TemplateInfo,
1710 DeclSpecContext DSC,
1713 if (TagTokKind == tok::kw_struct)
1715 else if (TagTokKind == tok::kw___interface)
1717 else if (TagTokKind == tok::kw_class)
1720 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1724 if (Tok.
is(tok::code_completion)) {
1738 const bool shouldDelayDiagsInTag =
1739 (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate);
1745 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1747 if (Tok.
isOneOf(tok::kw___single_inheritance,
1748 tok::kw___multiple_inheritance,
1749 tok::kw___virtual_inheritance)) {
1750 ParseMicrosoftInheritanceClassAttributes(attrs);
1753 if (Tok.
is(tok::kw__Nullable)) {
1754 ParseNullabilityClassAttributes(attrs);
1768#include
"clang/Basic/TransformTypeTraits.def"
1769 tok::kw___is_abstract,
1770 tok::kw___is_aggregate,
1771 tok::kw___is_arithmetic,
1773 tok::kw___is_assignable,
1774 tok::kw___is_base_of,
1775 tok::kw___is_bounded_array,
1777 tok::kw___is_complete_type,
1778 tok::kw___is_compound,
1780 tok::kw___is_constructible,
1781 tok::kw___is_convertible,
1782 tok::kw___is_convertible_to,
1783 tok::kw___is_destructible,
1786 tok::kw___is_floating_point,
1788 tok::kw___is_function,
1789 tok::kw___is_fundamental,
1790 tok::kw___is_integral,
1791 tok::kw___is_interface_class,
1792 tok::kw___is_literal,
1793 tok::kw___is_lvalue_expr,
1794 tok::kw___is_lvalue_reference,
1795 tok::kw___is_member_function_pointer,
1796 tok::kw___is_member_object_pointer,
1797 tok::kw___is_member_pointer,
1798 tok::kw___is_nothrow_assignable,
1799 tok::kw___is_nothrow_constructible,
1800 tok::kw___is_nothrow_convertible,
1801 tok::kw___is_nothrow_destructible,
1802 tok::kw___is_nullptr,
1803 tok::kw___is_object,
1805 tok::kw___is_pointer,
1806 tok::kw___is_polymorphic,
1807 tok::kw___is_reference,
1808 tok::kw___is_referenceable,
1809 tok::kw___is_rvalue_expr,
1810 tok::kw___is_rvalue_reference,
1812 tok::kw___is_scalar,
1813 tok::kw___is_scoped_enum,
1814 tok::kw___is_sealed,
1815 tok::kw___is_signed,
1816 tok::kw___is_standard_layout,
1817 tok::kw___is_trivial,
1818 tok::kw___is_trivially_equality_comparable,
1819 tok::kw___is_trivially_assignable,
1820 tok::kw___is_trivially_constructible,
1821 tok::kw___is_trivially_copyable,
1822 tok::kw___is_unbounded_array,
1824 tok::kw___is_unsigned,
1826 tok::kw___is_volatile
1833 TryKeywordIdentFallback(
true);
1835 struct PreserveAtomicIdentifierInfoRAII {
1836 PreserveAtomicIdentifierInfoRAII(
Token &Tok,
bool Enabled)
1837 : AtomicII(nullptr) {
1840 assert(Tok.
is(tok::kw__Atomic));
1845 ~PreserveAtomicIdentifierInfoRAII() {
1848 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1858 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1859 Tok.
is(tok::kw__Atomic) &&
1861 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1862 Tok, ShouldChangeAtomicToIdentifier);
1872 if (TemplateInfo.TemplateParams)
1875 bool HasValidSpec =
true;
1876 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1880 HasValidSpec =
false;
1883 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::annot_template_id)) {
1884 Diag(Tok, diag::err_expected) << tok::identifier;
1885 HasValidSpec =
false;
1893 auto RecoverFromUndeclaredTemplateName = [&](
IdentifierInfo *Name,
1896 bool KnownUndeclared) {
1897 Diag(NameLoc, diag::err_explicit_spec_non_template)
1898 << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
1899 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1903 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1904 if (TemplateParams->size() > 1) {
1905 TemplateParams->pop_back();
1907 TemplateParams =
nullptr;
1908 TemplateInfo.Kind = ParsedTemplateInfo::NonTemplate;
1910 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1912 TemplateParams =
nullptr;
1913 TemplateInfo.Kind = ParsedTemplateInfo::NonTemplate;
1923 if (Tok.
is(tok::identifier)) {
1932 TemplateArgList TemplateArgs;
1934 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1940 RecoverFromUndeclaredTemplateName(
1941 Name, NameLoc,
SourceRange(LAngleLoc, RAngleLoc),
false);
1943 }
else if (Tok.
is(tok::annot_template_id)) {
1944 TemplateId = takeTemplateIdAnnotation(Tok);
1945 NameLoc = ConsumeAnnotationToken();
1952 RecoverFromUndeclaredTemplateName(
1955 TemplateId =
nullptr;
1968 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1969 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) <<
Range;
2004 MaybeParseCXX11Attributes(Attributes);
2009 AllowDefiningTypeSpec::No ||
2012 else if (Tok.
is(tok::l_brace) ||
2013 (DSC != DeclSpecContext::DSC_association &&
2015 (isClassCompatibleKeyword() &&
2031 }
else if (isClassCompatibleKeyword() &&
2038 TentativeParsingAction PA(*
this);
2041 while (isClassCompatibleKeyword()) {
2047 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square)) {
2051 }
else if (Tok.
is(tok::kw_alignas) &&
NextToken().is(tok::l_paren)) {
2061 if (!
T.consumeOpen())
2069 if (Tok.
isOneOf(tok::l_brace, tok::colon))
2075 }
else if (!isTypeSpecifier(DSC) &&
2076 (Tok.
is(tok::semi) ||
2079 if (Tok.
isNot(tok::semi)) {
2082 ExpectAndConsume(tok::semi, diag::err_expected_after,
2100 auto *FirstAttr = Attributes.
empty() ? nullptr : &Attributes.
front();
2102 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2103 ?
Diag(
Loc, diag::err_keyword_not_allowed) << FirstAttr
2104 :
Diag(
Loc, diag::err_attributes_not_allowed))
2116 if (!Name && !TemplateId &&
2121 Diag(StartLoc, diag::err_anon_type_definition)
2148 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2151 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2152 diag::err_keyword_not_allowed,
2156 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2167 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
2168 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2169 diag::err_keyword_not_allowed,
2179 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2192 "Expected a definition here");
2196 TemplateParams =
nullptr;
2201 diag::err_explicit_instantiation_with_definition)
2210 std::nullopt, LAngleLoc,
nullptr));
2211 TemplateParams = &FakedParamLists;
2218 SS, *TemplateId, attrs,
2221 TemplateParams ? TemplateParams->size() : 0),
2224 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2231 ProhibitAttributes(attrs);
2234 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2235 TagType, StartLoc, SS, Name, NameLoc, attrs);
2237 TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
2238 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2239 diag::err_keyword_not_allowed,
2246 TemplateParams ? TemplateParams->size() : 0));
2249 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2250 diag::err_keyword_not_allowed,
2254 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2257 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2259 TemplateParams =
nullptr;
2262 bool IsDependent =
false;
2272 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2275 TagOrTempResult = Actions.
ActOnTag(
2279 DSC == DeclSpecContext::DSC_type_specifier,
2280 DSC == DeclSpecContext::DSC_template_param ||
2281 DSC == DeclSpecContext::DSC_template_type_arg,
2282 OffsetOfState, &SkipBody);
2289 Name, StartLoc, NameLoc);
2296 if (shouldDelayDiagsInTag) {
2297 diagsFromTag.done();
2299 TemplateInfo.Kind == ParsedTemplateInfo::Template)
2300 diagsFromTag.redelay();
2305 assert(Tok.
is(tok::l_brace) ||
2307 isClassCompatibleKeyword());
2309 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc,
TagType,
2310 TagOrTempResult.
get());
2312 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs,
TagType,
2313 TagOrTempResult.
get());
2318 ParseStructUnionBody(StartLoc,
TagType, cast<RecordDecl>(
D));
2331 const char *PrevSpec =
nullptr;
2336 NameLoc.
isValid() ? NameLoc : StartLoc,
2338 }
else if (!TagOrTempResult.
isInvalid()) {
2340 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2341 DiagID, TagOrTempResult.
get(), Owned, Policy);
2348 Diag(StartLoc, DiagID) << PrevSpec;
2364 (TemplateInfo.Kind || !isValidAfterTypeSpecifier(
false))) {
2365 if (Tok.
isNot(tok::semi)) {
2367 ExpectAndConsume(tok::semi, diag::err_expected_after,
2385void Parser::ParseBaseClause(
Decl *ClassDecl) {
2386 assert(Tok.
is(tok::colon) &&
"Not a base clause");
2395 if (
Result.isInvalid()) {
2401 BaseInfo.push_back(
Result.get());
2426 bool IsVirtual =
false;
2430 MaybeParseCXX11Attributes(Attributes);
2436 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2446 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2450 if (Tok.
is(tok::kw_virtual)) {
2454 Diag(VirtualLoc, diag::err_dup_virtual)
2461 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2475 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2491 Access, BaseType.
get(), BaseLoc,
2506 case tok::kw_private:
2508 case tok::kw_protected:
2510 case tok::kw_public:
2519void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2526 if (!NeedLateParse) {
2530 if (Param->hasUnparsedDefaultArg()) {
2531 NeedLateParse =
true;
2537 if (NeedLateParse) {
2540 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2541 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2546 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2548 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2585 if (II == Ident_override)
2588 if (II == Ident_sealed)
2591 if (II == Ident_abstract)
2594 if (II == Ident_final)
2597 if (II == Ident_GNU_final)
2608void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2627 const char *PrevSpec =
nullptr;
2645 ? diag::warn_cxx98_compat_override_control_keyword
2646 : diag::ext_override_control_keyword)
2655bool Parser::isCXX11FinalKeyword()
const {
2664bool Parser::isClassCompatibleKeyword()
const {
2674bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2676 LateParsedAttrList &LateParsedAttrs) {
2687 if (Tok.
isNot(tok::colon))
2688 ParseDeclarator(DeclaratorInfo);
2693 MaybeParseHLSLAnnotations(DeclaratorInfo,
nullptr,
2698 "don't know where identifier would go yet?");
2702 }
else if (Tok.
is(tok::kw_requires)) {
2703 ParseTrailingRequiresClause(DeclaratorInfo);
2705 ParseOptionalCXX11VirtSpecifierSeq(
2706 VS, getCurrentClass().IsInterface,
2709 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2714 if (Tok.
is(tok::kw_asm)) {
2717 if (AsmLabel.isInvalid())
2727 DiagnoseAndSkipCXX11Attributes();
2728 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2729 DiagnoseAndSkipCXX11Attributes();
2734 ParseOptionalCXX11VirtSpecifierSeq(
2735 VS, getCurrentClass().IsInterface,
2741 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2742 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2744 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2761void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2767 ParseTypeQualifierListOpt(
2768 DS, AR_NoAttributesParsed,
false,
2769 false, llvm::function_ref<
void()>([&]() {
2772 D.ExtendWithDeclSpec(DS);
2774 if (
D.isFunctionDeclarator()) {
2775 auto &
Function =
D.getFunctionTypeInfo();
2777 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2780 auto &MQ =
Function.getOrCreateMethodQualifiers();
2781 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2782 std::string Name(FixItName.data());
2785 MQ.SetTypeQual(TypeQual, SpecLoc);
2787 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2796 bool RefQualifierIsLValueRef =
true;
2798 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2799 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2802 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2803 Function.RefQualifierLoc = RefQualifierLoc;
2805 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2806 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2809 D.SetRangeEnd(RefQualifierLoc);
2855 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2856 if (Tok.
is(tok::at)) {
2858 Diag(Tok, diag::err_at_defs_cxx);
2860 Diag(Tok, diag::err_at_in_class);
2876 bool MalformedTypeSpec =
false;
2877 if (!TemplateInfo.Kind &&
2878 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2880 MalformedTypeSpec =
true;
2883 if (Tok.
isNot(tok::annot_cxxscope))
2884 isAccessDecl =
false;
2885 else if (
NextToken().is(tok::identifier))
2886 isAccessDecl = GetLookAheadToken(2).
is(tok::semi);
2893 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2906 false,
false,
true,
true,
2907 false, &TemplateKWLoc, Name)) {
2913 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2914 "access declaration")) {
2930 if (!TemplateInfo.Kind &&
2931 Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2937 if (Tok.
is(tok::kw_template)) {
2938 assert(!TemplateInfo.TemplateParams &&
2939 "Nested template improperly parsed?");
2943 DeclEnd, AccessAttrs, AS);
2947 if (Tok.
is(tok::kw___extension__)) {
2951 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2957 MaybeParseCXX11Attributes(DeclAttrs);
2962 if (Tok.
is(tok::annot_attr_openmp))
2963 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
2965 if (Tok.
is(tok::kw_using)) {
2970 while (Tok.
is(tok::kw_template)) {
2972 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
2976 if (Tok.
is(tok::kw_namespace)) {
2977 Diag(UsingLoc, diag::err_using_namespace_in_class);
2984 UsingLoc, DeclEnd, DeclAttrs, AS);
2988 MaybeParseMicrosoftAttributes(DeclSpecAttrs);
2991 LateParsedAttrList CommonLateParsedAttrs;
2998 if (MalformedTypeSpec)
3006 bool IsTemplateSpecOrInst =
3007 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
3008 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
3011 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
3012 &CommonLateParsedAttrs);
3014 if (IsTemplateSpecOrInst)
3015 diagsFromTag.done();
3023 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate &&
3024 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
3025 &CommonLateParsedAttrs))
3029 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
3031 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
3035 ProhibitAttributes(DeclAttrs);
3039 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
3041 DS.complete(TheDecl);
3043 Decl *decls[] = {AnonRecord, TheDecl};
3054 if (TemplateInfo.TemplateParams)
3059 LateParsedAttrList LateParsedAttrs;
3064 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
3065 if (Tok.
isNot(tok::equal))
3070 if (
Zero.isNot(tok::numeric_constant) ||
3074 auto &
After = GetLookAheadToken(2);
3075 if (!
After.isOneOf(tok::semi, tok::comma) &&
3076 !(AllowDefinition &&
3077 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3088 bool ExpectSemi =
true;
3096 if (ParseCXXMemberDeclaratorBeforeInitializer(
3097 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3102 if (IsTemplateSpecOrInst)
3110 TryConsumePureSpecifier(
true);
3121 if (Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3123 }
else if (Tok.
is(tok::equal)) {
3125 if (KW.
is(tok::kw_default))
3127 else if (KW.
is(tok::kw_delete))
3129 else if (KW.
is(tok::code_completion)) {
3146 ProhibitAttributes(DeclAttrs);
3163 diag::err_function_declared_typedef);
3169 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3170 TemplateInfo, VS, PureSpecLoc);
3173 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3174 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3176 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3177 LateParsedAttrs[i]->addDecl(FunDecl);
3180 LateParsedAttrs.clear();
3183 if (Tok.
is(tok::semi))
3184 ConsumeExtraSemi(AfterMemberFunctionDefinition);
3196 bool HasStaticInitializer =
false;
3201 Diag(Tok, diag::err_anon_bitfield_member_init);
3205 if (!TryConsumePureSpecifier(
false))
3207 HasStaticInitializer =
true;
3213 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate) {
3215 if (BitfieldSize.
get())
3217 ? diag::warn_cxx17_compat_bitfield_member_init
3218 : diag::ext_bitfield_member_init);
3221 HasStaticInitializer =
true;
3237 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3238 auto Loc = AL.getRange().getBegin();
3239 (AL.isRegularKeywordAttribute()
3240 ?
Diag(
Loc, diag::err_keyword_not_allowed) << AL
3241 :
Diag(
Loc, diag::err_attributes_not_allowed))
3249 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3250 VS, HasInClassInit);
3253 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3256 ThisDecl = VT->getTemplatedDecl();
3265 DeclaratorInfo.getDeclSpec().getStorageClassSpec() ==
3268 HasStaticInitializer =
true;
3272 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3274 if (ThisDecl && PureSpecLoc.
isValid())
3283 ? diag::warn_cxx98_compat_nonstatic_member_init
3284 : diag::ext_nonstatic_member_init);
3286 if (DeclaratorInfo.isArrayOfUnknownBound()) {
3292 Diag(Tok, diag::err_incomplete_array_member_init);
3299 ParseCXXNonStaticMemberInitializer(ThisDecl);
3300 }
else if (HasStaticInitializer) {
3303 ThisDecl, DeclaratorInfo.isDeclarationOfFunction(), EqualLoc);
3305 if (
Init.isInvalid()) {
3309 }
else if (ThisDecl)
3312 }
else if (ThisDecl && DeclaratorInfo.isStaticMember())
3319 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3320 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3322 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3323 LateParsedAttrs[i]->addDecl(ThisDecl);
3326 DeclsInGroup.push_back(ThisDecl);
3328 if (DeclaratorInfo.isFunctionDeclarator() &&
3329 DeclaratorInfo.getDeclSpec().getStorageClassSpec() !=
3331 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3333 LateParsedAttrs.clear();
3335 DeclaratorInfo.complete(ThisDecl);
3348 Diag(CommaLoc, diag::err_expected_semi_declaration)
3358 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
3359 DeclaratorInfo.isFirstDeclarator()) {
3360 Diag(CommaLoc, diag::err_multiple_template_declarators)
3361 << TemplateInfo.Kind;
3365 DeclaratorInfo.clear();
3369 DeclaratorInfo.setCommaLoc(CommaLoc);
3374 DiagnoseAndSkipCXX11Attributes();
3375 MaybeParseGNUAttributes(DeclaratorInfo);
3376 DiagnoseAndSkipCXX11Attributes();
3378 if (ParseCXXMemberDeclaratorBeforeInitializer(
3379 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3384 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
3417 assert(Tok.
isOneOf(tok::equal, tok::l_brace) &&
3418 "Data member initializer not starting with '=' or '{'");
3420 bool IsFieldInitialization = isa_and_present<FieldDecl>(
D);
3424 IsFieldInitialization
3433 IsFieldInitialization;
3436 if (Tok.
is(tok::kw_delete)) {
3443 if (IsFunction || Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3449 SkipDeletedFunctionBody();
3452 }
else if (Tok.
is(tok::kw_default)) {
3454 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3462 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(
D)) {
3463 Diag(Tok, diag::err_ms_property_initializer) << PD;
3466 return ParseInitializer();
3474 assert(isCXX11FinalKeyword() &&
"not a class definition");
3480 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3485 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_brace))
3492 if (Tok.
is(tok::colon)) {
3495 ParsingClassDefinition ParsingDef(*
this,
TagDecl,
true,
3501 ParseBaseClause(
nullptr);
3505 if (!Tok.
is(tok::l_brace)) {
3507 diag::err_expected_lbrace_after_base_specifiers);
3513 assert(Tok.
is(tok::l_brace));
3519 if (Tok.
is(tok::kw___attribute)) {
3521 MaybeParseGNUAttributes(Attrs);
3531 case tok::kw___if_exists:
3532 case tok::kw___if_not_exists:
3533 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, AS);
3538 ConsumeExtraSemi(InsideStruct,
TagType);
3542 case tok::annot_pragma_vis:
3543 HandlePragmaVisibility();
3545 case tok::annot_pragma_pack:
3548 case tok::annot_pragma_align:
3549 HandlePragmaAlign();
3551 case tok::annot_pragma_ms_pointers_to_members:
3552 HandlePragmaMSPointersToMembers();
3554 case tok::annot_pragma_ms_pragma:
3555 HandlePragmaMSPragma();
3557 case tok::annot_pragma_ms_vtordisp:
3558 HandlePragmaMSVtorDisp();
3560 case tok::annot_pragma_dump:
3564 case tok::kw_namespace:
3566 DiagnoseUnexpectedNamespace(cast<NamedDecl>(
TagDecl));
3569 case tok::kw_private:
3573 ParsedTemplateInfo TemplateInfo;
3574 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3577 case tok::kw_public:
3578 case tok::kw_protected: {
3588 AccessAttrs.
clear();
3589 MaybeParseGNUAttributes(AccessAttrs);
3594 Diag(EndLoc, diag::err_expected)
3598 Diag(EndLoc, diag::err_expected)
3610 AccessAttrs.
clear();
3616 case tok::annot_attr_openmp:
3617 case tok::annot_pragma_openmp:
3618 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3620 case tok::annot_pragma_openacc:
3628 ConsumeAnnotationToken();
3631 ParsedTemplateInfo TemplateInfo;
3632 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3649 "Invalid TagType!");
3651 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3652 if (
auto *TD = dyn_cast_or_null<NamedDecl>(
TagDecl))
3653 return TD->getQualifiedNameAsString();
3654 return std::string(
"<anonymous>");
3658 "parsing struct/union/class body");
3662 bool NonNestedClass =
true;
3663 if (!ClassStack.empty()) {
3665 if (S->isClassScope()) {
3667 NonNestedClass =
false;
3670 if (getCurrentClass().IsInterface) {
3674 ? cast<NamedDecl>(
TagDecl)->getQualifiedNameAsString()
3680 if (S->isFunctionScope())
3691 ParsingClassDefinition ParsingDef(*
this,
TagDecl, NonNestedClass,
3699 bool IsFinalSpelledSealed =
false;
3700 bool IsAbstract =
false;
3708 if (isCXX11FinalKeyword()) {
3711 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3716 IsFinalSpelledSealed =
true;
3721 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3729 Diag(FinalLoc, diag::err_override_control_interface)
3733 ? diag::warn_cxx98_compat_override_control_keyword
3734 : diag::ext_override_control_keyword)
3737 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3739 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3741 Diag(FinalLoc, diag::ext_warn_gnu_final);
3744 "not a class definition");
3750 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3759 if (!Tok.
is(tok::colon) && !Tok.
is(tok::l_brace)) {
3766 if (Tok.
is(tok::colon)) {
3767 ParseScope InheritanceScope(
this,
getCurScope()->getFlags() |
3771 if (!Tok.
is(tok::l_brace)) {
3772 bool SuggestFixIt =
false;
3776 case tok::kw_private:
3777 case tok::kw_protected:
3778 case tok::kw_public:
3781 case tok::kw_static_assert:
3785 case tok::kw_template:
3786 SuggestFixIt =
true;
3788 case tok::identifier:
3789 SuggestFixIt = isConstructorDeclarator(
true);
3792 SuggestFixIt = isCXXSimpleDeclaration(
false);
3797 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3811 assert(Tok.
is(tok::l_brace));
3817 IsFinalSpelledSealed, IsAbstract,
3818 T.getOpenLocation());
3833 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3834 Tok.
isNot(tok::eof)) {
3836 ParseCXXClassMemberDeclarationWithPragmas(
3838 MaybeDestroyTemplateIds();
3847 MaybeParseGNUAttributes(attrs);
3851 T.getOpenLocation(),
3852 T.getCloseLocation(), attrs);
3859 if (
TagDecl && NonNestedClass) {
3866 ParseLexedPragmas(getCurrentClass());
3867 ParseLexedAttributes(getCurrentClass());
3868 ParseLexedMethodDeclarations(getCurrentClass());
3873 ParseLexedMemberInitializers(getCurrentClass());
3874 ParseLexedMethodDefs(getCurrentClass());
3875 PrevTokLocation = SavedPrevTokLocation;
3890void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *
D) {
3891 assert(Tok.
is(tok::kw_namespace));
3930void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3931 assert(Tok.
is(tok::colon) &&
3932 "Constructor initializer always starts with ':'");
3940 bool AnyErrors =
false;
3943 if (Tok.
is(tok::code_completion)) {
3946 ConstructorDecl, MemInitializers);
3950 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3952 MemInitializers.push_back(MemInit.
get());
3956 if (Tok.
is(tok::comma))
3958 else if (Tok.
is(tok::l_brace))
3963 Tok.
isOneOf(tok::identifier, tok::coloncolon)) {
3965 Diag(
Loc, diag::err_ctor_init_missing_comma)
3971 << tok::l_brace << tok::comma;
3996 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
4009 if (Tok.
is(tok::identifier)) {
4014 }
else if (Tok.
is(tok::annot_decltype)) {
4019 ParseDecltypeSpecifier(DS);
4020 }
else if (Tok.
is(tok::annot_pack_indexing_type)) {
4023 ParsePackIndexingType(DS);
4026 ? takeTemplateIdAnnotation(Tok)
4031 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
4033 ConsumeAnnotationToken();
4035 Diag(Tok, diag::err_expected_member_or_base_name);
4042 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
4045 ExprResult InitList = ParseBraceInitializer();
4055 TemplateTypeTy.
get(), DS, IdLoc,
4056 InitList.
get(), EllipsisLoc);
4057 }
else if (Tok.
is(tok::l_paren)) {
4062 ExprVector ArgExprs;
4063 auto RunSignatureHelp = [&] {
4068 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
4069 T.getOpenLocation(),
false);
4070 CalledSignatureHelp =
true;
4071 return PreferredType;
4073 if (Tok.
isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
4074 PreferredType.enterFunctionArgument(Tok.
getLocation(),
4091 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
4092 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
4099 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
4101 return Diag(Tok, diag::err_expected) << tok::l_paren;
4119 ExceptionSpecTokens =
nullptr;
4123 if (Tok.
isNot(tok::kw_throw) && Tok.
isNot(tok::kw_noexcept))
4127 bool IsNoexcept = Tok.
is(tok::kw_noexcept);
4128 Token StartTok = Tok;
4132 if (!Tok.
is(tok::l_paren)) {
4135 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4136 NoexceptExpr =
nullptr;
4140 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4146 ExceptionSpecTokens->push_back(StartTok);
4147 ExceptionSpecTokens->push_back(Tok);
4148 SpecificationRange.
setEnd(ConsumeParen());
4150 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4153 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4159 if (Tok.
is(tok::kw_throw)) {
4160 Result = ParseDynamicExceptionSpecification(
4161 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4162 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4163 "Produced different number of exception types and ranges.");
4167 if (Tok.
isNot(tok::kw_noexcept))
4170 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4178 if (Tok.
is(tok::l_paren)) {
4191 NoexceptRange =
SourceRange(KeywordLoc,
T.getCloseLocation());
4198 NoexceptRange =
SourceRange(KeywordLoc, KeywordLoc);
4202 SpecificationRange = NoexceptRange;
4207 if (Tok.
is(tok::kw_throw)) {
4208 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4209 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4210 DynamicExceptionRanges);
4213 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4221 if (
P.getLangOpts().CPlusPlus11) {
4222 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4224 ? diag::ext_dynamic_exception_spec
4225 : diag::warn_exception_spec_deprecated)
4246 assert(Tok.
is(tok::kw_throw) &&
"expected throw");
4250 if (
T.consumeOpen()) {
4251 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4258 if (Tok.
is(tok::ellipsis)) {
4261 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4263 SpecificationRange.
setEnd(
T.getCloseLocation());
4270 while (Tok.
isNot(tok::r_paren)) {
4273 if (Tok.
is(tok::ellipsis)) {
4279 if (!Res.isInvalid())
4283 if (!Res.isInvalid()) {
4284 Exceptions.push_back(Res.get());
4285 Ranges.push_back(
Range);
4293 SpecificationRange.
setEnd(
T.getCloseLocation());
4295 Exceptions.empty());
4302 bool MayBeFollowedByDirectInit) {
4303 assert(Tok.
is(tok::arrow) &&
"expected arrow");
4313void Parser::ParseTrailingRequiresClause(
Declarator &
D) {
4314 assert(Tok.
is(tok::kw_requires) &&
"expected requires");
4332 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4334 DeclScopeObj.EnterDeclaratorScope();
4343 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4344 InitCXXThisScopeForDeclaratorIfRelevant(
D,
D.getDeclSpec(), ThisScope);
4346 TrailingRequiresClause =
4349 TrailingRequiresClause =
4352 if (!
D.isDeclarationOfFunction()) {
4354 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4359 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4362 D.setTrailingRequiresClause(TrailingRequiresClause.
get());
4365 if (
D.isFunctionDeclarator() && Tok.
is(tok::arrow) &&
4366 D.getDeclSpec().getTypeSpecType() ==
TST_auto) {
4370 ParseTrailingReturnType(
Range,
false);
4374 diag::err_requires_clause_must_appear_after_trailing_return)
4376 auto &FunctionChunk =
D.getFunctionTypeInfo();
4377 FunctionChunk.HasTrailingReturnType = TrailingReturnType.
isUsable();
4378 FunctionChunk.TrailingReturnType = TrailingReturnType.
get();
4381 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4390 bool NonNestedClass,
4392 assert((NonNestedClass || !ClassStack.empty()) &&
4393 "Nested class without outer class");
4394 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4400void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4401 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4402 delete Class->LateParsedDeclarations[I];
4413 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4417 ParsingClass *Victim = ClassStack.top();
4419 if (Victim->TopLevelClass) {
4422 DeallocateParsedClasses(Victim);
4425 assert(!ClassStack.empty() &&
"Missing top-level class?");
4427 if (Victim->LateParsedDeclarations.empty()) {
4432 DeallocateParsedClasses(Victim);
4440 "Nested class outside of class scope?");
4441 ClassStack.top()->LateParsedDeclarations.push_back(
4442 new LateParsedClass(
this, Victim));
4468 case tok::code_completion:
4475 case tok::numeric_constant: {
4483 StringRef Spelling = PP.
getSpelling(ExpansionLoc, ExpansionBuf);
4484 if (Spelling ==
"__clang__") {
4488 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4504 case tok::pipeequal:
4505 case tok::caretequal:
4507 case tok::exclaimequal:
4513 StringRef Spelling = PP.
getSpelling(SpellingLoc, SpellingBuf);
4522void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4527 if (
T.consumeOpen()) {
4528 Diag(Tok, diag::err_expected) << tok::l_paren;
4532 if (AttrName->
isStr(
"directive")) {
4538 OMPBeginTok.
setKind(tok::annot_attr_openmp);
4540 OpenMPTokens.push_back(OMPBeginTok);
4542 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4546 OMPEndTok.
setKind(tok::annot_pragma_openmp_end);
4548 OpenMPTokens.push_back(OMPEndTok);
4550 assert(AttrName->
isStr(
"sequence") &&
4551 "Expected either 'directive' or 'sequence'");
4560 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4564 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4565 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4569 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4576 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4590 case ParsedAttr::AT_CarriesDependency:
4591 case ParsedAttr::AT_Deprecated:
4592 case ParsedAttr::AT_FallThrough:
4593 case ParsedAttr::AT_CXX11NoReturn:
4594 case ParsedAttr::AT_NoUniqueAddress:
4595 case ParsedAttr::AT_Likely:
4596 case ParsedAttr::AT_Unlikely:
4598 case ParsedAttr::AT_WarnUnusedResult:
4599 return !ScopeName && AttrName->
getName() ==
"nodiscard";
4600 case ParsedAttr::AT_Unused:
4601 return !ScopeName && AttrName->
getName() ==
"maybe_unused";
4613 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4621 TentativeParsingAction TPA(*
this);
4624 if (Res.isInvalid()) {
4627 if (Tok.
is(tok::r_paren))
4632 if (!Tok.
isOneOf(tok::r_paren, tok::r_square)) {
4637 if (!Res.isInvalid()) {
4638 auto *
E = Res.get();
4677bool Parser::ParseCXX11AttributeArgs(
4681 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4685 LO.CPlusPlus ? ParsedAttr::Form::CXX11() :
ParsedAttr::Form::
C23();
4691 Form = ParsedAttr::Form::Microsoft();
4706 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4709 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4710 ScopeLoc, Form,
nullptr);
4715 if (ScopeName && ScopeName->
isStr(
"omp") &&
4716 (AttrName->
isStr(
"directive") || AttrName->
isStr(
"sequence"))) {
4718 ? diag::warn_omp51_compat_attributes
4719 : diag::ext_omp_attributes);
4721 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4730 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4731 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4732 ScopeName, ScopeLoc, Form);
4734 else if (!ScopeName && AttrName->
isStr(
"assume")) {
4735 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form))
4739 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4740 ScopeName, ScopeLoc, Form);
4742 if (!Attrs.
empty() &&
4748 Diag(LParenLoc, diag::warn_unknown_attribute_ignored) << AttrName;
4749 Attr.setInvalid(
true);
4757 if (
Attr.getMaxArgs() && !NumArgs) {
4760 Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
4761 Attr.setInvalid(
true);
4762 }
else if (!
Attr.getMaxArgs()) {
4766 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4769 Attr.setInvalid(
true);
4802 if (Tok.
is(tok::kw_alignas)) {
4809 ParseAlignmentSpecifier(Attrs, EndLoc);
4820 if (!Tok.
is(tok::l_paren))
4823 ParseAttributeArgsCommon(AttrName,
Loc, Attrs, EndLoc,
4827 Attrs.
addNew(AttrName,
Loc,
nullptr,
Loc,
nullptr, 0, Form);
4831 assert(Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square) &&
4832 "Not a double square bracket attribute list");
4837 : diag::warn_ext_cxx11_attributes);
4840 : diag::warn_ext_c23_attributes);
4844 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4849 if (Tok.
is(tok::kw_using)) {
4851 ? diag::warn_cxx14_compat_using_attribute_ns
4852 : diag::ext_using_attribute_ns);
4855 CommonScopeName = TryParseCXX11AttributeIdentifier(
4857 if (!CommonScopeName) {
4865 bool AttrParsed =
false;
4866 while (!Tok.
isOneOf(tok::r_square, tok::semi, tok::eof)) {
4870 if (ExpectAndConsume(tok::comma)) {
4884 AttrName = TryParseCXX11AttributeIdentifier(
4893 ScopeName = AttrName;
4896 AttrName = TryParseCXX11AttributeIdentifier(
4906 if (CommonScopeName) {
4908 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4911 ScopeName = CommonScopeName;
4912 ScopeLoc = CommonScopeLoc;
4917 if (Tok.
is(tok::l_paren))
4918 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
4919 ScopeName, ScopeLoc, OpenMPTokens);
4925 ScopeName, ScopeLoc,
nullptr, 0,
4927 : ParsedAttr::Form::C23());
4932 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) << AttrName;
4937 if (Tok.
is(tok::semi)) {
4943 if (ExpectAndConsume(tok::r_square))
4945 else if (Tok.
is(tok::r_square))
4946 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
4949 if (ExpectAndConsume(tok::r_square))
4962 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
4963 }
while (isAllowedCXX11AttributeSpecifier());
4968void Parser::DiagnoseAndSkipCXX11Attributes() {
4977 (Keyword ?
Diag(StartLoc, diag::err_keyword_not_allowed) << Keyword
4978 :
Diag(StartLoc, diag::err_attributes_not_allowed))
4986 if (!isCXX11AttributeSpecifier())
4990 if (Tok.
is(tok::l_square)) {
4994 EndLoc =
T.getCloseLocation();
5001 "not an attribute specifier");
5004 if (!
T.consumeOpen())
5006 EndLoc =
T.getCloseLocation();
5008 }
while (isCXX11AttributeSpecifier());
5015 assert(Tok.
is(tok::identifier) &&
"Not a Microsoft attribute list");
5017 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
5024 if (
T.consumeOpen()) {
5025 Diag(Tok, diag::err_expected) << tok::l_paren;
5030 if (isTokenStringLiteral()) {
5035 ArgExprs.push_back(StringResult.
get());
5052 while (Tok.
isNot(tok::r_paren)) {
5054 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5059 SpellingBuffer.resize(Tok.
getLength() + 1);
5061 StringRef TokSpelling = PP.
getSpelling(Tok, SpellingBuffer, &Invalid);
5066 StrBuffer += TokSpelling;
5072 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5082 Toks[0].
setKind(tok::string_literal);
5088 ArgExprs.push_back(UuidString);
5091 if (!
T.consumeClose()) {
5094 ParsedAttr::Form::Microsoft());
5107 assert(Tok.
is(tok::l_square) &&
"Not a Microsoft attribute list");
5118 SkipUntil(tok::r_square, tok::identifier,
5120 if (Tok.
is(tok::code_completion)) {
5128 if (Tok.
isNot(tok::identifier))
5131 ParseMicrosoftUuidAttributeArgs(Attrs);
5141 bool AttrParsed =
false;
5142 if (Tok.
is(tok::l_paren)) {
5145 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5147 ReplayOpenMPAttributeTokens(OpenMPTokens);
5151 ParsedAttr::Form::Microsoft());
5158 EndLoc =
T.getCloseLocation();
5159 }
while (Tok.
is(tok::l_square));
5164void Parser::ParseMicrosoftIfExistsClassDeclaration(
5167 IfExistsCondition
Result;
5168 if (ParseMicrosoftIfExistsCondition(
Result))
5172 if (
Braces.consumeOpen()) {
5173 Diag(Tok, diag::err_expected) << tok::l_brace;
5177 switch (
Result.Behavior) {
5183 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5193 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
5195 if (Tok.
isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5196 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, CurAS);
5201 if (Tok.
is(tok::semi)) {
5202 ConsumeExtraSemi(InsideStruct,
TagType);
5212 if (Tok.
is(tok::colon))
5216 Diag(Tok, diag::err_expected) << tok::colon;
5221 ParsedTemplateInfo TemplateInfo;
5223 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)
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.
SourceLocation getEndLoc() const LLVM_READONLY
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInvalidDecl() const
SourceLocation getLocation() const
SourceLocation getBeginLoc() const LLVM_READONLY
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const ParsedAttributes & getAttributes() const
SourceLocation getIdentifierLoc() const
void SetIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
void setTemplateParameterLists(ArrayRef< TemplateParameterList * > TPLs)
Sets the template parameter lists that preceded the declarator.
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
void setAsmLabel(Expr *E)
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
A little helper class used to produce diagnostics.
RAII object that enters a new expression evaluation context.
Represents a standard C++ module export declaration.
This represents one expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
One of these records is kept for each identifier that is lexed.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
StringRef getName() const
Return the actual identifier string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
This represents a decl that may have a name.
Wrapper for void* pointer.
static OpaquePtr make(PtrTy P)
A single parameter index whose accessors require each use to make explicit the parameter index encodi...
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing,...
ParsedAttr - Represents a syntactic attribute.
static const ParsedAttributesView & none()
void addAll(iterator B, iterator E)
ParsedAttributes - A collection of parsed attributes.
ParsedAttr * addNew(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
void takeAllFrom(ParsedAttributes &Other)
Parser - This implements a parser for the C family of languages.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
DeclGroupPtrTy ParseOpenACCDirectiveDecl()
Placeholder for now, should just ignore the directives after emitting a diagnostic.
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
ExprResult ParseConstantExpression()
ExprResult ParseConditionalExpression()
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
const TargetInfo & getTargetInfo() const
OpaquePtr< TemplateName > TemplateTy
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
friend class ObjCDeclContextSwitch
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtCodeCompletion
Stop at code completion.
@ StopAtSemi
Stop skipping at semicolon.
ExprResult ParseUnevaluatedStringLiteralExpression()
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
RAII object used to inform the actions that we're currently parsing a declaration.
A class for parsing a DeclSpec.
A class for parsing a declarator.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
SourceManager & getSourceManager() const
bool isBacktrackEnabled() const
True if EnableBacktrackAtThisPos() was called and caching of tokens is on.
void RevertCachedTokens(unsigned N)
When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens...
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
IdentifierTable & getIdentifierTable()
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
SourceLocation getLastCachedTokenLocation() const
Get the location of the last cached token, suitable for setting the end location of an annotation tok...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
Represents a struct/union/class.
Scope - A scope is a transient data structure that is used while parsing the program.
unsigned getFlags() const
getFlags - Return the flags for this scope.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ TypeAliasScope
This is a scope of type alias declaration.
@ ClassInheritanceScope
We are between inheritance colon and the real class/struct definition scope.
@ ClassScope
The scope of a struct/union/class definition.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
@ DeclScope
This is a scope that can contain a declaration.
void CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax, AttributeCompletion Completion=AttributeCompletion::Attribute, const IdentifierInfo *Scope=nullptr)
QualType ProduceCtorInitMemberSignatureHelp(Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy, ArrayRef< Expr * > ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc, bool Braced)
void CodeCompleteNamespaceAliasDecl(Scope *S)
void CodeCompleteUsing(Scope *S)
void CodeCompleteUsingDirective(Scope *S)
void CodeCompleteAfterFunctionEquals(Declarator &D)
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
void CodeCompleteNamespaceDecl(Scope *S)
void CodeCompleteTag(Scope *S, unsigned TagSpec)
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, CXXScopeSpec &SS, TemplateIdAnnotation &TemplateId, const ParsedAttributesView &Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, const ParsedAttributesView &AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
void PopParsingClass(ParsingClassState state)
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceRange TyLoc, const IdentifierInfo &II, ParsedType Ty, CXXScopeSpec *SS=nullptr)
void ActOnFinishCXXNonNestedClass()
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, const IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
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)
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.
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.