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 MaybeParseCXX11Attributes(DeclAttrs);
231 ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
232 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
246 UsingDirectiveDecl *ImplicitUsingDirectiveDecl =
nullptr;
247 Decl *NamespcDecl = Actions.ActOnStartNamespaceDef(
248 getCurScope(), InnerNSs[index].InlineLoc, InnerNSs[index].NamespaceLoc,
249 InnerNSs[index].IdentLoc, InnerNSs[index].Ident,
251 assert(!ImplicitUsingDirectiveDecl &&
252 "nested namespace definition cannot define anonymous namespace");
254 ParseInnerNamespace(InnerNSs, ++index, InlineLoc, attrs, Tracker);
256 NamespaceScope.Exit();
264 assert(Tok.is(tok::equal) &&
"Not equal token");
268 if (Tok.is(tok::code_completion)) {
270 Actions.CodeCompletion().CodeCompleteNamespaceAliasDecl(
getCurScope());
276 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
284 if (Tok.isNot(tok::identifier)) {
285 Diag(Tok, diag::err_expected_namespace_name);
299 IdentifierInfo *Ident = Tok.getIdentifierInfo();
303 DeclEnd = Tok.getLocation();
304 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name))
307 return Actions.ActOnNamespaceAliasDef(
getCurScope(), NamespaceLoc, AliasLoc,
308 Alias, SS, IdentLoc, Ident);
312 assert(isTokenStringLiteral() &&
"Not a string literal!");
319 : Actions.ActOnStartLinkageSpecification(
321 Tok.is(tok::l_brace) ? Tok.getLocation() : SourceLocation());
323 ParsedAttributes DeclAttrs(AttrFactory);
324 ParsedAttributes DeclSpecAttrs(AttrFactory);
326 while (MaybeParseCXX11Attributes(DeclAttrs) ||
327 MaybeParseGNUAttributes(DeclSpecAttrs))
330 if (Tok.isNot(tok::l_brace)) {
337 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs, &DS);
338 return LinkageSpec ? Actions.ActOnFinishLinkageSpecification(
345 ProhibitAttributes(DeclAttrs);
350 unsigned NestedModules = 0;
352 switch (Tok.getKind()) {
353 case tok::annot_module_begin:
358 case tok::annot_module_end:
365 case tok::annot_module_include:
377 ParsedAttributes DeclAttrs(AttrFactory);
378 ParsedAttributes DeclSpecAttrs(AttrFactory);
379 while (MaybeParseCXX11Attributes(DeclAttrs) ||
380 MaybeParseGNUAttributes(DeclSpecAttrs))
382 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
390 return LinkageSpec ? Actions.ActOnFinishLinkageSpecification(
395Decl *Parser::ParseExportDeclaration() {
396 assert(Tok.is(tok::kw_export));
399 if (Tok.is(tok::code_completion)) {
401 Actions.CodeCompletion().CodeCompleteOrdinaryName(
409 Decl *ExportDecl = Actions.ActOnStartExportDecl(
411 Tok.is(tok::l_brace) ? Tok.getLocation() : SourceLocation());
413 if (Tok.isNot(tok::l_brace)) {
415 ParsedAttributes DeclAttrs(AttrFactory);
416 MaybeParseCXX11Attributes(DeclAttrs);
417 ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
418 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
419 return Actions.ActOnFinishExportDecl(
getCurScope(), ExportDecl,
426 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
427 Tok.isNot(tok::eof)) {
428 ParsedAttributes DeclAttrs(AttrFactory);
429 MaybeParseCXX11Attributes(DeclAttrs);
430 ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
431 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
435 return Actions.ActOnFinishExportDecl(
getCurScope(), ExportDecl,
436 T.getCloseLocation());
442 assert(Tok.is(tok::kw_using) &&
"Not using token");
443 ObjCDeclContextSwitch ObjCDC(*
this);
448 if (Tok.is(tok::code_completion)) {
450 Actions.CodeCompletion().CodeCompleteUsing(
getCurScope());
455 while (Tok.is(tok::kw_template)) {
457 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
462 if (Tok.is(tok::kw_namespace)) {
465 SourceRange
R = TemplateInfo.getSourceRange();
466 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
470 Decl *UsingDir = ParseUsingDirective(Context, UsingLoc, DeclEnd, Attrs);
471 return Actions.ConvertDeclToDeclGroup(UsingDir);
475 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, Attrs,
483 assert(Tok.is(tok::kw_namespace) &&
"Not 'namespace' token");
488 if (Tok.is(tok::code_completion)) {
490 Actions.CodeCompletion().CodeCompleteUsingDirective(
getCurScope());
496 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
504 IdentifierInfo *NamespcName =
nullptr;
505 SourceLocation IdentLoc = SourceLocation();
508 if (Tok.isNot(tok::identifier)) {
509 Diag(Tok, diag::err_expected_namespace_name);
524 NamespcName = Tok.getIdentifierInfo();
528 bool GNUAttr =
false;
529 if (Tok.is(tok::kw___attribute)) {
531 ParseGNUAttributes(attrs);
535 DeclEnd = Tok.getLocation();
536 if (ExpectAndConsume(tok::semi,
537 GNUAttr ? diag::err_expected_semi_after_attribute_list
538 : diag::err_expected_semi_after_namespace_name))
541 return Actions.ActOnUsingDirective(
getCurScope(), UsingLoc, NamespcLoc, SS,
542 IdentLoc, NamespcName, attrs);
546 UsingDeclarator &D) {
553 if (Tok.is(tok::kw___super)) {
554 Diag(Tok.getLocation(), diag::err_super_in_using_declaration);
559 const IdentifierInfo *LastII =
nullptr;
560 if (ParseOptionalCXXScopeSpecifier(D.SS,
nullptr,
570 if (D.SS.isInvalid())
584 Tok.is(tok::identifier) &&
589 D.SS.isNotEmpty() && LastII == Tok.getIdentifierInfo() &&
593 Actions.getInheritingConstructorName(D.SS, IdLoc, *LastII);
594 D.Name.setConstructorName(
Type, IdLoc, IdLoc);
601 !(Tok.is(tok::identifier) &&
NextToken().
is(tok::equal)),
602 false,
nullptr, D.Name))
607 DiagCompat(Tok.getLocation(), diag_compat::using_declaration_pack);
616 SourceLocation UELoc;
622 DiagCompat(UELoc, diag_compat::using_enum_declaration);
623 DiagnoseCXX11AttributeExtension(PrefixAttrs);
626 SourceRange
R = TemplateInfo.getSourceRange();
627 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
633 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
645 if (Tok.is(tok::code_completion)) {
647 Actions.CodeCompletion().CodeCompleteUsing(
getCurScope());
655 if (Tok.is(tok::identifier)) {
656 IdentifierInfo *IdentInfo = Tok.getIdentifierInfo();
665 UED = Actions.ActOnUsingEnumDeclaration(
667 }
else if (Tok.is(tok::annot_template_id)) {
668 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
674 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
676 SourceRange Loc = Tok.getAnnotationRange();
677 ConsumeAnnotationToken();
679 UED = Actions.ActOnUsingEnumDeclaration(
getCurScope(), AS, UsingLoc,
680 UELoc, Loc, *TemplateId->
Name,
683 Diag(Tok.getLocation(), diag::err_using_enum_not_enum)
688 Diag(Tok.getLocation(), diag::err_using_enum_expect_identifier)
689 << Tok.is(tok::kw_enum);
699 DeclEnd = Tok.getLocation();
700 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
701 "using-enum declaration"))
704 return Actions.ConvertDeclToDeclGroup(UED);
709 ParsedAttributes MisplacedAttrs(AttrFactory);
710 MaybeParseCXX11Attributes(MisplacedAttrs);
712 if (InInitStatement && Tok.isNot(tok::identifier))
716 bool InvalidDeclarator = ParseUsingDeclarator(Context, D);
718 ParsedAttributes Attrs(AttrFactory);
719 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
723 if (MisplacedAttrs.Range.isValid()) {
725 MisplacedAttrs.empty() ?
nullptr : &MisplacedAttrs.front();
726 auto &
Range = MisplacedAttrs.Range;
727 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
728 ?
Diag(
Range.getBegin(), diag::err_keyword_not_allowed) << FirstAttr
729 :
Diag(
Range.getBegin(), diag::err_attributes_not_allowed))
737 if (Tok.is(tok::equal) || InInitStatement) {
738 if (InvalidDeclarator) {
743 ProhibitAttributes(PrefixAttrs, Tok.getLocation());
745 Decl *DeclFromDeclSpec =
nullptr;
751 Decl *AD = ParseAliasDeclarationAfterDeclarator(
752 TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
757 return Actions.ConvertDeclToDeclGroup(AD, DeclFromDeclSpec);
760 DiagnoseCXX11AttributeExtension(PrefixAttrs);
766 SourceRange
R = TemplateInfo.getSourceRange();
767 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
776 SmallVector<Decl *, 8> DeclsInGroup;
779 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
780 DiagnoseCXX11AttributeExtension(Attrs);
783 if (InvalidDeclarator)
788 if (D.TypenameLoc.isValid() &&
790 Diag(D.Name.getSourceRange().getBegin(),
791 diag::err_typename_identifiers_only)
794 D.TypenameLoc = SourceLocation();
798 D.TypenameLoc, D.SS, D.Name,
799 D.EllipsisLoc, Attrs);
801 DeclsInGroup.push_back(UD);
809 InvalidDeclarator = ParseUsingDeclarator(Context, D);
812 if (DeclsInGroup.size() > 1)
813 DiagCompat(Tok.getLocation(), diag_compat::multi_using_declaration);
816 DeclEnd = Tok.getLocation();
817 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
818 !Attrs.
empty() ?
"attributes list"
819 : UELoc.
isValid() ?
"using-enum declaration"
820 :
"using declaration"))
823 return Actions.BuildDeclaratorGroup(DeclsInGroup);
826Decl *Parser::ParseAliasDeclarationAfterDeclarator(
830 if (ExpectAndConsume(tok::equal)) {
835 DiagCompat(Tok.getLocation(), diag_compat::alias_declaration);
846 if (SpecKind != -1) {
849 Range = SourceRange(D.Name.TemplateId->LAngleLoc,
850 D.Name.TemplateId->RAngleLoc);
852 Range = TemplateInfo.getSourceRange();
853 Diag(
Range.getBegin(), diag::err_alias_declaration_specialization)
854 << SpecKind <<
Range;
861 Diag(D.Name.StartLocation, diag::err_alias_declaration_not_identifier);
865 }
else if (D.TypenameLoc.isValid())
866 Diag(D.TypenameLoc, diag::err_alias_declaration_not_identifier)
868 SourceRange(D.TypenameLoc, D.SS.isNotEmpty() ? D.SS.getEndLoc()
870 else if (D.SS.isNotEmpty())
871 Diag(D.SS.getBeginLoc(), diag::err_alias_declaration_not_identifier)
873 if (D.EllipsisLoc.isValid())
874 Diag(D.EllipsisLoc, diag::err_alias_declaration_pack_expansion)
877 Decl *DeclFromDeclSpec =
nullptr;
882 AS, &DeclFromDeclSpec, &Attrs);
884 *OwnedType = DeclFromDeclSpec;
887 DeclEnd = Tok.getLocation();
888 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
889 !Attrs.
empty() ?
"attributes list"
890 :
"alias declaration"))
895 TemplateParams ? TemplateParams->data() :
nullptr,
896 TemplateParams ? TemplateParams->size() : 0);
897 return Actions.ActOnAliasDeclaration(
getCurScope(), AS, TemplateParamsArg,
904 if (
const auto *BO = dyn_cast_or_null<BinaryOperator>(AssertExpr)) {
905 if (BO->getOpcode() == BO_LAnd &&
913 assert(Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
914 "Not a static_assert declaration");
917 const char *TokName = Tok.getName();
919 if (Tok.is(tok::kw__Static_assert))
920 diagnoseUseOfC11Keyword(Tok);
921 else if (Tok.is(tok::kw_static_assert)) {
924 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.getName();
926 Diag(Tok, diag::warn_cxx98_compat_static_assert);
932 if (
T.consumeOpen()) {
933 Diag(Tok, diag::err_expected) << tok::l_paren;
938 EnterExpressionEvaluationContext ConstantEvaluated(
941 if (AssertExpr.isInvalid()) {
947 if (Tok.is(tok::r_paren)) {
949 ? diag_compat::cxx_static_assert_no_message
950 : diag_compat::c_static_assert_no_message;
954 if (ExpectAndConsume(tok::comma)) {
959 bool ParseAsExpression =
false;
961 for (
unsigned I = 0;; ++I) {
963 if (
T.is(tok::r_paren))
966 ParseAsExpression =
true;
972 if (ParseAsExpression) {
974 if (Tok.is(tok::r_paren)) {
975 DiagCompat(Tok, diag_compat::static_assert_user_generated_message);
983 Diag(Tok, diag::err_expected_string_literal)
997 DeclEnd = Tok.getLocation();
998 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
1000 return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc, AssertExpr.get(),
1001 AssertMessage.
get(),
1002 T.getCloseLocation());
1006 assert(Tok.isOneOf(tok::kw_decltype, tok::annot_decltype) &&
1007 "Not a decltype specifier");
1010 SourceLocation StartLoc = Tok.getLocation();
1011 SourceLocation EndLoc;
1013 if (Tok.is(tok::annot_decltype)) {
1014 Result = getExprAnnotation(Tok);
1015 EndLoc = Tok.getAnnotationEndLoc();
1019 ConsumeAnnotationToken();
1020 if (
Result.isInvalid()) {
1025 if (Tok.getIdentifierInfo()->isStr(
"decltype"))
1026 Diag(Tok, diag::warn_cxx98_compat_decltype);
1031 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"decltype",
1034 return T.getOpenLocation() == Tok.getLocation() ? StartLoc
1035 :
T.getOpenLocation();
1039 if (Tok.is(tok::kw_auto) &&
NextToken().
is(tok::r_paren)) {
1042 DiagCompat(Tok.getLocation(), diag_compat::decltype_auto_type_specifier);
1053 if (
Result.isInvalid()) {
1056 EndLoc = ConsumeParen();
1058 if (PP.isBacktrackEnabled() && Tok.is(tok::semi)) {
1060 PP.RevertCachedTokens(2);
1064 EndLoc = Tok.getLocation();
1070 Result = Actions.ActOnDecltypeExpression(
Result.get());
1076 if (
T.getCloseLocation().isInvalid()) {
1080 return T.getCloseLocation();
1083 if (
Result.isInvalid()) {
1085 return T.getCloseLocation();
1088 EndLoc =
T.getCloseLocation();
1090 assert(!
Result.isInvalid());
1092 const char *PrevSpec =
nullptr;
1094 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1097 PrevSpec, DiagID,
Result.get(), Policy)
1099 PrevSpec, DiagID, Policy)) {
1100 Diag(StartLoc, DiagID) << PrevSpec;
1107void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
1111 if (PP.isBacktrackEnabled()) {
1112 PP.RevertCachedTokens(1);
1114 PP.EnterToken(Tok,
true);
1116 Tok.setKind(tok::annot_decltype);
1117 setExprAnnotation(Tok,
1121 Tok.setAnnotationEndLoc(EndLoc);
1122 Tok.setLocation(StartLoc);
1123 PP.AnnotateCachedTokens(Tok);
1127 assert(Tok.isOneOf(tok::annot_pack_indexing_type, tok::identifier) &&
1128 "Expected an identifier");
1131 SourceLocation StartLoc;
1132 SourceLocation EllipsisLoc;
1133 const char *PrevSpec;
1135 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1137 if (Tok.is(tok::annot_pack_indexing_type)) {
1138 StartLoc = Tok.getLocation();
1139 SourceLocation EndLoc;
1141 EndLoc = Tok.getAnnotationEndLoc();
1145 ConsumeAnnotationToken();
1146 if (
Type.isInvalid()) {
1151 DiagID,
Type, Policy);
1157 return Tok.getEndLoc();
1161 *Tok.getIdentifierInfo(), Tok.getLocation(),
getCurScope(),
1162 nullptr,
false,
false,
1167 return Tok.getEndLoc();
1182 ASTContext &
C = Actions.getASTContext();
1184 C.getSizeType(), SourceLocation());
1190 return T.getCloseLocation();
1195 assert(Tok.is(tok::identifier) &&
NextToken().
is(tok::ellipsis) &&
1201 Name.
setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
1202 CXXScopeSpec EmptySS;
1203 bool MemberOfUnknownSpecialization =
false;
1207 MemberOfUnknownSpecialization,
false);
1214bool Parser::AnnotatePackIndexingTemplateName(
CXXScopeSpec &SS,
1218 assert(Tok.is(tok::identifier) &&
"expected a simple-template-name");
1223 if (
T.consumeOpen())
1229 TemplateName Indexed = Actions.ActOnPackIndexingTemplateName(
1243 if (Tok.is(tok::less))
1244 return AnnotateTemplateIdToken(
Template, TNK, SS,
1245 SourceLocation(), Name,
1250 if (PP.isBacktrackEnabled())
1251 PP.RevertCachedTokens(1);
1253 PP.EnterToken(Tok,
true);
1264 : Actions.ActOnPackIndexingDeducedTemplateSpecializationType(
1266 Tok.setKind(tok::annot_typename);
1267 setTypeAnnotation(Tok,
Type);
1270 Tok.setKind(tok::annot_template_id);
1274 SourceLocation(), {},
1275 false, TemplateIds));
1277 Tok.setLocation(NameLoc);
1278 Tok.setAnnotationEndLoc(
T.getCloseLocation());
1279 PP.AnnotateCachedTokens(Tok);
1283void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1287 if (PP.isBacktrackEnabled()) {
1288 PP.RevertCachedTokens(1);
1294 EndLoc = PP.getLastCachedTokenLocation();
1297 PP.EnterToken(Tok,
true);
1299 Tok.setKind(tok::annot_pack_indexing_type);
1300 setTypeAnnotation(Tok,
T);
1301 Tok.setAnnotationEndLoc(EndLoc);
1302 Tok.setLocation(StartLoc);
1303 PP.AnnotateCachedTokens(Tok);
1307 switch (Tok.getKind()) {
1308#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1309 case tok::kw___##Trait: \
1310 return DeclSpec::TST_##Trait;
1311#include "clang/Basic/BuiltinTraits.inc"
1313 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1317bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1319 Tok.setKind(tok::identifier);
1322 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1326 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.getName(),
1331 if (
Result.isInvalid()) {
1337 if (
T.getCloseLocation().isInvalid())
1340 const char *PrevSpec =
nullptr;
1344 Actions.getASTContext().getPrintingPolicy()))
1345 Diag(StartLoc, DiagID) << PrevSpec;
1353 if (Tok.is(tok::kw_typename)) {
1354 Diag(Tok, diag::err_expected_class_name_not_template)
1361 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1366 BaseLoc = Tok.getLocation();
1371 if (Tok.isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1376 DeclSpec DS(AttrFactory);
1378 EndLocation = ParseDecltypeSpecifier(DS);
1382 return Actions.ActOnTypeName(DeclaratorInfo);
1385 if (Tok.is(tok::annot_pack_indexing_type)) {
1386 DeclSpec DS(AttrFactory);
1387 ParsePackIndexingType(DS);
1390 return Actions.ActOnTypeName(DeclaratorInfo);
1396 if (Tok.is(tok::annot_template_id)) {
1397 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1402 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
1404 EndLocation = Tok.getAnnotationEndLoc();
1405 ConsumeAnnotationToken();
1412 if (Tok.isNot(tok::identifier)) {
1413 Diag(Tok, diag::err_expected_class_name);
1417 IdentifierInfo *Id = Tok.getIdentifierInfo();
1420 if (Tok.is(tok::less)) {
1427 if (!Actions.DiagnoseUnknownTemplateName(*Id, IdLoc,
getCurScope(), &SS,
1429 Diag(IdLoc, diag::err_unknown_template_name) << Id;
1437 if (AnnotateTemplateIdToken(
Template, TNK, SS, SourceLocation(),
1440 if (Tok.is(tok::annot_template_id) &&
1441 takeTemplateIdAnnotation(Tok)->mightBeType())
1447 if (Tok.isNot(tok::annot_typename))
1452 EndLocation = Tok.getAnnotationEndLoc();
1454 ConsumeAnnotationToken();
1459 IdentifierInfo *CorrectedII =
nullptr;
1461 *Id, IdLoc,
getCurScope(), &SS,
true,
false,
nullptr,
1467 Diag(IdLoc, diag::err_expected_class_name);
1472 EndLocation = IdLoc;
1475 DeclSpec DS(AttrFactory);
1480 const char *PrevSpec =
nullptr;
1483 Actions.getASTContext().getPrintingPolicy());
1487 return Actions.ActOnTypeName(DeclaratorInfo);
1490void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1491 while (Tok.isOneOf(tok::kw___single_inheritance,
1492 tok::kw___multiple_inheritance,
1493 tok::kw___virtual_inheritance)) {
1494 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
1495 auto Kind = Tok.getKind();
1497 attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0, Kind);
1502 while (Tok.is(tok::kw__Nullable)) {
1503 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
1504 auto Kind = Tok.getKind();
1506 attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0, Kind);
1510bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1512 switch (Tok.getKind()) {
1514 if (Tok.isRegularKeywordAttribute())
1521 case tok::identifier:
1523 case tok::coloncolon:
1524 case tok::annot_cxxscope:
1525 case tok::annot_typename:
1526 case tok::annot_template_id:
1527 case tok::kw_decltype:
1530 case tok::kw_operator:
1531 case tok::kw___declspec:
1536 case tok::kw___attribute:
1537 case tok::annot_pragma_pack:
1539 case tok::annot_pragma_ms_pragma:
1541 case tok::annot_pragma_ms_vtordisp:
1543 case tok::annot_pragma_ms_pointers_to_members:
1545 case tok::annot_pragma_export:
1548 return CouldBeBitfield ||
1550 ParsingGenericAssociationType;
1552 case tok::kw___cdecl:
1553 case tok::kw___fastcall:
1554 case tok::kw___stdcall:
1555 case tok::kw___thiscall:
1556 case tok::kw___vectorcall:
1562 case tok::kw_volatile:
1563 case tok::kw_restrict:
1564 case tok::kw__Atomic:
1565 case tok::kw___unaligned:
1569 case tok::kw_inline:
1570 case tok::kw_virtual:
1571 case tok::kw_friend:
1573 case tok::kw_static:
1574 case tok::kw_extern:
1575 case tok::kw_typedef:
1576 case tok::kw_register:
1578 case tok::kw_mutable:
1579 case tok::kw_thread_local:
1580 case tok::kw_constexpr:
1581 case tok::kw_consteval:
1582 case tok::kw_constinit:
1598 if (!isKnownToBeTypeSpecifier(
NextToken()))
1615 ParsedTemplateInfo &TemplateInfo,
1617 DeclSpecContext DSC,
1620 if (TagTokKind == tok::kw_struct)
1622 else if (TagTokKind == tok::kw___interface)
1624 else if (TagTokKind == tok::kw_class)
1627 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1631 if (Tok.is(tok::code_completion)) {
1634 Actions.CodeCompletion().CodeCompleteTag(
getCurScope(), TagType);
1645 const bool shouldDelayDiagsInTag =
1647 SuppressAccessChecks diagsFromTag(*
this, shouldDelayDiagsInTag);
1649 ParsedAttributes attrs(AttrFactory);
1652 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1654 if (Tok.isOneOf(tok::kw___single_inheritance,
1655 tok::kw___multiple_inheritance,
1656 tok::kw___virtual_inheritance)) {
1657 ParseMicrosoftInheritanceClassAttributes(attrs);
1660 if (Tok.is(tok::kw__Nullable)) {
1661 ParseNullabilityClassAttributes(attrs);
1669 SourceLocation AttrFixitLoc = Tok.getLocation();
1672 !Tok.isAnnotation() && Tok.getIdentifierInfo() &&
1675#include
"clang/Basic/BuiltinTraits.inc"
1676 tok::kw___is_abstract,
1677 tok::kw___is_aggregate,
1678 tok::kw___is_arithmetic,
1680 tok::kw___is_assignable,
1681 tok::kw___is_base_of,
1682 tok::kw___is_bounded_array,
1684 tok::kw___is_complete_type,
1685 tok::kw___is_compound,
1687 tok::kw___is_constructible,
1688 tok::kw___is_convertible,
1689 tok::kw___is_convertible_to,
1690 tok::kw___is_destructible,
1693 tok::kw___is_floating_point,
1695 tok::kw___is_function,
1696 tok::kw___is_fundamental,
1697 tok::kw___is_integral,
1698 tok::kw___is_interface_class,
1699 tok::kw___is_literal,
1700 tok::kw___is_lvalue_expr,
1701 tok::kw___is_lvalue_reference,
1702 tok::kw___is_member_function_pointer,
1703 tok::kw___is_member_object_pointer,
1704 tok::kw___is_member_pointer,
1705 tok::kw___is_nothrow_assignable,
1706 tok::kw___is_nothrow_constructible,
1707 tok::kw___is_nothrow_convertible,
1708 tok::kw___is_nothrow_destructible,
1709 tok::kw___is_object,
1711 tok::kw___is_pointer,
1712 tok::kw___is_polymorphic,
1713 tok::kw___is_reference,
1714 tok::kw___is_rvalue_expr,
1715 tok::kw___is_rvalue_reference,
1717 tok::kw___is_scalar,
1718 tok::kw___is_scoped_enum,
1719 tok::kw___is_sealed,
1720 tok::kw___is_signed,
1721 tok::kw___is_standard_layout,
1722 tok::kw___is_trivial,
1723 tok::kw___is_trivially_equality_comparable,
1724 tok::kw___is_trivially_assignable,
1725 tok::kw___is_trivially_constructible,
1726 tok::kw___is_trivially_copyable,
1727 tok::kw___is_unbounded_array,
1729 tok::kw___is_unsigned,
1731 tok::kw___is_volatile
1738 TryKeywordIdentFallback(
true);
1740 struct PreserveAtomicIdentifierInfoRAII {
1741 PreserveAtomicIdentifierInfoRAII(Token &
Tok,
bool Enabled)
1745 assert(
Tok.
is(tok::kw__Atomic));
1750 ~PreserveAtomicIdentifierInfoRAII() {
1753 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1755 IdentifierInfo *AtomicII;
1763 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1764 Tok.is(tok::kw__Atomic) &&
1766 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1767 Tok, ShouldChangeAtomicToIdentifier);
1771 CXXScopeSpec InvalidDeclScope;
1781 if (TemplateInfo.TemplateParams)
1784 bool HasValidSpec =
true;
1785 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1789 HasValidSpec =
false;
1792 if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id)) {
1793 Diag(Tok, diag::err_expected) << tok::identifier;
1794 HasValidSpec =
false;
1802 auto RecoverFromUndeclaredTemplateName = [&](IdentifierInfo *Name,
1803 SourceLocation NameLoc,
1804 SourceRange TemplateArgRange,
1805 bool KnownUndeclared) {
1806 Diag(NameLoc, diag::err_explicit_spec_non_template)
1808 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1812 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1813 if (TemplateParams->size() > 1) {
1814 TemplateParams->pop_back();
1816 TemplateParams =
nullptr;
1821 TemplateParams =
nullptr;
1823 TemplateInfo.TemplateLoc = SourceLocation();
1824 TemplateInfo.ExternLoc = SourceLocation();
1829 IdentifierInfo *Name =
nullptr;
1830 SourceLocation NameLoc;
1831 TemplateIdAnnotation *TemplateId =
nullptr;
1832 if (Tok.is(tok::identifier)) {
1833 Name = Tok.getIdentifierInfo();
1841 TemplateArgList TemplateArgs;
1842 SourceLocation LAngleLoc, RAngleLoc;
1843 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1847 LAngleLoc = RAngleLoc = SourceLocation();
1849 RecoverFromUndeclaredTemplateName(
1850 Name, NameLoc, SourceRange(LAngleLoc, RAngleLoc),
false);
1852 }
else if (Tok.is(tok::annot_template_id)) {
1853 TemplateId = takeTemplateIdAnnotation(Tok);
1854 NameLoc = ConsumeAnnotationToken();
1858 Actions.ActOnUndeclaredTypeTemplateName(
1861 RecoverFromUndeclaredTemplateName(
1864 TemplateId =
nullptr;
1872 SourceRange
Range(NameLoc);
1877 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1878 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1913 MaybeParseCXX11Attributes(Attributes);
1915 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1922 Tok.isOneOf(tok::comma, tok::ellipsis))
1925 AllowDefiningTypeSpec::No ||
1928 else if (Tok.is(tok::l_brace) ||
1929 (DSC != DeclSpecContext::DSC_association &&
1931 (isClassCompatibleKeyword() &&
1933 isClassCompatibleKeyword(
NextToken())))) {
1937 Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
1948 }
else if (isClassCompatibleKeyword() &&
1955 TentativeParsingAction PA(*
this);
1958 while (isClassCompatibleKeyword())
1963 if (Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square)) {
1967 }
else if (Tok.is(tok::kw_alignas) &&
NextToken().
is(tok::l_paren)) {
1972 }
else if (Tok.isRegularKeywordAttribute()) {
1977 if (!
T.consumeOpen())
1985 if (Tok.isOneOf(tok::l_brace, tok::colon))
1991 }
else if (!isTypeSpecifier(DSC) &&
1992 (Tok.is(tok::semi) ||
1993 (Tok.isAtStartOfLine() && !isValidAfterTypeSpecifier(
false)))) {
1995 if (Tok.isNot(tok::semi)) {
1996 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
1998 ExpectAndConsume(tok::semi, diag::err_expected_after,
2000 PP.EnterToken(Tok,
true);
2001 Tok.setKind(tok::semi);
2014 SourceRange AttrRange = Attributes.
Range;
2018 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2019 ?
Diag(Loc, diag::err_keyword_not_allowed) << FirstAttr
2020 :
Diag(Loc, diag::err_attributes_not_allowed))
2023 AttrFixitLoc, CharSourceRange(AttrRange,
true))
2032 if (!Name && !TemplateId &&
2037 Diag(StartLoc, diag::err_anon_type_definition)
2056 SkipBodyInfo SkipBody;
2070 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2071 diag::err_keyword_not_allowed,
2074 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2075 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2076 TagType, StartLoc, SS, TemplateId->
Template,
2083 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2084 diag::err_keyword_not_allowed,
2107 "Expected a definition here");
2111 TemplateParams =
nullptr;
2113 SourceLocation LAngleLoc =
2114 PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
2116 diag::err_explicit_instantiation_with_definition)
2117 << SourceRange(TemplateInfo.TemplateLoc)
2123 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
2124 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, {},
2125 LAngleLoc,
nullptr));
2126 TemplateParams = &FakedParamLists;
2131 TagOrTempResult = Actions.ActOnClassTemplateSpecialization(
2133 SS, *TemplateId, attrs,
2136 TemplateParams ? TemplateParams->size() : 0),
2146 ProhibitAttributes(attrs);
2148 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2149 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2150 TagType, StartLoc, SS, Name, NameLoc, attrs);
2153 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2154 diag::err_keyword_not_allowed,
2158 SourceLocation EllipsisLoc;
2170 if (Tok.is(tok::comma)) {
2171 Diag(Tok.getLocation(),
2172 diag::err_friend_template_decl_multiple_specifiers);
2181 TagOrTempResult = Actions.ActOnTemplatedFriendTag(
2183 NameLoc, EllipsisLoc, attrs,
2185 TemplateParams ? TemplateParams->size() : 0),
2189 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2190 diag::err_keyword_not_allowed,
2197 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2199 TemplateParams =
nullptr;
2202 bool IsDependent =
false;
2212 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2215 TagOrTempResult = Actions.ActOnTag(
2216 getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, AS,
2219 DSC == DeclSpecContext::DSC_type_specifier,
2220 DSC == DeclSpecContext::DSC_template_param ||
2221 DSC == DeclSpecContext::DSC_template_type_arg,
2222 OffsetOfState, &SkipBody);
2229 Name, StartLoc, NameLoc);
2236 if (shouldDelayDiagsInTag) {
2237 diagsFromTag.done();
2240 diagsFromTag.redelay();
2245 assert(Tok.is(tok::l_brace) ||
2247 isClassCompatibleKeyword());
2249 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc, TagType,
2250 TagOrTempResult.
get());
2252 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs, TagType,
2253 TagOrTempResult.
get());
2261 TagOrTempResult.
get(), SkipBody)) {
2270 Actions.ProcessDeclAttributeDelayed(TagOrTempResult.
get(), attrs);
2272 const char *PrevSpec =
nullptr;
2277 NameLoc.
isValid() ? NameLoc : StartLoc,
2279 }
else if (!TagOrTempResult.
isInvalid()) {
2281 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2282 DiagID, TagOrTempResult.
get(), Owned, Policy);
2289 Diag(StartLoc, DiagID) << PrevSpec;
2306 if (Tok.isNot(tok::semi)) {
2307 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
2308 ExpectAndConsume(tok::semi, diag::err_expected_after,
2313 PP.EnterToken(Tok,
true);
2314 Tok.setKind(tok::semi);
2319void Parser::ParseBaseClause(
Decl *ClassDecl) {
2320 assert(Tok.is(tok::colon) &&
"Not a base clause");
2324 SmallVector<CXXBaseSpecifier *, 8> BaseInfo;
2329 if (!
Result.isUsable()) {
2335 BaseInfo.push_back(
Result.get());
2345 Actions.ActOnBaseSpecifiers(ClassDecl, BaseInfo);
2349 bool IsVirtual =
false;
2350 SourceLocation StartLoc = Tok.getLocation();
2352 ParsedAttributes Attributes(AttrFactory);
2353 MaybeParseCXX11Attributes(Attributes);
2359 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2366 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
2369 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2373 if (Tok.is(tok::kw_virtual)) {
2377 Diag(VirtualLoc, diag::err_dup_virtual)
2385 Diag(Tok.getLocation(), diag::err_hlsl_virtual_inheritance);
2387 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2395 if (
getLangOpts().MSVCCompat && Tok.is(tok::kw__Atomic) &&
2397 Tok.setKind(tok::identifier);
2399 SourceLocation EndLocation;
2400 SourceLocation BaseLoc;
2401 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2408 SourceLocation EllipsisLoc;
2412 SourceRange
Range(StartLoc, EndLocation);
2416 return Actions.ActOnBaseSpecifier(ClassDecl, Range, Attributes, IsVirtual,
2417 Access, BaseType.
get(), BaseLoc,
2422 switch (Tok.getKind()) {
2425 case tok::kw_private:
2427 case tok::kw_protected:
2429 case tok::kw_public:
2434void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2441 if (!NeedLateParse) {
2443 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx) {
2445 if (Param->hasUnparsedDefaultArg()) {
2446 NeedLateParse =
true;
2452 if (NeedLateParse) {
2455 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2456 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2461 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2462 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx)
2463 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2479 const IdentifierInfo *II = Tok.getIdentifierInfo();
2483 Ident_final = &PP.getIdentifierTable().get(
"final");
2485 Ident_GNU_final = &PP.getIdentifierTable().get(
"__final");
2487 Ident_sealed = &PP.getIdentifierTable().get(
"sealed");
2488 Ident_abstract = &PP.getIdentifierTable().get(
"abstract");
2490 Ident_override = &PP.getIdentifierTable().get(
"override");
2493 if (II == Ident_override)
2496 if (II == Ident_sealed)
2499 if (II == Ident_abstract)
2502 if (II == Ident_final)
2505 if (II == Ident_GNU_final)
2511void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2520 Diag(Tok.getLocation(), diag::err_friend_decl_spec)
2523 << SourceRange(FriendLoc, FriendLoc);
2530 const char *PrevSpec =
nullptr;
2531 if (VS.
SetSpecifier(Specifier, Tok.getLocation(), PrevSpec))
2532 Diag(Tok.getLocation(), diag::err_duplicate_virt_specifier)
2537 Diag(Tok.getLocation(), diag::err_override_control_interface)
2540 Diag(Tok.getLocation(), diag::ext_ms_sealed_keyword);
2542 Diag(Tok.getLocation(), diag::ext_ms_abstract_keyword);
2544 Diag(Tok.getLocation(), diag::ext_warn_gnu_final);
2546 DiagCompat(Tok.getLocation(), diag_compat::override_control_keyword)
2553bool Parser::isCXX11FinalKeyword()
const {
2560bool Parser::isClassCompatibleKeyword(
Token Tok)
const {
2568bool Parser::isClassCompatibleKeyword()
const {
2569 return isClassCompatibleKeyword(Tok);
2574bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2587 if (Tok.isNot(tok::colon))
2588 ParseDeclarator(DeclaratorInfo);
2593 if (!IsFunctionDeclarator && !
getLangOpts().MSVCCompat)
2594 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2597 MaybeParseHLSLAnnotations(DeclaratorInfo,
nullptr,
2602 "don't know where identifier would go yet?");
2606 }
else if (Tok.is(tok::kw_requires)) {
2607 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
2612 ++CurTemplateDepthTracker;
2613 ParseTrailingRequiresClauseWithScope(DeclaratorInfo);
2615 ParseOptionalCXX11VirtSpecifierSeq(
2616 VS, getCurrentClass().IsInterface,
2619 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2624 if (Tok.is(tok::kw_asm)) {
2626 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2627 if (AsmLabel.isInvalid())
2637 DiagnoseAndSkipCXX11Attributes();
2638 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2639 DiagnoseAndSkipCXX11Attributes();
2644 ParseOptionalCXX11VirtSpecifierSeq(
2645 VS, getCurrentClass().IsInterface,
2651 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2652 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2654 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2669void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2671 DeclSpec DS(AttrFactory);
2675 ParseTypeQualifierListOpt(
2676 DS, AR_NoAttributesParsed,
false,
2678 Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
2685 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2686 SourceLocation SpecLoc) {
2687 FixItHint Insertion;
2688 auto &MQ =
Function.getOrCreateMethodQualifiers();
2689 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2690 std::string Name(FixItName.data());
2693 MQ.SetTypeQual(TypeQual, SpecLoc);
2695 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2704 bool RefQualifierIsLValueRef =
true;
2705 SourceLocation RefQualifierLoc;
2706 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2707 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2708 FixItHint Insertion =
2710 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2711 Function.RefQualifierLoc = RefQualifierLoc;
2713 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2714 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2726 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2727 if (Tok.is(tok::at)) {
2729 Diag(Tok, diag::err_at_defs_cxx);
2731 Diag(Tok, diag::err_at_in_class);
2747 bool MalformedTypeSpec =
false;
2749 Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2751 MalformedTypeSpec =
true;
2754 if (Tok.isNot(tok::annot_cxxscope))
2755 isAccessDecl =
false;
2764 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2774 SourceLocation TemplateKWLoc;
2777 false,
false,
true,
true,
2778 false, &TemplateKWLoc, Name)) {
2784 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2785 "access declaration")) {
2793 SourceLocation(), SS, Name,
2795 ParsedAttributesView())));
2802 Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2803 SourceLocation DeclEnd;
2805 DeclGroupRef(ParseStaticAssertDeclaration(DeclEnd)));
2808 if (Tok.is(tok::kw_template)) {
2809 assert(!TemplateInfo.TemplateParams &&
2810 "Nested template improperly parsed?");
2811 ObjCDeclContextSwitch ObjCDC(*
this);
2812 SourceLocation DeclEnd;
2814 DeclEnd, AccessAttrs, AS);
2818 if (Tok.is(tok::kw___extension__)) {
2820 ExtensionRAIIObject O(Diags);
2822 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2826 ParsedAttributes DeclAttrs(AttrFactory);
2828 MaybeParseCXX11Attributes(DeclAttrs);
2833 if (Tok.is(tok::annot_attr_openmp))
2834 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
2836 if (Tok.is(tok::kw_using)) {
2841 while (Tok.is(tok::kw_template)) {
2843 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
2847 if (Tok.is(tok::kw_namespace)) {
2848 Diag(UsingLoc, diag::err_using_namespace_in_class);
2852 SourceLocation DeclEnd;
2855 UsingLoc, DeclEnd, DeclAttrs, AS);
2858 ParsedAttributes DeclSpecAttrs(AttrFactory);
2860 LateParsedAttrList CommonLateParsedAttrs;
2862 while (MaybeParseCXX11Attributes(DeclAttrs) ||
2863 MaybeParseGNUAttributes(DeclSpecAttrs, &CommonLateParsedAttrs) ||
2864 MaybeParseMicrosoftAttributes(DeclSpecAttrs))
2867 SourceLocation DeclStart;
2868 if (DeclAttrs.Range.isValid()) {
2869 DeclStart = DeclSpecAttrs.Range.
isInvalid()
2870 ? DeclAttrs.Range.getBegin()
2871 : std::min(DeclAttrs.Range.getBegin(),
2872 DeclSpecAttrs.Range.getBegin());
2874 DeclStart = DeclSpecAttrs.Range.getBegin();
2879 ParsingDeclSpec DS(*
this, TemplateDiags);
2882 if (MalformedTypeSpec)
2890 bool IsTemplateSpecOrInst =
2893 SuppressAccessChecks diagsFromTag(*
this, IsTemplateSpecOrInst);
2895 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
2896 &CommonLateParsedAttrs);
2898 if (IsTemplateSpecOrInst)
2899 diagsFromTag.done();
2911 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
2912 &CommonLateParsedAttrs))
2916 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
2918 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
2922 ProhibitAttributes(DeclAttrs);
2924 RecordDecl *AnonRecord =
nullptr;
2925 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(
2926 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
2927 Actions.ActOnDefinedDeclarationSpecifier(TheDecl);
2928 DS.complete(TheDecl);
2930 Decl *decls[] = {AnonRecord, TheDecl};
2931 return Actions.BuildDeclaratorGroup(decls);
2933 return Actions.ConvertDeclToDeclGroup(TheDecl);
2937 Actions.ActOnDefinedDeclarationSpecifier(DS.
getRepAsDecl());
2942 DiagCompat(Tok.getLocation(), diag_compat::variadic_friends);
2945 SmallVector<Decl *> Decls;
2948 auto ParsedFriendDecl = [&](ParsingDeclSpec &DeclSpec) {
2949 SourceLocation VariadicLoc;
2952 RecordDecl *AnonRecord =
nullptr;
2953 Decl *D = Actions.ParsedFreeStandingDeclSpec(
2954 getCurScope(), AS, DeclSpec, DeclAttrs, TemplateParams,
false,
2955 AnonRecord, VariadicLoc);
2956 DeclSpec.complete(D);
2966 if (ParsedFriendDecl(DS))
2970 ParsingDeclSpec DeclSpec(*
this, TemplateDiags);
2971 const char *PrevSpec =
nullptr;
2972 unsigned DiagId = 0;
2973 DeclSpec.SetFriendSpec(FriendLoc, PrevSpec, DiagId);
2974 ParseDeclarationSpecifiers(DeclSpec, TemplateInfo, AS,
2975 DeclSpecContext::DSC_class,
nullptr);
2976 if (ParsedFriendDecl(DeclSpec))
2980 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_stmt,
2981 "friend declaration");
2983 return Actions.BuildDeclaratorGroup(Decls);
2989 if (Tok.is(tok::kw_concept)) {
2993 ? llvm::to_underlying(diag::err_friend_concept)
2994 : llvm::to_underlying(
2996 err_concept_decls_may_only_appear_in_global_namespace_scope));
3001 ParsingDeclarator DeclaratorInfo(*
this, DS, DeclAttrs,
3003 if (TemplateInfo.TemplateParams)
3008 LateParsedAttrList LateParsedAttrs;
3010 SourceLocation EqualLoc;
3011 SourceLocation PureSpecLoc;
3013 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
3014 if (Tok.isNot(tok::equal))
3018 SmallString<8> Buffer;
3019 if (
Zero.isNot(tok::numeric_constant) ||
3020 PP.getSpelling(
Zero, Buffer) !=
"0")
3024 if (!
After.isOneOf(tok::semi, tok::comma) &&
3025 !(AllowDefinition &&
3026 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3034 SmallVector<Decl *, 8> DeclsInGroup;
3037 bool ExpectSemi =
true;
3042 SuppressAccessChecks SAC(*
this, IsTemplateSpecOrInst);
3045 if (ParseCXXMemberDeclaratorBeforeInitializer(
3046 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3051 if (IsTemplateSpecOrInst)
3059 TryConsumePureSpecifier(
true);
3070 if (Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3072 }
else if (Tok.is(tok::equal)) {
3074 if (KW.
is(tok::kw_default))
3076 else if (KW.
is(tok::kw_delete))
3078 else if (KW.
is(tok::code_completion)) {
3080 Actions.CodeCompletion().CodeCompleteAfterFunctionEquals(
3095 ProhibitAttributes(DeclAttrs);
3112 diag::err_function_declared_typedef);
3118 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3119 TemplateInfo, VS, PureSpecLoc);
3122 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3123 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3125 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3126 LateParsedAttrs[i]->addDecl(FunDecl);
3129 LateParsedAttrs.clear();
3132 if (Tok.is(tok::semi))
3145 bool HasStaticInitializer =
false;
3146 if (Tok.isOneOf(tok::equal, tok::l_brace) && PureSpecLoc.
isInvalid()) {
3150 Diag(Tok, diag::err_anon_bitfield_member_init);
3154 if (!TryConsumePureSpecifier(
false))
3156 HasStaticInitializer =
true;
3164 if (BitfieldSize.
get())
3165 DiagCompat(Tok, diag_compat::bitfield_member_init);
3168 HasStaticInitializer =
true;
3176 NamedDecl *ThisDecl =
nullptr;
3184 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3185 auto Loc = AL.getRange().getBegin();
3186 (AL.isRegularKeywordAttribute()
3187 ?
Diag(Loc, diag::err_keyword_not_allowed) << AL
3188 :
Diag(Loc, diag::err_attributes_not_allowed))
3192 ThisDecl = Actions.ActOnFriendFunctionDecl(
getCurScope(), DeclaratorInfo,
3195 ThisDecl = Actions.ActOnCXXMemberDeclarator(
3196 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3197 VS, HasInClassInit);
3199 if (VarTemplateDecl *VT =
3200 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3203 ThisDecl = VT->getTemplatedDecl();
3206 Actions.ProcessDeclAttributeList(
getCurScope(), ThisDecl, AccessAttrs);
3215 HasStaticInitializer =
true;
3219 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3221 if (ThisDecl && PureSpecLoc.
isValid())
3222 Actions.ActOnPureSpecifier(ThisDecl, PureSpecLoc);
3229 DiagCompat(Tok, diag_compat::nonstatic_member_init);
3237 Diag(Tok, diag::err_incomplete_array_member_init);
3244 ParseCXXNonStaticMemberInitializer(ThisDecl);
3245 }
else if (HasStaticInitializer) {
3250 if (
Init.isInvalid()) {
3252 Actions.ActOnUninitializedDecl(ThisDecl);
3254 }
else if (ThisDecl)
3255 Actions.AddInitializerToDecl(ThisDecl,
Init.get(),
3259 Actions.ActOnUninitializedDecl(ThisDecl);
3264 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3265 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3267 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3268 LateParsedAttrs[i]->addDecl(ThisDecl);
3270 Actions.FinalizeDeclaration(ThisDecl);
3271 DeclsInGroup.push_back(ThisDecl);
3276 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3278 LateParsedAttrs.clear();
3280 DeclaratorInfo.complete(ThisDecl);
3284 SourceLocation CommaLoc;
3288 if (Tok.isAtStartOfLine() &&
3293 Diag(CommaLoc, diag::err_expected_semi_declaration)
3305 Diag(CommaLoc, diag::err_multiple_template_declarators)
3306 << TemplateInfo.Kind;
3310 DeclaratorInfo.
clear();
3313 EqualLoc = PureSpecLoc = SourceLocation();
3319 DiagnoseAndSkipCXX11Attributes();
3320 MaybeParseGNUAttributes(DeclaratorInfo);
3321 DiagnoseAndSkipCXX11Attributes();
3323 if (ParseCXXMemberDeclaratorBeforeInitializer(
3324 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3329 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list) &&
3330 !isLikelyAtStartOfNewDeclaration()) {
3338 return Actions.FinalizeDeclaratorGroup(
getCurScope(), DS, DeclsInGroup);
3341ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
3343 assert(Tok.isOneOf(tok::equal, tok::l_brace) &&
3344 "Data member initializer not starting with '=' or '{'");
3346 bool IsFieldInitialization = isa_and_present<FieldDecl>(D);
3348 EnterExpressionEvaluationContext Context(
3350 IsFieldInitialization
3358 Actions.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
3359 IsFieldInitialization;
3362 if (Tok.is(tok::kw_delete)) {
3369 if (IsFunction ||
Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3375 SkipDeletedFunctionBody();
3378 }
else if (Tok.is(tok::kw_default)) {
3380 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3388 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
3389 Diag(Tok, diag::err_ms_property_initializer) << PD;
3392 return ParseInitializer(D);
3399 while (isClassCompatibleKeyword())
3404 ParsedAttributes Attrs(AttrFactory);
3405 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3410 if (Tok.isNot(tok::colon) && Tok.isNot(tok::l_brace))
3416 if (Tok.is(tok::colon)) {
3419 ParsingClassDefinition ParsingDef(*
this, TagDecl,
true,
3422 Actions.ActOnTagStartSkippedDefinition(
getCurScope(), TagDecl);
3425 ParseBaseClause(
nullptr);
3427 Actions.ActOnTagFinishSkippedDefinition(OldContext);
3429 if (!Tok.is(tok::l_brace)) {
3430 Diag(PP.getLocForEndOfToken(PrevTokLocation),
3431 diag::err_expected_lbrace_after_base_specifiers);
3437 assert(Tok.is(tok::l_brace));
3443 if (Tok.is(tok::kw___attribute)) {
3444 ParsedAttributes Attrs(AttrFactory);
3445 MaybeParseGNUAttributes(Attrs);
3454 switch (Tok.getKind()) {
3455 case tok::kw___if_exists:
3456 case tok::kw___if_not_exists:
3457 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, AS);
3466 case tok::annot_pragma_vis:
3467 HandlePragmaVisibility();
3469 case tok::annot_pragma_pack:
3472 case tok::annot_pragma_align:
3473 HandlePragmaAlign();
3475 case tok::annot_pragma_ms_pointers_to_members:
3476 HandlePragmaMSPointersToMembers();
3478 case tok::annot_pragma_ms_pragma:
3479 HandlePragmaMSPragma();
3481 case tok::annot_pragma_ms_vtordisp:
3482 HandlePragmaMSVtorDisp();
3484 case tok::annot_pragma_export:
3485 HandlePragmaExport();
3487 case tok::annot_pragma_dump:
3491 case tok::kw_namespace:
3496 case tok::kw_private:
3500 ParsedTemplateInfo TemplateInfo;
3501 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3504 case tok::kw_public:
3505 case tok::kw_protected: {
3507 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
3512 SourceLocation ASLoc = Tok.getLocation();
3513 unsigned TokLength = Tok.getLength();
3515 AccessAttrs.
clear();
3516 MaybeParseGNUAttributes(AccessAttrs);
3518 SourceLocation EndLoc;
3521 Diag(EndLoc, diag::err_expected)
3525 Diag(EndLoc, diag::err_expected)
3535 if (Actions.ActOnAccessSpecifier(NewAS, ASLoc, EndLoc, AccessAttrs)) {
3537 AccessAttrs.
clear();
3543 case tok::annot_attr_openmp:
3544 case tok::annot_pragma_openmp:
3545 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3546 AS, AccessAttrs,
true, TagType, TagDecl);
3547 case tok::annot_pragma_openacc:
3552 Diag(Tok.getLocation(), diag::err_pragma_misplaced_in_decl)
3554 TagType, Actions.getASTContext().getPrintingPolicy());
3555 ConsumeAnnotationToken();
3558 ParsedTemplateInfo TemplateInfo;
3559 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3570 "Invalid TagType!");
3572 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3573 if (
auto *TD = dyn_cast_or_null<NamedDecl>(TagDecl))
3574 return TD->getQualifiedNameAsString();
3575 return std::string(
"<anonymous>");
3578 PrettyDeclStackTraceEntry CrashInfo(Actions.Context, TagDecl,
RecordLoc,
3579 "parsing struct/union/class body");
3583 bool NonNestedClass =
true;
3584 if (!ClassStack.empty()) {
3586 if (S->isClassScope()) {
3588 NonNestedClass =
false;
3591 if (getCurrentClass().IsInterface) {
3601 if (S->isFunctionScope())
3612 ParsingClassDefinition ParsingDef(*
this, TagDecl, NonNestedClass,
3616 Actions.ActOnTagStartDefinition(
getCurScope(), TagDecl);
3618 SourceLocation FinalLoc;
3619 SourceLocation AbstractLoc;
3620 bool IsFinalSpelledSealed =
false;
3621 bool IsAbstract =
false;
3630 if (isCXX11FinalKeyword()) {
3633 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3638 IsFinalSpelledSealed =
true;
3643 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3651 Diag(FinalLoc, diag::err_override_control_interface)
3654 DiagCompat(FinalLoc, diag_compat::override_control_keyword)
3657 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3659 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3661 Diag(FinalLoc, diag::ext_warn_gnu_final);
3664 "not a class definition");
3670 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3679 if (!Tok.is(tok::colon) && !Tok.is(tok::l_brace)) {
3681 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3686 if (Tok.is(tok::colon)) {
3690 ParseBaseClause(TagDecl);
3691 if (!Tok.is(tok::l_brace)) {
3692 bool SuggestFixIt =
false;
3693 SourceLocation BraceLoc = PP.getLocForEndOfToken(PrevTokLocation);
3694 if (Tok.isAtStartOfLine()) {
3695 switch (Tok.getKind()) {
3696 case tok::kw_private:
3697 case tok::kw_protected:
3698 case tok::kw_public:
3701 case tok::kw_static_assert:
3705 case tok::kw_template:
3706 SuggestFixIt =
true;
3708 case tok::identifier:
3709 SuggestFixIt = isConstructorDeclarator(
true);
3712 SuggestFixIt = isCXXSimpleDeclaration(
false);
3716 DiagnosticBuilder LBraceDiag =
3717 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3721 PP.EnterToken(Tok,
true);
3722 Tok.setKind(tok::l_brace);
3725 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3731 assert(Tok.is(tok::l_brace));
3736 Actions.ActOnStartCXXMemberDeclarations(
getCurScope(), TagDecl, FinalLoc,
3737 IsFinalSpelledSealed, IsAbstract,
3738 T.getOpenLocation());
3749 ParsedAttributes AccessAttrs(AttrFactory);
3753 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
3754 Tok.isNot(tok::eof)) {
3756 ParseCXXClassMemberDeclarationWithPragmas(
3757 CurAS, AccessAttrs,
static_cast<DeclSpec::TST>(TagType), TagDecl);
3758 MaybeDestroyTemplateIds();
3766 ParsedAttributes attrs(AttrFactory);
3767 MaybeParseGNUAttributes(attrs);
3771 T.getOpenLocation(),
3772 T.getCloseLocation(), attrs);
3779 if (TagDecl && NonNestedClass) {
3785 SourceLocation SavedPrevTokLocation = PrevTokLocation;
3786 ParseLexedPragmas(getCurrentClass());
3787 ParseLexedAttributes(getCurrentClass());
3788 ParseLexedMethodDeclarations(getCurrentClass());
3791 Actions.ActOnFinishCXXMemberDecls();
3793 ParseLexedMemberInitializers(getCurrentClass());
3794 ParseLexedMethodDefs(getCurrentClass());
3795 PrevTokLocation = SavedPrevTokLocation;
3799 Actions.ActOnFinishCXXNonNestedClass();
3803 Actions.ActOnTagFinishDefinition(
getCurScope(), TagDecl,
T.getRange());
3810void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3811 assert(Tok.is(tok::kw_namespace));
3816 Diag(Tok.getLocation(), diag::note_missing_end_of_definition_before) << D;
3819 PP.EnterToken(Tok,
true);
3821 Tok =
Token::create(tok::semi, PP.getLocForEndOfToken(PrevTokLocation));
3822 PP.EnterToken(Tok,
true);
3824 Tok.setKind(tok::r_brace);
3827void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3828 assert(Tok.is(tok::colon) &&
3829 "Constructor initializer always starts with ':'");
3836 SmallVector<CXXCtorInitializer *, 4> MemInitializers;
3837 bool AnyErrors =
false;
3840 if (Tok.is(tok::code_completion)) {
3842 Actions.CodeCompletion().CodeCompleteConstructorInitializer(
3843 ConstructorDecl, MemInitializers);
3847 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3849 MemInitializers.push_back(MemInit.
get());
3853 if (Tok.is(tok::comma))
3855 else if (Tok.is(tok::l_brace))
3860 Tok.isOneOf(tok::identifier, tok::coloncolon)) {
3861 SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
3862 Diag(Loc, diag::err_ctor_init_missing_comma)
3867 Diag(Tok.getLocation(), diag::err_expected_either)
3868 << tok::l_brace << tok::comma;
3874 Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc, MemInitializers,
3881 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
3887 IdentifierInfo *II =
nullptr;
3888 SourceLocation IdLoc = Tok.getLocation();
3890 DeclSpec DS(AttrFactory);
3894 if (Tok.is(tok::identifier)) {
3897 II = Tok.getIdentifierInfo();
3899 }
else if (Tok.is(tok::annot_decltype)) {
3904 ParseDecltypeSpecifier(DS);
3905 }
else if (Tok.is(tok::annot_pack_indexing_type)) {
3908 ParsePackIndexingType(DS);
3910 TemplateIdAnnotation *TemplateId = Tok.is(tok::annot_template_id)
3911 ? takeTemplateIdAnnotation(Tok)
3916 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
3918 ConsumeAnnotationToken();
3920 Diag(Tok, diag::err_expected_member_or_base_name);
3927 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
3930 ExprResult InitList = ParseBraceInitializer();
3934 SourceLocation EllipsisLoc;
3939 return Actions.ActOnMemInitializer(ConstructorDecl,
getCurScope(), SS, II,
3940 TemplateTypeTy.
get(), DS, IdLoc,
3941 InitList.
get(), EllipsisLoc);
3942 }
else if (Tok.is(tok::l_paren)) {
3947 ExprVector ArgExprs;
3948 auto RunSignatureHelp = [&] {
3951 QualType PreferredType =
3952 Actions.CodeCompletion().ProduceCtorInitMemberSignatureHelp(
3953 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
3954 T.getOpenLocation(),
false);
3955 CalledSignatureHelp =
true;
3956 return PreferredType;
3958 if (Tok.isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
3959 PreferredType.enterFunctionArgument(Tok.getLocation(),
3962 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
3970 SourceLocation EllipsisLoc;
3975 return Actions.ActOnMemInitializer(
3976 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
3977 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
3984 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
3986 return Diag(Tok, diag::err_expected) << tok::l_paren;
3995 ExceptionSpecTokens =
nullptr;
3999 if (Tok.isNot(tok::kw_throw) && Tok.isNot(tok::kw_noexcept))
4003 bool IsNoexcept = Tok.is(tok::kw_noexcept);
4004 Token StartTok = Tok;
4008 if (!Tok.is(tok::l_paren)) {
4011 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4012 NoexceptExpr =
nullptr;
4016 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4022 ExceptionSpecTokens->push_back(StartTok);
4023 ExceptionSpecTokens->push_back(Tok);
4024 SpecificationRange.
setEnd(ConsumeParen());
4026 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4029 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4035 if (Tok.is(tok::kw_throw)) {
4036 Result = ParseDynamicExceptionSpecification(
4037 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4038 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4039 "Produced different number of exception types and ranges.");
4043 if (Tok.isNot(tok::kw_noexcept))
4046 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4050 SourceRange NoexceptRange;
4054 if (Tok.is(tok::l_paren)) {
4059 EnterExpressionEvaluationContext ConstantEvaluated(
4066 Actions.ActOnNoexceptSpec(NoexceptExpr.
get(), NoexceptType);
4067 NoexceptRange = SourceRange(KeywordLoc,
T.getCloseLocation());
4074 NoexceptRange = SourceRange(KeywordLoc, KeywordLoc);
4078 SpecificationRange = NoexceptRange;
4083 if (Tok.is(tok::kw_throw)) {
4084 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4085 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4086 DynamicExceptionRanges);
4089 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4098 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4100 ? diag::ext_dynamic_exception_spec
4101 : diag::warn_exception_spec_deprecated)
4103 P.
Diag(Range.getBegin(), diag::note_exception_spec_deprecated)
4111 assert(Tok.is(tok::kw_throw) &&
"expected throw");
4115 if (
T.consumeOpen()) {
4116 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4123 if (Tok.is(tok::ellipsis)) {
4126 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4128 SpecificationRange.
setEnd(
T.getCloseLocation());
4135 while (Tok.isNot(tok::r_paren)) {
4138 if (Tok.is(tok::ellipsis)) {
4143 Range.setEnd(Ellipsis);
4144 if (!Res.isInvalid())
4145 Res = Actions.ActOnPackExpansion(Res.get(), Ellipsis);
4148 if (!Res.isInvalid()) {
4149 Exceptions.push_back(Res.get());
4150 Ranges.push_back(Range);
4158 SpecificationRange.
setEnd(
T.getCloseLocation());
4160 Exceptions.empty());
4165 bool MayBeFollowedByDirectInit) {
4166 assert(Tok.is(tok::arrow) &&
"expected arrow");
4175void Parser::ParseTrailingRequiresClauseWithScope(
Declarator &D) {
4176 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4192 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4194 DeclScopeObj.EnterDeclaratorScope();
4200 ParseTrailingRequiresClause(D);
4203void Parser::ParseTrailingRequiresClause(
Declarator &D) {
4204 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4207 "trailing requires-clause must be parsed in a function prototype scope");
4212 Actions.ActOnStartTrailingRequiresClause(
getCurScope(), D);
4214 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4215 InitCXXThisScopeForDeclaratorIfRelevant(D, D.
getDeclSpec(), ThisScope);
4217 TrailingRequiresClause =
4220 TrailingRequiresClause =
4221 Actions.ActOnFinishTrailingRequiresClause(TrailingRequiresClause);
4225 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4230 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4238 SourceLocation ArrowLoc = Tok.getLocation();
4241 ParseTrailingReturnType(Range,
false);
4245 diag::err_requires_clause_must_appear_after_trailing_return)
4250 FunctionChunk.TrailingReturnTypeLoc =
Range.getBegin();
4252 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4258 bool NonNestedClass,
4260 assert((NonNestedClass || !ClassStack.empty()) &&
4261 "Nested class without outer class");
4262 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4263 return Actions.PushParsingClass();
4266void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4267 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4268 delete Class->LateParsedDeclarations[I];
4273 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4275 Actions.PopParsingClass(state);
4277 ParsingClass *Victim = ClassStack.top();
4279 if (Victim->TopLevelClass) {
4282 DeallocateParsedClasses(Victim);
4285 assert(!ClassStack.empty() &&
"Missing top-level class?");
4287 if (Victim->LateParsedDeclarations.empty()) {
4292 DeallocateParsedClasses(Victim);
4300 "Nested class outside of class scope?");
4301 ClassStack.top()->LateParsedDeclarations.push_back(
4302 new LateParsedClass(
this, Victim));
4308 switch (Tok.getKind()) {
4311 if (!Tok.isAnnotation()) {
4312 if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
4319 case tok::code_completion:
4321 Actions.CodeCompletion().CodeCompleteAttribute(
4326 case tok::numeric_constant: {
4330 if (Tok.getLocation().isMacroID()) {
4331 SmallString<8> ExpansionBuf;
4332 SourceLocation ExpansionLoc =
4333 PP.getSourceManager().getExpansionLoc(Tok.getLocation());
4334 StringRef Spelling = PP.getSpelling(ExpansionLoc, ExpansionBuf);
4335 if (Spelling ==
"__clang__") {
4336 SourceRange TokRange(
4338 PP.getSourceManager().getExpansionLoc(Tok.getEndLoc()));
4339 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4342 return &PP.getIdentifierTable().get(
"_Clang");
4355 case tok::pipeequal:
4356 case tok::caretequal:
4358 case tok::exclaimequal:
4361 SmallString<8> SpellingBuf;
4362 SourceLocation SpellingLoc =
4363 PP.getSourceManager().getSpellingLoc(Tok.getLocation());
4364 StringRef Spelling = PP.getSpelling(SpellingLoc, SpellingBuf);
4367 return &PP.getIdentifierTable().get(Spelling);
4373void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4378 if (
T.consumeOpen()) {
4379 Diag(Tok, diag::err_expected) << tok::l_paren;
4383 if (
AttrName->isStr(
"directive")) {
4389 OpenMPTokens.push_back(OMPBeginTok);
4391 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4395 OpenMPTokens.push_back(OMPEndTok);
4397 assert(
AttrName->isStr(
"sequence") &&
4398 "Expected either 'directive' or 'sequence'");
4406 SourceLocation IdentLoc;
4407 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4411 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4412 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4416 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4417 Diag(Tok.getLocation(), diag::err_expected_sequence_or_directive);
4423 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4437 case ParsedAttr::AT_Deprecated:
4438 case ParsedAttr::AT_FallThrough:
4439 case ParsedAttr::AT_CXX11NoReturn:
4440 case ParsedAttr::AT_NoUniqueAddress:
4441 case ParsedAttr::AT_Likely:
4442 case ParsedAttr::AT_Unlikely:
4444 case ParsedAttr::AT_WarnUnusedResult:
4445 return !ScopeName && AttrName->getName() ==
"nodiscard";
4446 case ParsedAttr::AT_Unused:
4447 return !ScopeName && AttrName->getName() ==
"maybe_unused";
4453bool Parser::ParseCXXAssumeAttributeArg(
4457 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4465 TentativeParsingAction TPA(*
this);
4470 if (Tok.is(tok::r_paren))
4475 if (!Tok.isOneOf(tok::r_paren, tok::r_square)) {
4481 auto *E = Res.
get();
4482 Diag(E->getExprLoc(), diag::err_assume_attr_expects_cond_expr)
4486 << E->getSourceRange();
4495 auto RParen = Tok.getLocation();
4497 Attrs.
addNew(AttrName, SourceRange(AttrNameLoc, RParen),
4498 AttributeScopeInfo(ScopeName, ScopeLoc), &Assumption, 1, Form);
4506bool Parser::ParseCXX11AttributeArgs(
4510 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4511 SourceLocation LParenLoc = Tok.getLocation();
4513 ParsedAttr::Form Form =
4514 LO.CPlusPlus ? ParsedAttr::Form::CXX11() : ParsedAttr::Form::
C23();
4520 Form = ParsedAttr::Form::Microsoft();
4524 TentativeParsingAction TPA(*this);
4525 bool HasInvalidArgument = false;
4526 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof)) {
4527 if (Tok.isOneOf(tok::hash, tok::hashhash)) {
4528 Diag(Tok.getLocation(), diag::ext_invalid_attribute_argument)
4529 << PP.getSpelling(Tok);
4530 HasInvalidArgument = true;
4535 if (HasInvalidArgument) {
4549 ScopeName, AttrName, getTargetInfo(), getLangOpts())) {
4552 SkipUntil(tok::r_paren);
4556 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4559 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4560 ScopeLoc, Form, nullptr);
4565 if (ScopeName && ScopeName->
isStr(
"omp") &&
4567 Diag(AttrNameLoc, getLangOpts().OpenMP >= 51
4568 ? diag::warn_omp51_compat_attributes
4569 : diag::ext_omp_attributes);
4571 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4580 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4581 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4582 ScopeName, ScopeLoc, Form);
4584 else if (!ScopeName &&
AttrName->isStr(
"assume")) {
4585 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, nullptr,
4586 SourceLocation{}, EndLoc, Form))
4590 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4591 ScopeName, ScopeLoc, Form);
4593 if (!Attrs.
empty() &&
4598 if (!
Attr.existsInTarget(getTargetInfo())) {
4599 Actions.DiagnoseUnknownAttribute(
Attr);
4600 Attr.setInvalid(
true);
4608 if (
Attr.getMaxArgs() && !NumArgs) {
4611 Diag(LParenLoc, diag::err_attribute_requires_arguments) <<
AttrName;
4612 Attr.setInvalid(
true);
4613 }
else if (!
Attr.getMaxArgs()) {
4617 auto D =
Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4621 Attr.setInvalid(
true);
4630 if (Tok.is(tok::kw_alignas)) {
4636 Diag(Tok.getLocation(), diag::warn_cxx98_compat_alignas);
4637 ParseAlignmentSpecifier(Attrs, EndLoc);
4641 if (Tok.isRegularKeywordAttribute()) {
4642 SourceLocation Loc = Tok.getLocation();
4643 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
4644 ParsedAttr::Form Form = ParsedAttr::Form(Tok.getKind());
4648 if (!Tok.is(tok::l_paren))
4649 Diag(Tok.getLocation(), diag::err_expected_lparen_after) <<
AttrName;
4651 ParseAttributeArgsCommon(AttrName, Loc, Attrs, EndLoc,
4655 Attrs.
addNew(AttrName, Loc, AttributeScopeInfo(),
nullptr, 0, Form);
4659 assert(Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square) &&
4660 "Not a double square bracket attribute list");
4662 SourceLocation OpenLoc = Tok.getLocation();
4664 : diag_compat::c23_attributes);
4667 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4670 SourceLocation CommonScopeLoc;
4671 IdentifierInfo *CommonScopeName =
nullptr;
4672 if (Tok.is(tok::kw_using)) {
4673 DiagCompat(Tok.getLocation(), diag_compat::using_attribute_ns);
4676 CommonScopeName = TryParseCXX11AttributeIdentifier(
4678 if (!CommonScopeName) {
4679 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4683 Diag(Tok.getLocation(), diag::err_expected) << tok::colon;
4686 bool AttrParsed =
false;
4687 while (!Tok.isOneOf(tok::r_square, tok::semi, tok::eof)) {
4691 if (ExpectAndConsume(tok::comma)) {
4702 SourceLocation ScopeLoc, AttrLoc;
4703 IdentifierInfo *ScopeName =
nullptr, *
AttrName =
nullptr;
4705 AttrName = TryParseCXX11AttributeIdentifier(
4717 AttrName = TryParseCXX11AttributeIdentifier(
4721 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4727 if (CommonScopeName) {
4729 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4730 << SourceRange(CommonScopeLoc);
4732 ScopeName = CommonScopeName;
4733 ScopeLoc = CommonScopeLoc;
4738 if (Tok.is(tok::l_paren))
4739 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
4740 ScopeName, ScopeLoc, OpenMPTokens);
4748 AttributeScopeInfo(ScopeName, ScopeLoc, CommonScopeLoc),
4751 : ParsedAttr::Form::C23());
4756 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) <<
AttrName;
4759 SourceLocation CloseLoc = Tok.getLocation();
4760 bool IsTokenNotFound = ExpectAndConsume(tok::r_square);
4761 if (IsTokenNotFound)
4763 else if (Tok.is(tok::r_square))
4764 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
4766 *EndLoc = Tok.getLocation();
4767 if (!IsTokenNotFound && ExpectAndConsume(tok::r_square))
4772 SourceLocation StartLoc = Tok.getLocation();
4773 SourceLocation EndLoc = StartLoc;
4776 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
4777 }
while (isAllowedCXX11AttributeSpecifier());
4779 Attrs.
Range = SourceRange(StartLoc, EndLoc);
4782void Parser::DiagnoseAndSkipCXX11Attributes() {
4784 Tok.isRegularKeywordAttribute() ? Tok.getIdentifierInfo() :
nullptr;
4786 SourceLocation StartLoc = Tok.getLocation();
4787 SourceLocation EndLoc = SkipCXX11Attributes();
4790 SourceRange
Range(StartLoc, EndLoc);
4792 :
Diag(StartLoc, diag::err_attributes_not_allowed))
4798 SourceLocation EndLoc;
4804 if (Tok.is(tok::l_square)) {
4808 EndLoc =
T.getCloseLocation();
4809 }
else if (Tok.isRegularKeywordAttribute() &&
4811 EndLoc = Tok.getLocation();
4814 assert((Tok.is(tok::kw_alignas) || Tok.isRegularKeywordAttribute()) &&
4815 "not an attribute specifier");
4818 if (!
T.consumeOpen())
4820 EndLoc =
T.getCloseLocation();
4822 }
while (isCXX11AttributeSpecifier() !=
4829 assert(Tok.is(tok::identifier) &&
"Not a Microsoft attribute list");
4830 IdentifierInfo *UuidIdent = Tok.getIdentifierInfo();
4831 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
4833 SourceLocation UuidLoc = Tok.getLocation();
4838 if (
T.consumeOpen()) {
4839 Diag(Tok, diag::err_expected) << tok::l_paren;
4844 if (isTokenStringLiteral()) {
4849 ArgExprs.push_back(StringResult.
get());
4855 SmallString<42> StrBuffer;
4865 SourceLocation StartLoc = Tok.getLocation();
4866 while (Tok.isNot(tok::r_paren)) {
4867 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4868 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4872 SmallString<16> SpellingBuffer;
4873 SpellingBuffer.resize(Tok.getLength() + 1);
4874 bool Invalid =
false;
4875 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
4880 StrBuffer += TokSpelling;
4885 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4886 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4895 Toks[0] =
Token::create(tok::string_literal, StartLoc, StrBuffer.size());
4897 StringLiteral *UuidString =
4899 ArgExprs.push_back(UuidString);
4902 if (!
T.consumeClose()) {
4903 Attrs.
addNew(UuidIdent, SourceRange(UuidLoc,
T.getCloseLocation()),
4904 AttributeScopeInfo(), ArgExprs.data(), ArgExprs.size(),
4905 ParsedAttr::Form::Microsoft());
4910 assert(Tok.is(tok::identifier) &&
4911 "Expected an identifier to denote which MS attribute to consider");
4912 IdentifierInfo *RootSignatureIdent = Tok.getIdentifierInfo();
4913 assert(RootSignatureIdent->
getName() ==
"RootSignature" &&
4914 "Expected RootSignature identifier for root signature attribute");
4916 SourceLocation RootSignatureLoc = Tok.getLocation();
4921 if (
T.consumeOpen()) {
4922 Diag(Tok, diag::err_expected) << tok::l_paren;
4926 auto ProcessStringLiteral = [
this]() -> std::optional<StringLiteral *> {
4927 if (!isTokenStringLiteral())
4928 return std::nullopt;
4932 return std::nullopt;
4934 if (
auto Lit = dyn_cast<StringLiteral>(StringResult.
get()))
4937 return std::nullopt;
4940 auto Signature = ProcessStringLiteral();
4941 if (!Signature.has_value()) {
4942 Diag(Tok, diag::err_expected_string_literal)
4943 << 4 <<
"RootSignature";
4949 Actions,
getLangOpts().HLSLRootSigVer, *Signature);
4957 IdentifierLoc *ILoc = ::new (Actions.getASTContext())
4958 IdentifierLoc(RootSignatureLoc, DeclIdent);
4962 if (!
T.consumeClose())
4963 Attrs.
addNew(RootSignatureIdent,
4964 SourceRange(RootSignatureLoc,
T.getCloseLocation()),
4965 AttributeScopeInfo(), Args.data(), Args.size(),
4966 ParsedAttr::Form::Microsoft());
4970 assert(Tok.is(tok::l_square) &&
"Not a Microsoft attribute list");
4972 SourceLocation StartLoc = Tok.getLocation();
4973 SourceLocation EndLoc = StartLoc;
4981 SkipUntil(tok::r_square, tok::identifier,
4983 if (Tok.is(tok::code_completion)) {
4985 Actions.CodeCompletion().CodeCompleteAttribute(
4991 if (Tok.isNot(tok::identifier))
4993 if (Tok.getIdentifierInfo()->getName() ==
"uuid")
4994 ParseMicrosoftUuidAttributeArgs(Attrs);
4995 else if (Tok.getIdentifierInfo()->getName() ==
"RootSignature")
4996 ParseHLSLRootSignatureAttributeArgs(Attrs);
4998 IdentifierInfo *II = Tok.getIdentifierInfo();
4999 SourceLocation NameLoc = Tok.getLocation();
5006 bool AttrParsed =
false;
5007 if (Tok.is(tok::l_paren)) {
5010 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5011 SourceLocation(), OpenMPTokens);
5012 ReplayOpenMPAttributeTokens(OpenMPTokens);
5015 Attrs.
addNew(II, NameLoc, AttributeScopeInfo(),
nullptr, 0,
5016 ParsedAttr::Form::Microsoft());
5023 EndLoc =
T.getCloseLocation();
5024 }
while (Tok.is(tok::l_square));
5026 Attrs.
Range = SourceRange(StartLoc, EndLoc);
5029void Parser::ParseMicrosoftIfExistsClassDeclaration(
5032 IfExistsCondition
Result;
5033 if (ParseMicrosoftIfExistsCondition(
Result))
5037 if (
Braces.consumeOpen()) {
5038 Diag(Tok, diag::err_expected) << tok::l_brace;
5042 switch (
Result.Behavior) {
5048 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5058 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
5060 if (Tok.isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5061 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, CurAS);
5066 if (Tok.is(tok::semi)) {
5075 SourceLocation ASLoc = Tok.getLocation();
5077 if (Tok.is(tok::colon))
5078 Actions.ActOnAccessSpecifier(AS, ASLoc, Tok.getLocation(),
5079 ParsedAttributesView{});
5081 Diag(Tok, diag::err_expected) << tok::colon;
5086 ParsedTemplateInfo TemplateInfo;
5088 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.