32#include "llvm/Support/TimeProfiler.h"
40 assert(Tok.is(tok::kw_namespace) &&
"Not a namespace!");
42 ObjCDeclContextSwitch ObjCDC(*
this);
44 if (Tok.is(tok::code_completion)) {
46 Actions.CodeCompletion().CodeCompleteNamespaceDecl(
getCurScope());
50 SourceLocation IdentLoc;
51 IdentifierInfo *Ident =
nullptr;
52 InnerNamespaceInfoList ExtraNSs;
53 SourceLocation FirstNestedInlineLoc;
55 ParsedAttributes attrs(AttrFactory);
57 while (MaybeParseGNUAttributes(attrs) || isAllowedCXX11AttributeSpecifier()) {
58 if (isAllowedCXX11AttributeSpecifier()) {
60 DiagCompat(Tok.getLocation(), diag_compat::ns_enum_attribute)
62 ParseCXX11Attributes(attrs);
66 if (Tok.is(tok::identifier)) {
67 Ident = Tok.getIdentifierInfo();
69 while (Tok.is(tok::coloncolon) &&
74 InnerNamespaceInfo Info;
77 if (Tok.is(tok::kw_inline)) {
80 FirstNestedInlineLoc = Info.InlineLoc;
83 Info.Ident = Tok.getIdentifierInfo();
86 ExtraNSs.push_back(Info);
90 DiagnoseAndSkipCXX11Attributes();
91 MaybeParseGNUAttributes(attrs);
92 DiagnoseAndSkipCXX11Attributes();
94 SourceLocation attrLoc = attrs.Range.getBegin();
97 if (!ExtraNSs.empty() && attrLoc.
isValid())
98 Diag(attrLoc, diag::err_unexpected_nested_namespace_attribute);
100 if (Tok.is(tok::equal)) {
102 Diag(Tok, diag::err_expected) << tok::identifier;
107 if (!ExtraNSs.empty()) {
108 Diag(ExtraNSs.front().NamespaceLoc,
109 diag::err_unexpected_qualified_namespace_alias)
110 << SourceRange(ExtraNSs.front().NamespaceLoc,
111 ExtraNSs.back().IdentLoc);
116 Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
118 Diag(InlineLoc, diag::err_inline_namespace_alias)
120 Decl *NSAlias = ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd);
121 return Actions.ConvertDeclToDeclGroup(NSAlias);
125 if (
T.consumeOpen()) {
127 Diag(Tok, diag::err_expected) << tok::l_brace;
129 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
136 Diag(
T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
141 if (ExtraNSs.empty()) {
143 }
else if (InlineLoc.
isValid()) {
144 Diag(InlineLoc, diag::err_inline_nested_namespace_definition);
146 Diag(ExtraNSs[0].NamespaceLoc,
147 diag::warn_cxx14_compat_nested_namespace_definition);
148 if (FirstNestedInlineLoc.
isValid())
149 Diag(FirstNestedInlineLoc,
150 diag::warn_cxx17_compat_inline_nested_namespace_definition);
152 Diag(ExtraNSs[0].NamespaceLoc,
153 diag::warn_cxx14_compat_nested_namespace_definition);
154 if (FirstNestedInlineLoc.
isValid())
155 Diag(FirstNestedInlineLoc, diag::ext_inline_nested_namespace_definition);
157 TentativeParsingAction TPA(*
this);
159 Token rBraceToken = Tok;
162 if (!rBraceToken.
is(tok::r_brace)) {
163 Diag(ExtraNSs[0].NamespaceLoc, diag::ext_nested_namespace_definition)
164 << SourceRange(ExtraNSs.front().NamespaceLoc,
165 ExtraNSs.back().IdentLoc);
167 std::string NamespaceFix;
168 for (
const auto &ExtraNS : ExtraNSs) {
169 NamespaceFix +=
" { ";
170 if (ExtraNS.InlineLoc.isValid())
171 NamespaceFix +=
"inline ";
172 NamespaceFix +=
"namespace ";
173 NamespaceFix += ExtraNS.Ident->getName();
177 for (
unsigned i = 0, e = ExtraNSs.size(); i != e; ++i)
180 Diag(ExtraNSs[0].NamespaceLoc, diag::ext_nested_namespace_definition)
182 SourceRange(ExtraNSs.front().NamespaceLoc,
183 ExtraNSs.back().IdentLoc),
189 if (FirstNestedInlineLoc.
isValid())
190 Diag(FirstNestedInlineLoc, diag::ext_inline_nested_namespace_definition);
195 DiagCompat(InlineLoc, diag_compat::inline_namespace);
200 UsingDirectiveDecl *ImplicitUsingDirectiveDecl =
nullptr;
201 Decl *NamespcDecl = Actions.ActOnStartNamespaceDef(
202 getCurScope(), InlineLoc, NamespaceLoc, IdentLoc, Ident,
203 T.getOpenLocation(), attrs, ImplicitUsingDirectiveDecl,
false);
205 PrettyDeclStackTraceEntry CrashInfo(Actions.Context, NamespcDecl,
206 NamespaceLoc,
"parsing namespace");
210 ParseInnerNamespace(ExtraNSs, 0, InlineLoc, attrs,
T);
213 NamespaceScope.Exit();
215 DeclEnd =
T.getCloseLocation();
216 Actions.ActOnFinishNamespaceDef(NamespcDecl, DeclEnd);
218 return Actions.ConvertDeclToDeclGroup(NamespcDecl,
219 ImplicitUsingDirectiveDecl);
222void Parser::ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
226 if (index == InnerNSs.size()) {
227 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
228 Tok.isNot(tok::eof)) {
229 ParsedAttributes DeclAttrs(AttrFactory);
230 ParsedAttributes DeclSpecAttrs(AttrFactory);
231 while (MaybeParseCXX11Attributes(DeclAttrs) ||
232 MaybeParseGNUAttributes(DeclSpecAttrs))
234 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
248 UsingDirectiveDecl *ImplicitUsingDirectiveDecl =
nullptr;
249 Decl *NamespcDecl = Actions.ActOnStartNamespaceDef(
250 getCurScope(), InnerNSs[index].InlineLoc, InnerNSs[index].NamespaceLoc,
251 InnerNSs[index].IdentLoc, InnerNSs[index].Ident,
253 assert(!ImplicitUsingDirectiveDecl &&
254 "nested namespace definition cannot define anonymous namespace");
256 ParseInnerNamespace(InnerNSs, ++index, InlineLoc, attrs, Tracker);
258 NamespaceScope.Exit();
266 assert(Tok.is(tok::equal) &&
"Not equal token");
270 if (Tok.is(tok::code_completion)) {
272 Actions.CodeCompletion().CodeCompleteNamespaceAliasDecl(
getCurScope());
278 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
286 if (Tok.isNot(tok::identifier)) {
287 Diag(Tok, diag::err_expected_namespace_name);
301 IdentifierInfo *Ident = Tok.getIdentifierInfo();
305 DeclEnd = Tok.getLocation();
306 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name))
309 return Actions.ActOnNamespaceAliasDef(
getCurScope(), NamespaceLoc, AliasLoc,
310 Alias, SS, IdentLoc, Ident);
314 assert(isTokenStringLiteral() &&
"Not a string literal!");
321 : Actions.ActOnStartLinkageSpecification(
323 Tok.is(tok::l_brace) ? Tok.getLocation() : SourceLocation());
325 ParsedAttributes DeclAttrs(AttrFactory);
326 ParsedAttributes DeclSpecAttrs(AttrFactory);
328 while (MaybeParseCXX11Attributes(DeclAttrs) ||
329 MaybeParseGNUAttributes(DeclSpecAttrs))
332 if (Tok.isNot(tok::l_brace)) {
339 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs, &DS);
340 return LinkageSpec ? Actions.ActOnFinishLinkageSpecification(
347 ProhibitAttributes(DeclAttrs);
352 unsigned NestedModules = 0;
354 switch (Tok.getKind()) {
355 case tok::annot_module_begin:
360 case tok::annot_module_end:
367 case tok::annot_module_include:
379 ParsedAttributes DeclAttrs(AttrFactory);
380 ParsedAttributes DeclSpecAttrs(AttrFactory);
381 while (MaybeParseCXX11Attributes(DeclAttrs) ||
382 MaybeParseGNUAttributes(DeclSpecAttrs))
384 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
392 return LinkageSpec ? Actions.ActOnFinishLinkageSpecification(
397Decl *Parser::ParseExportDeclaration() {
398 assert(Tok.is(tok::kw_export));
401 if (Tok.is(tok::code_completion)) {
403 Actions.CodeCompletion().CodeCompleteOrdinaryName(
411 Decl *ExportDecl = Actions.ActOnStartExportDecl(
413 Tok.is(tok::l_brace) ? Tok.getLocation() : SourceLocation());
415 if (Tok.isNot(tok::l_brace)) {
417 ParsedAttributes DeclAttrs(AttrFactory);
418 MaybeParseCXX11Attributes(DeclAttrs);
419 ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
420 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
421 return Actions.ActOnFinishExportDecl(
getCurScope(), ExportDecl,
428 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
429 Tok.isNot(tok::eof)) {
430 ParsedAttributes DeclAttrs(AttrFactory);
431 MaybeParseCXX11Attributes(DeclAttrs);
432 ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
433 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
437 return Actions.ActOnFinishExportDecl(
getCurScope(), ExportDecl,
438 T.getCloseLocation());
444 assert(Tok.is(tok::kw_using) &&
"Not using token");
445 ObjCDeclContextSwitch ObjCDC(*
this);
450 if (Tok.is(tok::code_completion)) {
452 Actions.CodeCompletion().CodeCompleteUsing(
getCurScope());
457 while (Tok.is(tok::kw_template)) {
459 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
464 if (Tok.is(tok::kw_namespace)) {
467 SourceRange
R = TemplateInfo.getSourceRange();
468 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
472 Decl *UsingDir = ParseUsingDirective(Context, UsingLoc, DeclEnd, Attrs);
473 return Actions.ConvertDeclToDeclGroup(UsingDir);
477 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, Attrs,
485 assert(Tok.is(tok::kw_namespace) &&
"Not 'namespace' token");
490 if (Tok.is(tok::code_completion)) {
492 Actions.CodeCompletion().CodeCompleteUsingDirective(
getCurScope());
498 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
506 IdentifierInfo *NamespcName =
nullptr;
507 SourceLocation IdentLoc = SourceLocation();
510 if (Tok.isNot(tok::identifier)) {
511 Diag(Tok, diag::err_expected_namespace_name);
526 NamespcName = Tok.getIdentifierInfo();
530 bool GNUAttr =
false;
531 if (Tok.is(tok::kw___attribute)) {
533 ParseGNUAttributes(attrs);
537 DeclEnd = Tok.getLocation();
538 if (ExpectAndConsume(tok::semi,
539 GNUAttr ? diag::err_expected_semi_after_attribute_list
540 : diag::err_expected_semi_after_namespace_name))
543 return Actions.ActOnUsingDirective(
getCurScope(), UsingLoc, NamespcLoc, SS,
544 IdentLoc, NamespcName, attrs);
548 UsingDeclarator &D) {
555 if (Tok.is(tok::kw___super)) {
556 Diag(Tok.getLocation(), diag::err_super_in_using_declaration);
561 const IdentifierInfo *LastII =
nullptr;
562 if (ParseOptionalCXXScopeSpecifier(D.SS,
nullptr,
572 if (D.SS.isInvalid())
586 Tok.is(tok::identifier) &&
591 D.SS.isNotEmpty() && LastII == Tok.getIdentifierInfo() &&
595 Actions.getInheritingConstructorName(D.SS, IdLoc, *LastII);
596 D.Name.setConstructorName(
Type, IdLoc, IdLoc);
603 !(Tok.is(tok::identifier) &&
NextToken().
is(tok::equal)),
604 false,
nullptr, D.Name))
609 DiagCompat(Tok.getLocation(), diag_compat::using_declaration_pack);
618 SourceLocation UELoc;
624 DiagCompat(UELoc, diag_compat::using_enum_declaration);
625 DiagnoseCXX11AttributeExtension(PrefixAttrs);
628 SourceRange
R = TemplateInfo.getSourceRange();
629 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
635 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
647 if (Tok.is(tok::code_completion)) {
649 Actions.CodeCompletion().CodeCompleteUsing(
getCurScope());
657 if (Tok.is(tok::identifier)) {
658 IdentifierInfo *IdentInfo = Tok.getIdentifierInfo();
667 UED = Actions.ActOnUsingEnumDeclaration(
669 }
else if (Tok.is(tok::annot_template_id)) {
670 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
676 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
678 SourceRange Loc = Tok.getAnnotationRange();
679 ConsumeAnnotationToken();
681 UED = Actions.ActOnUsingEnumDeclaration(
getCurScope(), AS, UsingLoc,
682 UELoc, Loc, *TemplateId->
Name,
685 Diag(Tok.getLocation(), diag::err_using_enum_not_enum)
690 Diag(Tok.getLocation(), diag::err_using_enum_expect_identifier)
691 << Tok.is(tok::kw_enum);
701 DeclEnd = Tok.getLocation();
702 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
703 "using-enum declaration"))
706 return Actions.ConvertDeclToDeclGroup(UED);
711 ParsedAttributes MisplacedAttrs(AttrFactory);
712 MaybeParseCXX11Attributes(MisplacedAttrs);
714 if (InInitStatement && Tok.isNot(tok::identifier))
718 bool InvalidDeclarator = ParseUsingDeclarator(Context, D);
720 ParsedAttributes Attrs(AttrFactory);
721 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
725 if (MisplacedAttrs.Range.isValid()) {
727 MisplacedAttrs.empty() ?
nullptr : &MisplacedAttrs.front();
728 auto &
Range = MisplacedAttrs.Range;
729 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
730 ?
Diag(
Range.getBegin(), diag::err_keyword_not_allowed) << FirstAttr
731 :
Diag(
Range.getBegin(), diag::err_attributes_not_allowed))
739 if (Tok.is(tok::equal) || InInitStatement) {
740 if (InvalidDeclarator) {
745 ProhibitAttributes(PrefixAttrs, Tok.getLocation());
747 Decl *DeclFromDeclSpec =
nullptr;
753 Decl *AD = ParseAliasDeclarationAfterDeclarator(
754 TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
759 return Actions.ConvertDeclToDeclGroup(AD, DeclFromDeclSpec);
762 DiagnoseCXX11AttributeExtension(PrefixAttrs);
768 SourceRange
R = TemplateInfo.getSourceRange();
769 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
778 SmallVector<Decl *, 8> DeclsInGroup;
781 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
782 DiagnoseCXX11AttributeExtension(Attrs);
785 if (InvalidDeclarator)
790 if (D.TypenameLoc.isValid() &&
792 Diag(D.Name.getSourceRange().getBegin(),
793 diag::err_typename_identifiers_only)
796 D.TypenameLoc = SourceLocation();
800 D.TypenameLoc, D.SS, D.Name,
801 D.EllipsisLoc, Attrs);
803 DeclsInGroup.push_back(UD);
811 InvalidDeclarator = ParseUsingDeclarator(Context, D);
814 if (DeclsInGroup.size() > 1)
815 DiagCompat(Tok.getLocation(), diag_compat::multi_using_declaration);
818 DeclEnd = Tok.getLocation();
819 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
820 !Attrs.
empty() ?
"attributes list"
821 : UELoc.
isValid() ?
"using-enum declaration"
822 :
"using declaration"))
825 return Actions.BuildDeclaratorGroup(DeclsInGroup);
828Decl *Parser::ParseAliasDeclarationAfterDeclarator(
832 if (ExpectAndConsume(tok::equal)) {
837 DiagCompat(Tok.getLocation(), diag_compat::alias_declaration);
848 if (SpecKind != -1) {
851 Range = SourceRange(D.Name.TemplateId->LAngleLoc,
852 D.Name.TemplateId->RAngleLoc);
854 Range = TemplateInfo.getSourceRange();
855 Diag(
Range.getBegin(), diag::err_alias_declaration_specialization)
856 << SpecKind <<
Range;
863 Diag(D.Name.StartLocation, diag::err_alias_declaration_not_identifier);
867 }
else if (D.TypenameLoc.isValid())
868 Diag(D.TypenameLoc, diag::err_alias_declaration_not_identifier)
870 SourceRange(D.TypenameLoc, D.SS.isNotEmpty() ? D.SS.getEndLoc()
872 else if (D.SS.isNotEmpty())
873 Diag(D.SS.getBeginLoc(), diag::err_alias_declaration_not_identifier)
875 if (D.EllipsisLoc.isValid())
876 Diag(D.EllipsisLoc, diag::err_alias_declaration_pack_expansion)
879 Decl *DeclFromDeclSpec =
nullptr;
884 AS, &DeclFromDeclSpec, &Attrs);
886 *OwnedType = DeclFromDeclSpec;
889 DeclEnd = Tok.getLocation();
890 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
891 !Attrs.
empty() ?
"attributes list"
892 :
"alias declaration"))
897 TemplateParams ? TemplateParams->data() :
nullptr,
898 TemplateParams ? TemplateParams->size() : 0);
899 return Actions.ActOnAliasDeclaration(
getCurScope(), AS, TemplateParamsArg,
906 if (
const auto *BO = dyn_cast_or_null<BinaryOperator>(AssertExpr)) {
907 if (BO->getOpcode() == BO_LAnd &&
915 assert(Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
916 "Not a static_assert declaration");
919 const char *TokName = Tok.getName();
921 if (Tok.is(tok::kw__Static_assert))
922 diagnoseUseOfC11Keyword(Tok);
923 else if (Tok.is(tok::kw_static_assert)) {
926 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.getName();
928 Diag(Tok, diag::warn_cxx98_compat_static_assert);
934 if (
T.consumeOpen()) {
935 Diag(Tok, diag::err_expected) << tok::l_paren;
940 EnterExpressionEvaluationContext ConstantEvaluated(
943 if (AssertExpr.isInvalid()) {
949 if (Tok.is(tok::r_paren)) {
951 ? diag_compat::cxx_static_assert_no_message
952 : diag_compat::c_static_assert_no_message;
956 if (ExpectAndConsume(tok::comma)) {
961 bool ParseAsExpression =
false;
963 for (
unsigned I = 0;; ++I) {
965 if (
T.is(tok::r_paren))
968 ParseAsExpression =
true;
974 if (ParseAsExpression) {
976 if (Tok.is(tok::r_paren)) {
977 DiagCompat(Tok, diag_compat::static_assert_user_generated_message);
985 Diag(Tok, diag::err_expected_string_literal)
999 DeclEnd = Tok.getLocation();
1000 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
1002 return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc, AssertExpr.get(),
1003 AssertMessage.
get(),
1004 T.getCloseLocation());
1008 assert(Tok.isOneOf(tok::kw_decltype, tok::annot_decltype) &&
1009 "Not a decltype specifier");
1012 SourceLocation StartLoc = Tok.getLocation();
1013 SourceLocation EndLoc;
1015 if (Tok.is(tok::annot_decltype)) {
1016 Result = getExprAnnotation(Tok);
1017 EndLoc = Tok.getAnnotationEndLoc();
1021 ConsumeAnnotationToken();
1022 if (
Result.isInvalid()) {
1027 if (Tok.getIdentifierInfo()->isStr(
"decltype"))
1028 Diag(Tok, diag::warn_cxx98_compat_decltype);
1033 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"decltype",
1036 return T.getOpenLocation() == Tok.getLocation() ? StartLoc
1037 :
T.getOpenLocation();
1041 if (Tok.is(tok::kw_auto) &&
NextToken().
is(tok::r_paren)) {
1044 DiagCompat(Tok.getLocation(), diag_compat::decltype_auto_type_specifier);
1055 if (
Result.isInvalid()) {
1058 EndLoc = ConsumeParen();
1060 if (PP.isBacktrackEnabled() && Tok.is(tok::semi)) {
1062 PP.RevertCachedTokens(2);
1066 EndLoc = Tok.getLocation();
1072 Result = Actions.ActOnDecltypeExpression(
Result.get());
1078 if (
T.getCloseLocation().isInvalid()) {
1082 return T.getCloseLocation();
1085 if (
Result.isInvalid()) {
1087 return T.getCloseLocation();
1090 EndLoc =
T.getCloseLocation();
1092 assert(!
Result.isInvalid());
1094 const char *PrevSpec =
nullptr;
1096 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1099 PrevSpec, DiagID,
Result.get(), Policy)
1101 PrevSpec, DiagID, Policy)) {
1102 Diag(StartLoc, DiagID) << PrevSpec;
1109void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
1113 if (PP.isBacktrackEnabled()) {
1114 PP.RevertCachedTokens(1);
1116 PP.EnterToken(Tok,
true);
1118 Tok.setKind(tok::annot_decltype);
1119 setExprAnnotation(Tok,
1123 Tok.setAnnotationEndLoc(EndLoc);
1124 Tok.setLocation(StartLoc);
1125 PP.AnnotateCachedTokens(Tok);
1129 assert(Tok.isOneOf(tok::annot_pack_indexing_type, tok::identifier) &&
1130 "Expected an identifier");
1133 SourceLocation StartLoc;
1134 SourceLocation EllipsisLoc;
1135 const char *PrevSpec;
1137 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1139 if (Tok.is(tok::annot_pack_indexing_type)) {
1140 StartLoc = Tok.getLocation();
1141 SourceLocation EndLoc;
1143 EndLoc = Tok.getAnnotationEndLoc();
1147 ConsumeAnnotationToken();
1148 if (
Type.isInvalid()) {
1153 DiagID,
Type, Policy);
1159 return Tok.getEndLoc();
1163 *Tok.getIdentifierInfo(), Tok.getLocation(),
getCurScope(),
1164 nullptr,
false,
false,
1169 return Tok.getEndLoc();
1184 ASTContext &
C = Actions.getASTContext();
1186 C.getSizeType(), SourceLocation());
1192 return T.getCloseLocation();
1197 assert(Tok.is(tok::identifier) &&
NextToken().
is(tok::ellipsis) &&
1203 Name.
setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
1204 CXXScopeSpec EmptySS;
1205 bool MemberOfUnknownSpecialization =
false;
1209 MemberOfUnknownSpecialization,
false);
1216bool Parser::AnnotatePackIndexingTemplateName(
CXXScopeSpec &SS,
1220 assert(Tok.is(tok::identifier) &&
"expected a simple-template-name");
1225 if (
T.consumeOpen())
1231 TemplateName Indexed = Actions.ActOnPackIndexingTemplateName(
1245 if (Tok.is(tok::less))
1246 return AnnotateTemplateIdToken(
Template, TNK, SS,
1247 SourceLocation(), Name,
1252 if (PP.isBacktrackEnabled())
1253 PP.RevertCachedTokens(1);
1255 PP.EnterToken(Tok,
true);
1266 : Actions.ActOnPackIndexingDeducedTemplateSpecializationType(
1268 Tok.setKind(tok::annot_typename);
1269 setTypeAnnotation(Tok,
Type);
1272 Tok.setKind(tok::annot_template_id);
1276 SourceLocation(), {},
1277 false, TemplateIds));
1279 Tok.setLocation(NameLoc);
1280 Tok.setAnnotationEndLoc(
T.getCloseLocation());
1281 PP.AnnotateCachedTokens(Tok);
1285void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1289 if (PP.isBacktrackEnabled()) {
1290 PP.RevertCachedTokens(1);
1296 EndLoc = PP.getLastCachedTokenLocation();
1299 PP.EnterToken(Tok,
true);
1301 Tok.setKind(tok::annot_pack_indexing_type);
1302 setTypeAnnotation(Tok,
T);
1303 Tok.setAnnotationEndLoc(EndLoc);
1304 Tok.setLocation(StartLoc);
1305 PP.AnnotateCachedTokens(Tok);
1309 switch (Tok.getKind()) {
1310#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1311 case tok::kw___##Trait: \
1312 return DeclSpec::TST_##Trait;
1313#include "clang/Basic/BuiltinTraits.inc"
1315 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1319bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1321 Tok.setKind(tok::identifier);
1324 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1328 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.getName(),
1333 if (
Result.isInvalid()) {
1339 if (
T.getCloseLocation().isInvalid())
1342 const char *PrevSpec =
nullptr;
1346 Actions.getASTContext().getPrintingPolicy()))
1347 Diag(StartLoc, DiagID) << PrevSpec;
1355 if (Tok.is(tok::kw_typename)) {
1356 Diag(Tok, diag::err_expected_class_name_not_template)
1363 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1368 BaseLoc = Tok.getLocation();
1373 if (Tok.isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1378 DeclSpec DS(AttrFactory);
1380 EndLocation = ParseDecltypeSpecifier(DS);
1384 return Actions.ActOnTypeName(DeclaratorInfo);
1387 if (Tok.is(tok::annot_pack_indexing_type)) {
1388 DeclSpec DS(AttrFactory);
1389 ParsePackIndexingType(DS);
1392 return Actions.ActOnTypeName(DeclaratorInfo);
1398 if (Tok.is(tok::annot_template_id)) {
1399 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1404 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
1406 EndLocation = Tok.getAnnotationEndLoc();
1407 ConsumeAnnotationToken();
1414 if (Tok.isNot(tok::identifier)) {
1415 Diag(Tok, diag::err_expected_class_name);
1419 IdentifierInfo *Id = Tok.getIdentifierInfo();
1422 if (Tok.is(tok::less)) {
1429 if (!Actions.DiagnoseUnknownTemplateName(*Id, IdLoc,
getCurScope(), &SS,
1431 Diag(IdLoc, diag::err_unknown_template_name) << Id;
1439 if (AnnotateTemplateIdToken(
Template, TNK, SS, SourceLocation(),
1442 if (Tok.is(tok::annot_template_id) &&
1443 takeTemplateIdAnnotation(Tok)->mightBeType())
1449 if (Tok.isNot(tok::annot_typename))
1454 EndLocation = Tok.getAnnotationEndLoc();
1456 ConsumeAnnotationToken();
1461 IdentifierInfo *CorrectedII =
nullptr;
1463 *Id, IdLoc,
getCurScope(), &SS,
true,
false,
nullptr,
1469 Diag(IdLoc, diag::err_expected_class_name);
1474 EndLocation = IdLoc;
1477 DeclSpec DS(AttrFactory);
1482 const char *PrevSpec =
nullptr;
1485 Actions.getASTContext().getPrintingPolicy());
1489 return Actions.ActOnTypeName(DeclaratorInfo);
1492void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1493 while (Tok.isOneOf(tok::kw___single_inheritance,
1494 tok::kw___multiple_inheritance,
1495 tok::kw___virtual_inheritance)) {
1496 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
1497 auto Kind = Tok.getKind();
1499 attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0, Kind);
1504 while (Tok.is(tok::kw__Nullable)) {
1505 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
1506 auto Kind = Tok.getKind();
1508 attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0, Kind);
1512bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1514 switch (Tok.getKind()) {
1516 if (Tok.isRegularKeywordAttribute())
1523 case tok::identifier:
1525 case tok::coloncolon:
1526 case tok::annot_cxxscope:
1527 case tok::annot_typename:
1528 case tok::annot_template_id:
1529 case tok::kw_decltype:
1532 case tok::kw_operator:
1533 case tok::kw___declspec:
1538 case tok::kw___attribute:
1539 case tok::annot_pragma_pack:
1541 case tok::annot_pragma_ms_pragma:
1543 case tok::annot_pragma_ms_vtordisp:
1545 case tok::annot_pragma_ms_pointers_to_members:
1547 case tok::annot_pragma_export:
1550 return CouldBeBitfield ||
1552 ParsingGenericAssociationType;
1554 case tok::kw___cdecl:
1555 case tok::kw___fastcall:
1556 case tok::kw___stdcall:
1557 case tok::kw___thiscall:
1558 case tok::kw___vectorcall:
1564 case tok::kw_volatile:
1565 case tok::kw_restrict:
1566 case tok::kw__Atomic:
1567 case tok::kw___unaligned:
1571 case tok::kw_inline:
1572 case tok::kw_virtual:
1573 case tok::kw_friend:
1575 case tok::kw_static:
1576 case tok::kw_extern:
1577 case tok::kw_typedef:
1578 case tok::kw_register:
1580 case tok::kw_mutable:
1581 case tok::kw_thread_local:
1582 case tok::kw_constexpr:
1583 case tok::kw_consteval:
1584 case tok::kw_constinit:
1600 if (!isKnownToBeTypeSpecifier(
NextToken()))
1617 ParsedTemplateInfo &TemplateInfo,
1619 DeclSpecContext DSC,
1622 if (TagTokKind == tok::kw_struct)
1624 else if (TagTokKind == tok::kw___interface)
1626 else if (TagTokKind == tok::kw_class)
1629 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1633 if (Tok.is(tok::code_completion)) {
1636 Actions.CodeCompletion().CodeCompleteTag(
getCurScope(), TagType);
1647 const bool shouldDelayDiagsInTag =
1649 SuppressAccessChecks diagsFromTag(*
this, shouldDelayDiagsInTag);
1651 ParsedAttributes attrs(AttrFactory);
1654 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1656 if (Tok.isOneOf(tok::kw___single_inheritance,
1657 tok::kw___multiple_inheritance,
1658 tok::kw___virtual_inheritance)) {
1659 ParseMicrosoftInheritanceClassAttributes(attrs);
1662 if (Tok.is(tok::kw__Nullable)) {
1663 ParseNullabilityClassAttributes(attrs);
1671 SourceLocation AttrFixitLoc = Tok.getLocation();
1674 !Tok.isAnnotation() && Tok.getIdentifierInfo() &&
1677#include
"clang/Basic/BuiltinTraits.inc"
1678 tok::kw___is_abstract,
1679 tok::kw___is_aggregate,
1680 tok::kw___is_arithmetic,
1682 tok::kw___is_assignable,
1683 tok::kw___is_base_of,
1684 tok::kw___is_bounded_array,
1686 tok::kw___is_complete_type,
1687 tok::kw___is_compound,
1689 tok::kw___is_constructible,
1690 tok::kw___is_convertible,
1691 tok::kw___is_convertible_to,
1692 tok::kw___is_destructible,
1695 tok::kw___is_floating_point,
1697 tok::kw___is_function,
1698 tok::kw___is_fundamental,
1699 tok::kw___is_integral,
1700 tok::kw___is_interface_class,
1701 tok::kw___is_literal,
1702 tok::kw___is_lvalue_expr,
1703 tok::kw___is_lvalue_reference,
1704 tok::kw___is_member_function_pointer,
1705 tok::kw___is_member_object_pointer,
1706 tok::kw___is_member_pointer,
1707 tok::kw___is_nothrow_assignable,
1708 tok::kw___is_nothrow_constructible,
1709 tok::kw___is_nothrow_convertible,
1710 tok::kw___is_nothrow_destructible,
1711 tok::kw___is_object,
1713 tok::kw___is_pointer,
1714 tok::kw___is_polymorphic,
1715 tok::kw___is_reference,
1716 tok::kw___is_rvalue_expr,
1717 tok::kw___is_rvalue_reference,
1719 tok::kw___is_scalar,
1720 tok::kw___is_scoped_enum,
1721 tok::kw___is_sealed,
1722 tok::kw___is_signed,
1723 tok::kw___is_standard_layout,
1724 tok::kw___is_trivial,
1725 tok::kw___is_trivially_equality_comparable,
1726 tok::kw___is_trivially_assignable,
1727 tok::kw___is_trivially_constructible,
1728 tok::kw___is_trivially_copyable,
1729 tok::kw___is_unbounded_array,
1731 tok::kw___is_unsigned,
1733 tok::kw___is_volatile
1740 TryKeywordIdentFallback(
true);
1742 struct PreserveAtomicIdentifierInfoRAII {
1743 PreserveAtomicIdentifierInfoRAII(Token &
Tok,
bool Enabled)
1747 assert(
Tok.
is(tok::kw__Atomic));
1752 ~PreserveAtomicIdentifierInfoRAII() {
1755 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1757 IdentifierInfo *AtomicII;
1765 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1766 Tok.is(tok::kw__Atomic) &&
1768 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1769 Tok, ShouldChangeAtomicToIdentifier);
1773 CXXScopeSpec InvalidDeclScope;
1783 if (TemplateInfo.TemplateParams)
1786 bool HasValidSpec =
true;
1787 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1791 HasValidSpec =
false;
1794 if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id)) {
1795 Diag(Tok, diag::err_expected) << tok::identifier;
1796 HasValidSpec =
false;
1804 auto RecoverFromUndeclaredTemplateName = [&](IdentifierInfo *Name,
1805 SourceLocation NameLoc,
1806 SourceRange TemplateArgRange,
1807 bool KnownUndeclared) {
1808 Diag(NameLoc, diag::err_explicit_spec_non_template)
1810 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1814 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1815 if (TemplateParams->size() > 1) {
1816 TemplateParams->pop_back();
1818 TemplateParams =
nullptr;
1823 TemplateParams =
nullptr;
1825 TemplateInfo.TemplateLoc = SourceLocation();
1826 TemplateInfo.ExternLoc = SourceLocation();
1831 IdentifierInfo *Name =
nullptr;
1832 SourceLocation NameLoc;
1833 TemplateIdAnnotation *TemplateId =
nullptr;
1834 if (Tok.is(tok::identifier)) {
1835 Name = Tok.getIdentifierInfo();
1843 TemplateArgList TemplateArgs;
1844 SourceLocation LAngleLoc, RAngleLoc;
1845 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1849 LAngleLoc = RAngleLoc = SourceLocation();
1851 RecoverFromUndeclaredTemplateName(
1852 Name, NameLoc, SourceRange(LAngleLoc, RAngleLoc),
false);
1854 }
else if (Tok.is(tok::annot_template_id)) {
1855 TemplateId = takeTemplateIdAnnotation(Tok);
1856 NameLoc = ConsumeAnnotationToken();
1860 Actions.ActOnUndeclaredTypeTemplateName(
1863 RecoverFromUndeclaredTemplateName(
1866 TemplateId =
nullptr;
1874 SourceRange
Range(NameLoc);
1879 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1880 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1915 MaybeParseCXX11Attributes(Attributes);
1917 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1924 Tok.isOneOf(tok::comma, tok::ellipsis))
1927 AllowDefiningTypeSpec::No ||
1930 else if (Tok.is(tok::l_brace) ||
1931 (DSC != DeclSpecContext::DSC_association &&
1933 (isClassCompatibleKeyword() &&
1935 isClassCompatibleKeyword(
NextToken())))) {
1939 Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
1950 }
else if (isClassCompatibleKeyword() &&
1957 TentativeParsingAction PA(*
this);
1960 while (isClassCompatibleKeyword())
1965 if (Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square)) {
1969 }
else if (Tok.is(tok::kw_alignas) &&
NextToken().
is(tok::l_paren)) {
1974 }
else if (Tok.isRegularKeywordAttribute()) {
1979 if (!
T.consumeOpen())
1987 if (Tok.isOneOf(tok::l_brace, tok::colon))
1993 }
else if (!isTypeSpecifier(DSC) &&
1994 (Tok.is(tok::semi) ||
1995 (Tok.isAtStartOfLine() && !isValidAfterTypeSpecifier(
false)))) {
1997 if (Tok.isNot(tok::semi)) {
1998 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
2000 ExpectAndConsume(tok::semi, diag::err_expected_after,
2002 PP.EnterToken(Tok,
true);
2003 Tok.setKind(tok::semi);
2016 SourceRange AttrRange = Attributes.
Range;
2020 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2021 ?
Diag(Loc, diag::err_keyword_not_allowed) << FirstAttr
2022 :
Diag(Loc, diag::err_attributes_not_allowed))
2025 AttrFixitLoc, CharSourceRange(AttrRange,
true))
2034 if (!Name && !TemplateId &&
2039 Diag(StartLoc, diag::err_anon_type_definition)
2058 SkipBodyInfo SkipBody;
2072 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2073 diag::err_keyword_not_allowed,
2076 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2077 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2078 TagType, StartLoc, SS, TemplateId->
Template,
2085 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2086 diag::err_keyword_not_allowed,
2109 "Expected a definition here");
2113 TemplateParams =
nullptr;
2115 SourceLocation LAngleLoc =
2116 PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
2118 diag::err_explicit_instantiation_with_definition)
2119 << SourceRange(TemplateInfo.TemplateLoc)
2125 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
2126 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, {},
2127 LAngleLoc,
nullptr));
2128 TemplateParams = &FakedParamLists;
2133 TagOrTempResult = Actions.ActOnClassTemplateSpecialization(
2135 SS, *TemplateId, attrs,
2138 TemplateParams ? TemplateParams->size() : 0),
2148 ProhibitAttributes(attrs);
2150 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2151 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2152 TagType, StartLoc, SS, Name, NameLoc, attrs);
2155 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2156 diag::err_keyword_not_allowed,
2160 SourceLocation EllipsisLoc;
2172 if (Tok.is(tok::comma)) {
2173 Diag(Tok.getLocation(),
2174 diag::err_friend_template_decl_multiple_specifiers);
2183 TagOrTempResult = Actions.ActOnTemplatedFriendTag(
2185 NameLoc, EllipsisLoc, attrs,
2187 TemplateParams ? TemplateParams->size() : 0),
2191 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2192 diag::err_keyword_not_allowed,
2199 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2201 TemplateParams =
nullptr;
2204 bool IsDependent =
false;
2214 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2217 TagOrTempResult = Actions.ActOnTag(
2218 getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, AS,
2221 DSC == DeclSpecContext::DSC_type_specifier,
2222 DSC == DeclSpecContext::DSC_template_param ||
2223 DSC == DeclSpecContext::DSC_template_type_arg,
2224 OffsetOfState, &SkipBody);
2231 Name, StartLoc, NameLoc);
2238 if (shouldDelayDiagsInTag) {
2239 diagsFromTag.done();
2242 diagsFromTag.redelay();
2247 assert(Tok.is(tok::l_brace) ||
2249 isClassCompatibleKeyword());
2251 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc, TagType,
2252 TagOrTempResult.
get());
2254 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs, TagType,
2255 TagOrTempResult.
get());
2263 TagOrTempResult.
get(), SkipBody)) {
2272 Actions.ProcessDeclAttributeDelayed(TagOrTempResult.
get(), attrs);
2274 const char *PrevSpec =
nullptr;
2279 NameLoc.
isValid() ? NameLoc : StartLoc,
2281 }
else if (!TagOrTempResult.
isInvalid()) {
2283 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2284 DiagID, TagOrTempResult.
get(), Owned, Policy);
2291 Diag(StartLoc, DiagID) << PrevSpec;
2308 if (Tok.isNot(tok::semi)) {
2309 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
2310 ExpectAndConsume(tok::semi, diag::err_expected_after,
2315 PP.EnterToken(Tok,
true);
2316 Tok.setKind(tok::semi);
2321void Parser::ParseBaseClause(
Decl *ClassDecl) {
2322 assert(Tok.is(tok::colon) &&
"Not a base clause");
2326 SmallVector<CXXBaseSpecifier *, 8> BaseInfo;
2331 if (!
Result.isUsable()) {
2337 BaseInfo.push_back(
Result.get());
2347 Actions.ActOnBaseSpecifiers(ClassDecl, BaseInfo);
2351 bool IsVirtual =
false;
2352 SourceLocation StartLoc = Tok.getLocation();
2354 ParsedAttributes Attributes(AttrFactory);
2355 MaybeParseCXX11Attributes(Attributes);
2361 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2368 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
2371 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2375 if (Tok.is(tok::kw_virtual)) {
2379 Diag(VirtualLoc, diag::err_dup_virtual)
2387 Diag(Tok.getLocation(), diag::err_hlsl_virtual_inheritance);
2389 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2397 if (
getLangOpts().MSVCCompat && Tok.is(tok::kw__Atomic) &&
2399 Tok.setKind(tok::identifier);
2401 SourceLocation EndLocation;
2402 SourceLocation BaseLoc;
2403 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2410 SourceLocation EllipsisLoc;
2414 SourceRange
Range(StartLoc, EndLocation);
2418 return Actions.ActOnBaseSpecifier(ClassDecl, Range, Attributes, IsVirtual,
2419 Access, BaseType.
get(), BaseLoc,
2424 switch (Tok.getKind()) {
2427 case tok::kw_private:
2429 case tok::kw_protected:
2431 case tok::kw_public:
2436void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2443 if (!NeedLateParse) {
2445 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx) {
2447 if (Param->hasUnparsedDefaultArg()) {
2448 NeedLateParse =
true;
2454 if (NeedLateParse) {
2457 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2458 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2463 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2464 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx)
2465 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2481 const IdentifierInfo *II = Tok.getIdentifierInfo();
2485 Ident_final = &PP.getIdentifierTable().get(
"final");
2487 Ident_GNU_final = &PP.getIdentifierTable().get(
"__final");
2489 Ident_sealed = &PP.getIdentifierTable().get(
"sealed");
2490 Ident_abstract = &PP.getIdentifierTable().get(
"abstract");
2492 Ident_override = &PP.getIdentifierTable().get(
"override");
2495 if (II == Ident_override)
2498 if (II == Ident_sealed)
2501 if (II == Ident_abstract)
2504 if (II == Ident_final)
2507 if (II == Ident_GNU_final)
2513void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2522 Diag(Tok.getLocation(), diag::err_friend_decl_spec)
2525 << SourceRange(FriendLoc, FriendLoc);
2532 const char *PrevSpec =
nullptr;
2533 if (VS.
SetSpecifier(Specifier, Tok.getLocation(), PrevSpec))
2534 Diag(Tok.getLocation(), diag::err_duplicate_virt_specifier)
2539 Diag(Tok.getLocation(), diag::err_override_control_interface)
2542 Diag(Tok.getLocation(), diag::ext_ms_sealed_keyword);
2544 Diag(Tok.getLocation(), diag::ext_ms_abstract_keyword);
2546 Diag(Tok.getLocation(), diag::ext_warn_gnu_final);
2548 DiagCompat(Tok.getLocation(), diag_compat::override_control_keyword)
2555bool Parser::isCXX11FinalKeyword()
const {
2562bool Parser::isClassCompatibleKeyword(
Token Tok)
const {
2570bool Parser::isClassCompatibleKeyword()
const {
2571 return isClassCompatibleKeyword(Tok);
2576bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2589 if (Tok.isNot(tok::colon))
2590 ParseDeclarator(DeclaratorInfo);
2595 if (!IsFunctionDeclarator && !
getLangOpts().MSVCCompat)
2596 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2599 MaybeParseHLSLAnnotations(DeclaratorInfo,
nullptr,
2604 "don't know where identifier would go yet?");
2608 }
else if (Tok.is(tok::kw_requires)) {
2609 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
2614 ++CurTemplateDepthTracker;
2615 ParseTrailingRequiresClauseWithScope(DeclaratorInfo);
2617 ParseOptionalCXX11VirtSpecifierSeq(
2618 VS, getCurrentClass().IsInterface,
2621 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2626 if (Tok.is(tok::kw_asm)) {
2628 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2629 if (AsmLabel.isInvalid())
2639 DiagnoseAndSkipCXX11Attributes();
2640 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2641 DiagnoseAndSkipCXX11Attributes();
2646 ParseOptionalCXX11VirtSpecifierSeq(
2647 VS, getCurrentClass().IsInterface,
2653 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2654 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2656 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2671void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2673 DeclSpec DS(AttrFactory);
2677 ParseTypeQualifierListOpt(
2678 DS, AR_NoAttributesParsed,
false,
2680 Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
2687 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2688 SourceLocation SpecLoc) {
2689 FixItHint Insertion;
2690 auto &MQ =
Function.getOrCreateMethodQualifiers();
2691 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2692 std::string Name(FixItName.data());
2695 MQ.SetTypeQual(TypeQual, SpecLoc);
2697 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2706 bool RefQualifierIsLValueRef =
true;
2707 SourceLocation RefQualifierLoc;
2708 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2709 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2710 FixItHint Insertion =
2712 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2713 Function.RefQualifierLoc = RefQualifierLoc;
2715 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2716 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2728 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2729 if (Tok.is(tok::at)) {
2731 Diag(Tok, diag::err_at_defs_cxx);
2733 Diag(Tok, diag::err_at_in_class);
2749 bool MalformedTypeSpec =
false;
2751 Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2753 MalformedTypeSpec =
true;
2756 if (Tok.isNot(tok::annot_cxxscope))
2757 isAccessDecl =
false;
2766 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2776 SourceLocation TemplateKWLoc;
2779 false,
false,
true,
true,
2780 false, &TemplateKWLoc, Name)) {
2786 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2787 "access declaration")) {
2795 SourceLocation(), SS, Name,
2797 ParsedAttributesView())));
2804 Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2805 SourceLocation DeclEnd;
2807 DeclGroupRef(ParseStaticAssertDeclaration(DeclEnd)));
2810 if (Tok.is(tok::kw_template)) {
2811 assert(!TemplateInfo.TemplateParams &&
2812 "Nested template improperly parsed?");
2813 ObjCDeclContextSwitch ObjCDC(*
this);
2814 SourceLocation DeclEnd;
2816 DeclEnd, AccessAttrs, AS);
2820 if (Tok.is(tok::kw___extension__)) {
2822 ExtensionRAIIObject O(Diags);
2824 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2828 ParsedAttributes DeclAttrs(AttrFactory);
2830 MaybeParseCXX11Attributes(DeclAttrs);
2835 if (Tok.is(tok::annot_attr_openmp))
2836 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
2838 if (Tok.is(tok::kw_using)) {
2843 while (Tok.is(tok::kw_template)) {
2845 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
2849 if (Tok.is(tok::kw_namespace)) {
2850 Diag(UsingLoc, diag::err_using_namespace_in_class);
2854 SourceLocation DeclEnd;
2857 UsingLoc, DeclEnd, DeclAttrs, AS);
2860 ParsedAttributes DeclSpecAttrs(AttrFactory);
2862 LateParsedAttrList CommonLateParsedAttrs;
2864 while (MaybeParseCXX11Attributes(DeclAttrs) ||
2865 MaybeParseGNUAttributes(DeclSpecAttrs, &CommonLateParsedAttrs) ||
2866 MaybeParseMicrosoftAttributes(DeclSpecAttrs))
2869 SourceLocation DeclStart;
2870 if (DeclAttrs.Range.isValid()) {
2871 DeclStart = DeclSpecAttrs.Range.
isInvalid()
2872 ? DeclAttrs.Range.getBegin()
2873 : std::min(DeclAttrs.Range.getBegin(),
2874 DeclSpecAttrs.Range.getBegin());
2876 DeclStart = DeclSpecAttrs.Range.getBegin();
2881 ParsingDeclSpec DS(*
this, TemplateDiags);
2884 if (MalformedTypeSpec)
2892 bool IsTemplateSpecOrInst =
2895 SuppressAccessChecks diagsFromTag(*
this, IsTemplateSpecOrInst);
2897 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
2898 &CommonLateParsedAttrs);
2900 if (IsTemplateSpecOrInst)
2901 diagsFromTag.done();
2913 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
2914 &CommonLateParsedAttrs))
2918 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
2920 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
2924 ProhibitAttributes(DeclAttrs);
2926 RecordDecl *AnonRecord =
nullptr;
2927 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(
2928 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
2929 Actions.ActOnDefinedDeclarationSpecifier(TheDecl);
2930 DS.complete(TheDecl);
2932 Decl *decls[] = {AnonRecord, TheDecl};
2933 return Actions.BuildDeclaratorGroup(decls);
2935 return Actions.ConvertDeclToDeclGroup(TheDecl);
2939 Actions.ActOnDefinedDeclarationSpecifier(DS.
getRepAsDecl());
2944 DiagCompat(Tok.getLocation(), diag_compat::variadic_friends);
2947 SmallVector<Decl *> Decls;
2950 auto ParsedFriendDecl = [&](ParsingDeclSpec &DeclSpec) {
2951 SourceLocation VariadicLoc;
2954 RecordDecl *AnonRecord =
nullptr;
2955 Decl *D = Actions.ParsedFreeStandingDeclSpec(
2956 getCurScope(), AS, DeclSpec, DeclAttrs, TemplateParams,
false,
2957 AnonRecord, VariadicLoc);
2958 DeclSpec.complete(D);
2968 if (ParsedFriendDecl(DS))
2972 ParsingDeclSpec DeclSpec(*
this, TemplateDiags);
2973 const char *PrevSpec =
nullptr;
2974 unsigned DiagId = 0;
2975 DeclSpec.SetFriendSpec(FriendLoc, PrevSpec, DiagId);
2976 ParseDeclarationSpecifiers(DeclSpec, TemplateInfo, AS,
2977 DeclSpecContext::DSC_class,
nullptr);
2978 if (ParsedFriendDecl(DeclSpec))
2982 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_stmt,
2983 "friend declaration");
2985 return Actions.BuildDeclaratorGroup(Decls);
2991 if (Tok.is(tok::kw_concept)) {
2995 ? llvm::to_underlying(diag::err_friend_concept)
2996 : llvm::to_underlying(
2998 err_concept_decls_may_only_appear_in_global_namespace_scope));
3003 ParsingDeclarator DeclaratorInfo(*
this, DS, DeclAttrs,
3005 if (TemplateInfo.TemplateParams)
3010 LateParsedAttrList LateParsedAttrs;
3012 SourceLocation EqualLoc;
3013 SourceLocation PureSpecLoc;
3015 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
3016 if (Tok.isNot(tok::equal))
3020 SmallString<8> Buffer;
3021 if (
Zero.isNot(tok::numeric_constant) ||
3022 PP.getSpelling(
Zero, Buffer) !=
"0")
3026 if (!
After.isOneOf(tok::semi, tok::comma) &&
3027 !(AllowDefinition &&
3028 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3036 SmallVector<Decl *, 8> DeclsInGroup;
3039 bool ExpectSemi =
true;
3044 SuppressAccessChecks SAC(*
this, IsTemplateSpecOrInst);
3047 if (ParseCXXMemberDeclaratorBeforeInitializer(
3048 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3053 if (IsTemplateSpecOrInst)
3061 TryConsumePureSpecifier(
true);
3072 if (Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3074 }
else if (Tok.is(tok::equal)) {
3076 if (KW.
is(tok::kw_default))
3078 else if (KW.
is(tok::kw_delete))
3080 else if (KW.
is(tok::code_completion)) {
3082 Actions.CodeCompletion().CodeCompleteAfterFunctionEquals(
3097 ProhibitAttributes(DeclAttrs);
3114 diag::err_function_declared_typedef);
3120 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3121 TemplateInfo, VS, PureSpecLoc);
3124 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3125 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3127 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3128 LateParsedAttrs[i]->addDecl(FunDecl);
3131 LateParsedAttrs.clear();
3134 if (Tok.is(tok::semi))
3147 bool HasStaticInitializer =
false;
3148 if (Tok.isOneOf(tok::equal, tok::l_brace) && PureSpecLoc.
isInvalid()) {
3152 Diag(Tok, diag::err_anon_bitfield_member_init);
3156 if (!TryConsumePureSpecifier(
false))
3158 HasStaticInitializer =
true;
3166 if (BitfieldSize.
get())
3167 DiagCompat(Tok, diag_compat::bitfield_member_init);
3170 HasStaticInitializer =
true;
3178 NamedDecl *ThisDecl =
nullptr;
3186 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3187 auto Loc = AL.getRange().getBegin();
3188 (AL.isRegularKeywordAttribute()
3189 ?
Diag(Loc, diag::err_keyword_not_allowed) << AL
3190 :
Diag(Loc, diag::err_attributes_not_allowed))
3194 ThisDecl = Actions.ActOnFriendFunctionDecl(
getCurScope(), DeclaratorInfo,
3197 ThisDecl = Actions.ActOnCXXMemberDeclarator(
3198 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3199 VS, HasInClassInit);
3201 if (VarTemplateDecl *VT =
3202 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3205 ThisDecl = VT->getTemplatedDecl();
3208 Actions.ProcessDeclAttributeList(
getCurScope(), ThisDecl, AccessAttrs);
3217 HasStaticInitializer =
true;
3221 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3223 if (ThisDecl && PureSpecLoc.
isValid())
3224 Actions.ActOnPureSpecifier(ThisDecl, PureSpecLoc);
3231 DiagCompat(Tok, diag_compat::nonstatic_member_init);
3239 Diag(Tok, diag::err_incomplete_array_member_init);
3246 ParseCXXNonStaticMemberInitializer(ThisDecl);
3247 }
else if (HasStaticInitializer) {
3252 if (
Init.isInvalid()) {
3254 Actions.ActOnUninitializedDecl(ThisDecl);
3256 }
else if (ThisDecl)
3257 Actions.AddInitializerToDecl(ThisDecl,
Init.get(),
3261 Actions.ActOnUninitializedDecl(ThisDecl);
3266 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3267 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3269 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3270 LateParsedAttrs[i]->addDecl(ThisDecl);
3272 Actions.FinalizeDeclaration(ThisDecl);
3273 DeclsInGroup.push_back(ThisDecl);
3278 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3280 LateParsedAttrs.clear();
3282 DeclaratorInfo.complete(ThisDecl);
3286 SourceLocation CommaLoc;
3290 if (Tok.isAtStartOfLine() &&
3295 Diag(CommaLoc, diag::err_expected_semi_declaration)
3307 Diag(CommaLoc, diag::err_multiple_template_declarators)
3308 << TemplateInfo.Kind;
3312 DeclaratorInfo.
clear();
3315 EqualLoc = PureSpecLoc = SourceLocation();
3321 DiagnoseAndSkipCXX11Attributes();
3322 MaybeParseGNUAttributes(DeclaratorInfo);
3323 DiagnoseAndSkipCXX11Attributes();
3325 if (ParseCXXMemberDeclaratorBeforeInitializer(
3326 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3331 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list) &&
3332 !isLikelyAtStartOfNewDeclaration()) {
3340 return Actions.FinalizeDeclaratorGroup(
getCurScope(), DS, DeclsInGroup);
3343ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
3345 assert(Tok.isOneOf(tok::equal, tok::l_brace) &&
3346 "Data member initializer not starting with '=' or '{'");
3348 bool IsFieldInitialization = isa_and_present<FieldDecl>(D);
3350 EnterExpressionEvaluationContext Context(
3352 IsFieldInitialization
3360 Actions.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
3361 IsFieldInitialization;
3364 if (Tok.is(tok::kw_delete)) {
3371 if (IsFunction ||
Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3377 SkipDeletedFunctionBody();
3380 }
else if (Tok.is(tok::kw_default)) {
3382 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3387 ? diag::DefaultableFunctionKinds::Cxx29
3389 ? diag::DefaultableFunctionKinds::Cxx20
3390 : diag::DefaultableFunctionKinds::Default);
3394 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
3395 Diag(Tok, diag::err_ms_property_initializer) << PD;
3398 return ParseInitializer(D);
3405 while (isClassCompatibleKeyword())
3410 ParsedAttributes Attrs(AttrFactory);
3411 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3416 if (Tok.isNot(tok::colon) && Tok.isNot(tok::l_brace))
3422 if (Tok.is(tok::colon)) {
3425 ParsingClassDefinition ParsingDef(*
this, TagDecl,
true,
3428 Actions.ActOnTagStartSkippedDefinition(
getCurScope(), TagDecl);
3431 ParseBaseClause(
nullptr);
3433 Actions.ActOnTagFinishSkippedDefinition(OldContext);
3435 if (!Tok.is(tok::l_brace)) {
3436 Diag(PP.getLocForEndOfToken(PrevTokLocation),
3437 diag::err_expected_lbrace_after_base_specifiers);
3443 assert(Tok.is(tok::l_brace));
3449 if (Tok.is(tok::kw___attribute)) {
3450 ParsedAttributes Attrs(AttrFactory);
3451 MaybeParseGNUAttributes(Attrs);
3460 switch (Tok.getKind()) {
3461 case tok::kw___if_exists:
3462 case tok::kw___if_not_exists:
3463 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, AS);
3472 case tok::annot_pragma_vis:
3473 HandlePragmaVisibility();
3475 case tok::annot_pragma_pack:
3478 case tok::annot_pragma_align:
3479 HandlePragmaAlign();
3481 case tok::annot_pragma_ms_pointers_to_members:
3482 HandlePragmaMSPointersToMembers();
3484 case tok::annot_pragma_ms_pragma:
3485 HandlePragmaMSPragma();
3487 case tok::annot_pragma_ms_vtordisp:
3488 HandlePragmaMSVtorDisp();
3490 case tok::annot_pragma_export:
3491 HandlePragmaExport();
3493 case tok::annot_pragma_dump:
3497 case tok::kw_namespace:
3502 case tok::kw_private:
3506 ParsedTemplateInfo TemplateInfo;
3507 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3510 case tok::kw_public:
3511 case tok::kw_protected: {
3513 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
3518 SourceLocation ASLoc = Tok.getLocation();
3519 unsigned TokLength = Tok.getLength();
3521 AccessAttrs.
clear();
3522 MaybeParseGNUAttributes(AccessAttrs);
3524 SourceLocation EndLoc;
3527 Diag(EndLoc, diag::err_expected)
3531 Diag(EndLoc, diag::err_expected)
3541 if (Actions.ActOnAccessSpecifier(NewAS, ASLoc, EndLoc, AccessAttrs)) {
3543 AccessAttrs.
clear();
3549 case tok::annot_attr_openmp:
3550 case tok::annot_pragma_openmp:
3551 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3552 AS, AccessAttrs,
true, TagType, TagDecl);
3553 case tok::annot_pragma_openacc:
3558 Diag(Tok.getLocation(), diag::err_pragma_misplaced_in_decl)
3560 TagType, Actions.getASTContext().getPrintingPolicy());
3561 ConsumeAnnotationToken();
3564 ParsedTemplateInfo TemplateInfo;
3565 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3576 "Invalid TagType!");
3578 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3579 if (
auto *TD = dyn_cast_or_null<NamedDecl>(TagDecl))
3580 return TD->getQualifiedNameAsString();
3581 return std::string(
"<anonymous>");
3584 PrettyDeclStackTraceEntry CrashInfo(Actions.Context, TagDecl,
RecordLoc,
3585 "parsing struct/union/class body");
3589 bool NonNestedClass =
true;
3590 if (!ClassStack.empty()) {
3592 if (S->isClassScope()) {
3594 NonNestedClass =
false;
3597 if (getCurrentClass().IsInterface) {
3607 if (S->isFunctionScope())
3618 ParsingClassDefinition ParsingDef(*
this, TagDecl, NonNestedClass,
3622 Actions.ActOnTagStartDefinition(
getCurScope(), TagDecl);
3624 SourceLocation FinalLoc;
3625 SourceLocation AbstractLoc;
3626 bool IsFinalSpelledSealed =
false;
3627 bool IsAbstract =
false;
3636 if (isCXX11FinalKeyword()) {
3639 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3644 IsFinalSpelledSealed =
true;
3649 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3657 Diag(FinalLoc, diag::err_override_control_interface)
3660 DiagCompat(FinalLoc, diag_compat::override_control_keyword)
3663 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3665 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3667 Diag(FinalLoc, diag::ext_warn_gnu_final);
3670 "not a class definition");
3676 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3685 if (!Tok.is(tok::colon) && !Tok.is(tok::l_brace)) {
3687 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3692 if (Tok.is(tok::colon)) {
3696 ParseBaseClause(TagDecl);
3697 if (!Tok.is(tok::l_brace)) {
3698 bool SuggestFixIt =
false;
3699 SourceLocation BraceLoc = PP.getLocForEndOfToken(PrevTokLocation);
3700 if (Tok.isAtStartOfLine()) {
3701 switch (Tok.getKind()) {
3702 case tok::kw_private:
3703 case tok::kw_protected:
3704 case tok::kw_public:
3707 case tok::kw_static_assert:
3711 case tok::kw_template:
3712 SuggestFixIt =
true;
3714 case tok::identifier:
3715 SuggestFixIt = isConstructorDeclarator(
true);
3718 SuggestFixIt = isCXXSimpleDeclaration(
false);
3722 DiagnosticBuilder LBraceDiag =
3723 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3727 PP.EnterToken(Tok,
true);
3728 Tok.setKind(tok::l_brace);
3731 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3737 assert(Tok.is(tok::l_brace));
3742 Actions.ActOnStartCXXMemberDeclarations(
getCurScope(), TagDecl, FinalLoc,
3743 IsFinalSpelledSealed, IsAbstract,
3744 T.getOpenLocation());
3755 ParsedAttributes AccessAttrs(AttrFactory);
3759 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
3760 Tok.isNot(tok::eof)) {
3762 ParseCXXClassMemberDeclarationWithPragmas(
3763 CurAS, AccessAttrs,
static_cast<DeclSpec::TST>(TagType), TagDecl);
3764 MaybeDestroyTemplateIds();
3772 ParsedAttributes attrs(AttrFactory);
3773 MaybeParseGNUAttributes(attrs);
3777 T.getOpenLocation(),
3778 T.getCloseLocation(), attrs);
3785 if (TagDecl && NonNestedClass) {
3791 SourceLocation SavedPrevTokLocation = PrevTokLocation;
3792 ParseLexedPragmas(getCurrentClass());
3793 ParseLexedAttributes(getCurrentClass());
3794 ParseLexedMethodDeclarations(getCurrentClass());
3797 Actions.ActOnFinishCXXMemberDecls();
3799 ParseLexedMemberInitializers(getCurrentClass());
3800 ParseLexedMethodDefs(getCurrentClass());
3801 PrevTokLocation = SavedPrevTokLocation;
3805 Actions.ActOnFinishCXXNonNestedClass();
3809 Actions.ActOnTagFinishDefinition(
getCurScope(), TagDecl,
T.getRange());
3816void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3817 assert(Tok.is(tok::kw_namespace));
3822 Diag(Tok.getLocation(), diag::note_missing_end_of_definition_before) << D;
3825 PP.EnterToken(Tok,
true);
3827 Tok =
Token::create(tok::semi, PP.getLocForEndOfToken(PrevTokLocation));
3828 PP.EnterToken(Tok,
true);
3830 Tok.setKind(tok::r_brace);
3833void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3834 assert(Tok.is(tok::colon) &&
3835 "Constructor initializer always starts with ':'");
3842 SmallVector<CXXCtorInitializer *, 4> MemInitializers;
3843 bool AnyErrors =
false;
3846 if (Tok.is(tok::code_completion)) {
3848 Actions.CodeCompletion().CodeCompleteConstructorInitializer(
3849 ConstructorDecl, MemInitializers);
3853 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3855 MemInitializers.push_back(MemInit.
get());
3859 if (Tok.is(tok::comma))
3861 else if (Tok.is(tok::l_brace))
3866 Tok.isOneOf(tok::identifier, tok::coloncolon)) {
3867 SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
3868 Diag(Loc, diag::err_ctor_init_missing_comma)
3873 Diag(Tok.getLocation(), diag::err_expected_either)
3874 << tok::l_brace << tok::comma;
3880 Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc, MemInitializers,
3887 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
3893 IdentifierInfo *II =
nullptr;
3894 SourceLocation IdLoc = Tok.getLocation();
3896 DeclSpec DS(AttrFactory);
3900 if (Tok.is(tok::identifier)) {
3903 II = Tok.getIdentifierInfo();
3905 }
else if (Tok.is(tok::annot_decltype)) {
3910 ParseDecltypeSpecifier(DS);
3911 }
else if (Tok.is(tok::annot_pack_indexing_type)) {
3914 ParsePackIndexingType(DS);
3916 TemplateIdAnnotation *TemplateId = Tok.is(tok::annot_template_id)
3917 ? takeTemplateIdAnnotation(Tok)
3922 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
3924 ConsumeAnnotationToken();
3926 Diag(Tok, diag::err_expected_member_or_base_name);
3933 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
3936 ExprResult InitList = ParseBraceInitializer();
3940 SourceLocation EllipsisLoc;
3945 return Actions.ActOnMemInitializer(ConstructorDecl,
getCurScope(), SS, II,
3946 TemplateTypeTy.
get(), DS, IdLoc,
3947 InitList.
get(), EllipsisLoc);
3948 }
else if (Tok.is(tok::l_paren)) {
3953 ExprVector ArgExprs;
3954 auto RunSignatureHelp = [&] {
3957 QualType PreferredType =
3958 Actions.CodeCompletion().ProduceCtorInitMemberSignatureHelp(
3959 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
3960 T.getOpenLocation(),
false);
3961 CalledSignatureHelp =
true;
3962 return PreferredType;
3964 if (Tok.isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
3965 PreferredType.enterFunctionArgument(Tok.getLocation(),
3968 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
3976 SourceLocation EllipsisLoc;
3981 return Actions.ActOnMemInitializer(
3982 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
3983 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
3990 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
3992 return Diag(Tok, diag::err_expected) << tok::l_paren;
4001 ExceptionSpecTokens =
nullptr;
4005 if (Tok.isNot(tok::kw_throw) && Tok.isNot(tok::kw_noexcept))
4009 bool IsNoexcept = Tok.is(tok::kw_noexcept);
4010 Token StartTok = Tok;
4014 if (!Tok.is(tok::l_paren)) {
4017 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4018 NoexceptExpr =
nullptr;
4022 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4028 ExceptionSpecTokens->push_back(StartTok);
4029 ExceptionSpecTokens->push_back(Tok);
4030 SpecificationRange.
setEnd(ConsumeParen());
4032 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4035 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4041 if (Tok.is(tok::kw_throw)) {
4042 Result = ParseDynamicExceptionSpecification(
4043 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4044 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4045 "Produced different number of exception types and ranges.");
4049 if (Tok.isNot(tok::kw_noexcept))
4052 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4056 SourceRange NoexceptRange;
4060 if (Tok.is(tok::l_paren)) {
4065 EnterExpressionEvaluationContext ConstantEvaluated(
4072 Actions.ActOnNoexceptSpec(NoexceptExpr.
get(), NoexceptType);
4073 NoexceptRange = SourceRange(KeywordLoc,
T.getCloseLocation());
4080 NoexceptRange = SourceRange(KeywordLoc, KeywordLoc);
4084 SpecificationRange = NoexceptRange;
4089 if (Tok.is(tok::kw_throw)) {
4090 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4091 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4092 DynamicExceptionRanges);
4095 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4104 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4106 ? diag::ext_dynamic_exception_spec
4107 : diag::warn_exception_spec_deprecated)
4109 P.
Diag(Range.getBegin(), diag::note_exception_spec_deprecated)
4117 assert(Tok.is(tok::kw_throw) &&
"expected throw");
4121 if (
T.consumeOpen()) {
4122 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4129 if (Tok.is(tok::ellipsis)) {
4132 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4134 SpecificationRange.
setEnd(
T.getCloseLocation());
4141 while (Tok.isNot(tok::r_paren)) {
4144 if (Tok.is(tok::ellipsis)) {
4149 Range.setEnd(Ellipsis);
4150 if (!Res.isInvalid())
4151 Res = Actions.ActOnPackExpansion(Res.get(), Ellipsis);
4154 if (!Res.isInvalid()) {
4155 Exceptions.push_back(Res.get());
4156 Ranges.push_back(Range);
4164 SpecificationRange.
setEnd(
T.getCloseLocation());
4166 Exceptions.empty());
4171 bool MayBeFollowedByDirectInit) {
4172 assert(Tok.is(tok::arrow) &&
"expected arrow");
4181void Parser::ParseTrailingRequiresClauseWithScope(
Declarator &D) {
4182 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4198 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4200 DeclScopeObj.EnterDeclaratorScope();
4206 ParseTrailingRequiresClause(D);
4209void Parser::ParseTrailingRequiresClause(
Declarator &D) {
4210 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4213 "trailing requires-clause must be parsed in a function prototype scope");
4218 Actions.ActOnStartTrailingRequiresClause(
getCurScope(), D);
4220 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4221 InitCXXThisScopeForDeclaratorIfRelevant(D, D.
getDeclSpec(), ThisScope);
4223 TrailingRequiresClause =
4226 TrailingRequiresClause =
4227 Actions.ActOnFinishTrailingRequiresClause(TrailingRequiresClause);
4231 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4236 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4244 SourceLocation ArrowLoc = Tok.getLocation();
4247 ParseTrailingReturnType(Range,
false);
4251 diag::err_requires_clause_must_appear_after_trailing_return)
4256 FunctionChunk.TrailingReturnTypeLoc =
Range.getBegin();
4258 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4264 bool NonNestedClass,
4266 assert((NonNestedClass || !ClassStack.empty()) &&
4267 "Nested class without outer class");
4268 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4269 return Actions.PushParsingClass();
4272void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4273 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4274 delete Class->LateParsedDeclarations[I];
4279 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4281 Actions.PopParsingClass(state);
4283 ParsingClass *Victim = ClassStack.top();
4285 if (Victim->TopLevelClass) {
4288 DeallocateParsedClasses(Victim);
4291 assert(!ClassStack.empty() &&
"Missing top-level class?");
4293 if (Victim->LateParsedDeclarations.empty()) {
4298 DeallocateParsedClasses(Victim);
4306 "Nested class outside of class scope?");
4307 ClassStack.top()->LateParsedDeclarations.push_back(
4308 new LateParsedClass(
this, Victim));
4314 switch (Tok.getKind()) {
4317 if (!Tok.isAnnotation()) {
4318 if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
4325 case tok::code_completion:
4327 Actions.CodeCompletion().CodeCompleteAttribute(
4332 case tok::numeric_constant: {
4336 if (Tok.getLocation().isMacroID()) {
4337 SmallString<8> ExpansionBuf;
4338 SourceLocation ExpansionLoc =
4339 PP.getSourceManager().getExpansionLoc(Tok.getLocation());
4340 StringRef Spelling = PP.getSpelling(ExpansionLoc, ExpansionBuf);
4341 if (Spelling ==
"__clang__") {
4342 SourceRange TokRange(
4344 PP.getSourceManager().getExpansionLoc(Tok.getEndLoc()));
4345 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4348 return &PP.getIdentifierTable().get(
"_Clang");
4361 case tok::pipeequal:
4362 case tok::caretequal:
4364 case tok::exclaimequal:
4367 SmallString<8> SpellingBuf;
4368 SourceLocation SpellingLoc =
4369 PP.getSourceManager().getSpellingLoc(Tok.getLocation());
4370 StringRef Spelling = PP.getSpelling(SpellingLoc, SpellingBuf);
4373 return &PP.getIdentifierTable().get(Spelling);
4379void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4384 if (
T.consumeOpen()) {
4385 Diag(Tok, diag::err_expected) << tok::l_paren;
4389 if (
AttrName->isStr(
"directive")) {
4395 OpenMPTokens.push_back(OMPBeginTok);
4397 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4401 OpenMPTokens.push_back(OMPEndTok);
4403 assert(
AttrName->isStr(
"sequence") &&
4404 "Expected either 'directive' or 'sequence'");
4412 SourceLocation IdentLoc;
4413 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4417 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4418 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4422 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4423 Diag(Tok.getLocation(), diag::err_expected_sequence_or_directive);
4429 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4443 case ParsedAttr::AT_Deprecated:
4444 case ParsedAttr::AT_FallThrough:
4445 case ParsedAttr::AT_CXX11NoReturn:
4446 case ParsedAttr::AT_NoUniqueAddress:
4447 case ParsedAttr::AT_Likely:
4448 case ParsedAttr::AT_Unlikely:
4450 case ParsedAttr::AT_WarnUnusedResult:
4451 return !ScopeName && AttrName->getName() ==
"nodiscard";
4452 case ParsedAttr::AT_Unused:
4453 return !ScopeName && AttrName->getName() ==
"maybe_unused";
4459bool Parser::ParseCXXAssumeAttributeArg(
4463 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4471 TentativeParsingAction TPA(*
this);
4476 if (Tok.is(tok::r_paren))
4481 if (!Tok.isOneOf(tok::r_paren, tok::r_square)) {
4487 auto *E = Res.
get();
4488 Diag(E->getExprLoc(), diag::err_assume_attr_expects_cond_expr)
4492 << E->getSourceRange();
4501 auto RParen = Tok.getLocation();
4503 Attrs.
addNew(AttrName, SourceRange(AttrNameLoc, RParen),
4504 AttributeScopeInfo(ScopeName, ScopeLoc), &Assumption, 1, Form);
4512bool Parser::ParseCXX11AttributeArgs(
4516 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4517 SourceLocation LParenLoc = Tok.getLocation();
4519 ParsedAttr::Form Form =
4520 LO.CPlusPlus ? ParsedAttr::Form::CXX11() : ParsedAttr::Form::
C23();
4526 Form = ParsedAttr::Form::Microsoft();
4530 TentativeParsingAction TPA(*this);
4531 bool HasInvalidArgument = false;
4532 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof)) {
4533 if (Tok.isOneOf(tok::hash, tok::hashhash)) {
4534 Diag(Tok.getLocation(), diag::ext_invalid_attribute_argument)
4535 << PP.getSpelling(Tok);
4536 HasInvalidArgument = true;
4541 if (HasInvalidArgument) {
4555 ScopeName, AttrName, getTargetInfo(), getLangOpts())) {
4558 SkipUntil(tok::r_paren);
4562 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4565 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4566 ScopeLoc, Form, nullptr);
4571 if (ScopeName && ScopeName->
isStr(
"omp") &&
4573 Diag(AttrNameLoc, getLangOpts().OpenMP >= 51
4574 ? diag::warn_omp51_compat_attributes
4575 : diag::ext_omp_attributes);
4577 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4586 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4587 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4588 ScopeName, ScopeLoc, Form);
4590 else if (!ScopeName &&
AttrName->isStr(
"assume")) {
4591 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, nullptr,
4592 SourceLocation{}, EndLoc, Form))
4596 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4597 ScopeName, ScopeLoc, Form);
4599 if (!Attrs.
empty() &&
4604 if (!
Attr.existsInTarget(getTargetInfo())) {
4605 Actions.DiagnoseUnknownAttribute(
Attr);
4606 Attr.setInvalid(
true);
4614 if (
Attr.getMaxArgs() && !NumArgs) {
4617 Diag(LParenLoc, diag::err_attribute_requires_arguments) <<
AttrName;
4618 Attr.setInvalid(
true);
4619 }
else if (!
Attr.getMaxArgs()) {
4623 auto D =
Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4627 Attr.setInvalid(
true);
4636 if (Tok.is(tok::kw_alignas)) {
4642 Diag(Tok.getLocation(), diag::warn_cxx98_compat_alignas);
4643 ParseAlignmentSpecifier(Attrs, EndLoc);
4647 if (Tok.isRegularKeywordAttribute()) {
4648 SourceLocation Loc = Tok.getLocation();
4649 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
4650 ParsedAttr::Form Form = ParsedAttr::Form(Tok.getKind());
4654 if (!Tok.is(tok::l_paren))
4655 Diag(Tok.getLocation(), diag::err_expected_lparen_after) <<
AttrName;
4657 ParseAttributeArgsCommon(AttrName, Loc, Attrs, EndLoc,
4661 Attrs.
addNew(AttrName, Loc, AttributeScopeInfo(),
nullptr, 0, Form);
4665 assert(Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square) &&
4666 "Not a double square bracket attribute list");
4668 SourceLocation OpenLoc = Tok.getLocation();
4670 : diag_compat::c23_attributes);
4673 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4676 SourceLocation CommonScopeLoc;
4677 IdentifierInfo *CommonScopeName =
nullptr;
4678 if (Tok.is(tok::kw_using)) {
4679 DiagCompat(Tok.getLocation(), diag_compat::using_attribute_ns);
4682 CommonScopeName = TryParseCXX11AttributeIdentifier(
4684 if (!CommonScopeName) {
4685 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4689 Diag(Tok.getLocation(), diag::err_expected) << tok::colon;
4692 bool AttrParsed =
false;
4693 while (!Tok.isOneOf(tok::r_square, tok::semi, tok::eof)) {
4697 if (ExpectAndConsume(tok::comma)) {
4708 SourceLocation ScopeLoc, AttrLoc;
4709 IdentifierInfo *ScopeName =
nullptr, *
AttrName =
nullptr;
4711 AttrName = TryParseCXX11AttributeIdentifier(
4723 AttrName = TryParseCXX11AttributeIdentifier(
4727 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4733 if (CommonScopeName) {
4735 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4736 << SourceRange(CommonScopeLoc);
4738 ScopeName = CommonScopeName;
4739 ScopeLoc = CommonScopeLoc;
4744 if (Tok.is(tok::l_paren))
4745 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
4746 ScopeName, ScopeLoc, OpenMPTokens);
4754 AttributeScopeInfo(ScopeName, ScopeLoc, CommonScopeLoc),
4757 : ParsedAttr::Form::C23());
4762 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) <<
AttrName;
4765 SourceLocation CloseLoc = Tok.getLocation();
4766 bool IsTokenNotFound = ExpectAndConsume(tok::r_square);
4767 if (IsTokenNotFound)
4769 else if (Tok.is(tok::r_square))
4770 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
4772 *EndLoc = Tok.getLocation();
4773 if (!IsTokenNotFound && ExpectAndConsume(tok::r_square))
4778 SourceLocation StartLoc = Tok.getLocation();
4779 SourceLocation EndLoc = StartLoc;
4782 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
4783 }
while (isAllowedCXX11AttributeSpecifier());
4785 Attrs.
Range = SourceRange(StartLoc, EndLoc);
4788void Parser::DiagnoseAndSkipCXX11Attributes() {
4790 Tok.isRegularKeywordAttribute() ? Tok.getIdentifierInfo() :
nullptr;
4792 SourceLocation StartLoc = Tok.getLocation();
4793 SourceLocation EndLoc = SkipCXX11Attributes();
4796 SourceRange
Range(StartLoc, EndLoc);
4798 :
Diag(StartLoc, diag::err_attributes_not_allowed))
4804 SourceLocation EndLoc;
4810 if (Tok.is(tok::l_square)) {
4814 EndLoc =
T.getCloseLocation();
4815 }
else if (Tok.isRegularKeywordAttribute() &&
4817 EndLoc = Tok.getLocation();
4820 assert((Tok.is(tok::kw_alignas) || Tok.isRegularKeywordAttribute()) &&
4821 "not an attribute specifier");
4824 if (!
T.consumeOpen())
4826 EndLoc =
T.getCloseLocation();
4828 }
while (isCXX11AttributeSpecifier() !=
4835 assert(Tok.is(tok::identifier) &&
"Not a Microsoft attribute list");
4836 IdentifierInfo *UuidIdent = Tok.getIdentifierInfo();
4837 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
4839 SourceLocation UuidLoc = Tok.getLocation();
4844 if (
T.consumeOpen()) {
4845 Diag(Tok, diag::err_expected) << tok::l_paren;
4850 if (isTokenStringLiteral()) {
4855 ArgExprs.push_back(StringResult.
get());
4861 SmallString<42> StrBuffer;
4871 SourceLocation StartLoc = Tok.getLocation();
4872 while (Tok.isNot(tok::r_paren)) {
4873 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4874 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4878 SmallString<16> SpellingBuffer;
4879 SpellingBuffer.resize(Tok.getLength() + 1);
4880 bool Invalid =
false;
4881 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
4886 StrBuffer += TokSpelling;
4891 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4892 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4901 Toks[0] =
Token::create(tok::string_literal, StartLoc, StrBuffer.size());
4903 StringLiteral *UuidString =
4905 ArgExprs.push_back(UuidString);
4908 if (!
T.consumeClose()) {
4909 Attrs.
addNew(UuidIdent, SourceRange(UuidLoc,
T.getCloseLocation()),
4910 AttributeScopeInfo(), ArgExprs.data(), ArgExprs.size(),
4911 ParsedAttr::Form::Microsoft());
4916 assert(Tok.is(tok::identifier) &&
4917 "Expected an identifier to denote which MS attribute to consider");
4918 IdentifierInfo *RootSignatureIdent = Tok.getIdentifierInfo();
4919 assert(RootSignatureIdent->
getName() ==
"RootSignature" &&
4920 "Expected RootSignature identifier for root signature attribute");
4922 SourceLocation RootSignatureLoc = Tok.getLocation();
4927 if (
T.consumeOpen()) {
4928 Diag(Tok, diag::err_expected) << tok::l_paren;
4932 auto ProcessStringLiteral = [
this]() -> std::optional<StringLiteral *> {
4933 if (!isTokenStringLiteral())
4934 return std::nullopt;
4938 return std::nullopt;
4940 if (
auto Lit = dyn_cast<StringLiteral>(StringResult.
get()))
4943 return std::nullopt;
4946 auto Signature = ProcessStringLiteral();
4947 if (!Signature.has_value()) {
4948 Diag(Tok, diag::err_expected_string_literal)
4949 << 4 <<
"RootSignature";
4955 Actions,
getLangOpts().HLSLRootSigVer, *Signature);
4963 IdentifierLoc *ILoc = ::new (Actions.getASTContext())
4964 IdentifierLoc(RootSignatureLoc, DeclIdent);
4968 if (!
T.consumeClose())
4969 Attrs.
addNew(RootSignatureIdent,
4970 SourceRange(RootSignatureLoc,
T.getCloseLocation()),
4971 AttributeScopeInfo(), Args.data(), Args.size(),
4972 ParsedAttr::Form::Microsoft());
4976 assert(Tok.is(tok::l_square) &&
"Not a Microsoft attribute list");
4978 SourceLocation StartLoc = Tok.getLocation();
4979 SourceLocation EndLoc = StartLoc;
4987 SkipUntil(tok::r_square, tok::identifier,
4989 if (Tok.is(tok::code_completion)) {
4991 Actions.CodeCompletion().CodeCompleteAttribute(
4997 if (Tok.isNot(tok::identifier))
4999 if (Tok.getIdentifierInfo()->getName() ==
"uuid")
5000 ParseMicrosoftUuidAttributeArgs(Attrs);
5001 else if (Tok.getIdentifierInfo()->getName() ==
"RootSignature")
5002 ParseHLSLRootSignatureAttributeArgs(Attrs);
5004 IdentifierInfo *II = Tok.getIdentifierInfo();
5005 SourceLocation NameLoc = Tok.getLocation();
5012 bool AttrParsed =
false;
5013 if (Tok.is(tok::l_paren)) {
5016 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5017 SourceLocation(), OpenMPTokens);
5018 ReplayOpenMPAttributeTokens(OpenMPTokens);
5021 Attrs.
addNew(II, NameLoc, AttributeScopeInfo(),
nullptr, 0,
5022 ParsedAttr::Form::Microsoft());
5029 EndLoc =
T.getCloseLocation();
5030 }
while (Tok.is(tok::l_square));
5032 Attrs.
Range = SourceRange(StartLoc, EndLoc);
5035void Parser::ParseMicrosoftIfExistsClassDeclaration(
5038 IfExistsCondition
Result;
5039 if (ParseMicrosoftIfExistsCondition(
Result))
5043 if (
Braces.consumeOpen()) {
5044 Diag(Tok, diag::err_expected) << tok::l_brace;
5048 switch (
Result.Behavior) {
5054 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5064 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
5066 if (Tok.isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5067 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, CurAS);
5072 if (Tok.is(tok::semi)) {
5081 SourceLocation ASLoc = Tok.getLocation();
5083 if (Tok.is(tok::colon))
5084 Actions.ActOnAccessSpecifier(AS, ASLoc, Tok.getLocation(),
5085 ParsedAttributesView{});
5087 Diag(Tok, diag::err_expected) << tok::colon;
5092 ParsedTemplateInfo TemplateInfo;
5094 ParseCXXClassMemberDeclaration(CurAS, AccessAttrs, TemplateInfo);
Defines the clang::ASTContext interface.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::RecordLoc RecordLoc
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.
This file declares semantic analysis for HLSL constructs.
Defines the clang::TokenKind enum and support functions.
#define TRANSFORM_TYPE_TRAIT_DEF(Enum, _)
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)
static CharSourceRange getTokenRange(SourceRange R)
Captures information about "declaration specifiers".
void setTypeArgumentRange(SourceRange range)
static const TST TST_typename
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
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
bool isFriendSpecifiedFirst() const
Expr * getRepAsExpr() const
static const TST TST_decltype
void takeAttributesAppendingingFrom(ParsedAttributes &attrs)
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
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 isArrayOfUnknownBound() const
isArrayOfUnknownBound - This method returns true if the declarator is a declarator for an array of un...
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function.
void setCommaLoc(SourceLocation CL)
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.
TemplateParameterList * getInventedTemplateParameterList() const
The template parameter list generated from the explicit template parameters along with any invented t...
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.
bool isFirstDeclarator() const
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
The template parameter lists that preceded the declarator.
void clear()
Reset the contents of this Declarator.
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.
bool isStaticMember()
Returns true if this declares a static member.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
This represents one expression.
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.
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'.
This represents a decl that may have a name.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
static OpaquePtr make(TemplateName P)
ParsedAttr - Represents a syntactic attribute.
static const ParsedAttributesView & none()
void prepend(iterator B, iterator E)
ParsedAttributes - A collection of parsed attributes.
void takeAllPrependingFrom(ParsedAttributes &Other)
void takeAllAppendingFrom(ParsedAttributes &Other)
ParsedAttr * addNew(IdentifierInfo *attrName, SourceRange attrRange, AttributeScopeInfo scope, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
ParseScope - Introduces a new scope for parsing.
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.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
DiagnosticBuilder DiagCompat(SourceLocation Loc, unsigned CompatDiagId)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
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.
ExprResult ParseConstantExpressionInExprEvalContext(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
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.
friend class ColonProtectionRAIIObject
DeclGroupPtrTy ParseOpenACCDirectiveDecl(AccessSpecifier &AS, ParsedAttributes &Attrs, DeclSpec::TST TagType, Decl *TagDecl)
Parse OpenACC directive on a declaration.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
const Token & GetLookAheadToken(unsigned N)
GetLookAheadToken - This peeks ahead N tokens and returns that token without consuming any tokens.
ExprResult ParseConstantExpression()
ExprResult ParseConditionalExpression()
bool TryConsumeToken(tok::TokenKind Expected)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
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 PoisonSEHIdentifiersRAIIObject
const LangOptions & getLangOpts() const
friend class ParenBraceBracketBalancer
ExprResult ParseExpression(TypoCorrectionTypeBehavior CorrectionBehavior=TypoCorrectionTypeBehavior::AllowNonTypes)
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.
friend class BalancedDelimiterTracker
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.
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.
const Scope * getParent() const
getParent - Return the scope that this is nested in.
@ 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.
@ PCC_TopLevelOrExpression
Code completion occurs at top-level in a REPL session.
@ PCC_Namespace
Code completion occurs at top-level or namespace context.
ProcessingContextState ParsingClassState
@ 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...
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.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getBegin() const
void setEnd(SourceLocation e)
Represents the declaration of a struct/union/class/enum.
bool isNull() const
Determine whether this template name is NULL.
bool isDependent() const
Determines whether this is a dependent template name.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
void setLiteralData(const char *Ptr)
static Token create(tok::TokenKind Kind, SourceLocation Loc, unsigned Length=0)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setKind(tok::TokenKind K)
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
static Token createAnnotation(tok::TokenKind Kind, SourceRange Range, void *Value=nullptr)
Represents a C++ unqualified-id that has been parsed.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
const IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId,...
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.
IdentifierInfo * ParseHLSLRootSignature(Sema &Actions, llvm::dxbc::RootSignatureVersion Version, StringLiteral *Signature)
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
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.
Top level wrappers for InstallAPI frontend operations.
bool doesKeywordAttributeTakeArgs(tok::TokenKind Kind)
@ OO_None
Not an overloaded operator.
bool isa(CodeGen::Address addr)
@ NotAttributeSpecifier
This is not an attribute specifier.
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
FunctionDefinitionKind
Described the kind of function definition (if any) provided for a function.
int hasAttribute(AttributeCommonInfo::Syntax Syntax, llvm::StringRef ScopeName, llvm::StringRef AttrName, const TargetInfo &Target, const LangOptions &LangOpts, bool CheckPlugins)
Return the version number associated with the attribute if we recognize and implement the attribute s...
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.
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an ParsedAttr as an argument.
@ TemplateName
The identifier is a template name. FIXME: Add an annotation for that.
bool tokenIsLikeStringLiteral(const Token &Tok, const LangOptions &LO)
Return true if the token is a string literal, or a function local predefined macro,...
@ IK_TemplateId
A template-id, e.g., f<int>.
@ IK_Identifier
An identifier.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
ActionResult< Decl * > DeclResult
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
llvm::SmallVector< ArgsUnion, 12U > ArgsVector
@ Dependent
Parse the block as a dependent block, which may be used in some template instantiations but not other...
@ Skip
Skip the block entirely; this code is never used.
@ Parse
Parse the block; this code is always used.
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< ParsedType > TypeResult
ActionResult< CXXCtorInitializer * > MemInitResult
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
@ ExplicitSpecialization
We are parsing an explicit specialization.
@ ExplicitInstantiation
We are parsing an explicit instantiation.
@ NonTemplate
We are not parsing a template at all.
ActionResult< CXXBaseSpecifier * > BaseResult
@ Keyword
The name has been typo-corrected to a keyword.
MutableArrayRef< ParsedTemplateArgument > ASTTemplateArgsPtr
@ AfterMemberFunctionDefinition
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
@ TNK_Dependent_template_name
The name refers to a dependent template name:
@ 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.
U cast(CodeGen::Address addr)
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
ActionResult< Expr * > ExprResult
@ 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)
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...
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.
static TemplateIdAnnotation * Create(SourceLocation TemplateKWLoc, SourceLocation TemplateNameLoc, const IdentifierInfo *Name, OverloadedOperatorKind OperatorKind, ParsedTemplateTy OpaqueTemplateName, TemplateNameKind TemplateKind, SourceLocation LAngleLoc, SourceLocation RAngleLoc, ArrayRef< ParsedTemplateArgument > TemplateArgs, bool ArgsInvalid, SmallVectorImpl< TemplateIdAnnotation * > &CleanupList)
Creates a new TemplateIdAnnotation with NumArgs arguments and appends it to List.