31 #include "llvm/ADT/SmallString.h"
32 #include "llvm/Support/TimeProfiler.h"
35 using namespace clang;
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);
262 void Parser::ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
266 if (index == InnerNSs.size()) {
267 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
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);
448 Decl *Parser::ParseExportDeclaration() {
449 assert(Tok.
is(tok::kw_export));
457 if (Tok.
isNot(tok::l_brace)) {
460 MaybeParseCXX11Attributes(DeclAttrs);
462 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
470 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
473 MaybeParseCXX11Attributes(DeclAttrs);
475 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
480 T.getCloseLocation());
488 assert(Tok.
is(tok::kw_using) &&
"Not using token");
494 if (Tok.
is(tok::code_completion)) {
501 while (Tok.
is(tok::kw_template)) {
503 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
508 if (Tok.
is(tok::kw_namespace)) {
510 if (TemplateInfo.Kind) {
512 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
516 Decl *UsingDir = ParseUsingDirective(Context, UsingLoc, DeclEnd, Attrs);
521 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, Attrs,
539 assert(Tok.
is(tok::kw_namespace) &&
"Not 'namespace' token");
544 if (Tok.
is(tok::code_completion)) {
552 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
564 if (Tok.
isNot(tok::identifier)) {
565 Diag(Tok, diag::err_expected_namespace_name);
584 bool GNUAttr =
false;
585 if (Tok.
is(tok::kw___attribute)) {
587 ParseGNUAttributes(attrs);
592 if (ExpectAndConsume(tok::semi,
593 GNUAttr ? diag::err_expected_semi_after_attribute_list
594 : diag::err_expected_semi_after_namespace_name))
598 IdentLoc, NamespcName, attrs);
607 UsingDeclarator &D) {
614 if (Tok.
is(tok::kw___super)) {
621 if (ParseOptionalCXXScopeSpecifier(D.SS,
nullptr,
631 if (D.SS.isInvalid())
645 Tok.
is(tok::identifier) &&
651 !D.SS.getScopeRep()->getAsNamespace() &&
652 !D.SS.getScopeRep()->getAsNamespaceAlias()) {
656 D.Name.setConstructorName(
Type, IdLoc, IdLoc);
663 !(Tok.
is(tok::identifier) &&
NextToken().is(tok::equal)),
664 false,
nullptr, D.Name))
670 ? diag::warn_cxx17_compat_using_declaration_pack
671 : diag::ext_using_declaration_pack);
710 ? diag::warn_cxx17_compat_using_enum_declaration
711 : diag::ext_using_enum_declaration);
713 DiagnoseCXX11AttributeExtension(PrefixAttrs);
715 if (TemplateInfo.Kind) {
717 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
723 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
735 if (Tok.
is(tok::code_completion)) {
741 if (!Tok.
is(tok::identifier)) {
743 << Tok.
is(tok::kw_enum);
750 getCurScope(), AS, UsingLoc, UELoc, IdentLoc, *IdentInfo, &SS);
757 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
758 "using-enum declaration"))
767 MaybeParseCXX11Attributes(MisplacedAttrs);
769 if (InInitStatement && Tok.
isNot(tok::identifier))
773 bool InvalidDeclarator = ParseUsingDeclarator(Context, D);
776 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
780 if (MisplacedAttrs.Range.isValid()) {
782 MisplacedAttrs.empty() ? nullptr : &MisplacedAttrs.front();
783 auto &
Range = MisplacedAttrs.Range;
784 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
794 if (Tok.
is(tok::equal) || InInitStatement) {
795 if (InvalidDeclarator) {
800 ProhibitAttributes(PrefixAttrs);
802 Decl *DeclFromDeclSpec =
nullptr;
805 CurScope->setFlags(Scope::ScopeFlags::TypeAliasScope |
808 Decl *AD = ParseAliasDeclarationAfterDeclarator(
809 TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
813 DiagnoseCXX11AttributeExtension(PrefixAttrs);
818 if (TemplateInfo.Kind) {
820 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
832 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
833 DiagnoseCXX11AttributeExtension(Attrs);
836 if (InvalidDeclarator)
841 if (D.TypenameLoc.isValid() &&
843 Diag(D.Name.getSourceRange().getBegin(),
844 diag::err_typename_identifiers_only)
851 D.TypenameLoc, D.SS, D.Name,
852 D.EllipsisLoc, Attrs);
854 DeclsInGroup.push_back(UD);
862 InvalidDeclarator = ParseUsingDeclarator(Context, D);
865 if (DeclsInGroup.size() > 1)
868 ? diag::warn_cxx17_compat_multi_using_declaration
869 : diag::ext_multi_using_declaration);
873 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
874 !Attrs.
empty() ?
"attributes list"
875 : UELoc.
isValid() ?
"using-enum declaration"
876 :
"using declaration"))
882 Decl *Parser::ParseAliasDeclarationAfterDeclarator(
886 if (ExpectAndConsume(tok::equal)) {
892 ? diag::warn_cxx98_compat_alias_declaration
893 : diag::ext_alias_declaration);
897 if (TemplateInfo.Kind == ParsedTemplateInfo::Template &&
900 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization)
902 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
904 if (SpecKind != -1) {
908 D.Name.TemplateId->RAngleLoc);
910 Range = TemplateInfo.getSourceRange();
912 << SpecKind <<
Range;
919 Diag(D.Name.StartLocation, diag::err_alias_declaration_not_identifier);
923 }
else if (D.TypenameLoc.isValid())
924 Diag(D.TypenameLoc, diag::err_alias_declaration_not_identifier)
926 SourceRange(D.TypenameLoc, D.SS.isNotEmpty() ? D.SS.getEndLoc()
928 else if (D.SS.isNotEmpty())
929 Diag(D.SS.getBeginLoc(), diag::err_alias_declaration_not_identifier)
931 if (D.EllipsisLoc.isValid())
932 Diag(D.EllipsisLoc, diag::err_alias_declaration_pack_expansion)
935 Decl *DeclFromDeclSpec =
nullptr;
940 AS, &DeclFromDeclSpec, &Attrs);
942 *OwnedType = DeclFromDeclSpec;
946 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
947 !Attrs.
empty() ?
"attributes list"
948 :
"alias declaration"))
953 TemplateParams ? TemplateParams->data() :
nullptr,
954 TemplateParams ? TemplateParams->size() : 0);
956 UsingLoc, D.Name, Attrs, TypeAlias,
962 if (
const auto *BO = dyn_cast_or_null<BinaryOperator>(AssertExpr)) {
963 if (BO->getOpcode() == BO_LAnd &&
964 isa<StringLiteral>(BO->getRHS()->IgnoreImpCasts()))
979 assert(Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
980 "Not a static_assert declaration");
983 const char *TokName = Tok.
getName();
985 if (Tok.
is(tok::kw__Static_assert))
986 diagnoseUseOfC11Keyword(Tok);
987 else if (Tok.
is(tok::kw_static_assert)) {
990 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
995 Diag(Tok, diag::warn_cxx98_compat_static_assert);
1001 if (
T.consumeOpen()) {
1002 Diag(Tok, diag::err_expected) << tok::l_paren;
1010 if (AssertExpr.isInvalid()) {
1016 if (Tok.
is(tok::r_paren)) {
1019 DiagVal = diag::warn_cxx14_compat_static_assert_no_message;
1021 DiagVal = diag::ext_cxx_static_assert_no_message;
1023 DiagVal = diag::warn_c17_compat_static_assert_no_message;
1025 DiagVal = diag::ext_c_static_assert_no_message;
1029 if (ExpectAndConsume(tok::comma)) {
1034 bool ParseAsExpression =
false;
1036 for (
unsigned I = 0;; ++I) {
1037 const Token &
T = GetLookAheadToken(I);
1038 if (
T.is(tok::r_paren))
1041 ParseAsExpression =
true;
1047 if (ParseAsExpression)
1052 Diag(Tok, diag::err_expected_string_literal)
1067 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
1070 AssertMessage.
get(),
1071 T.getCloseLocation());
1080 assert(Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype) &&
1081 "Not a decltype specifier");
1087 if (Tok.
is(tok::annot_decltype)) {
1088 Result = getExprAnnotation(Tok);
1093 ConsumeAnnotationToken();
1094 if (Result.isInvalid()) {
1100 Diag(Tok, diag::warn_cxx98_compat_decltype);
1105 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"decltype",
1108 return T.getOpenLocation() == Tok.
getLocation() ? StartLoc
1109 :
T.getOpenLocation();
1113 if (Tok.
is(tok::kw_auto) &&
NextToken().is(tok::r_paren)) {
1118 ? diag::warn_cxx11_compat_decltype_auto_type_specifier
1119 : diag::ext_decltype_auto_type_specifier);
1133 if (Result.isInvalid()) {
1136 EndLoc = ConsumeParen();
1143 assert(Tok.
is(tok::semi));
1157 if (
T.getCloseLocation().isInvalid()) {
1161 return T.getCloseLocation();
1164 if (Result.isInvalid()) {
1166 return T.getCloseLocation();
1169 EndLoc =
T.getCloseLocation();
1171 assert(!Result.isInvalid());
1173 const char *PrevSpec =
nullptr;
1178 PrevSpec, DiagID, Result.get(), Policy)
1180 PrevSpec, DiagID, Policy)) {
1181 Diag(StartLoc, DiagID) << PrevSpec;
1187 void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
1203 Tok.
setKind(tok::annot_decltype);
1204 setExprAnnotation(Tok,
1214 assert(Tok.
isOneOf(tok::annot_pack_indexing_type, tok::identifier) &&
1215 "Expected an identifier");
1220 const char *PrevSpec;
1224 if (Tok.
is(tok::annot_pack_indexing_type)) {
1232 ConsumeAnnotationToken();
1233 if (
Type.isInvalid()) {
1238 DiagID,
Type, Policy);
1242 !GetLookAheadToken(2).is(tok::l_square)) {
1274 return T.getCloseLocation();
1277 void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1293 Tok.
setKind(tok::annot_pack_indexing_type);
1294 setTypeAnnotation(Tok,
T);
1302 #define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1303 case tok::kw___##Trait: \
1304 return DeclSpec::TST_##Trait;
1305 #include "clang/Basic/TransformTypeTraits.def"
1307 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1311 bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1316 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1320 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.
getName(),
1325 if (Result.isInvalid()) {
1331 if (
T.getCloseLocation().isInvalid())
1334 const char *PrevSpec =
nullptr;
1339 Diag(StartLoc, DiagID) << PrevSpec;
1365 if (Tok.
is(tok::kw_typename)) {
1366 Diag(Tok, diag::err_expected_class_name_not_template)
1373 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1383 if (Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1390 EndLocation = ParseDecltypeSpecifier(DS);
1397 if (Tok.
is(tok::annot_pack_indexing_type)) {
1399 ParsePackIndexingType(DS);
1406 if (Tok.
is(tok::annot_template_id)) {
1412 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
1415 ConsumeAnnotationToken();
1422 if (Tok.
isNot(tok::identifier)) {
1423 Diag(Tok, diag::err_expected_class_name);
1430 if (Tok.
is(tok::less)) {
1439 Diag(IdLoc, diag::err_unknown_template_name) <<
Id;
1450 if (Tok.
is(tok::annot_template_id) &&
1451 takeTemplateIdAnnotation(Tok)->mightBeType())
1457 if (Tok.
isNot(tok::annot_typename))
1464 ConsumeAnnotationToken();
1477 Diag(IdLoc, diag::err_expected_class_name);
1482 EndLocation = IdLoc;
1490 const char *PrevSpec =
nullptr;
1500 void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1501 while (Tok.
isOneOf(tok::kw___single_inheritance,
1502 tok::kw___multiple_inheritance,
1503 tok::kw___virtual_inheritance)) {
1507 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
Kind);
1512 while (Tok.
is(tok::kw__Nullable)) {
1516 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
Kind);
1523 bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1534 case tok::identifier:
1536 case tok::coloncolon:
1537 case tok::annot_cxxscope:
1538 case tok::annot_typename:
1539 case tok::annot_template_id:
1540 case tok::kw_decltype:
1543 case tok::kw_operator:
1544 case tok::kw___declspec:
1549 case tok::kw___attribute:
1550 case tok::annot_pragma_pack:
1552 case tok::annot_pragma_ms_pragma:
1554 case tok::annot_pragma_ms_vtordisp:
1556 case tok::annot_pragma_ms_pointers_to_members:
1559 return CouldBeBitfield ||
1562 case tok::kw___cdecl:
1563 case tok::kw___fastcall:
1564 case tok::kw___stdcall:
1565 case tok::kw___thiscall:
1566 case tok::kw___vectorcall:
1572 case tok::kw_volatile:
1573 case tok::kw_restrict:
1574 case tok::kw__Atomic:
1575 case tok::kw___unaligned:
1579 case tok::kw_inline:
1580 case tok::kw_virtual:
1581 case tok::kw_friend:
1583 case tok::kw_static:
1584 case tok::kw_extern:
1585 case tok::kw_typedef:
1586 case tok::kw_register:
1588 case tok::kw_mutable:
1589 case tok::kw_thread_local:
1590 case tok::kw_constexpr:
1591 case tok::kw_consteval:
1592 case tok::kw_constinit:
1608 if (!isKnownToBeTypeSpecifier(
NextToken()))
1665 ParsedTemplateInfo &TemplateInfo,
1667 DeclSpecContext DSC,
1670 if (TagTokKind == tok::kw_struct)
1672 else if (TagTokKind == tok::kw___interface)
1674 else if (TagTokKind == tok::kw_class)
1677 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1681 if (Tok.
is(tok::code_completion)) {
1695 const bool shouldDelayDiagsInTag =
1696 (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate);
1702 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1704 if (Tok.
isOneOf(tok::kw___single_inheritance,
1705 tok::kw___multiple_inheritance,
1706 tok::kw___virtual_inheritance)) {
1707 ParseMicrosoftInheritanceClassAttributes(attrs);
1710 if (Tok.
is(tok::kw__Nullable)) {
1711 ParseNullabilityClassAttributes(attrs);
1725 #include
"clang/Basic/TransformTypeTraits.def"
1726 tok::kw___is_abstract,
1727 tok::kw___is_aggregate,
1728 tok::kw___is_arithmetic,
1730 tok::kw___is_assignable,
1731 tok::kw___is_base_of,
1732 tok::kw___is_bounded_array,
1734 tok::kw___is_complete_type,
1735 tok::kw___is_compound,
1737 tok::kw___is_constructible,
1738 tok::kw___is_convertible,
1739 tok::kw___is_convertible_to,
1740 tok::kw___is_destructible,
1743 tok::kw___is_floating_point,
1745 tok::kw___is_function,
1746 tok::kw___is_fundamental,
1747 tok::kw___is_integral,
1748 tok::kw___is_interface_class,
1749 tok::kw___is_literal,
1750 tok::kw___is_lvalue_expr,
1751 tok::kw___is_lvalue_reference,
1752 tok::kw___is_member_function_pointer,
1753 tok::kw___is_member_object_pointer,
1754 tok::kw___is_member_pointer,
1755 tok::kw___is_nothrow_assignable,
1756 tok::kw___is_nothrow_constructible,
1757 tok::kw___is_nothrow_convertible,
1758 tok::kw___is_nothrow_destructible,
1759 tok::kw___is_nullptr,
1760 tok::kw___is_object,
1762 tok::kw___is_pointer,
1763 tok::kw___is_polymorphic,
1764 tok::kw___is_reference,
1765 tok::kw___is_referenceable,
1766 tok::kw___is_rvalue_expr,
1767 tok::kw___is_rvalue_reference,
1769 tok::kw___is_scalar,
1770 tok::kw___is_scoped_enum,
1771 tok::kw___is_sealed,
1772 tok::kw___is_signed,
1773 tok::kw___is_standard_layout,
1774 tok::kw___is_trivial,
1775 tok::kw___is_trivially_equality_comparable,
1776 tok::kw___is_trivially_assignable,
1777 tok::kw___is_trivially_constructible,
1778 tok::kw___is_trivially_copyable,
1779 tok::kw___is_unbounded_array,
1781 tok::kw___is_unsigned,
1783 tok::kw___is_volatile
1790 TryKeywordIdentFallback(
true);
1792 struct PreserveAtomicIdentifierInfoRAII {
1793 PreserveAtomicIdentifierInfoRAII(
Token &Tok,
bool Enabled)
1794 : AtomicII(nullptr) {
1797 assert(Tok.
is(tok::kw__Atomic));
1802 ~PreserveAtomicIdentifierInfoRAII() {
1805 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1815 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1816 Tok.
is(tok::kw__Atomic) &&
1818 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1819 Tok, ShouldChangeAtomicToIdentifier);
1829 if (TemplateInfo.TemplateParams)
1832 bool HasValidSpec =
true;
1833 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1837 HasValidSpec =
false;
1840 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::annot_template_id)) {
1841 Diag(Tok, diag::err_expected) << tok::identifier;
1842 HasValidSpec =
false;
1850 auto RecoverFromUndeclaredTemplateName = [&](
IdentifierInfo *Name,
1853 bool KnownUndeclared) {
1854 Diag(NameLoc, diag::err_explicit_spec_non_template)
1855 << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
1856 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1860 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1861 if (TemplateParams->size() > 1) {
1862 TemplateParams->pop_back();
1864 TemplateParams =
nullptr;
1865 TemplateInfo.Kind = ParsedTemplateInfo::NonTemplate;
1867 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1869 TemplateParams =
nullptr;
1870 TemplateInfo.Kind = ParsedTemplateInfo::NonTemplate;
1880 if (Tok.
is(tok::identifier)) {
1889 TemplateArgList TemplateArgs;
1891 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1897 RecoverFromUndeclaredTemplateName(
1898 Name, NameLoc,
SourceRange(LAngleLoc, RAngleLoc),
false);
1900 }
else if (Tok.
is(tok::annot_template_id)) {
1901 TemplateId = takeTemplateIdAnnotation(Tok);
1902 NameLoc = ConsumeAnnotationToken();
1909 RecoverFromUndeclaredTemplateName(
1912 TemplateId =
nullptr;
1925 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1926 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1961 MaybeParseCXX11Attributes(Attributes);
1966 AllowDefiningTypeSpec::No ||
1969 else if (Tok.
is(tok::l_brace) ||
1970 (DSC != DeclSpecContext::DSC_association &&
1972 (isClassCompatibleKeyword() &&
1988 }
else if (isClassCompatibleKeyword() &&
1995 TentativeParsingAction PA(*
this);
1998 while (isClassCompatibleKeyword()) {
2004 if (Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square)) {
2008 }
else if (Tok.
is(tok::kw_alignas) &&
NextToken().is(tok::l_paren)) {
2018 if (!
T.consumeOpen())
2026 if (Tok.
isOneOf(tok::l_brace, tok::colon))
2032 }
else if (!isTypeSpecifier(DSC) &&
2033 (Tok.
is(tok::semi) ||
2036 if (Tok.
isNot(tok::semi)) {
2039 ExpectAndConsume(tok::semi, diag::err_expected_after,
2057 auto *FirstAttr = Attributes.
empty() ? nullptr : &Attributes.
front();
2059 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2060 ?
Diag(
Loc, diag::err_keyword_not_allowed) << FirstAttr
2061 :
Diag(
Loc, diag::err_attributes_not_allowed))
2073 if (!Name && !TemplateId &&
2078 Diag(StartLoc, diag::err_anon_type_definition)
2105 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2108 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2109 diag::err_keyword_not_allowed,
2113 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2124 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
2125 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2126 diag::err_keyword_not_allowed,
2136 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2149 "Expected a definition here");
2153 TemplateParams =
nullptr;
2158 diag::err_explicit_instantiation_with_definition)
2167 std::nullopt, LAngleLoc,
nullptr));
2168 TemplateParams = &FakedParamLists;
2175 SS, *TemplateId, attrs,
2178 TemplateParams ? TemplateParams->size() : 0),
2181 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
2188 ProhibitAttributes(attrs);
2191 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2192 TagType, StartLoc, SS, Name, NameLoc, attrs);
2194 TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
2195 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2196 diag::err_keyword_not_allowed,
2203 TemplateParams ? TemplateParams->size() : 0));
2206 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2207 diag::err_keyword_not_allowed,
2211 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2214 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2216 TemplateParams =
nullptr;
2219 bool IsDependent =
false;
2229 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2232 TagOrTempResult = Actions.
ActOnTag(
2236 DSC == DeclSpecContext::DSC_type_specifier,
2237 DSC == DeclSpecContext::DSC_template_param ||
2238 DSC == DeclSpecContext::DSC_template_type_arg,
2239 OffsetOfState, &SkipBody);
2246 Name, StartLoc, NameLoc);
2253 if (shouldDelayDiagsInTag) {
2254 diagsFromTag.done();
2256 TemplateInfo.Kind == ParsedTemplateInfo::Template)
2257 diagsFromTag.redelay();
2262 assert(Tok.
is(tok::l_brace) ||
2264 isClassCompatibleKeyword());
2266 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc,
TagType,
2267 TagOrTempResult.
get());
2269 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs,
TagType,
2270 TagOrTempResult.
get());
2275 ParseStructUnionBody(StartLoc,
TagType, cast<RecordDecl>(D));
2288 const char *PrevSpec =
nullptr;
2293 NameLoc.
isValid() ? NameLoc : StartLoc,
2295 }
else if (!TagOrTempResult.
isInvalid()) {
2297 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2298 DiagID, TagOrTempResult.
get(), Owned, Policy);
2305 Diag(StartLoc, DiagID) << PrevSpec;
2321 (TemplateInfo.Kind || !isValidAfterTypeSpecifier(
false))) {
2322 if (Tok.
isNot(tok::semi)) {
2324 ExpectAndConsume(tok::semi, diag::err_expected_after,
2342 void Parser::ParseBaseClause(
Decl *ClassDecl) {
2343 assert(Tok.
is(tok::colon) &&
"Not a base clause");
2351 BaseResult Result = ParseBaseSpecifier(ClassDecl);
2352 if (Result.isInvalid()) {
2358 BaseInfo.push_back(Result.get());
2383 bool IsVirtual =
false;
2387 MaybeParseCXX11Attributes(Attributes);
2393 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2403 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2407 if (Tok.
is(tok::kw_virtual)) {
2411 Diag(VirtualLoc, diag::err_dup_virtual)
2418 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2432 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2448 Access, BaseType.
get(), BaseLoc,
2463 case tok::kw_private:
2465 case tok::kw_protected:
2467 case tok::kw_public:
2476 void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2483 if (!NeedLateParse) {
2487 if (Param->hasUnparsedDefaultArg()) {
2488 NeedLateParse =
true;
2494 if (NeedLateParse) {
2497 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2498 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2503 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2505 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2542 if (II == Ident_override)
2545 if (II == Ident_sealed)
2548 if (II == Ident_abstract)
2551 if (II == Ident_final)
2554 if (II == Ident_GNU_final)
2565 void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2584 const char *PrevSpec =
nullptr;
2602 ? diag::warn_cxx98_compat_override_control_keyword
2603 : diag::ext_override_control_keyword)
2612 bool Parser::isCXX11FinalKeyword()
const {
2621 bool Parser::isClassCompatibleKeyword()
const {
2631 bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2633 LateParsedAttrList &LateParsedAttrs) {
2644 if (Tok.
isNot(tok::colon))
2645 ParseDeclarator(DeclaratorInfo);
2651 "don't know where identifier would go yet?");
2655 }
else if (Tok.
is(tok::kw_requires)) {
2656 ParseTrailingRequiresClause(DeclaratorInfo);
2658 ParseOptionalCXX11VirtSpecifierSeq(
2659 VS, getCurrentClass().IsInterface,
2662 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2667 if (Tok.
is(tok::kw_asm)) {
2670 if (AsmLabel.isInvalid())
2680 DiagnoseAndSkipCXX11Attributes();
2681 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2682 DiagnoseAndSkipCXX11Attributes();
2687 ParseOptionalCXX11VirtSpecifierSeq(
2688 VS, getCurrentClass().IsInterface,
2694 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2695 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2697 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2714 void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2720 ParseTypeQualifierListOpt(
2721 DS, AR_NoAttributesParsed,
false,
2722 false, llvm::function_ref<
void()>([&]() {
2723 Actions.
CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
2730 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2733 auto &MQ =
Function.getOrCreateMethodQualifiers();
2734 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2735 std::string Name(FixItName.data());
2738 MQ.SetTypeQual(TypeQual, SpecLoc);
2740 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2749 bool RefQualifierIsLValueRef =
true;
2751 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2752 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2755 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2756 Function.RefQualifierLoc = RefQualifierLoc;
2758 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2759 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2808 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2809 if (Tok.
is(tok::at)) {
2811 Diag(Tok, diag::err_at_defs_cxx);
2813 Diag(Tok, diag::err_at_in_class);
2829 bool MalformedTypeSpec =
false;
2830 if (!TemplateInfo.Kind &&
2831 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2833 MalformedTypeSpec =
true;
2836 if (Tok.
isNot(tok::annot_cxxscope))
2837 isAccessDecl =
false;
2838 else if (
NextToken().is(tok::identifier))
2839 isAccessDecl = GetLookAheadToken(2).
is(tok::semi);
2846 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2859 false,
false,
true,
true,
2860 false, &TemplateKWLoc, Name)) {
2866 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2867 "access declaration")) {
2883 if (!TemplateInfo.Kind &&
2884 Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2890 if (Tok.
is(tok::kw_template)) {
2891 assert(!TemplateInfo.TemplateParams &&
2892 "Nested template improperly parsed?");
2896 DeclEnd, AccessAttrs, AS);
2900 if (Tok.
is(tok::kw___extension__)) {
2904 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2910 MaybeParseCXX11Attributes(DeclAttrs);
2915 if (Tok.
is(tok::annot_attr_openmp))
2916 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
2918 if (Tok.
is(tok::kw_using)) {
2923 while (Tok.
is(tok::kw_template)) {
2925 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
2929 if (Tok.
is(tok::kw_namespace)) {
2930 Diag(UsingLoc, diag::err_using_namespace_in_class);
2937 UsingLoc, DeclEnd, DeclAttrs, AS);
2941 MaybeParseMicrosoftAttributes(DeclSpecAttrs);
2944 LateParsedAttrList CommonLateParsedAttrs;
2951 if (MalformedTypeSpec)
2959 bool IsTemplateSpecOrInst =
2960 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
2961 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
2964 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
2965 &CommonLateParsedAttrs);
2967 if (IsTemplateSpecOrInst)
2968 diagsFromTag.done();
2976 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate &&
2977 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
2978 &CommonLateParsedAttrs))
2982 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
2984 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
2988 ProhibitAttributes(DeclAttrs);
2992 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
2994 DS.complete(TheDecl);
2996 Decl *decls[] = {AnonRecord, TheDecl};
3007 if (TemplateInfo.TemplateParams)
3012 LateParsedAttrList LateParsedAttrs;
3017 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
3018 if (Tok.
isNot(tok::equal))
3023 if (
Zero.isNot(tok::numeric_constant) ||
3027 auto &
After = GetLookAheadToken(2);
3028 if (!
After.isOneOf(tok::semi, tok::comma) &&
3029 !(AllowDefinition &&
3030 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3041 bool ExpectSemi =
true;
3049 if (ParseCXXMemberDeclaratorBeforeInitializer(
3050 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3055 if (IsTemplateSpecOrInst)
3063 TryConsumePureSpecifier(
true);
3074 if (Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3076 }
else if (Tok.
is(tok::equal)) {
3078 if (KW.
is(tok::kw_default))
3080 else if (KW.
is(tok::kw_delete))
3082 else if (KW.
is(tok::code_completion)) {
3099 ProhibitAttributes(DeclAttrs);
3116 diag::err_function_declared_typedef);
3122 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3123 TemplateInfo, VS, PureSpecLoc);
3126 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3127 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3129 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3130 LateParsedAttrs[i]->addDecl(FunDecl);
3133 LateParsedAttrs.clear();
3136 if (Tok.
is(tok::semi))
3137 ConsumeExtraSemi(AfterMemberFunctionDefinition);
3149 bool HasStaticInitializer =
false;
3154 Diag(Tok, diag::err_anon_bitfield_member_init);
3158 if (!TryConsumePureSpecifier(
false))
3160 HasStaticInitializer =
true;
3167 if (BitfieldSize.
get())
3169 ? diag::warn_cxx17_compat_bitfield_member_init
3170 : diag::ext_bitfield_member_init);
3173 HasStaticInitializer =
true;
3189 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3190 auto Loc = AL.getRange().getBegin();
3191 (AL.isRegularKeywordAttribute()
3192 ?
Diag(
Loc, diag::err_keyword_not_allowed) << AL
3193 :
Diag(
Loc, diag::err_attributes_not_allowed))
3201 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3202 VS, HasInClassInit);
3205 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3208 ThisDecl = VT->getTemplatedDecl();
3217 DeclaratorInfo.getDeclSpec().getStorageClassSpec() ==
3220 HasStaticInitializer =
true;
3224 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3226 if (ThisDecl && PureSpecLoc.
isValid())
3235 ? diag::warn_cxx98_compat_nonstatic_member_init
3236 : diag::ext_nonstatic_member_init);
3238 if (DeclaratorInfo.isArrayOfUnknownBound()) {
3244 Diag(Tok, diag::err_incomplete_array_member_init);
3251 ParseCXXNonStaticMemberInitializer(ThisDecl);
3252 }
else if (HasStaticInitializer) {
3255 ThisDecl, DeclaratorInfo.isDeclarationOfFunction(), EqualLoc);
3257 if (
Init.isInvalid()) {
3261 }
else if (ThisDecl)
3271 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3272 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3274 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3275 LateParsedAttrs[i]->addDecl(ThisDecl);
3278 DeclsInGroup.push_back(ThisDecl);
3280 if (DeclaratorInfo.isFunctionDeclarator() &&
3281 DeclaratorInfo.getDeclSpec().getStorageClassSpec() !=
3283 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3285 LateParsedAttrs.clear();
3287 DeclaratorInfo.complete(ThisDecl);
3300 Diag(CommaLoc, diag::err_expected_semi_declaration)
3310 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
3311 DeclaratorInfo.isFirstDeclarator()) {
3312 Diag(CommaLoc, diag::err_multiple_template_declarators)
3313 << TemplateInfo.Kind;
3317 DeclaratorInfo.clear();
3321 DeclaratorInfo.setCommaLoc(CommaLoc);
3326 DiagnoseAndSkipCXX11Attributes();
3327 MaybeParseGNUAttributes(DeclaratorInfo);
3328 DiagnoseAndSkipCXX11Attributes();
3330 if (ParseCXXMemberDeclaratorBeforeInitializer(
3331 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3336 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
3367 ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
3369 assert(Tok.
isOneOf(tok::equal, tok::l_brace) &&
3370 "Data member initializer not starting with '=' or '{'");
3372 bool IsFieldInitialization = isa_and_present<FieldDecl>(D);
3376 IsFieldInitialization
3385 IsFieldInitialization;
3388 if (Tok.
is(tok::kw_delete)) {
3395 if (IsFunction || Next.isOneOf(tok::semi, tok::comma,
tok::eof)) {
3401 SkipDeletedFunctionBody();
3404 }
else if (Tok.
is(tok::kw_default)) {
3406 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3414 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
3415 Diag(Tok, diag::err_ms_property_initializer) << PD;
3418 return ParseInitializer();
3426 assert(isCXX11FinalKeyword() &&
"not a class definition");
3432 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3437 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_brace))
3444 if (Tok.
is(tok::colon)) {
3447 ParsingClassDefinition ParsingDef(*
this,
TagDecl,
true,
3453 ParseBaseClause(
nullptr);
3457 if (!Tok.
is(tok::l_brace)) {
3459 diag::err_expected_lbrace_after_base_specifiers);
3465 assert(Tok.
is(tok::l_brace));
3471 if (Tok.
is(tok::kw___attribute)) {
3473 MaybeParseGNUAttributes(Attrs);
3483 case tok::kw___if_exists:
3484 case tok::kw___if_not_exists:
3485 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, AS);
3490 ConsumeExtraSemi(InsideStruct,
TagType);
3494 case tok::annot_pragma_vis:
3495 HandlePragmaVisibility();
3497 case tok::annot_pragma_pack:
3500 case tok::annot_pragma_align:
3501 HandlePragmaAlign();
3503 case tok::annot_pragma_ms_pointers_to_members:
3504 HandlePragmaMSPointersToMembers();
3506 case tok::annot_pragma_ms_pragma:
3507 HandlePragmaMSPragma();
3509 case tok::annot_pragma_ms_vtordisp:
3510 HandlePragmaMSVtorDisp();
3512 case tok::annot_pragma_dump:
3516 case tok::kw_namespace:
3518 DiagnoseUnexpectedNamespace(cast<NamedDecl>(
TagDecl));
3521 case tok::kw_private:
3525 ParsedTemplateInfo TemplateInfo;
3526 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3529 case tok::kw_public:
3530 case tok::kw_protected: {
3540 AccessAttrs.
clear();
3541 MaybeParseGNUAttributes(AccessAttrs);
3546 Diag(EndLoc, diag::err_expected)
3550 Diag(EndLoc, diag::err_expected)
3562 AccessAttrs.
clear();
3568 case tok::annot_attr_openmp:
3569 case tok::annot_pragma_openmp:
3570 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3572 case tok::annot_pragma_openacc:
3580 ConsumeAnnotationToken();
3583 ParsedTemplateInfo TemplateInfo;
3584 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3601 "Invalid TagType!");
3603 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3604 if (
auto *TD = dyn_cast_or_null<NamedDecl>(
TagDecl))
3605 return TD->getQualifiedNameAsString();
3606 return std::string(
"<anonymous>");
3610 "parsing struct/union/class body");
3614 bool NonNestedClass =
true;
3615 if (!ClassStack.empty()) {
3617 if (S->isClassScope()) {
3619 NonNestedClass =
false;
3622 if (getCurrentClass().IsInterface) {
3626 ? cast<NamedDecl>(
TagDecl)->getQualifiedNameAsString()
3632 if (S->isFunctionScope())
3643 ParsingClassDefinition ParsingDef(*
this,
TagDecl, NonNestedClass,
3651 bool IsFinalSpelledSealed =
false;
3652 bool IsAbstract =
false;
3660 if (isCXX11FinalKeyword()) {
3663 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3668 IsFinalSpelledSealed =
true;
3673 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3681 Diag(FinalLoc, diag::err_override_control_interface)
3685 ? diag::warn_cxx98_compat_override_control_keyword
3686 : diag::ext_override_control_keyword)
3689 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3691 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3693 Diag(FinalLoc, diag::ext_warn_gnu_final);
3696 "not a class definition");
3702 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3711 if (!Tok.
is(tok::colon) && !Tok.
is(tok::l_brace)) {
3718 if (Tok.
is(tok::colon)) {
3723 if (!Tok.
is(tok::l_brace)) {
3724 bool SuggestFixIt =
false;
3728 case tok::kw_private:
3729 case tok::kw_protected:
3730 case tok::kw_public:
3733 case tok::kw_static_assert:
3737 case tok::kw_template:
3738 SuggestFixIt =
true;
3740 case tok::identifier:
3741 SuggestFixIt = isConstructorDeclarator(
true);
3744 SuggestFixIt = isCXXSimpleDeclaration(
false);
3749 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3763 assert(Tok.
is(tok::l_brace));
3769 IsFinalSpelledSealed, IsAbstract,
3770 T.getOpenLocation());
3785 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3788 ParseCXXClassMemberDeclarationWithPragmas(
3790 MaybeDestroyTemplateIds();
3799 MaybeParseGNUAttributes(attrs);
3803 T.getOpenLocation(),
3804 T.getCloseLocation(), attrs);
3811 if (
TagDecl && NonNestedClass) {
3818 ParseLexedPragmas(getCurrentClass());
3819 ParseLexedAttributes(getCurrentClass());
3820 ParseLexedMethodDeclarations(getCurrentClass());
3825 ParseLexedMemberInitializers(getCurrentClass());
3826 ParseLexedMethodDefs(getCurrentClass());
3827 PrevTokLocation = SavedPrevTokLocation;
3842 void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3843 assert(Tok.
is(tok::kw_namespace));
3848 Diag(Tok.
getLocation(), diag::note_missing_end_of_definition_before) << D;
3882 void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3883 assert(Tok.
is(tok::colon) &&
3884 "Constructor initializer always starts with ':'");
3892 bool AnyErrors =
false;
3895 if (Tok.
is(tok::code_completion)) {
3898 ConstructorDecl, MemInitializers);
3902 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3904 MemInitializers.push_back(MemInit.
get());
3908 if (Tok.
is(tok::comma))
3910 else if (Tok.
is(tok::l_brace))
3915 Tok.
isOneOf(tok::identifier, tok::coloncolon)) {
3917 Diag(
Loc, diag::err_ctor_init_missing_comma)
3923 << tok::l_brace << tok::comma;
3948 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
3961 if (Tok.
is(tok::identifier)) {
3966 }
else if (Tok.
is(tok::annot_decltype)) {
3971 ParseDecltypeSpecifier(DS);
3972 }
else if (Tok.
is(tok::annot_pack_indexing_type)) {
3975 ParsePackIndexingType(DS);
3978 ? takeTemplateIdAnnotation(Tok)
3983 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
3985 ConsumeAnnotationToken();
3987 Diag(Tok, diag::err_expected_member_or_base_name);
3994 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3997 ExprResult InitList = ParseBraceInitializer();
4007 TemplateTypeTy.
get(), DS, IdLoc,
4008 InitList.
get(), EllipsisLoc);
4009 }
else if (Tok.
is(tok::l_paren)) {
4014 ExprVector ArgExprs;
4015 auto RunSignatureHelp = [&] {
4020 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
4021 T.getOpenLocation(),
false);
4022 CalledSignatureHelp =
true;
4023 return PreferredType;
4025 if (Tok.
isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
4026 PreferredType.enterFunctionArgument(Tok.
getLocation(),
4043 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
4044 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
4051 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
4053 return Diag(Tok, diag::err_expected) << tok::l_paren;
4071 ExceptionSpecTokens =
nullptr;
4075 if (Tok.
isNot(tok::kw_throw) && Tok.
isNot(tok::kw_noexcept))
4079 bool IsNoexcept = Tok.
is(tok::kw_noexcept);
4080 Token StartTok = Tok;
4084 if (!Tok.
is(tok::l_paren)) {
4087 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4088 NoexceptExpr =
nullptr;
4092 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4098 ExceptionSpecTokens->push_back(StartTok);
4099 ExceptionSpecTokens->push_back(Tok);
4100 SpecificationRange.
setEnd(ConsumeParen());
4102 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4105 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4111 if (Tok.
is(tok::kw_throw)) {
4112 Result = ParseDynamicExceptionSpecification(
4113 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4114 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4115 "Produced different number of exception types and ranges.");
4119 if (Tok.
isNot(tok::kw_noexcept))
4122 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4130 if (Tok.
is(tok::l_paren)) {
4143 NoexceptRange =
SourceRange(KeywordLoc,
T.getCloseLocation());
4150 NoexceptRange =
SourceRange(KeywordLoc, KeywordLoc);
4154 SpecificationRange = NoexceptRange;
4155 Result = NoexceptType;
4159 if (Tok.
is(tok::kw_throw)) {
4160 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4161 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4162 DynamicExceptionRanges);
4165 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
4173 if (
P.getLangOpts().CPlusPlus11) {
4174 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4176 ? diag::ext_dynamic_exception_spec
4177 : diag::warn_exception_spec_deprecated)
4198 assert(Tok.
is(tok::kw_throw) &&
"expected throw");
4202 if (
T.consumeOpen()) {
4203 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4210 if (Tok.
is(tok::ellipsis)) {
4213 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4215 SpecificationRange.
setEnd(
T.getCloseLocation());
4222 while (Tok.
isNot(tok::r_paren)) {
4225 if (Tok.
is(tok::ellipsis)) {
4231 if (!Res.isInvalid())
4235 if (!Res.isInvalid()) {
4236 Exceptions.push_back(Res.get());
4237 Ranges.push_back(Range);
4245 SpecificationRange.
setEnd(
T.getCloseLocation());
4247 Exceptions.empty());
4254 bool MayBeFollowedByDirectInit) {
4255 assert(Tok.
is(tok::arrow) &&
"expected arrow");
4265 void Parser::ParseTrailingRequiresClause(
Declarator &D) {
4266 assert(Tok.
is(tok::kw_requires) &&
"expected requires");
4284 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4286 DeclScopeObj.EnterDeclaratorScope();
4295 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4296 InitCXXThisScopeForDeclaratorIfRelevant(D, D.
getDeclSpec(), ThisScope);
4298 TrailingRequiresClause =
4301 TrailingRequiresClause =
4306 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4311 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4322 ParseTrailingReturnType(Range,
false);
4326 diag::err_requires_clause_must_appear_after_trailing_return)
4330 FunctionChunk.TrailingReturnType = TrailingReturnType.
get();
4333 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4342 bool NonNestedClass,
4344 assert((NonNestedClass || !ClassStack.empty()) &&
4345 "Nested class without outer class");
4346 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4352 void Parser::DeallocateParsedClasses(Parser::ParsingClass *Class) {
4353 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4354 delete Class->LateParsedDeclarations[I];
4365 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4369 ParsingClass *Victim = ClassStack.top();
4371 if (Victim->TopLevelClass) {
4374 DeallocateParsedClasses(Victim);
4377 assert(!ClassStack.empty() &&
"Missing top-level class?");
4379 if (Victim->LateParsedDeclarations.empty()) {
4384 DeallocateParsedClasses(Victim);
4392 "Nested class outside of class scope?");
4393 ClassStack.top()->LateParsedDeclarations.push_back(
4394 new LateParsedClass(
this, Victim));
4420 case tok::code_completion:
4427 case tok::numeric_constant: {
4435 StringRef Spelling = PP.
getSpelling(ExpansionLoc, ExpansionBuf);
4436 if (Spelling ==
"__clang__") {
4440 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4456 case tok::pipeequal:
4457 case tok::caretequal:
4459 case tok::exclaimequal:
4465 StringRef Spelling = PP.
getSpelling(SpellingLoc, SpellingBuf);
4474 void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4479 if (
T.consumeOpen()) {
4480 Diag(Tok, diag::err_expected) << tok::l_paren;
4484 if (AttrName->
isStr(
"directive")) {
4490 OMPBeginTok.
setKind(tok::annot_attr_openmp);
4492 OpenMPTokens.push_back(OMPBeginTok);
4494 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4498 OMPEndTok.
setKind(tok::annot_pragma_openmp_end);
4500 OpenMPTokens.push_back(OMPEndTok);
4502 assert(AttrName->
isStr(
"sequence") &&
4503 "Expected either 'directive' or 'sequence'");
4512 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4516 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4517 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4521 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4528 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4542 case ParsedAttr::AT_CarriesDependency:
4543 case ParsedAttr::AT_Deprecated:
4544 case ParsedAttr::AT_FallThrough:
4545 case ParsedAttr::AT_CXX11NoReturn:
4546 case ParsedAttr::AT_NoUniqueAddress:
4547 case ParsedAttr::AT_Likely:
4548 case ParsedAttr::AT_Unlikely:
4550 case ParsedAttr::AT_WarnUnusedResult:
4551 return !ScopeName && AttrName->
getName() ==
"nodiscard";
4552 case ParsedAttr::AT_Unused:
4553 return !ScopeName && AttrName->
getName() ==
"maybe_unused";
4564 ParsedAttr::Form Form) {
4565 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4573 TentativeParsingAction TPA(*
this);
4576 if (Res.isInvalid()) {
4579 if (Tok.
is(tok::r_paren))
4584 if (!Tok.
isOneOf(tok::r_paren, tok::r_square)) {
4589 if (!Res.isInvalid()) {
4590 auto *E = Res.get();
4629 bool Parser::ParseCXX11AttributeArgs(
4633 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4636 ParsedAttr::Form Form =
4641 if (
hasAttribute(AttributeCommonInfo::Syntax::AS_Microsoft, ScopeName,
4649 !
hasAttribute(LO.CPlusPlus ? AttributeCommonInfo::Syntax::AS_CXX11
4650 : AttributeCommonInfo::Syntax::AS_C23,
4658 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4661 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4662 ScopeLoc, Form,
nullptr);
4667 if (ScopeName && ScopeName->
isStr(
"omp") &&
4668 (AttrName->
isStr(
"directive") || AttrName->
isStr(
"sequence"))) {
4670 ? diag::warn_omp51_compat_attributes
4671 : diag::ext_omp_attributes);
4673 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4682 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4683 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4684 ScopeName, ScopeLoc, Form);
4686 else if (!ScopeName && AttrName->
isStr(
"assume")) {
4687 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form))
4691 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4692 ScopeName, ScopeLoc, Form);
4694 if (!Attrs.
empty() &&
4700 Diag(LParenLoc, diag::warn_unknown_attribute_ignored) << AttrName;
4701 Attr.setInvalid(
true);
4709 if (
Attr.getMaxArgs() && !NumArgs) {
4712 Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
4713 Attr.setInvalid(
true);
4714 }
else if (!
Attr.getMaxArgs()) {
4718 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4721 Attr.setInvalid(
true);
4754 if (Tok.
is(tok::kw_alignas)) {
4761 ParseAlignmentSpecifier(Attrs, EndLoc);
4768 ParsedAttr::Form Form = ParsedAttr::Form(Tok.
getKind());
4772 if (!Tok.
is(tok::l_paren))
4775 ParseAttributeArgsCommon(AttrName,
Loc, Attrs, EndLoc,
4779 Attrs.
addNew(AttrName,
Loc,
nullptr,
Loc,
nullptr, 0, Form);
4783 assert(Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square) &&
4784 "Not a double square bracket attribute list");
4789 : diag::warn_ext_cxx11_attributes);
4792 : diag::warn_ext_c23_attributes);
4796 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4801 if (Tok.
is(tok::kw_using)) {
4803 ? diag::warn_cxx14_compat_using_attribute_ns
4804 : diag::ext_using_attribute_ns);
4807 CommonScopeName = TryParseCXX11AttributeIdentifier(
4809 if (!CommonScopeName) {
4817 bool AttrParsed =
false;
4822 if (ExpectAndConsume(tok::comma)) {
4836 AttrName = TryParseCXX11AttributeIdentifier(
4845 ScopeName = AttrName;
4848 AttrName = TryParseCXX11AttributeIdentifier(
4858 if (CommonScopeName) {
4860 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4863 ScopeName = CommonScopeName;
4864 ScopeLoc = CommonScopeLoc;
4869 if (Tok.
is(tok::l_paren))
4870 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
4871 ScopeName, ScopeLoc, OpenMPTokens);
4877 ScopeName, ScopeLoc,
nullptr, 0,
4884 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) << AttrName;
4889 if (Tok.
is(tok::semi)) {
4895 if (ExpectAndConsume(tok::r_square))
4897 else if (Tok.
is(tok::r_square))
4898 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
4901 if (ExpectAndConsume(tok::r_square))
4914 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
4915 }
while (isAllowedCXX11AttributeSpecifier());
4920 void Parser::DiagnoseAndSkipCXX11Attributes() {
4929 (Keyword ?
Diag(StartLoc, diag::err_keyword_not_allowed) << Keyword
4930 :
Diag(StartLoc, diag::err_attributes_not_allowed))
4938 if (!isCXX11AttributeSpecifier())
4942 if (Tok.
is(tok::l_square)) {
4946 EndLoc =
T.getCloseLocation();
4953 "not an attribute specifier");
4956 if (!
T.consumeOpen())
4958 EndLoc =
T.getCloseLocation();
4960 }
while (isCXX11AttributeSpecifier());
4967 assert(Tok.
is(tok::identifier) &&
"Not a Microsoft attribute list");
4969 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
4976 if (
T.consumeOpen()) {
4977 Diag(Tok, diag::err_expected) << tok::l_paren;
4982 if (isTokenStringLiteral()) {
4987 ArgExprs.push_back(StringResult.
get());
5004 while (Tok.
isNot(tok::r_paren)) {
5006 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5011 SpellingBuffer.resize(Tok.
getLength() + 1);
5013 StringRef TokSpelling = PP.
getSpelling(Tok, SpellingBuffer, &Invalid);
5018 StrBuffer += TokSpelling;
5024 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
5034 Toks[0].
setKind(tok::string_literal);
5040 ArgExprs.push_back(UuidString);
5043 if (!
T.consumeClose()) {
5059 assert(Tok.
is(tok::l_square) &&
"Not a Microsoft attribute list");
5070 SkipUntil(tok::r_square, tok::identifier,
5072 if (Tok.
is(tok::code_completion)) {
5080 if (Tok.
isNot(tok::identifier))
5083 ParseMicrosoftUuidAttributeArgs(Attrs);
5093 bool AttrParsed =
false;
5094 if (Tok.
is(tok::l_paren)) {
5097 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5099 ReplayOpenMPAttributeTokens(OpenMPTokens);
5110 EndLoc =
T.getCloseLocation();
5111 }
while (Tok.
is(tok::l_square));
5116 void Parser::ParseMicrosoftIfExistsClassDeclaration(
5119 IfExistsCondition Result;
5120 if (ParseMicrosoftIfExistsCondition(Result))
5124 if (
Braces.consumeOpen()) {
5125 Diag(Tok, diag::err_expected) << tok::l_brace;
5129 switch (Result.Behavior) {
5135 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5136 << Result.IsIfExists;
5145 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
5147 if (Tok.
isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5148 ParseMicrosoftIfExistsClassDeclaration(
TagType, AccessAttrs, CurAS);
5153 if (Tok.
is(tok::semi)) {
5154 ConsumeExtraSemi(InsideStruct,
TagType);
5164 if (Tok.
is(tok::colon))
5168 Diag(Tok, diag::err_expected) << tok::colon;
5173 ParsedTemplateInfo TemplateInfo;
5175 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)
#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait)
static FixItHint getStaticAssertNoMessageFixIt(const Expr *AssertExpr, SourceLocation EndExprLoc)
This file declares facilities that support code completion.
Defines the clang::TokenKind enum and support functions.
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
static const TST TST_decltype
static const TST TST_class
bool hasTagDefinition() const
CXXScopeSpec & getTypeSpecScope()
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
Expr * getRepAsExpr() const
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.
Decl * getRepAsDecl() const
FriendSpecified isFriendSpecified() const
void takeAttributesFrom(ParsedAttributes &attrs)
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInvalidDecl() const
SourceLocation getLocation() const
Information about one declarator, including the parsed type information and the identifier.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
SourceLocation getIdentifierLoc() const
void SetIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
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)
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
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.
const ParsedAttributes & getAttributes() const
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.
void takeAllFrom(ParsedAttributes &Other)
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.
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)
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
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.
Scope * getCurScope() const
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)
const LangOptions & getLangOpts() 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
const TargetInfo & getTargetInfo() const
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
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()
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.
SourceManager & getSourceManager() const
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
bool isBacktrackEnabled() const
True if EnableBacktrackAtThisPos() was called and caching of tokens is on.
IdentifierTable & getIdentifierTable()
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 ...
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.
@ 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.
void ActOnFinishCXXNonNestedClass()
void ProcessDeclAttributeDelayed(Decl *D, const ParsedAttributesView &AttrList)
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, const ParsedAttributesView &Attrs)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, const IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, const ParsedAttributesView &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
Decl * ActOnUsingEnumDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation EnumLoc, SourceLocation IdentLoc, IdentifierInfo &II, CXXScopeSpec *SS=nullptr)
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
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.
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 ProcessDeclAttributeList(Scope *S, Decl *D, const ParsedAttributesView &AttrList, const ProcessDeclAttributeOptions &Options=ProcessDeclAttributeOptions())
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
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)
ASTContext & getASTContext() const
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.
SemaCodeCompletion & CodeCompletion()
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.
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.
unsigned getLength() const
void setLength(unsigned Len)
void setKind(tok::TokenKind K)
const char * getName() const
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.
IdentifierInfo * getIdentifierInfo() const
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
void setLocation(SourceLocation L)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void startToken()
Reset all flags to cleared.
The base class of the type hierarchy.
Represents a C++ unqualified-id that has been parsed.
Represents C++ using-directive.
Declaration of a variable template.
Represents a C++11 virt-specifier-seq.
Specifier getLastSpecifier() const
SourceLocation getFirstLocation() const
SourceLocation getAbstractLoc() const
static const char * getSpecifierName(Specifier VS)
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
Defines the clang::TargetInfo interface.
@ After
Like System, but searched after the system directories.
static SymbolFlags getFlags(bool WeakDef, bool ThreadLocal=false)
bool Zero(InterpState &S, CodePtr OpPC)
bool Init(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].
ActionResult< Expr * > ExprResult
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
int hasAttribute(AttributeCommonInfo::Syntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
@ TNK_Non_template
The name does not refer to a template.
@ TNK_Undeclared_template
Lookup for the name failed, but we're assuming it was a template name anyway.
const FunctionProtoType * T
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
@ Braces
New-expression has a C++11 list-initializer.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_Unparsed
not parsed yet
@ EST_None
no exception specification
@ EST_MSAny
Microsoft throw(...) extension.
@ EST_BasicNoexcept
noexcept
@ EST_Dynamic
throw(T1, T2)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
unsigned HasTrailingReturnType
HasTrailingReturnType - If this is true, a trailing return type was specified.
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
Describes how types, statements, expressions, and declarations should be printed.
Information about a template-id annotation token.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
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.
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.