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();
1160 ParsedType Ty = Actions.getTypeName(*Tok.getIdentifierInfo(),
1164 return Tok.getEndLoc();
1179 ASTContext &
C = Actions.getASTContext();
1181 C.getSizeType(), SourceLocation());
1187 return T.getCloseLocation();
1192 assert(Tok.is(tok::identifier) &&
NextToken().
is(tok::ellipsis) &&
1198 Name.
setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
1199 CXXScopeSpec EmptySS;
1200 bool MemberOfUnknownSpecialization =
false;
1204 MemberOfUnknownSpecialization,
false);
1211bool Parser::AnnotatePackIndexingTemplateName(
CXXScopeSpec &SS,
1215 assert(Tok.is(tok::identifier) &&
"expected a simple-template-name");
1220 if (
T.consumeOpen())
1226 TemplateName Indexed = Actions.ActOnPackIndexingTemplateName(
1240 if (Tok.is(tok::less))
1241 return AnnotateTemplateIdToken(
Template, TNK, SS,
1242 SourceLocation(), Name,
1247 if (PP.isBacktrackEnabled())
1248 PP.RevertCachedTokens(1);
1250 PP.EnterToken(Tok,
true);
1261 : Actions.ActOnPackIndexingDeducedTemplateSpecializationType(
1263 Tok.setKind(tok::annot_typename);
1264 setTypeAnnotation(Tok,
Type);
1267 Tok.setKind(tok::annot_template_id);
1271 SourceLocation(), {},
1272 false, TemplateIds));
1274 Tok.setLocation(NameLoc);
1275 Tok.setAnnotationEndLoc(
T.getCloseLocation());
1276 PP.AnnotateCachedTokens(Tok);
1280void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1284 if (PP.isBacktrackEnabled()) {
1285 PP.RevertCachedTokens(1);
1291 EndLoc = PP.getLastCachedTokenLocation();
1294 PP.EnterToken(Tok,
true);
1296 Tok.setKind(tok::annot_pack_indexing_type);
1297 setTypeAnnotation(Tok,
T);
1298 Tok.setAnnotationEndLoc(EndLoc);
1299 Tok.setLocation(StartLoc);
1300 PP.AnnotateCachedTokens(Tok);
1304 switch (Tok.getKind()) {
1305#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1306 case tok::kw___##Trait: \
1307 return DeclSpec::TST_##Trait;
1308#include "clang/Basic/BuiltinTraits.inc"
1310 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1314bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1316 Tok.setKind(tok::identifier);
1319 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1323 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.getName(),
1328 if (
Result.isInvalid()) {
1334 if (
T.getCloseLocation().isInvalid())
1337 const char *PrevSpec =
nullptr;
1341 Actions.getASTContext().getPrintingPolicy()))
1342 Diag(StartLoc, DiagID) << PrevSpec;
1350 if (Tok.is(tok::kw_typename)) {
1351 Diag(Tok, diag::err_expected_class_name_not_template)
1358 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1363 BaseLoc = Tok.getLocation();
1368 if (Tok.isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1373 DeclSpec DS(AttrFactory);
1375 EndLocation = ParseDecltypeSpecifier(DS);
1379 return Actions.ActOnTypeName(DeclaratorInfo);
1382 if (Tok.is(tok::annot_pack_indexing_type)) {
1383 DeclSpec DS(AttrFactory);
1384 ParsePackIndexingType(DS);
1387 return Actions.ActOnTypeName(DeclaratorInfo);
1393 if (Tok.is(tok::annot_template_id)) {
1394 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1399 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
1401 EndLocation = Tok.getAnnotationEndLoc();
1402 ConsumeAnnotationToken();
1409 if (Tok.isNot(tok::identifier)) {
1410 Diag(Tok, diag::err_expected_class_name);
1414 IdentifierInfo *Id = Tok.getIdentifierInfo();
1417 if (Tok.is(tok::less)) {
1424 if (!Actions.DiagnoseUnknownTemplateName(*Id, IdLoc,
getCurScope(), &SS,
1426 Diag(IdLoc, diag::err_unknown_template_name) << Id;
1434 if (AnnotateTemplateIdToken(
Template, TNK, SS, SourceLocation(),
1437 if (Tok.is(tok::annot_template_id) &&
1438 takeTemplateIdAnnotation(Tok)->mightBeType())
1444 if (Tok.isNot(tok::annot_typename))
1449 EndLocation = Tok.getAnnotationEndLoc();
1451 ConsumeAnnotationToken();
1456 IdentifierInfo *CorrectedII =
nullptr;
1458 *Id, IdLoc,
getCurScope(), &SS,
true,
false,
nullptr,
1464 Diag(IdLoc, diag::err_expected_class_name);
1469 EndLocation = IdLoc;
1472 DeclSpec DS(AttrFactory);
1477 const char *PrevSpec =
nullptr;
1480 Actions.getASTContext().getPrintingPolicy());
1484 return Actions.ActOnTypeName(DeclaratorInfo);
1487void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1488 while (Tok.isOneOf(tok::kw___single_inheritance,
1489 tok::kw___multiple_inheritance,
1490 tok::kw___virtual_inheritance)) {
1491 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
1492 auto Kind = Tok.getKind();
1494 attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0, Kind);
1499 while (Tok.is(tok::kw__Nullable)) {
1500 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
1501 auto Kind = Tok.getKind();
1503 attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0, Kind);
1507bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1509 switch (Tok.getKind()) {
1511 if (Tok.isRegularKeywordAttribute())
1518 case tok::identifier:
1520 case tok::coloncolon:
1521 case tok::annot_cxxscope:
1522 case tok::annot_typename:
1523 case tok::annot_template_id:
1524 case tok::kw_decltype:
1527 case tok::kw_operator:
1528 case tok::kw___declspec:
1533 case tok::kw___attribute:
1534 case tok::annot_pragma_pack:
1536 case tok::annot_pragma_ms_pragma:
1538 case tok::annot_pragma_ms_vtordisp:
1540 case tok::annot_pragma_ms_pointers_to_members:
1542 case tok::annot_pragma_export:
1545 return CouldBeBitfield ||
1547 ParsingGenericAssociationType;
1549 case tok::kw___cdecl:
1550 case tok::kw___fastcall:
1551 case tok::kw___stdcall:
1552 case tok::kw___thiscall:
1553 case tok::kw___vectorcall:
1559 case tok::kw_volatile:
1560 case tok::kw_restrict:
1561 case tok::kw__Atomic:
1562 case tok::kw___unaligned:
1566 case tok::kw_inline:
1567 case tok::kw_virtual:
1568 case tok::kw_friend:
1570 case tok::kw_static:
1571 case tok::kw_extern:
1572 case tok::kw_typedef:
1573 case tok::kw_register:
1575 case tok::kw_mutable:
1576 case tok::kw_thread_local:
1577 case tok::kw_constexpr:
1578 case tok::kw_consteval:
1579 case tok::kw_constinit:
1595 if (!isKnownToBeTypeSpecifier(
NextToken()))
1612 ParsedTemplateInfo &TemplateInfo,
1614 DeclSpecContext DSC,
1617 if (TagTokKind == tok::kw_struct)
1619 else if (TagTokKind == tok::kw___interface)
1621 else if (TagTokKind == tok::kw_class)
1624 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1628 if (Tok.is(tok::code_completion)) {
1631 Actions.CodeCompletion().CodeCompleteTag(
getCurScope(), TagType);
1642 const bool shouldDelayDiagsInTag =
1644 SuppressAccessChecks diagsFromTag(*
this, shouldDelayDiagsInTag);
1646 ParsedAttributes attrs(AttrFactory);
1649 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1651 if (Tok.isOneOf(tok::kw___single_inheritance,
1652 tok::kw___multiple_inheritance,
1653 tok::kw___virtual_inheritance)) {
1654 ParseMicrosoftInheritanceClassAttributes(attrs);
1657 if (Tok.is(tok::kw__Nullable)) {
1658 ParseNullabilityClassAttributes(attrs);
1666 SourceLocation AttrFixitLoc = Tok.getLocation();
1669 !Tok.isAnnotation() && Tok.getIdentifierInfo() &&
1672#include
"clang/Basic/BuiltinTraits.inc"
1673 tok::kw___is_abstract,
1674 tok::kw___is_aggregate,
1675 tok::kw___is_arithmetic,
1677 tok::kw___is_assignable,
1678 tok::kw___is_base_of,
1679 tok::kw___is_bounded_array,
1681 tok::kw___is_complete_type,
1682 tok::kw___is_compound,
1684 tok::kw___is_constructible,
1685 tok::kw___is_convertible,
1686 tok::kw___is_convertible_to,
1687 tok::kw___is_destructible,
1690 tok::kw___is_floating_point,
1692 tok::kw___is_function,
1693 tok::kw___is_fundamental,
1694 tok::kw___is_integral,
1695 tok::kw___is_interface_class,
1696 tok::kw___is_literal,
1697 tok::kw___is_lvalue_expr,
1698 tok::kw___is_lvalue_reference,
1699 tok::kw___is_member_function_pointer,
1700 tok::kw___is_member_object_pointer,
1701 tok::kw___is_member_pointer,
1702 tok::kw___is_nothrow_assignable,
1703 tok::kw___is_nothrow_constructible,
1704 tok::kw___is_nothrow_convertible,
1705 tok::kw___is_nothrow_destructible,
1706 tok::kw___is_object,
1708 tok::kw___is_pointer,
1709 tok::kw___is_polymorphic,
1710 tok::kw___is_reference,
1711 tok::kw___is_rvalue_expr,
1712 tok::kw___is_rvalue_reference,
1714 tok::kw___is_scalar,
1715 tok::kw___is_scoped_enum,
1716 tok::kw___is_sealed,
1717 tok::kw___is_signed,
1718 tok::kw___is_standard_layout,
1719 tok::kw___is_trivial,
1720 tok::kw___is_trivially_equality_comparable,
1721 tok::kw___is_trivially_assignable,
1722 tok::kw___is_trivially_constructible,
1723 tok::kw___is_trivially_copyable,
1724 tok::kw___is_unbounded_array,
1726 tok::kw___is_unsigned,
1728 tok::kw___is_volatile
1735 TryKeywordIdentFallback(
true);
1737 struct PreserveAtomicIdentifierInfoRAII {
1738 PreserveAtomicIdentifierInfoRAII(Token &
Tok,
bool Enabled)
1742 assert(
Tok.
is(tok::kw__Atomic));
1747 ~PreserveAtomicIdentifierInfoRAII() {
1750 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1752 IdentifierInfo *AtomicII;
1760 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1761 Tok.is(tok::kw__Atomic) &&
1763 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1764 Tok, ShouldChangeAtomicToIdentifier);
1768 CXXScopeSpec InvalidDeclScope;
1778 if (TemplateInfo.TemplateParams)
1781 bool HasValidSpec =
true;
1782 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1786 HasValidSpec =
false;
1789 if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id)) {
1790 Diag(Tok, diag::err_expected) << tok::identifier;
1791 HasValidSpec =
false;
1799 auto RecoverFromUndeclaredTemplateName = [&](IdentifierInfo *Name,
1800 SourceLocation NameLoc,
1801 SourceRange TemplateArgRange,
1802 bool KnownUndeclared) {
1803 Diag(NameLoc, diag::err_explicit_spec_non_template)
1805 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1809 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1810 if (TemplateParams->size() > 1) {
1811 TemplateParams->pop_back();
1813 TemplateParams =
nullptr;
1818 TemplateParams =
nullptr;
1820 TemplateInfo.TemplateLoc = SourceLocation();
1821 TemplateInfo.ExternLoc = SourceLocation();
1826 IdentifierInfo *Name =
nullptr;
1827 SourceLocation NameLoc;
1828 TemplateIdAnnotation *TemplateId =
nullptr;
1829 if (Tok.is(tok::identifier)) {
1830 Name = Tok.getIdentifierInfo();
1838 TemplateArgList TemplateArgs;
1839 SourceLocation LAngleLoc, RAngleLoc;
1840 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1844 LAngleLoc = RAngleLoc = SourceLocation();
1846 RecoverFromUndeclaredTemplateName(
1847 Name, NameLoc, SourceRange(LAngleLoc, RAngleLoc),
false);
1849 }
else if (Tok.is(tok::annot_template_id)) {
1850 TemplateId = takeTemplateIdAnnotation(Tok);
1851 NameLoc = ConsumeAnnotationToken();
1855 Actions.ActOnUndeclaredTypeTemplateName(
1858 RecoverFromUndeclaredTemplateName(
1861 TemplateId =
nullptr;
1869 SourceRange
Range(NameLoc);
1874 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1875 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1910 MaybeParseCXX11Attributes(Attributes);
1912 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1919 Tok.isOneOf(tok::comma, tok::ellipsis))
1922 AllowDefiningTypeSpec::No ||
1925 else if (Tok.is(tok::l_brace) ||
1926 (DSC != DeclSpecContext::DSC_association &&
1928 (isClassCompatibleKeyword() &&
1930 isClassCompatibleKeyword(
NextToken())))) {
1934 Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
1945 }
else if (isClassCompatibleKeyword() &&
1952 TentativeParsingAction PA(*
this);
1955 while (isClassCompatibleKeyword())
1960 if (Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square)) {
1964 }
else if (Tok.is(tok::kw_alignas) &&
NextToken().
is(tok::l_paren)) {
1969 }
else if (Tok.isRegularKeywordAttribute()) {
1974 if (!
T.consumeOpen())
1982 if (Tok.isOneOf(tok::l_brace, tok::colon))
1988 }
else if (!isTypeSpecifier(DSC) &&
1989 (Tok.is(tok::semi) ||
1990 (Tok.isAtStartOfLine() && !isValidAfterTypeSpecifier(
false)))) {
1992 if (Tok.isNot(tok::semi)) {
1993 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
1995 ExpectAndConsume(tok::semi, diag::err_expected_after,
1997 PP.EnterToken(Tok,
true);
1998 Tok.setKind(tok::semi);
2011 SourceRange AttrRange = Attributes.
Range;
2015 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2016 ?
Diag(Loc, diag::err_keyword_not_allowed) << FirstAttr
2017 :
Diag(Loc, diag::err_attributes_not_allowed))
2020 AttrFixitLoc, CharSourceRange(AttrRange,
true))
2029 if (!Name && !TemplateId &&
2034 Diag(StartLoc, diag::err_anon_type_definition)
2053 SkipBodyInfo SkipBody;
2067 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2068 diag::err_keyword_not_allowed,
2071 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2072 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2073 TagType, StartLoc, SS, TemplateId->
Template,
2080 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2081 diag::err_keyword_not_allowed,
2104 "Expected a definition here");
2108 TemplateParams =
nullptr;
2110 SourceLocation LAngleLoc =
2111 PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
2113 diag::err_explicit_instantiation_with_definition)
2114 << SourceRange(TemplateInfo.TemplateLoc)
2120 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
2121 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, {},
2122 LAngleLoc,
nullptr));
2123 TemplateParams = &FakedParamLists;
2128 TagOrTempResult = Actions.ActOnClassTemplateSpecialization(
2130 SS, *TemplateId, attrs,
2133 TemplateParams ? TemplateParams->size() : 0),
2143 ProhibitAttributes(attrs);
2145 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2146 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2147 TagType, StartLoc, SS, Name, NameLoc, attrs);
2150 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2151 diag::err_keyword_not_allowed,
2155 SourceLocation EllipsisLoc;
2167 if (Tok.is(tok::comma)) {
2168 Diag(Tok.getLocation(),
2169 diag::err_friend_template_decl_multiple_specifiers);
2178 TagOrTempResult = Actions.ActOnTemplatedFriendTag(
2180 NameLoc, EllipsisLoc, attrs,
2182 TemplateParams ? TemplateParams->size() : 0),
2186 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2187 diag::err_keyword_not_allowed,
2194 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2196 TemplateParams =
nullptr;
2199 bool IsDependent =
false;
2209 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2212 TagOrTempResult = Actions.ActOnTag(
2213 getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, AS,
2216 DSC == DeclSpecContext::DSC_type_specifier,
2217 DSC == DeclSpecContext::DSC_template_param ||
2218 DSC == DeclSpecContext::DSC_template_type_arg,
2219 OffsetOfState, &SkipBody);
2226 Name, StartLoc, NameLoc);
2233 if (shouldDelayDiagsInTag) {
2234 diagsFromTag.done();
2237 diagsFromTag.redelay();
2242 assert(Tok.is(tok::l_brace) ||
2244 isClassCompatibleKeyword());
2246 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc, TagType,
2247 TagOrTempResult.
get());
2249 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs, TagType,
2250 TagOrTempResult.
get());
2258 TagOrTempResult.
get(), SkipBody)) {
2267 Actions.ProcessDeclAttributeDelayed(TagOrTempResult.
get(), attrs);
2269 const char *PrevSpec =
nullptr;
2274 NameLoc.
isValid() ? NameLoc : StartLoc,
2276 }
else if (!TagOrTempResult.
isInvalid()) {
2278 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2279 DiagID, TagOrTempResult.
get(), Owned, Policy);
2286 Diag(StartLoc, DiagID) << PrevSpec;
2303 if (Tok.isNot(tok::semi)) {
2304 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
2305 ExpectAndConsume(tok::semi, diag::err_expected_after,
2310 PP.EnterToken(Tok,
true);
2311 Tok.setKind(tok::semi);
2316void Parser::ParseBaseClause(
Decl *ClassDecl) {
2317 assert(Tok.is(tok::colon) &&
"Not a base clause");
2321 SmallVector<CXXBaseSpecifier *, 8> BaseInfo;
2326 if (!
Result.isUsable()) {
2332 BaseInfo.push_back(
Result.get());
2342 Actions.ActOnBaseSpecifiers(ClassDecl, BaseInfo);
2346 bool IsVirtual =
false;
2347 SourceLocation StartLoc = Tok.getLocation();
2349 ParsedAttributes Attributes(AttrFactory);
2350 MaybeParseCXX11Attributes(Attributes);
2356 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2363 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
2366 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2370 if (Tok.is(tok::kw_virtual)) {
2374 Diag(VirtualLoc, diag::err_dup_virtual)
2382 Diag(Tok.getLocation(), diag::err_hlsl_virtual_inheritance);
2384 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2392 if (
getLangOpts().MSVCCompat && Tok.is(tok::kw__Atomic) &&
2394 Tok.setKind(tok::identifier);
2396 SourceLocation EndLocation;
2397 SourceLocation BaseLoc;
2398 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2405 SourceLocation EllipsisLoc;
2409 SourceRange
Range(StartLoc, EndLocation);
2413 return Actions.ActOnBaseSpecifier(ClassDecl, Range, Attributes, IsVirtual,
2414 Access, BaseType.
get(), BaseLoc,
2419 switch (Tok.getKind()) {
2422 case tok::kw_private:
2424 case tok::kw_protected:
2426 case tok::kw_public:
2431void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2438 if (!NeedLateParse) {
2440 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx) {
2442 if (Param->hasUnparsedDefaultArg()) {
2443 NeedLateParse =
true;
2449 if (NeedLateParse) {
2452 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2453 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2458 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2459 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx)
2460 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2476 const IdentifierInfo *II = Tok.getIdentifierInfo();
2480 Ident_final = &PP.getIdentifierTable().get(
"final");
2482 Ident_GNU_final = &PP.getIdentifierTable().get(
"__final");
2484 Ident_sealed = &PP.getIdentifierTable().get(
"sealed");
2485 Ident_abstract = &PP.getIdentifierTable().get(
"abstract");
2487 Ident_override = &PP.getIdentifierTable().get(
"override");
2490 if (II == Ident_override)
2493 if (II == Ident_sealed)
2496 if (II == Ident_abstract)
2499 if (II == Ident_final)
2502 if (II == Ident_GNU_final)
2508void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2517 Diag(Tok.getLocation(), diag::err_friend_decl_spec)
2520 << SourceRange(FriendLoc, FriendLoc);
2527 const char *PrevSpec =
nullptr;
2528 if (VS.
SetSpecifier(Specifier, Tok.getLocation(), PrevSpec))
2529 Diag(Tok.getLocation(), diag::err_duplicate_virt_specifier)
2534 Diag(Tok.getLocation(), diag::err_override_control_interface)
2537 Diag(Tok.getLocation(), diag::ext_ms_sealed_keyword);
2539 Diag(Tok.getLocation(), diag::ext_ms_abstract_keyword);
2541 Diag(Tok.getLocation(), diag::ext_warn_gnu_final);
2543 DiagCompat(Tok.getLocation(), diag_compat::override_control_keyword)
2550bool Parser::isCXX11FinalKeyword()
const {
2557bool Parser::isClassCompatibleKeyword(
Token Tok)
const {
2565bool Parser::isClassCompatibleKeyword()
const {
2566 return isClassCompatibleKeyword(Tok);
2571bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2584 if (Tok.isNot(tok::colon))
2585 ParseDeclarator(DeclaratorInfo);
2590 if (!IsFunctionDeclarator && !
getLangOpts().MSVCCompat)
2591 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2594 MaybeParseHLSLAnnotations(DeclaratorInfo,
nullptr,
2599 "don't know where identifier would go yet?");
2603 }
else if (Tok.is(tok::kw_requires)) {
2604 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
2609 ++CurTemplateDepthTracker;
2610 ParseTrailingRequiresClauseWithScope(DeclaratorInfo);
2612 ParseOptionalCXX11VirtSpecifierSeq(
2613 VS, getCurrentClass().IsInterface,
2616 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2621 if (Tok.is(tok::kw_asm)) {
2623 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2624 if (AsmLabel.isInvalid())
2634 DiagnoseAndSkipCXX11Attributes();
2635 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2636 DiagnoseAndSkipCXX11Attributes();
2641 ParseOptionalCXX11VirtSpecifierSeq(
2642 VS, getCurrentClass().IsInterface,
2648 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2649 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2651 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2666void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2668 DeclSpec DS(AttrFactory);
2672 ParseTypeQualifierListOpt(
2673 DS, AR_NoAttributesParsed,
false,
2675 Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
2682 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2683 SourceLocation SpecLoc) {
2684 FixItHint Insertion;
2685 auto &MQ =
Function.getOrCreateMethodQualifiers();
2686 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2687 std::string Name(FixItName.data());
2690 MQ.SetTypeQual(TypeQual, SpecLoc);
2692 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2701 bool RefQualifierIsLValueRef =
true;
2702 SourceLocation RefQualifierLoc;
2703 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2704 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2705 FixItHint Insertion =
2707 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2708 Function.RefQualifierLoc = RefQualifierLoc;
2710 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2711 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2723 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2724 if (Tok.is(tok::at)) {
2726 Diag(Tok, diag::err_at_defs_cxx);
2728 Diag(Tok, diag::err_at_in_class);
2744 bool MalformedTypeSpec =
false;
2746 Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2748 MalformedTypeSpec =
true;
2751 if (Tok.isNot(tok::annot_cxxscope))
2752 isAccessDecl =
false;
2761 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2771 SourceLocation TemplateKWLoc;
2774 false,
false,
true,
true,
2775 false, &TemplateKWLoc, Name)) {
2781 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2782 "access declaration")) {
2790 SourceLocation(), SS, Name,
2792 ParsedAttributesView())));
2799 Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2800 SourceLocation DeclEnd;
2802 DeclGroupRef(ParseStaticAssertDeclaration(DeclEnd)));
2805 if (Tok.is(tok::kw_template)) {
2806 assert(!TemplateInfo.TemplateParams &&
2807 "Nested template improperly parsed?");
2808 ObjCDeclContextSwitch ObjCDC(*
this);
2809 SourceLocation DeclEnd;
2811 DeclEnd, AccessAttrs, AS);
2815 if (Tok.is(tok::kw___extension__)) {
2817 ExtensionRAIIObject O(Diags);
2819 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2823 ParsedAttributes DeclAttrs(AttrFactory);
2825 MaybeParseCXX11Attributes(DeclAttrs);
2830 if (Tok.is(tok::annot_attr_openmp))
2831 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
2833 if (Tok.is(tok::kw_using)) {
2838 while (Tok.is(tok::kw_template)) {
2840 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
2844 if (Tok.is(tok::kw_namespace)) {
2845 Diag(UsingLoc, diag::err_using_namespace_in_class);
2849 SourceLocation DeclEnd;
2852 UsingLoc, DeclEnd, DeclAttrs, AS);
2855 ParsedAttributes DeclSpecAttrs(AttrFactory);
2857 LateParsedAttrList CommonLateParsedAttrs;
2859 while (MaybeParseCXX11Attributes(DeclAttrs) ||
2860 MaybeParseGNUAttributes(DeclSpecAttrs, &CommonLateParsedAttrs) ||
2861 MaybeParseMicrosoftAttributes(DeclSpecAttrs))
2864 SourceLocation DeclStart;
2865 if (DeclAttrs.Range.isValid()) {
2866 DeclStart = DeclSpecAttrs.Range.
isInvalid()
2867 ? DeclAttrs.Range.getBegin()
2868 : std::min(DeclAttrs.Range.getBegin(),
2869 DeclSpecAttrs.Range.getBegin());
2871 DeclStart = DeclSpecAttrs.Range.getBegin();
2876 ParsingDeclSpec DS(*
this, TemplateDiags);
2879 if (MalformedTypeSpec)
2887 bool IsTemplateSpecOrInst =
2890 SuppressAccessChecks diagsFromTag(*
this, IsTemplateSpecOrInst);
2892 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
2893 &CommonLateParsedAttrs);
2895 if (IsTemplateSpecOrInst)
2896 diagsFromTag.done();
2908 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
2909 &CommonLateParsedAttrs))
2913 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
2915 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
2919 ProhibitAttributes(DeclAttrs);
2921 RecordDecl *AnonRecord =
nullptr;
2922 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(
2923 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
2924 Actions.ActOnDefinedDeclarationSpecifier(TheDecl);
2925 DS.complete(TheDecl);
2927 Decl *decls[] = {AnonRecord, TheDecl};
2928 return Actions.BuildDeclaratorGroup(decls);
2930 return Actions.ConvertDeclToDeclGroup(TheDecl);
2934 Actions.ActOnDefinedDeclarationSpecifier(DS.
getRepAsDecl());
2939 DiagCompat(Tok.getLocation(), diag_compat::variadic_friends);
2942 SmallVector<Decl *> Decls;
2945 auto ParsedFriendDecl = [&](ParsingDeclSpec &DeclSpec) {
2946 SourceLocation VariadicLoc;
2949 RecordDecl *AnonRecord =
nullptr;
2950 Decl *D = Actions.ParsedFreeStandingDeclSpec(
2951 getCurScope(), AS, DeclSpec, DeclAttrs, TemplateParams,
false,
2952 AnonRecord, VariadicLoc);
2953 DeclSpec.complete(D);
2963 if (ParsedFriendDecl(DS))
2967 ParsingDeclSpec DeclSpec(*
this, TemplateDiags);
2968 const char *PrevSpec =
nullptr;
2969 unsigned DiagId = 0;
2970 DeclSpec.SetFriendSpec(FriendLoc, PrevSpec, DiagId);
2971 ParseDeclarationSpecifiers(DeclSpec, TemplateInfo, AS,
2972 DeclSpecContext::DSC_class,
nullptr);
2973 if (ParsedFriendDecl(DeclSpec))
2977 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_stmt,
2978 "friend declaration");
2980 return Actions.BuildDeclaratorGroup(Decls);
2986 if (Tok.is(tok::kw_concept)) {
2990 ? llvm::to_underlying(diag::err_friend_concept)
2991 : llvm::to_underlying(
2993 err_concept_decls_may_only_appear_in_global_namespace_scope));
2998 ParsingDeclarator DeclaratorInfo(*
this, DS, DeclAttrs,
3000 if (TemplateInfo.TemplateParams)
3005 LateParsedAttrList LateParsedAttrs;
3007 SourceLocation EqualLoc;
3008 SourceLocation PureSpecLoc;
3010 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
3011 if (Tok.isNot(tok::equal))
3015 SmallString<8> Buffer;
3016 if (
Zero.isNot(tok::numeric_constant) ||
3017 PP.getSpelling(
Zero, Buffer) !=
"0")
3021 if (!
After.isOneOf(tok::semi, tok::comma) &&
3022 !(AllowDefinition &&
3023 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3031 SmallVector<Decl *, 8> DeclsInGroup;
3034 bool ExpectSemi =
true;
3039 SuppressAccessChecks SAC(*
this, IsTemplateSpecOrInst);
3042 if (ParseCXXMemberDeclaratorBeforeInitializer(
3043 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3048 if (IsTemplateSpecOrInst)
3056 TryConsumePureSpecifier(
true);
3067 if (Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3069 }
else if (Tok.is(tok::equal)) {
3071 if (KW.
is(tok::kw_default))
3073 else if (KW.
is(tok::kw_delete))
3075 else if (KW.
is(tok::code_completion)) {
3077 Actions.CodeCompletion().CodeCompleteAfterFunctionEquals(
3092 ProhibitAttributes(DeclAttrs);
3109 diag::err_function_declared_typedef);
3115 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3116 TemplateInfo, VS, PureSpecLoc);
3119 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3120 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3122 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3123 LateParsedAttrs[i]->addDecl(FunDecl);
3126 LateParsedAttrs.clear();
3129 if (Tok.is(tok::semi))
3142 bool HasStaticInitializer =
false;
3143 if (Tok.isOneOf(tok::equal, tok::l_brace) && PureSpecLoc.
isInvalid()) {
3147 Diag(Tok, diag::err_anon_bitfield_member_init);
3151 if (!TryConsumePureSpecifier(
false))
3153 HasStaticInitializer =
true;
3161 if (BitfieldSize.
get())
3162 DiagCompat(Tok, diag_compat::bitfield_member_init);
3165 HasStaticInitializer =
true;
3173 NamedDecl *ThisDecl =
nullptr;
3181 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3182 auto Loc = AL.getRange().getBegin();
3183 (AL.isRegularKeywordAttribute()
3184 ?
Diag(Loc, diag::err_keyword_not_allowed) << AL
3185 :
Diag(Loc, diag::err_attributes_not_allowed))
3189 ThisDecl = Actions.ActOnFriendFunctionDecl(
getCurScope(), DeclaratorInfo,
3192 ThisDecl = Actions.ActOnCXXMemberDeclarator(
3193 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3194 VS, HasInClassInit);
3196 if (VarTemplateDecl *VT =
3197 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3200 ThisDecl = VT->getTemplatedDecl();
3203 Actions.ProcessDeclAttributeList(
getCurScope(), ThisDecl, AccessAttrs);
3212 HasStaticInitializer =
true;
3216 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3218 if (ThisDecl && PureSpecLoc.
isValid())
3219 Actions.ActOnPureSpecifier(ThisDecl, PureSpecLoc);
3226 DiagCompat(Tok, diag_compat::nonstatic_member_init);
3234 Diag(Tok, diag::err_incomplete_array_member_init);
3241 ParseCXXNonStaticMemberInitializer(ThisDecl);
3242 }
else if (HasStaticInitializer) {
3247 if (
Init.isInvalid()) {
3249 Actions.ActOnUninitializedDecl(ThisDecl);
3251 }
else if (ThisDecl)
3252 Actions.AddInitializerToDecl(ThisDecl,
Init.get(),
3256 Actions.ActOnUninitializedDecl(ThisDecl);
3261 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3262 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3264 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3265 LateParsedAttrs[i]->addDecl(ThisDecl);
3267 Actions.FinalizeDeclaration(ThisDecl);
3268 DeclsInGroup.push_back(ThisDecl);
3273 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3275 LateParsedAttrs.clear();
3277 DeclaratorInfo.complete(ThisDecl);
3281 SourceLocation CommaLoc;
3285 if (Tok.isAtStartOfLine() &&
3290 Diag(CommaLoc, diag::err_expected_semi_declaration)
3302 Diag(CommaLoc, diag::err_multiple_template_declarators)
3303 << TemplateInfo.Kind;
3307 DeclaratorInfo.
clear();
3310 EqualLoc = PureSpecLoc = SourceLocation();
3316 DiagnoseAndSkipCXX11Attributes();
3317 MaybeParseGNUAttributes(DeclaratorInfo);
3318 DiagnoseAndSkipCXX11Attributes();
3320 if (ParseCXXMemberDeclaratorBeforeInitializer(
3321 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3326 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list) &&
3327 !isLikelyAtStartOfNewDeclaration()) {
3335 return Actions.FinalizeDeclaratorGroup(
getCurScope(), DS, DeclsInGroup);
3338ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
3340 assert(Tok.isOneOf(tok::equal, tok::l_brace) &&
3341 "Data member initializer not starting with '=' or '{'");
3343 bool IsFieldInitialization = isa_and_present<FieldDecl>(D);
3345 EnterExpressionEvaluationContext Context(
3347 IsFieldInitialization
3355 Actions.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
3356 IsFieldInitialization;
3359 if (Tok.is(tok::kw_delete)) {
3366 if (IsFunction ||
Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3372 SkipDeletedFunctionBody();
3375 }
else if (Tok.is(tok::kw_default)) {
3377 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3385 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
3386 Diag(Tok, diag::err_ms_property_initializer) << PD;
3389 return ParseInitializer(D);
3396 while (isClassCompatibleKeyword())
3401 ParsedAttributes Attrs(AttrFactory);
3402 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3407 if (Tok.isNot(tok::colon) && Tok.isNot(tok::l_brace))
3413 if (Tok.is(tok::colon)) {
3416 ParsingClassDefinition ParsingDef(*
this, TagDecl,
true,
3419 Actions.ActOnTagStartSkippedDefinition(
getCurScope(), TagDecl);
3422 ParseBaseClause(
nullptr);
3424 Actions.ActOnTagFinishSkippedDefinition(OldContext);
3426 if (!Tok.is(tok::l_brace)) {
3427 Diag(PP.getLocForEndOfToken(PrevTokLocation),
3428 diag::err_expected_lbrace_after_base_specifiers);
3434 assert(Tok.is(tok::l_brace));
3440 if (Tok.is(tok::kw___attribute)) {
3441 ParsedAttributes Attrs(AttrFactory);
3442 MaybeParseGNUAttributes(Attrs);
3451 switch (Tok.getKind()) {
3452 case tok::kw___if_exists:
3453 case tok::kw___if_not_exists:
3454 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, AS);
3463 case tok::annot_pragma_vis:
3464 HandlePragmaVisibility();
3466 case tok::annot_pragma_pack:
3469 case tok::annot_pragma_align:
3470 HandlePragmaAlign();
3472 case tok::annot_pragma_ms_pointers_to_members:
3473 HandlePragmaMSPointersToMembers();
3475 case tok::annot_pragma_ms_pragma:
3476 HandlePragmaMSPragma();
3478 case tok::annot_pragma_ms_vtordisp:
3479 HandlePragmaMSVtorDisp();
3481 case tok::annot_pragma_export:
3482 HandlePragmaExport();
3484 case tok::annot_pragma_dump:
3488 case tok::kw_namespace:
3493 case tok::kw_private:
3497 ParsedTemplateInfo TemplateInfo;
3498 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3501 case tok::kw_public:
3502 case tok::kw_protected: {
3504 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
3509 SourceLocation ASLoc = Tok.getLocation();
3510 unsigned TokLength = Tok.getLength();
3512 AccessAttrs.
clear();
3513 MaybeParseGNUAttributes(AccessAttrs);
3515 SourceLocation EndLoc;
3518 Diag(EndLoc, diag::err_expected)
3522 Diag(EndLoc, diag::err_expected)
3532 if (Actions.ActOnAccessSpecifier(NewAS, ASLoc, EndLoc, AccessAttrs)) {
3534 AccessAttrs.
clear();
3540 case tok::annot_attr_openmp:
3541 case tok::annot_pragma_openmp:
3542 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3543 AS, AccessAttrs,
true, TagType, TagDecl);
3544 case tok::annot_pragma_openacc:
3549 Diag(Tok.getLocation(), diag::err_pragma_misplaced_in_decl)
3551 TagType, Actions.getASTContext().getPrintingPolicy());
3552 ConsumeAnnotationToken();
3555 ParsedTemplateInfo TemplateInfo;
3556 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3567 "Invalid TagType!");
3569 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3570 if (
auto *TD = dyn_cast_or_null<NamedDecl>(TagDecl))
3571 return TD->getQualifiedNameAsString();
3572 return std::string(
"<anonymous>");
3575 PrettyDeclStackTraceEntry CrashInfo(Actions.Context, TagDecl,
RecordLoc,
3576 "parsing struct/union/class body");
3580 bool NonNestedClass =
true;
3581 if (!ClassStack.empty()) {
3583 if (S->isClassScope()) {
3585 NonNestedClass =
false;
3588 if (getCurrentClass().IsInterface) {
3598 if (S->isFunctionScope())
3609 ParsingClassDefinition ParsingDef(*
this, TagDecl, NonNestedClass,
3613 Actions.ActOnTagStartDefinition(
getCurScope(), TagDecl);
3615 SourceLocation FinalLoc;
3616 SourceLocation AbstractLoc;
3617 bool IsFinalSpelledSealed =
false;
3618 bool IsAbstract =
false;
3627 if (isCXX11FinalKeyword()) {
3630 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3635 IsFinalSpelledSealed =
true;
3640 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3648 Diag(FinalLoc, diag::err_override_control_interface)
3651 DiagCompat(FinalLoc, diag_compat::override_control_keyword)
3654 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3656 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3658 Diag(FinalLoc, diag::ext_warn_gnu_final);
3661 "not a class definition");
3667 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3676 if (!Tok.is(tok::colon) && !Tok.is(tok::l_brace)) {
3678 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3683 if (Tok.is(tok::colon)) {
3687 ParseBaseClause(TagDecl);
3688 if (!Tok.is(tok::l_brace)) {
3689 bool SuggestFixIt =
false;
3690 SourceLocation BraceLoc = PP.getLocForEndOfToken(PrevTokLocation);
3691 if (Tok.isAtStartOfLine()) {
3692 switch (Tok.getKind()) {
3693 case tok::kw_private:
3694 case tok::kw_protected:
3695 case tok::kw_public:
3698 case tok::kw_static_assert:
3702 case tok::kw_template:
3703 SuggestFixIt =
true;
3705 case tok::identifier:
3706 SuggestFixIt = isConstructorDeclarator(
true);
3709 SuggestFixIt = isCXXSimpleDeclaration(
false);
3713 DiagnosticBuilder LBraceDiag =
3714 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3718 PP.EnterToken(Tok,
true);
3719 Tok.setKind(tok::l_brace);
3722 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3728 assert(Tok.is(tok::l_brace));
3733 Actions.ActOnStartCXXMemberDeclarations(
getCurScope(), TagDecl, FinalLoc,
3734 IsFinalSpelledSealed, IsAbstract,
3735 T.getOpenLocation());
3746 ParsedAttributes AccessAttrs(AttrFactory);
3750 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
3751 Tok.isNot(tok::eof)) {
3753 ParseCXXClassMemberDeclarationWithPragmas(
3754 CurAS, AccessAttrs,
static_cast<DeclSpec::TST>(TagType), TagDecl);
3755 MaybeDestroyTemplateIds();
3763 ParsedAttributes attrs(AttrFactory);
3764 MaybeParseGNUAttributes(attrs);
3768 T.getOpenLocation(),
3769 T.getCloseLocation(), attrs);
3776 if (TagDecl && NonNestedClass) {
3782 SourceLocation SavedPrevTokLocation = PrevTokLocation;
3783 ParseLexedPragmas(getCurrentClass());
3784 ParseLexedAttributes(getCurrentClass());
3785 ParseLexedMethodDeclarations(getCurrentClass());
3788 Actions.ActOnFinishCXXMemberDecls();
3790 ParseLexedMemberInitializers(getCurrentClass());
3791 ParseLexedMethodDefs(getCurrentClass());
3792 PrevTokLocation = SavedPrevTokLocation;
3796 Actions.ActOnFinishCXXNonNestedClass();
3800 Actions.ActOnTagFinishDefinition(
getCurScope(), TagDecl,
T.getRange());
3807void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3808 assert(Tok.is(tok::kw_namespace));
3813 Diag(Tok.getLocation(), diag::note_missing_end_of_definition_before) << D;
3816 PP.EnterToken(Tok,
true);
3818 Tok =
Token::create(tok::semi, PP.getLocForEndOfToken(PrevTokLocation));
3819 PP.EnterToken(Tok,
true);
3821 Tok.setKind(tok::r_brace);
3824void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3825 assert(Tok.is(tok::colon) &&
3826 "Constructor initializer always starts with ':'");
3833 SmallVector<CXXCtorInitializer *, 4> MemInitializers;
3834 bool AnyErrors =
false;
3837 if (Tok.is(tok::code_completion)) {
3839 Actions.CodeCompletion().CodeCompleteConstructorInitializer(
3840 ConstructorDecl, MemInitializers);
3844 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3846 MemInitializers.push_back(MemInit.
get());
3850 if (Tok.is(tok::comma))
3852 else if (Tok.is(tok::l_brace))
3857 Tok.isOneOf(tok::identifier, tok::coloncolon)) {
3858 SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
3859 Diag(Loc, diag::err_ctor_init_missing_comma)
3864 Diag(Tok.getLocation(), diag::err_expected_either)
3865 << tok::l_brace << tok::comma;
3871 Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc, MemInitializers,
3878 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
3884 IdentifierInfo *II =
nullptr;
3885 SourceLocation IdLoc = Tok.getLocation();
3887 DeclSpec DS(AttrFactory);
3891 if (Tok.is(tok::identifier)) {
3894 II = Tok.getIdentifierInfo();
3896 }
else if (Tok.is(tok::annot_decltype)) {
3901 ParseDecltypeSpecifier(DS);
3902 }
else if (Tok.is(tok::annot_pack_indexing_type)) {
3905 ParsePackIndexingType(DS);
3907 TemplateIdAnnotation *TemplateId = Tok.is(tok::annot_template_id)
3908 ? takeTemplateIdAnnotation(Tok)
3913 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
3915 ConsumeAnnotationToken();
3917 Diag(Tok, diag::err_expected_member_or_base_name);
3924 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
3927 ExprResult InitList = ParseBraceInitializer();
3931 SourceLocation EllipsisLoc;
3936 return Actions.ActOnMemInitializer(ConstructorDecl,
getCurScope(), SS, II,
3937 TemplateTypeTy.
get(), DS, IdLoc,
3938 InitList.
get(), EllipsisLoc);
3939 }
else if (Tok.is(tok::l_paren)) {
3944 ExprVector ArgExprs;
3945 auto RunSignatureHelp = [&] {
3948 QualType PreferredType =
3949 Actions.CodeCompletion().ProduceCtorInitMemberSignatureHelp(
3950 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
3951 T.getOpenLocation(),
false);
3952 CalledSignatureHelp =
true;
3953 return PreferredType;
3955 if (Tok.isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
3956 PreferredType.enterFunctionArgument(Tok.getLocation(),
3959 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
3967 SourceLocation EllipsisLoc;
3972 return Actions.ActOnMemInitializer(
3973 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
3974 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
3981 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
3983 return Diag(Tok, diag::err_expected) << tok::l_paren;
3992 ExceptionSpecTokens =
nullptr;
3996 if (Tok.isNot(tok::kw_throw) && Tok.isNot(tok::kw_noexcept))
4000 bool IsNoexcept = Tok.is(tok::kw_noexcept);
4001 Token StartTok = Tok;
4005 if (!Tok.is(tok::l_paren)) {
4008 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4009 NoexceptExpr =
nullptr;
4013 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4019 ExceptionSpecTokens->push_back(StartTok);
4020 ExceptionSpecTokens->push_back(Tok);
4021 SpecificationRange.
setEnd(ConsumeParen());
4023 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4026 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4032 if (Tok.is(tok::kw_throw)) {
4033 Result = ParseDynamicExceptionSpecification(
4034 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4035 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4036 "Produced different number of exception types and ranges.");
4040 if (Tok.isNot(tok::kw_noexcept))
4043 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4047 SourceRange NoexceptRange;
4051 if (Tok.is(tok::l_paren)) {
4056 EnterExpressionEvaluationContext ConstantEvaluated(
4063 Actions.ActOnNoexceptSpec(NoexceptExpr.
get(), NoexceptType);
4064 NoexceptRange = SourceRange(KeywordLoc,
T.getCloseLocation());
4071 NoexceptRange = SourceRange(KeywordLoc, KeywordLoc);
4075 SpecificationRange = NoexceptRange;
4080 if (Tok.is(tok::kw_throw)) {
4081 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4082 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4083 DynamicExceptionRanges);
4086 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4095 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4097 ? diag::ext_dynamic_exception_spec
4098 : diag::warn_exception_spec_deprecated)
4100 P.
Diag(Range.getBegin(), diag::note_exception_spec_deprecated)
4108 assert(Tok.is(tok::kw_throw) &&
"expected throw");
4112 if (
T.consumeOpen()) {
4113 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4120 if (Tok.is(tok::ellipsis)) {
4123 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4125 SpecificationRange.
setEnd(
T.getCloseLocation());
4132 while (Tok.isNot(tok::r_paren)) {
4135 if (Tok.is(tok::ellipsis)) {
4140 Range.setEnd(Ellipsis);
4141 if (!Res.isInvalid())
4142 Res = Actions.ActOnPackExpansion(Res.get(), Ellipsis);
4145 if (!Res.isInvalid()) {
4146 Exceptions.push_back(Res.get());
4147 Ranges.push_back(Range);
4155 SpecificationRange.
setEnd(
T.getCloseLocation());
4157 Exceptions.empty());
4162 bool MayBeFollowedByDirectInit) {
4163 assert(Tok.is(tok::arrow) &&
"expected arrow");
4172void Parser::ParseTrailingRequiresClauseWithScope(
Declarator &D) {
4173 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4189 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4191 DeclScopeObj.EnterDeclaratorScope();
4197 ParseTrailingRequiresClause(D);
4200void Parser::ParseTrailingRequiresClause(
Declarator &D) {
4201 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4204 "trailing requires-clause must be parsed in a function prototype scope");
4209 Actions.ActOnStartTrailingRequiresClause(
getCurScope(), D);
4211 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4212 InitCXXThisScopeForDeclaratorIfRelevant(D, D.
getDeclSpec(), ThisScope);
4214 TrailingRequiresClause =
4217 TrailingRequiresClause =
4218 Actions.ActOnFinishTrailingRequiresClause(TrailingRequiresClause);
4222 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4227 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4235 SourceLocation ArrowLoc = Tok.getLocation();
4238 ParseTrailingReturnType(Range,
false);
4242 diag::err_requires_clause_must_appear_after_trailing_return)
4247 FunctionChunk.TrailingReturnTypeLoc =
Range.getBegin();
4249 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4255 bool NonNestedClass,
4257 assert((NonNestedClass || !ClassStack.empty()) &&
4258 "Nested class without outer class");
4259 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4260 return Actions.PushParsingClass();
4263void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4264 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4265 delete Class->LateParsedDeclarations[I];
4270 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4272 Actions.PopParsingClass(state);
4274 ParsingClass *Victim = ClassStack.top();
4276 if (Victim->TopLevelClass) {
4279 DeallocateParsedClasses(Victim);
4282 assert(!ClassStack.empty() &&
"Missing top-level class?");
4284 if (Victim->LateParsedDeclarations.empty()) {
4289 DeallocateParsedClasses(Victim);
4297 "Nested class outside of class scope?");
4298 ClassStack.top()->LateParsedDeclarations.push_back(
4299 new LateParsedClass(
this, Victim));
4305 switch (Tok.getKind()) {
4308 if (!Tok.isAnnotation()) {
4309 if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
4316 case tok::code_completion:
4318 Actions.CodeCompletion().CodeCompleteAttribute(
4323 case tok::numeric_constant: {
4327 if (Tok.getLocation().isMacroID()) {
4328 SmallString<8> ExpansionBuf;
4329 SourceLocation ExpansionLoc =
4330 PP.getSourceManager().getExpansionLoc(Tok.getLocation());
4331 StringRef Spelling = PP.getSpelling(ExpansionLoc, ExpansionBuf);
4332 if (Spelling ==
"__clang__") {
4333 SourceRange TokRange(
4335 PP.getSourceManager().getExpansionLoc(Tok.getEndLoc()));
4336 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4339 return &PP.getIdentifierTable().get(
"_Clang");
4352 case tok::pipeequal:
4353 case tok::caretequal:
4355 case tok::exclaimequal:
4358 SmallString<8> SpellingBuf;
4359 SourceLocation SpellingLoc =
4360 PP.getSourceManager().getSpellingLoc(Tok.getLocation());
4361 StringRef Spelling = PP.getSpelling(SpellingLoc, SpellingBuf);
4364 return &PP.getIdentifierTable().get(Spelling);
4370void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4375 if (
T.consumeOpen()) {
4376 Diag(Tok, diag::err_expected) << tok::l_paren;
4380 if (
AttrName->isStr(
"directive")) {
4386 OpenMPTokens.push_back(OMPBeginTok);
4388 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4392 OpenMPTokens.push_back(OMPEndTok);
4394 assert(
AttrName->isStr(
"sequence") &&
4395 "Expected either 'directive' or 'sequence'");
4403 SourceLocation IdentLoc;
4404 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4408 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4409 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4413 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4414 Diag(Tok.getLocation(), diag::err_expected_sequence_or_directive);
4420 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4434 case ParsedAttr::AT_Deprecated:
4435 case ParsedAttr::AT_FallThrough:
4436 case ParsedAttr::AT_CXX11NoReturn:
4437 case ParsedAttr::AT_NoUniqueAddress:
4438 case ParsedAttr::AT_Likely:
4439 case ParsedAttr::AT_Unlikely:
4441 case ParsedAttr::AT_WarnUnusedResult:
4442 return !ScopeName && AttrName->getName() ==
"nodiscard";
4443 case ParsedAttr::AT_Unused:
4444 return !ScopeName && AttrName->getName() ==
"maybe_unused";
4450bool Parser::ParseCXXAssumeAttributeArg(
4454 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4462 TentativeParsingAction TPA(*
this);
4467 if (Tok.is(tok::r_paren))
4472 if (!Tok.isOneOf(tok::r_paren, tok::r_square)) {
4478 auto *E = Res.
get();
4479 Diag(E->getExprLoc(), diag::err_assume_attr_expects_cond_expr)
4483 << E->getSourceRange();
4492 auto RParen = Tok.getLocation();
4494 Attrs.
addNew(AttrName, SourceRange(AttrNameLoc, RParen),
4495 AttributeScopeInfo(ScopeName, ScopeLoc), &Assumption, 1, Form);
4503bool Parser::ParseCXX11AttributeArgs(
4507 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4508 SourceLocation LParenLoc = Tok.getLocation();
4510 ParsedAttr::Form Form =
4511 LO.CPlusPlus ? ParsedAttr::Form::CXX11() : ParsedAttr::Form::
C23();
4517 Form = ParsedAttr::Form::Microsoft();
4521 TentativeParsingAction TPA(*this);
4522 bool HasInvalidArgument = false;
4523 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof)) {
4524 if (Tok.isOneOf(tok::hash, tok::hashhash)) {
4525 Diag(Tok.getLocation(), diag::ext_invalid_attribute_argument)
4526 << PP.getSpelling(Tok);
4527 HasInvalidArgument = true;
4532 if (HasInvalidArgument) {
4546 ScopeName, AttrName, getTargetInfo(), getLangOpts())) {
4549 SkipUntil(tok::r_paren);
4553 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4556 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4557 ScopeLoc, Form, nullptr);
4562 if (ScopeName && ScopeName->
isStr(
"omp") &&
4564 Diag(AttrNameLoc, getLangOpts().OpenMP >= 51
4565 ? diag::warn_omp51_compat_attributes
4566 : diag::ext_omp_attributes);
4568 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4577 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4578 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4579 ScopeName, ScopeLoc, Form);
4581 else if (!ScopeName &&
AttrName->isStr(
"assume")) {
4582 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, nullptr,
4583 SourceLocation{}, EndLoc, Form))
4587 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4588 ScopeName, ScopeLoc, Form);
4590 if (!Attrs.
empty() &&
4595 if (!
Attr.existsInTarget(getTargetInfo())) {
4596 Actions.DiagnoseUnknownAttribute(
Attr);
4597 Attr.setInvalid(
true);
4605 if (
Attr.getMaxArgs() && !NumArgs) {
4608 Diag(LParenLoc, diag::err_attribute_requires_arguments) <<
AttrName;
4609 Attr.setInvalid(
true);
4610 }
else if (!
Attr.getMaxArgs()) {
4614 auto D =
Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4618 Attr.setInvalid(
true);
4627 if (Tok.is(tok::kw_alignas)) {
4633 Diag(Tok.getLocation(), diag::warn_cxx98_compat_alignas);
4634 ParseAlignmentSpecifier(Attrs, EndLoc);
4638 if (Tok.isRegularKeywordAttribute()) {
4639 SourceLocation Loc = Tok.getLocation();
4640 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
4641 ParsedAttr::Form Form = ParsedAttr::Form(Tok.getKind());
4645 if (!Tok.is(tok::l_paren))
4646 Diag(Tok.getLocation(), diag::err_expected_lparen_after) <<
AttrName;
4648 ParseAttributeArgsCommon(AttrName, Loc, Attrs, EndLoc,
4652 Attrs.
addNew(AttrName, Loc, AttributeScopeInfo(),
nullptr, 0, Form);
4656 assert(Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square) &&
4657 "Not a double square bracket attribute list");
4659 SourceLocation OpenLoc = Tok.getLocation();
4661 : diag_compat::c23_attributes);
4664 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4667 SourceLocation CommonScopeLoc;
4668 IdentifierInfo *CommonScopeName =
nullptr;
4669 if (Tok.is(tok::kw_using)) {
4670 DiagCompat(Tok.getLocation(), diag_compat::using_attribute_ns);
4673 CommonScopeName = TryParseCXX11AttributeIdentifier(
4675 if (!CommonScopeName) {
4676 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4680 Diag(Tok.getLocation(), diag::err_expected) << tok::colon;
4683 bool AttrParsed =
false;
4684 while (!Tok.isOneOf(tok::r_square, tok::semi, tok::eof)) {
4688 if (ExpectAndConsume(tok::comma)) {
4699 SourceLocation ScopeLoc, AttrLoc;
4700 IdentifierInfo *ScopeName =
nullptr, *
AttrName =
nullptr;
4702 AttrName = TryParseCXX11AttributeIdentifier(
4714 AttrName = TryParseCXX11AttributeIdentifier(
4718 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4724 if (CommonScopeName) {
4726 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4727 << SourceRange(CommonScopeLoc);
4729 ScopeName = CommonScopeName;
4730 ScopeLoc = CommonScopeLoc;
4735 if (Tok.is(tok::l_paren))
4736 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
4737 ScopeName, ScopeLoc, OpenMPTokens);
4745 AttributeScopeInfo(ScopeName, ScopeLoc, CommonScopeLoc),
4748 : ParsedAttr::Form::C23());
4753 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) <<
AttrName;
4756 SourceLocation CloseLoc = Tok.getLocation();
4757 bool IsTokenNotFound = ExpectAndConsume(tok::r_square);
4758 if (IsTokenNotFound)
4760 else if (Tok.is(tok::r_square))
4761 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
4763 *EndLoc = Tok.getLocation();
4764 if (!IsTokenNotFound && ExpectAndConsume(tok::r_square))
4769 SourceLocation StartLoc = Tok.getLocation();
4770 SourceLocation EndLoc = StartLoc;
4773 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
4774 }
while (isAllowedCXX11AttributeSpecifier());
4776 Attrs.
Range = SourceRange(StartLoc, EndLoc);
4779void Parser::DiagnoseAndSkipCXX11Attributes() {
4781 Tok.isRegularKeywordAttribute() ? Tok.getIdentifierInfo() :
nullptr;
4783 SourceLocation StartLoc = Tok.getLocation();
4784 SourceLocation EndLoc = SkipCXX11Attributes();
4787 SourceRange
Range(StartLoc, EndLoc);
4789 :
Diag(StartLoc, diag::err_attributes_not_allowed))
4795 SourceLocation EndLoc;
4801 if (Tok.is(tok::l_square)) {
4805 EndLoc =
T.getCloseLocation();
4806 }
else if (Tok.isRegularKeywordAttribute() &&
4808 EndLoc = Tok.getLocation();
4811 assert((Tok.is(tok::kw_alignas) || Tok.isRegularKeywordAttribute()) &&
4812 "not an attribute specifier");
4815 if (!
T.consumeOpen())
4817 EndLoc =
T.getCloseLocation();
4819 }
while (isCXX11AttributeSpecifier() !=
4826 assert(Tok.is(tok::identifier) &&
"Not a Microsoft attribute list");
4827 IdentifierInfo *UuidIdent = Tok.getIdentifierInfo();
4828 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
4830 SourceLocation UuidLoc = Tok.getLocation();
4835 if (
T.consumeOpen()) {
4836 Diag(Tok, diag::err_expected) << tok::l_paren;
4841 if (isTokenStringLiteral()) {
4846 ArgExprs.push_back(StringResult.
get());
4852 SmallString<42> StrBuffer;
4862 SourceLocation StartLoc = Tok.getLocation();
4863 while (Tok.isNot(tok::r_paren)) {
4864 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4865 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4869 SmallString<16> SpellingBuffer;
4870 SpellingBuffer.resize(Tok.getLength() + 1);
4871 bool Invalid =
false;
4872 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
4877 StrBuffer += TokSpelling;
4882 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4883 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4892 Toks[0] =
Token::create(tok::string_literal, StartLoc, StrBuffer.size());
4894 StringLiteral *UuidString =
4896 ArgExprs.push_back(UuidString);
4899 if (!
T.consumeClose()) {
4900 Attrs.
addNew(UuidIdent, SourceRange(UuidLoc,
T.getCloseLocation()),
4901 AttributeScopeInfo(), ArgExprs.data(), ArgExprs.size(),
4902 ParsedAttr::Form::Microsoft());
4907 assert(Tok.is(tok::identifier) &&
4908 "Expected an identifier to denote which MS attribute to consider");
4909 IdentifierInfo *RootSignatureIdent = Tok.getIdentifierInfo();
4910 assert(RootSignatureIdent->
getName() ==
"RootSignature" &&
4911 "Expected RootSignature identifier for root signature attribute");
4913 SourceLocation RootSignatureLoc = Tok.getLocation();
4918 if (
T.consumeOpen()) {
4919 Diag(Tok, diag::err_expected) << tok::l_paren;
4923 auto ProcessStringLiteral = [
this]() -> std::optional<StringLiteral *> {
4924 if (!isTokenStringLiteral())
4925 return std::nullopt;
4929 return std::nullopt;
4931 if (
auto Lit = dyn_cast<StringLiteral>(StringResult.
get()))
4934 return std::nullopt;
4937 auto Signature = ProcessStringLiteral();
4938 if (!Signature.has_value()) {
4939 Diag(Tok, diag::err_expected_string_literal)
4940 << 4 <<
"RootSignature";
4946 Actions,
getLangOpts().HLSLRootSigVer, *Signature);
4954 IdentifierLoc *ILoc = ::new (Actions.getASTContext())
4955 IdentifierLoc(RootSignatureLoc, DeclIdent);
4959 if (!
T.consumeClose())
4960 Attrs.
addNew(RootSignatureIdent,
4961 SourceRange(RootSignatureLoc,
T.getCloseLocation()),
4962 AttributeScopeInfo(), Args.data(), Args.size(),
4963 ParsedAttr::Form::Microsoft());
4967 assert(Tok.is(tok::l_square) &&
"Not a Microsoft attribute list");
4969 SourceLocation StartLoc = Tok.getLocation();
4970 SourceLocation EndLoc = StartLoc;
4978 SkipUntil(tok::r_square, tok::identifier,
4980 if (Tok.is(tok::code_completion)) {
4982 Actions.CodeCompletion().CodeCompleteAttribute(
4988 if (Tok.isNot(tok::identifier))
4990 if (Tok.getIdentifierInfo()->getName() ==
"uuid")
4991 ParseMicrosoftUuidAttributeArgs(Attrs);
4992 else if (Tok.getIdentifierInfo()->getName() ==
"RootSignature")
4993 ParseHLSLRootSignatureAttributeArgs(Attrs);
4995 IdentifierInfo *II = Tok.getIdentifierInfo();
4996 SourceLocation NameLoc = Tok.getLocation();
5003 bool AttrParsed =
false;
5004 if (Tok.is(tok::l_paren)) {
5007 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5008 SourceLocation(), OpenMPTokens);
5009 ReplayOpenMPAttributeTokens(OpenMPTokens);
5012 Attrs.
addNew(II, NameLoc, AttributeScopeInfo(),
nullptr, 0,
5013 ParsedAttr::Form::Microsoft());
5020 EndLoc =
T.getCloseLocation();
5021 }
while (Tok.is(tok::l_square));
5023 Attrs.
Range = SourceRange(StartLoc, EndLoc);
5026void Parser::ParseMicrosoftIfExistsClassDeclaration(
5029 IfExistsCondition
Result;
5030 if (ParseMicrosoftIfExistsCondition(
Result))
5034 if (
Braces.consumeOpen()) {
5035 Diag(Tok, diag::err_expected) << tok::l_brace;
5039 switch (
Result.Behavior) {
5045 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5055 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
5057 if (Tok.isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5058 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, CurAS);
5063 if (Tok.is(tok::semi)) {
5072 SourceLocation ASLoc = Tok.getLocation();
5074 if (Tok.is(tok::colon))
5075 Actions.ActOnAccessSpecifier(AS, ASLoc, Tok.getLocation(),
5076 ParsedAttributesView{});
5078 Diag(Tok, diag::err_expected) << tok::colon;
5083 ParsedTemplateInfo TemplateInfo;
5085 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.