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);
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 ||
1548 case tok::kw___cdecl:
1549 case tok::kw___fastcall:
1550 case tok::kw___stdcall:
1551 case tok::kw___thiscall:
1552 case tok::kw___vectorcall:
1558 case tok::kw_volatile:
1559 case tok::kw_restrict:
1560 case tok::kw__Atomic:
1561 case tok::kw___unaligned:
1565 case tok::kw_inline:
1566 case tok::kw_virtual:
1567 case tok::kw_friend:
1569 case tok::kw_static:
1570 case tok::kw_extern:
1571 case tok::kw_typedef:
1572 case tok::kw_register:
1574 case tok::kw_mutable:
1575 case tok::kw_thread_local:
1576 case tok::kw_constexpr:
1577 case tok::kw_consteval:
1578 case tok::kw_constinit:
1594 if (!isKnownToBeTypeSpecifier(
NextToken()))
1611 ParsedTemplateInfo &TemplateInfo,
1613 DeclSpecContext DSC,
1616 if (TagTokKind == tok::kw_struct)
1618 else if (TagTokKind == tok::kw___interface)
1620 else if (TagTokKind == tok::kw_class)
1623 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1627 if (Tok.is(tok::code_completion)) {
1630 Actions.CodeCompletion().CodeCompleteTag(
getCurScope(), TagType);
1641 const bool shouldDelayDiagsInTag =
1643 SuppressAccessChecks diagsFromTag(*
this, shouldDelayDiagsInTag);
1645 ParsedAttributes attrs(AttrFactory);
1648 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1650 if (Tok.isOneOf(tok::kw___single_inheritance,
1651 tok::kw___multiple_inheritance,
1652 tok::kw___virtual_inheritance)) {
1653 ParseMicrosoftInheritanceClassAttributes(attrs);
1656 if (Tok.is(tok::kw__Nullable)) {
1657 ParseNullabilityClassAttributes(attrs);
1665 SourceLocation AttrFixitLoc = Tok.getLocation();
1668 !Tok.isAnnotation() && Tok.getIdentifierInfo() &&
1671#include
"clang/Basic/BuiltinTraits.inc"
1672 tok::kw___is_abstract,
1673 tok::kw___is_aggregate,
1674 tok::kw___is_arithmetic,
1676 tok::kw___is_assignable,
1677 tok::kw___is_base_of,
1678 tok::kw___is_bounded_array,
1680 tok::kw___is_complete_type,
1681 tok::kw___is_compound,
1683 tok::kw___is_constructible,
1684 tok::kw___is_convertible,
1685 tok::kw___is_convertible_to,
1686 tok::kw___is_destructible,
1689 tok::kw___is_floating_point,
1691 tok::kw___is_function,
1692 tok::kw___is_fundamental,
1693 tok::kw___is_integral,
1694 tok::kw___is_interface_class,
1695 tok::kw___is_literal,
1696 tok::kw___is_lvalue_expr,
1697 tok::kw___is_lvalue_reference,
1698 tok::kw___is_member_function_pointer,
1699 tok::kw___is_member_object_pointer,
1700 tok::kw___is_member_pointer,
1701 tok::kw___is_nothrow_assignable,
1702 tok::kw___is_nothrow_constructible,
1703 tok::kw___is_nothrow_convertible,
1704 tok::kw___is_nothrow_destructible,
1705 tok::kw___is_object,
1707 tok::kw___is_pointer,
1708 tok::kw___is_polymorphic,
1709 tok::kw___is_reference,
1710 tok::kw___is_rvalue_expr,
1711 tok::kw___is_rvalue_reference,
1713 tok::kw___is_scalar,
1714 tok::kw___is_scoped_enum,
1715 tok::kw___is_sealed,
1716 tok::kw___is_signed,
1717 tok::kw___is_standard_layout,
1718 tok::kw___is_trivial,
1719 tok::kw___is_trivially_equality_comparable,
1720 tok::kw___is_trivially_assignable,
1721 tok::kw___is_trivially_constructible,
1722 tok::kw___is_trivially_copyable,
1723 tok::kw___is_unbounded_array,
1725 tok::kw___is_unsigned,
1727 tok::kw___is_volatile
1734 TryKeywordIdentFallback(
true);
1736 struct PreserveAtomicIdentifierInfoRAII {
1737 PreserveAtomicIdentifierInfoRAII(Token &
Tok,
bool Enabled)
1741 assert(
Tok.
is(tok::kw__Atomic));
1746 ~PreserveAtomicIdentifierInfoRAII() {
1749 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1751 IdentifierInfo *AtomicII;
1759 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1760 Tok.is(tok::kw__Atomic) &&
1762 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1763 Tok, ShouldChangeAtomicToIdentifier);
1767 CXXScopeSpec InvalidDeclScope;
1777 if (TemplateInfo.TemplateParams)
1780 bool HasValidSpec =
true;
1781 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1785 HasValidSpec =
false;
1788 if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id)) {
1789 Diag(Tok, diag::err_expected) << tok::identifier;
1790 HasValidSpec =
false;
1798 auto RecoverFromUndeclaredTemplateName = [&](IdentifierInfo *Name,
1799 SourceLocation NameLoc,
1800 SourceRange TemplateArgRange,
1801 bool KnownUndeclared) {
1802 Diag(NameLoc, diag::err_explicit_spec_non_template)
1804 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1808 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1809 if (TemplateParams->size() > 1) {
1810 TemplateParams->pop_back();
1812 TemplateParams =
nullptr;
1817 TemplateParams =
nullptr;
1819 TemplateInfo.TemplateLoc = SourceLocation();
1820 TemplateInfo.ExternLoc = SourceLocation();
1825 IdentifierInfo *Name =
nullptr;
1826 SourceLocation NameLoc;
1827 TemplateIdAnnotation *TemplateId =
nullptr;
1828 if (Tok.is(tok::identifier)) {
1829 Name = Tok.getIdentifierInfo();
1837 TemplateArgList TemplateArgs;
1838 SourceLocation LAngleLoc, RAngleLoc;
1839 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1843 LAngleLoc = RAngleLoc = SourceLocation();
1845 RecoverFromUndeclaredTemplateName(
1846 Name, NameLoc, SourceRange(LAngleLoc, RAngleLoc),
false);
1848 }
else if (Tok.is(tok::annot_template_id)) {
1849 TemplateId = takeTemplateIdAnnotation(Tok);
1850 NameLoc = ConsumeAnnotationToken();
1854 Actions.ActOnUndeclaredTypeTemplateName(
1857 RecoverFromUndeclaredTemplateName(
1860 TemplateId =
nullptr;
1868 SourceRange
Range(NameLoc);
1873 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1874 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1909 MaybeParseCXX11Attributes(Attributes);
1911 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1918 Tok.isOneOf(tok::comma, tok::ellipsis))
1921 AllowDefiningTypeSpec::No ||
1924 else if (Tok.is(tok::l_brace) ||
1925 (DSC != DeclSpecContext::DSC_association &&
1927 (isClassCompatibleKeyword() &&
1929 isClassCompatibleKeyword(
NextToken())))) {
1933 Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
1944 }
else if (isClassCompatibleKeyword() &&
1951 TentativeParsingAction PA(*
this);
1954 while (isClassCompatibleKeyword())
1959 if (Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square)) {
1963 }
else if (Tok.is(tok::kw_alignas) &&
NextToken().
is(tok::l_paren)) {
1968 }
else if (Tok.isRegularKeywordAttribute()) {
1973 if (!
T.consumeOpen())
1981 if (Tok.isOneOf(tok::l_brace, tok::colon))
1987 }
else if (!isTypeSpecifier(DSC) &&
1988 (Tok.is(tok::semi) ||
1989 (Tok.isAtStartOfLine() && !isValidAfterTypeSpecifier(
false)))) {
1991 if (Tok.isNot(tok::semi)) {
1992 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
1994 ExpectAndConsume(tok::semi, diag::err_expected_after,
1996 PP.EnterToken(Tok,
true);
1997 Tok.setKind(tok::semi);
2010 SourceRange AttrRange = Attributes.
Range;
2014 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2015 ?
Diag(Loc, diag::err_keyword_not_allowed) << FirstAttr
2016 :
Diag(Loc, diag::err_attributes_not_allowed))
2019 AttrFixitLoc, CharSourceRange(AttrRange,
true))
2028 if (!Name && !TemplateId &&
2033 Diag(StartLoc, diag::err_anon_type_definition)
2052 SkipBodyInfo SkipBody;
2066 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2067 diag::err_keyword_not_allowed,
2070 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2071 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2072 TagType, StartLoc, SS, TemplateId->
Template,
2079 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2080 diag::err_keyword_not_allowed,
2103 "Expected a definition here");
2107 TemplateParams =
nullptr;
2109 SourceLocation LAngleLoc =
2110 PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
2112 diag::err_explicit_instantiation_with_definition)
2113 << SourceRange(TemplateInfo.TemplateLoc)
2119 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
2120 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, {},
2121 LAngleLoc,
nullptr));
2122 TemplateParams = &FakedParamLists;
2127 TagOrTempResult = Actions.ActOnClassTemplateSpecialization(
2129 SS, *TemplateId, attrs,
2132 TemplateParams ? TemplateParams->size() : 0),
2142 ProhibitAttributes(attrs);
2144 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2145 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2146 TagType, StartLoc, SS, Name, NameLoc, attrs);
2149 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2150 diag::err_keyword_not_allowed,
2154 SourceLocation EllipsisLoc;
2166 if (Tok.is(tok::comma)) {
2167 Diag(Tok.getLocation(),
2168 diag::err_friend_template_decl_multiple_specifiers);
2177 TagOrTempResult = Actions.ActOnTemplatedFriendTag(
2179 NameLoc, EllipsisLoc, attrs,
2181 TemplateParams ? TemplateParams->size() : 0),
2185 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2186 diag::err_keyword_not_allowed,
2193 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2195 TemplateParams =
nullptr;
2198 bool IsDependent =
false;
2208 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2211 TagOrTempResult = Actions.ActOnTag(
2212 getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, AS,
2215 DSC == DeclSpecContext::DSC_type_specifier,
2216 DSC == DeclSpecContext::DSC_template_param ||
2217 DSC == DeclSpecContext::DSC_template_type_arg,
2218 OffsetOfState, &SkipBody);
2225 Name, StartLoc, NameLoc);
2232 if (shouldDelayDiagsInTag) {
2233 diagsFromTag.done();
2236 diagsFromTag.redelay();
2241 assert(Tok.is(tok::l_brace) ||
2243 isClassCompatibleKeyword());
2245 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc, TagType,
2246 TagOrTempResult.
get());
2248 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs, TagType,
2249 TagOrTempResult.
get());
2257 TagOrTempResult.
get(), SkipBody)) {
2266 Actions.ProcessDeclAttributeDelayed(TagOrTempResult.
get(), attrs);
2268 const char *PrevSpec =
nullptr;
2273 NameLoc.
isValid() ? NameLoc : StartLoc,
2275 }
else if (!TagOrTempResult.
isInvalid()) {
2277 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2278 DiagID, TagOrTempResult.
get(), Owned, Policy);
2285 Diag(StartLoc, DiagID) << PrevSpec;
2302 if (Tok.isNot(tok::semi)) {
2303 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
2304 ExpectAndConsume(tok::semi, diag::err_expected_after,
2309 PP.EnterToken(Tok,
true);
2310 Tok.setKind(tok::semi);
2315void Parser::ParseBaseClause(
Decl *ClassDecl) {
2316 assert(Tok.is(tok::colon) &&
"Not a base clause");
2320 SmallVector<CXXBaseSpecifier *, 8> BaseInfo;
2325 if (!
Result.isUsable()) {
2331 BaseInfo.push_back(
Result.get());
2341 Actions.ActOnBaseSpecifiers(ClassDecl, BaseInfo);
2345 bool IsVirtual =
false;
2346 SourceLocation StartLoc = Tok.getLocation();
2348 ParsedAttributes Attributes(AttrFactory);
2349 MaybeParseCXX11Attributes(Attributes);
2355 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2362 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
2365 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2369 if (Tok.is(tok::kw_virtual)) {
2373 Diag(VirtualLoc, diag::err_dup_virtual)
2381 Diag(Tok.getLocation(), diag::err_hlsl_virtual_inheritance);
2383 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2391 if (
getLangOpts().MSVCCompat && Tok.is(tok::kw__Atomic) &&
2393 Tok.setKind(tok::identifier);
2395 SourceLocation EndLocation;
2396 SourceLocation BaseLoc;
2397 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2404 SourceLocation EllipsisLoc;
2408 SourceRange
Range(StartLoc, EndLocation);
2412 return Actions.ActOnBaseSpecifier(ClassDecl, Range, Attributes, IsVirtual,
2413 Access, BaseType.
get(), BaseLoc,
2418 switch (Tok.getKind()) {
2421 case tok::kw_private:
2423 case tok::kw_protected:
2425 case tok::kw_public:
2430void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2437 if (!NeedLateParse) {
2439 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx) {
2441 if (Param->hasUnparsedDefaultArg()) {
2442 NeedLateParse =
true;
2448 if (NeedLateParse) {
2451 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2452 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2457 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2458 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx)
2459 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2475 const IdentifierInfo *II = Tok.getIdentifierInfo();
2479 Ident_final = &PP.getIdentifierTable().get(
"final");
2481 Ident_GNU_final = &PP.getIdentifierTable().get(
"__final");
2483 Ident_sealed = &PP.getIdentifierTable().get(
"sealed");
2484 Ident_abstract = &PP.getIdentifierTable().get(
"abstract");
2486 Ident_override = &PP.getIdentifierTable().get(
"override");
2489 if (II == Ident_override)
2492 if (II == Ident_sealed)
2495 if (II == Ident_abstract)
2498 if (II == Ident_final)
2501 if (II == Ident_GNU_final)
2507void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2516 Diag(Tok.getLocation(), diag::err_friend_decl_spec)
2519 << SourceRange(FriendLoc, FriendLoc);
2526 const char *PrevSpec =
nullptr;
2527 if (VS.
SetSpecifier(Specifier, Tok.getLocation(), PrevSpec))
2528 Diag(Tok.getLocation(), diag::err_duplicate_virt_specifier)
2533 Diag(Tok.getLocation(), diag::err_override_control_interface)
2536 Diag(Tok.getLocation(), diag::ext_ms_sealed_keyword);
2538 Diag(Tok.getLocation(), diag::ext_ms_abstract_keyword);
2540 Diag(Tok.getLocation(), diag::ext_warn_gnu_final);
2542 DiagCompat(Tok.getLocation(), diag_compat::override_control_keyword)
2549bool Parser::isCXX11FinalKeyword()
const {
2556bool Parser::isClassCompatibleKeyword(
Token Tok)
const {
2564bool Parser::isClassCompatibleKeyword()
const {
2565 return isClassCompatibleKeyword(Tok);
2570bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2583 if (Tok.isNot(tok::colon))
2584 ParseDeclarator(DeclaratorInfo);
2589 if (!IsFunctionDeclarator && !
getLangOpts().MSVCCompat)
2590 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2593 MaybeParseHLSLAnnotations(DeclaratorInfo,
nullptr,
2598 "don't know where identifier would go yet?");
2602 }
else if (Tok.is(tok::kw_requires)) {
2603 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
2608 ++CurTemplateDepthTracker;
2609 ParseTrailingRequiresClauseWithScope(DeclaratorInfo);
2611 ParseOptionalCXX11VirtSpecifierSeq(
2612 VS, getCurrentClass().IsInterface,
2615 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2620 if (Tok.is(tok::kw_asm)) {
2622 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2623 if (AsmLabel.isInvalid())
2633 DiagnoseAndSkipCXX11Attributes();
2634 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2635 DiagnoseAndSkipCXX11Attributes();
2640 ParseOptionalCXX11VirtSpecifierSeq(
2641 VS, getCurrentClass().IsInterface,
2647 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2648 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2650 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2665void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2667 DeclSpec DS(AttrFactory);
2671 ParseTypeQualifierListOpt(
2672 DS, AR_NoAttributesParsed,
false,
2674 Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
2681 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2682 SourceLocation SpecLoc) {
2683 FixItHint Insertion;
2684 auto &MQ =
Function.getOrCreateMethodQualifiers();
2685 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2686 std::string Name(FixItName.data());
2689 MQ.SetTypeQual(TypeQual, SpecLoc);
2691 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2700 bool RefQualifierIsLValueRef =
true;
2701 SourceLocation RefQualifierLoc;
2702 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2703 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2704 FixItHint Insertion =
2706 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2707 Function.RefQualifierLoc = RefQualifierLoc;
2709 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2710 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2722 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2723 if (Tok.is(tok::at)) {
2725 Diag(Tok, diag::err_at_defs_cxx);
2727 Diag(Tok, diag::err_at_in_class);
2743 bool MalformedTypeSpec =
false;
2745 Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2747 MalformedTypeSpec =
true;
2750 if (Tok.isNot(tok::annot_cxxscope))
2751 isAccessDecl =
false;
2760 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2770 SourceLocation TemplateKWLoc;
2773 false,
false,
true,
true,
2774 false, &TemplateKWLoc, Name)) {
2780 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2781 "access declaration")) {
2789 SourceLocation(), SS, Name,
2791 ParsedAttributesView())));
2798 Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2799 SourceLocation DeclEnd;
2801 DeclGroupRef(ParseStaticAssertDeclaration(DeclEnd)));
2804 if (Tok.is(tok::kw_template)) {
2805 assert(!TemplateInfo.TemplateParams &&
2806 "Nested template improperly parsed?");
2807 ObjCDeclContextSwitch ObjCDC(*
this);
2808 SourceLocation DeclEnd;
2810 DeclEnd, AccessAttrs, AS);
2814 if (Tok.is(tok::kw___extension__)) {
2816 ExtensionRAIIObject O(Diags);
2818 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2822 ParsedAttributes DeclAttrs(AttrFactory);
2824 MaybeParseCXX11Attributes(DeclAttrs);
2829 if (Tok.is(tok::annot_attr_openmp))
2830 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
2832 if (Tok.is(tok::kw_using)) {
2837 while (Tok.is(tok::kw_template)) {
2839 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
2843 if (Tok.is(tok::kw_namespace)) {
2844 Diag(UsingLoc, diag::err_using_namespace_in_class);
2848 SourceLocation DeclEnd;
2851 UsingLoc, DeclEnd, DeclAttrs, AS);
2854 ParsedAttributes DeclSpecAttrs(AttrFactory);
2856 LateParsedAttrList CommonLateParsedAttrs;
2858 while (MaybeParseCXX11Attributes(DeclAttrs) ||
2859 MaybeParseGNUAttributes(DeclSpecAttrs, &CommonLateParsedAttrs) ||
2860 MaybeParseMicrosoftAttributes(DeclSpecAttrs))
2863 SourceLocation DeclStart;
2864 if (DeclAttrs.Range.isValid()) {
2865 DeclStart = DeclSpecAttrs.Range.
isInvalid()
2866 ? DeclAttrs.Range.getBegin()
2867 : std::min(DeclAttrs.Range.getBegin(),
2868 DeclSpecAttrs.Range.getBegin());
2870 DeclStart = DeclSpecAttrs.Range.getBegin();
2875 ParsingDeclSpec DS(*
this, TemplateDiags);
2878 if (MalformedTypeSpec)
2886 bool IsTemplateSpecOrInst =
2889 SuppressAccessChecks diagsFromTag(*
this, IsTemplateSpecOrInst);
2891 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
2892 &CommonLateParsedAttrs);
2894 if (IsTemplateSpecOrInst)
2895 diagsFromTag.done();
2907 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
2908 &CommonLateParsedAttrs))
2912 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
2914 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
2918 ProhibitAttributes(DeclAttrs);
2920 RecordDecl *AnonRecord =
nullptr;
2921 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(
2922 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
2923 Actions.ActOnDefinedDeclarationSpecifier(TheDecl);
2924 DS.complete(TheDecl);
2926 Decl *decls[] = {AnonRecord, TheDecl};
2927 return Actions.BuildDeclaratorGroup(decls);
2929 return Actions.ConvertDeclToDeclGroup(TheDecl);
2933 Actions.ActOnDefinedDeclarationSpecifier(DS.
getRepAsDecl());
2938 DiagCompat(Tok.getLocation(), diag_compat::variadic_friends);
2941 SmallVector<Decl *> Decls;
2944 auto ParsedFriendDecl = [&](ParsingDeclSpec &DeclSpec) {
2945 SourceLocation VariadicLoc;
2948 RecordDecl *AnonRecord =
nullptr;
2949 Decl *D = Actions.ParsedFreeStandingDeclSpec(
2950 getCurScope(), AS, DeclSpec, DeclAttrs, TemplateParams,
false,
2951 AnonRecord, VariadicLoc);
2952 DeclSpec.complete(D);
2962 if (ParsedFriendDecl(DS))
2966 ParsingDeclSpec DeclSpec(*
this, TemplateDiags);
2967 const char *PrevSpec =
nullptr;
2968 unsigned DiagId = 0;
2969 DeclSpec.SetFriendSpec(FriendLoc, PrevSpec, DiagId);
2970 ParseDeclarationSpecifiers(DeclSpec, TemplateInfo, AS,
2971 DeclSpecContext::DSC_class,
nullptr);
2972 if (ParsedFriendDecl(DeclSpec))
2976 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_stmt,
2977 "friend declaration");
2979 return Actions.BuildDeclaratorGroup(Decls);
2985 if (Tok.is(tok::kw_concept)) {
2989 ? llvm::to_underlying(diag::err_friend_concept)
2990 : llvm::to_underlying(
2992 err_concept_decls_may_only_appear_in_global_namespace_scope));
2997 ParsingDeclarator DeclaratorInfo(*
this, DS, DeclAttrs,
2999 if (TemplateInfo.TemplateParams)
3004 LateParsedAttrList LateParsedAttrs;
3006 SourceLocation EqualLoc;
3007 SourceLocation PureSpecLoc;
3009 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
3010 if (Tok.isNot(tok::equal))
3014 SmallString<8> Buffer;
3015 if (
Zero.isNot(tok::numeric_constant) ||
3016 PP.getSpelling(
Zero, Buffer) !=
"0")
3020 if (!
After.isOneOf(tok::semi, tok::comma) &&
3021 !(AllowDefinition &&
3022 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3030 SmallVector<Decl *, 8> DeclsInGroup;
3033 bool ExpectSemi =
true;
3038 SuppressAccessChecks SAC(*
this, IsTemplateSpecOrInst);
3041 if (ParseCXXMemberDeclaratorBeforeInitializer(
3042 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3047 if (IsTemplateSpecOrInst)
3055 TryConsumePureSpecifier(
true);
3066 if (Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3068 }
else if (Tok.is(tok::equal)) {
3070 if (KW.
is(tok::kw_default))
3072 else if (KW.
is(tok::kw_delete))
3074 else if (KW.
is(tok::code_completion)) {
3076 Actions.CodeCompletion().CodeCompleteAfterFunctionEquals(
3091 ProhibitAttributes(DeclAttrs);
3108 diag::err_function_declared_typedef);
3114 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3115 TemplateInfo, VS, PureSpecLoc);
3118 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3119 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3121 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3122 LateParsedAttrs[i]->addDecl(FunDecl);
3125 LateParsedAttrs.clear();
3128 if (Tok.is(tok::semi))
3141 bool HasStaticInitializer =
false;
3142 if (Tok.isOneOf(tok::equal, tok::l_brace) && PureSpecLoc.
isInvalid()) {
3146 Diag(Tok, diag::err_anon_bitfield_member_init);
3150 if (!TryConsumePureSpecifier(
false))
3152 HasStaticInitializer =
true;
3160 if (BitfieldSize.
get())
3161 DiagCompat(Tok, diag_compat::bitfield_member_init);
3164 HasStaticInitializer =
true;
3172 NamedDecl *ThisDecl =
nullptr;
3180 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3181 auto Loc = AL.getRange().getBegin();
3182 (AL.isRegularKeywordAttribute()
3183 ?
Diag(Loc, diag::err_keyword_not_allowed) << AL
3184 :
Diag(Loc, diag::err_attributes_not_allowed))
3188 ThisDecl = Actions.ActOnFriendFunctionDecl(
getCurScope(), DeclaratorInfo,
3191 ThisDecl = Actions.ActOnCXXMemberDeclarator(
3192 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3193 VS, HasInClassInit);
3195 if (VarTemplateDecl *VT =
3196 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3199 ThisDecl = VT->getTemplatedDecl();
3202 Actions.ProcessDeclAttributeList(
getCurScope(), ThisDecl, AccessAttrs);
3211 HasStaticInitializer =
true;
3215 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3217 if (ThisDecl && PureSpecLoc.
isValid())
3218 Actions.ActOnPureSpecifier(ThisDecl, PureSpecLoc);
3225 DiagCompat(Tok, diag_compat::nonstatic_member_init);
3233 Diag(Tok, diag::err_incomplete_array_member_init);
3240 ParseCXXNonStaticMemberInitializer(ThisDecl);
3241 }
else if (HasStaticInitializer) {
3246 if (
Init.isInvalid()) {
3248 Actions.ActOnUninitializedDecl(ThisDecl);
3250 }
else if (ThisDecl)
3251 Actions.AddInitializerToDecl(ThisDecl,
Init.get(),
3255 Actions.ActOnUninitializedDecl(ThisDecl);
3260 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3261 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3263 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3264 LateParsedAttrs[i]->addDecl(ThisDecl);
3266 Actions.FinalizeDeclaration(ThisDecl);
3267 DeclsInGroup.push_back(ThisDecl);
3272 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3274 LateParsedAttrs.clear();
3276 DeclaratorInfo.complete(ThisDecl);
3280 SourceLocation CommaLoc;
3284 if (Tok.isAtStartOfLine() &&
3289 Diag(CommaLoc, diag::err_expected_semi_declaration)
3301 Diag(CommaLoc, diag::err_multiple_template_declarators)
3302 << TemplateInfo.Kind;
3306 DeclaratorInfo.
clear();
3309 EqualLoc = PureSpecLoc = SourceLocation();
3315 DiagnoseAndSkipCXX11Attributes();
3316 MaybeParseGNUAttributes(DeclaratorInfo);
3317 DiagnoseAndSkipCXX11Attributes();
3319 if (ParseCXXMemberDeclaratorBeforeInitializer(
3320 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3325 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list) &&
3326 !isLikelyAtStartOfNewDeclaration()) {
3334 return Actions.FinalizeDeclaratorGroup(
getCurScope(), DS, DeclsInGroup);
3337ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
3339 assert(Tok.isOneOf(tok::equal, tok::l_brace) &&
3340 "Data member initializer not starting with '=' or '{'");
3342 bool IsFieldInitialization = isa_and_present<FieldDecl>(D);
3344 EnterExpressionEvaluationContext Context(
3346 IsFieldInitialization
3354 Actions.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
3355 IsFieldInitialization;
3358 if (Tok.is(tok::kw_delete)) {
3365 if (IsFunction ||
Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3371 SkipDeletedFunctionBody();
3374 }
else if (Tok.is(tok::kw_default)) {
3376 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3384 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
3385 Diag(Tok, diag::err_ms_property_initializer) << PD;
3388 return ParseInitializer(D);
3395 while (isClassCompatibleKeyword())
3400 ParsedAttributes Attrs(AttrFactory);
3401 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3406 if (Tok.isNot(tok::colon) && Tok.isNot(tok::l_brace))
3412 if (Tok.is(tok::colon)) {
3415 ParsingClassDefinition ParsingDef(*
this, TagDecl,
true,
3418 Actions.ActOnTagStartSkippedDefinition(
getCurScope(), TagDecl);
3421 ParseBaseClause(
nullptr);
3423 Actions.ActOnTagFinishSkippedDefinition(OldContext);
3425 if (!Tok.is(tok::l_brace)) {
3426 Diag(PP.getLocForEndOfToken(PrevTokLocation),
3427 diag::err_expected_lbrace_after_base_specifiers);
3433 assert(Tok.is(tok::l_brace));
3439 if (Tok.is(tok::kw___attribute)) {
3440 ParsedAttributes Attrs(AttrFactory);
3441 MaybeParseGNUAttributes(Attrs);
3450 switch (Tok.getKind()) {
3451 case tok::kw___if_exists:
3452 case tok::kw___if_not_exists:
3453 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, AS);
3462 case tok::annot_pragma_vis:
3463 HandlePragmaVisibility();
3465 case tok::annot_pragma_pack:
3468 case tok::annot_pragma_align:
3469 HandlePragmaAlign();
3471 case tok::annot_pragma_ms_pointers_to_members:
3472 HandlePragmaMSPointersToMembers();
3474 case tok::annot_pragma_ms_pragma:
3475 HandlePragmaMSPragma();
3477 case tok::annot_pragma_ms_vtordisp:
3478 HandlePragmaMSVtorDisp();
3480 case tok::annot_pragma_export:
3481 HandlePragmaExport();
3483 case tok::annot_pragma_dump:
3487 case tok::kw_namespace:
3492 case tok::kw_private:
3496 ParsedTemplateInfo TemplateInfo;
3497 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3500 case tok::kw_public:
3501 case tok::kw_protected: {
3503 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
3508 SourceLocation ASLoc = Tok.getLocation();
3509 unsigned TokLength = Tok.getLength();
3511 AccessAttrs.
clear();
3512 MaybeParseGNUAttributes(AccessAttrs);
3514 SourceLocation EndLoc;
3517 Diag(EndLoc, diag::err_expected)
3521 Diag(EndLoc, diag::err_expected)
3531 if (Actions.ActOnAccessSpecifier(NewAS, ASLoc, EndLoc, AccessAttrs)) {
3533 AccessAttrs.
clear();
3539 case tok::annot_attr_openmp:
3540 case tok::annot_pragma_openmp:
3541 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3542 AS, AccessAttrs,
true, TagType, TagDecl);
3543 case tok::annot_pragma_openacc:
3548 Diag(Tok.getLocation(), diag::err_pragma_misplaced_in_decl)
3550 TagType, Actions.getASTContext().getPrintingPolicy());
3551 ConsumeAnnotationToken();
3554 ParsedTemplateInfo TemplateInfo;
3555 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3566 "Invalid TagType!");
3568 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3569 if (
auto *TD = dyn_cast_or_null<NamedDecl>(TagDecl))
3570 return TD->getQualifiedNameAsString();
3571 return std::string(
"<anonymous>");
3574 PrettyDeclStackTraceEntry CrashInfo(Actions.Context, TagDecl,
RecordLoc,
3575 "parsing struct/union/class body");
3579 bool NonNestedClass =
true;
3580 if (!ClassStack.empty()) {
3582 if (S->isClassScope()) {
3584 NonNestedClass =
false;
3587 if (getCurrentClass().IsInterface) {
3597 if (S->isFunctionScope())
3608 ParsingClassDefinition ParsingDef(*
this, TagDecl, NonNestedClass,
3612 Actions.ActOnTagStartDefinition(
getCurScope(), TagDecl);
3614 SourceLocation FinalLoc;
3615 SourceLocation AbstractLoc;
3616 bool IsFinalSpelledSealed =
false;
3617 bool IsAbstract =
false;
3626 if (isCXX11FinalKeyword()) {
3629 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3634 IsFinalSpelledSealed =
true;
3639 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3647 Diag(FinalLoc, diag::err_override_control_interface)
3650 DiagCompat(FinalLoc, diag_compat::override_control_keyword)
3653 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3655 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3657 Diag(FinalLoc, diag::ext_warn_gnu_final);
3660 "not a class definition");
3666 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3675 if (!Tok.is(tok::colon) && !Tok.is(tok::l_brace)) {
3677 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3682 if (Tok.is(tok::colon)) {
3686 ParseBaseClause(TagDecl);
3687 if (!Tok.is(tok::l_brace)) {
3688 bool SuggestFixIt =
false;
3689 SourceLocation BraceLoc = PP.getLocForEndOfToken(PrevTokLocation);
3690 if (Tok.isAtStartOfLine()) {
3691 switch (Tok.getKind()) {
3692 case tok::kw_private:
3693 case tok::kw_protected:
3694 case tok::kw_public:
3697 case tok::kw_static_assert:
3701 case tok::kw_template:
3702 SuggestFixIt =
true;
3704 case tok::identifier:
3705 SuggestFixIt = isConstructorDeclarator(
true);
3708 SuggestFixIt = isCXXSimpleDeclaration(
false);
3712 DiagnosticBuilder LBraceDiag =
3713 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3717 PP.EnterToken(Tok,
true);
3718 Tok.setKind(tok::l_brace);
3721 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3727 assert(Tok.is(tok::l_brace));
3732 Actions.ActOnStartCXXMemberDeclarations(
getCurScope(), TagDecl, FinalLoc,
3733 IsFinalSpelledSealed, IsAbstract,
3734 T.getOpenLocation());
3745 ParsedAttributes AccessAttrs(AttrFactory);
3749 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
3750 Tok.isNot(tok::eof)) {
3752 ParseCXXClassMemberDeclarationWithPragmas(
3753 CurAS, AccessAttrs,
static_cast<DeclSpec::TST>(TagType), TagDecl);
3754 MaybeDestroyTemplateIds();
3762 ParsedAttributes attrs(AttrFactory);
3763 MaybeParseGNUAttributes(attrs);
3767 T.getOpenLocation(),
3768 T.getCloseLocation(), attrs);
3775 if (TagDecl && NonNestedClass) {
3781 SourceLocation SavedPrevTokLocation = PrevTokLocation;
3782 ParseLexedPragmas(getCurrentClass());
3783 ParseLexedAttributes(getCurrentClass());
3784 ParseLexedMethodDeclarations(getCurrentClass());
3787 Actions.ActOnFinishCXXMemberDecls();
3789 ParseLexedMemberInitializers(getCurrentClass());
3790 ParseLexedMethodDefs(getCurrentClass());
3791 PrevTokLocation = SavedPrevTokLocation;
3795 Actions.ActOnFinishCXXNonNestedClass();
3799 Actions.ActOnTagFinishDefinition(
getCurScope(), TagDecl,
T.getRange());
3806void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3807 assert(Tok.is(tok::kw_namespace));
3812 Diag(Tok.getLocation(), diag::note_missing_end_of_definition_before) << D;
3815 PP.EnterToken(Tok,
true);
3818 Tok.
setLocation(PP.getLocForEndOfToken(PrevTokLocation));
3819 Tok.setKind(tok::semi);
3820 PP.EnterToken(Tok,
true);
3822 Tok.setKind(tok::r_brace);
3825void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3826 assert(Tok.is(tok::colon) &&
3827 "Constructor initializer always starts with ':'");
3834 SmallVector<CXXCtorInitializer *, 4> MemInitializers;
3835 bool AnyErrors =
false;
3838 if (Tok.is(tok::code_completion)) {
3840 Actions.CodeCompletion().CodeCompleteConstructorInitializer(
3841 ConstructorDecl, MemInitializers);
3845 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3847 MemInitializers.push_back(MemInit.
get());
3851 if (Tok.is(tok::comma))
3853 else if (Tok.is(tok::l_brace))
3858 Tok.isOneOf(tok::identifier, tok::coloncolon)) {
3859 SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
3860 Diag(Loc, diag::err_ctor_init_missing_comma)
3865 Diag(Tok.getLocation(), diag::err_expected_either)
3866 << tok::l_brace << tok::comma;
3872 Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc, MemInitializers,
3879 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
3885 IdentifierInfo *II =
nullptr;
3886 SourceLocation IdLoc = Tok.getLocation();
3888 DeclSpec DS(AttrFactory);
3892 if (Tok.is(tok::identifier)) {
3895 II = Tok.getIdentifierInfo();
3897 }
else if (Tok.is(tok::annot_decltype)) {
3902 ParseDecltypeSpecifier(DS);
3903 }
else if (Tok.is(tok::annot_pack_indexing_type)) {
3906 ParsePackIndexingType(DS);
3908 TemplateIdAnnotation *TemplateId = Tok.is(tok::annot_template_id)
3909 ? takeTemplateIdAnnotation(Tok)
3914 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
3916 ConsumeAnnotationToken();
3918 Diag(Tok, diag::err_expected_member_or_base_name);
3925 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
3928 ExprResult InitList = ParseBraceInitializer();
3932 SourceLocation EllipsisLoc;
3937 return Actions.ActOnMemInitializer(ConstructorDecl,
getCurScope(), SS, II,
3938 TemplateTypeTy.
get(), DS, IdLoc,
3939 InitList.
get(), EllipsisLoc);
3940 }
else if (Tok.is(tok::l_paren)) {
3945 ExprVector ArgExprs;
3946 auto RunSignatureHelp = [&] {
3949 QualType PreferredType =
3950 Actions.CodeCompletion().ProduceCtorInitMemberSignatureHelp(
3951 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
3952 T.getOpenLocation(),
false);
3953 CalledSignatureHelp =
true;
3954 return PreferredType;
3956 if (Tok.isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
3957 PreferredType.enterFunctionArgument(Tok.getLocation(),
3960 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
3968 SourceLocation EllipsisLoc;
3973 return Actions.ActOnMemInitializer(
3974 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
3975 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
3982 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
3984 return Diag(Tok, diag::err_expected) << tok::l_paren;
3993 ExceptionSpecTokens =
nullptr;
3997 if (Tok.isNot(tok::kw_throw) && Tok.isNot(tok::kw_noexcept))
4001 bool IsNoexcept = Tok.is(tok::kw_noexcept);
4002 Token StartTok = Tok;
4006 if (!Tok.is(tok::l_paren)) {
4009 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4010 NoexceptExpr =
nullptr;
4014 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4020 ExceptionSpecTokens->push_back(StartTok);
4021 ExceptionSpecTokens->push_back(Tok);
4022 SpecificationRange.
setEnd(ConsumeParen());
4024 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4027 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4033 if (Tok.is(tok::kw_throw)) {
4034 Result = ParseDynamicExceptionSpecification(
4035 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4036 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4037 "Produced different number of exception types and ranges.");
4041 if (Tok.isNot(tok::kw_noexcept))
4044 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4048 SourceRange NoexceptRange;
4052 if (Tok.is(tok::l_paren)) {
4057 EnterExpressionEvaluationContext ConstantEvaluated(
4064 Actions.ActOnNoexceptSpec(NoexceptExpr.
get(), NoexceptType);
4065 NoexceptRange = SourceRange(KeywordLoc,
T.getCloseLocation());
4072 NoexceptRange = SourceRange(KeywordLoc, KeywordLoc);
4076 SpecificationRange = NoexceptRange;
4081 if (Tok.is(tok::kw_throw)) {
4082 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4083 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4084 DynamicExceptionRanges);
4087 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4096 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4098 ? diag::ext_dynamic_exception_spec
4099 : diag::warn_exception_spec_deprecated)
4101 P.
Diag(Range.getBegin(), diag::note_exception_spec_deprecated)
4109 assert(Tok.is(tok::kw_throw) &&
"expected throw");
4113 if (
T.consumeOpen()) {
4114 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4121 if (Tok.is(tok::ellipsis)) {
4124 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4126 SpecificationRange.
setEnd(
T.getCloseLocation());
4133 while (Tok.isNot(tok::r_paren)) {
4136 if (Tok.is(tok::ellipsis)) {
4141 Range.setEnd(Ellipsis);
4142 if (!Res.isInvalid())
4143 Res = Actions.ActOnPackExpansion(Res.get(), Ellipsis);
4146 if (!Res.isInvalid()) {
4147 Exceptions.push_back(Res.get());
4148 Ranges.push_back(Range);
4156 SpecificationRange.
setEnd(
T.getCloseLocation());
4158 Exceptions.empty());
4163 bool MayBeFollowedByDirectInit) {
4164 assert(Tok.is(tok::arrow) &&
"expected arrow");
4173void Parser::ParseTrailingRequiresClauseWithScope(
Declarator &D) {
4174 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4190 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4192 DeclScopeObj.EnterDeclaratorScope();
4198 ParseTrailingRequiresClause(D);
4201void Parser::ParseTrailingRequiresClause(
Declarator &D) {
4202 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4205 "trailing requires-clause must be parsed in a function prototype scope");
4210 Actions.ActOnStartTrailingRequiresClause(
getCurScope(), D);
4212 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4213 InitCXXThisScopeForDeclaratorIfRelevant(D, D.
getDeclSpec(), ThisScope);
4215 TrailingRequiresClause =
4218 TrailingRequiresClause =
4219 Actions.ActOnFinishTrailingRequiresClause(TrailingRequiresClause);
4223 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4228 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4236 SourceLocation ArrowLoc = Tok.getLocation();
4239 ParseTrailingReturnType(Range,
false);
4243 diag::err_requires_clause_must_appear_after_trailing_return)
4248 FunctionChunk.TrailingReturnTypeLoc =
Range.getBegin();
4250 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4256 bool NonNestedClass,
4258 assert((NonNestedClass || !ClassStack.empty()) &&
4259 "Nested class without outer class");
4260 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4261 return Actions.PushParsingClass();
4264void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4265 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4266 delete Class->LateParsedDeclarations[I];
4271 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4273 Actions.PopParsingClass(state);
4275 ParsingClass *Victim = ClassStack.top();
4277 if (Victim->TopLevelClass) {
4280 DeallocateParsedClasses(Victim);
4283 assert(!ClassStack.empty() &&
"Missing top-level class?");
4285 if (Victim->LateParsedDeclarations.empty()) {
4290 DeallocateParsedClasses(Victim);
4298 "Nested class outside of class scope?");
4299 ClassStack.top()->LateParsedDeclarations.push_back(
4300 new LateParsedClass(
this, Victim));
4306 switch (Tok.getKind()) {
4309 if (!Tok.isAnnotation()) {
4310 if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
4317 case tok::code_completion:
4319 Actions.CodeCompletion().CodeCompleteAttribute(
4324 case tok::numeric_constant: {
4328 if (Tok.getLocation().isMacroID()) {
4329 SmallString<8> ExpansionBuf;
4330 SourceLocation ExpansionLoc =
4331 PP.getSourceManager().getExpansionLoc(Tok.getLocation());
4332 StringRef Spelling = PP.getSpelling(ExpansionLoc, ExpansionBuf);
4333 if (Spelling ==
"__clang__") {
4334 SourceRange TokRange(
4336 PP.getSourceManager().getExpansionLoc(Tok.getEndLoc()));
4337 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4340 return &PP.getIdentifierTable().get(
"_Clang");
4353 case tok::pipeequal:
4354 case tok::caretequal:
4356 case tok::exclaimequal:
4359 SmallString<8> SpellingBuf;
4360 SourceLocation SpellingLoc =
4361 PP.getSourceManager().getSpellingLoc(Tok.getLocation());
4362 StringRef Spelling = PP.getSpelling(SpellingLoc, SpellingBuf);
4365 return &PP.getIdentifierTable().get(Spelling);
4371void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4376 if (
T.consumeOpen()) {
4377 Diag(Tok, diag::err_expected) << tok::l_paren;
4381 if (
AttrName->isStr(
"directive")) {
4387 OMPBeginTok.
setKind(tok::annot_attr_openmp);
4389 OpenMPTokens.push_back(OMPBeginTok);
4391 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4395 OMPEndTok.
setKind(tok::annot_pragma_openmp_end);
4397 OpenMPTokens.push_back(OMPEndTok);
4399 assert(
AttrName->isStr(
"sequence") &&
4400 "Expected either 'directive' or 'sequence'");
4408 SourceLocation IdentLoc;
4409 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4413 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4414 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4418 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4419 Diag(Tok.getLocation(), diag::err_expected_sequence_or_directive);
4425 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4439 case ParsedAttr::AT_Deprecated:
4440 case ParsedAttr::AT_FallThrough:
4441 case ParsedAttr::AT_CXX11NoReturn:
4442 case ParsedAttr::AT_NoUniqueAddress:
4443 case ParsedAttr::AT_Likely:
4444 case ParsedAttr::AT_Unlikely:
4446 case ParsedAttr::AT_WarnUnusedResult:
4447 return !ScopeName && AttrName->getName() ==
"nodiscard";
4448 case ParsedAttr::AT_Unused:
4449 return !ScopeName && AttrName->getName() ==
"maybe_unused";
4455bool Parser::ParseCXXAssumeAttributeArg(
4459 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4467 TentativeParsingAction TPA(*
this);
4472 if (Tok.is(tok::r_paren))
4477 if (!Tok.isOneOf(tok::r_paren, tok::r_square)) {
4483 auto *E = Res.
get();
4484 Diag(E->getExprLoc(), diag::err_assume_attr_expects_cond_expr)
4488 << E->getSourceRange();
4497 auto RParen = Tok.getLocation();
4499 Attrs.
addNew(AttrName, SourceRange(AttrNameLoc, RParen),
4500 AttributeScopeInfo(ScopeName, ScopeLoc), &Assumption, 1, Form);
4508bool Parser::ParseCXX11AttributeArgs(
4512 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4513 SourceLocation LParenLoc = Tok.getLocation();
4515 ParsedAttr::Form Form =
4516 LO.CPlusPlus ? ParsedAttr::Form::CXX11() : ParsedAttr::Form::
C23();
4522 Form = ParsedAttr::Form::Microsoft();
4526 TentativeParsingAction TPA(*this);
4527 bool HasInvalidArgument = false;
4528 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof)) {
4529 if (Tok.isOneOf(tok::hash, tok::hashhash)) {
4530 Diag(Tok.getLocation(), diag::ext_invalid_attribute_argument)
4531 << PP.getSpelling(Tok);
4532 HasInvalidArgument = true;
4537 if (HasInvalidArgument) {
4551 ScopeName, AttrName, getTargetInfo(), getLangOpts())) {
4554 SkipUntil(tok::r_paren);
4558 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4561 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4562 ScopeLoc, Form, nullptr);
4567 if (ScopeName && ScopeName->
isStr(
"omp") &&
4569 Diag(AttrNameLoc, getLangOpts().OpenMP >= 51
4570 ? diag::warn_omp51_compat_attributes
4571 : diag::ext_omp_attributes);
4573 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4582 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4583 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4584 ScopeName, ScopeLoc, Form);
4586 else if (!ScopeName &&
AttrName->isStr(
"assume")) {
4587 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, nullptr,
4588 SourceLocation{}, EndLoc, Form))
4592 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4593 ScopeName, ScopeLoc, Form);
4595 if (!Attrs.
empty() &&
4600 if (!
Attr.existsInTarget(getTargetInfo())) {
4601 Actions.DiagnoseUnknownAttribute(
Attr);
4602 Attr.setInvalid(
true);
4610 if (
Attr.getMaxArgs() && !NumArgs) {
4613 Diag(LParenLoc, diag::err_attribute_requires_arguments) <<
AttrName;
4614 Attr.setInvalid(
true);
4615 }
else if (!
Attr.getMaxArgs()) {
4619 auto D =
Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4623 Attr.setInvalid(
true);
4632 if (Tok.is(tok::kw_alignas)) {
4638 Diag(Tok.getLocation(), diag::warn_cxx98_compat_alignas);
4639 ParseAlignmentSpecifier(Attrs, EndLoc);
4643 if (Tok.isRegularKeywordAttribute()) {
4644 SourceLocation Loc = Tok.getLocation();
4645 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
4646 ParsedAttr::Form Form = ParsedAttr::Form(Tok.getKind());
4650 if (!Tok.is(tok::l_paren))
4651 Diag(Tok.getLocation(), diag::err_expected_lparen_after) <<
AttrName;
4653 ParseAttributeArgsCommon(AttrName, Loc, Attrs, EndLoc,
4657 Attrs.
addNew(AttrName, Loc, AttributeScopeInfo(),
nullptr, 0, Form);
4661 assert(Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square) &&
4662 "Not a double square bracket attribute list");
4664 SourceLocation OpenLoc = Tok.getLocation();
4666 : diag_compat::c23_attributes);
4669 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4672 SourceLocation CommonScopeLoc;
4673 IdentifierInfo *CommonScopeName =
nullptr;
4674 if (Tok.is(tok::kw_using)) {
4675 DiagCompat(Tok.getLocation(), diag_compat::using_attribute_ns);
4678 CommonScopeName = TryParseCXX11AttributeIdentifier(
4680 if (!CommonScopeName) {
4681 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4685 Diag(Tok.getLocation(), diag::err_expected) << tok::colon;
4688 bool AttrParsed =
false;
4689 while (!Tok.isOneOf(tok::r_square, tok::semi, tok::eof)) {
4693 if (ExpectAndConsume(tok::comma)) {
4704 SourceLocation ScopeLoc, AttrLoc;
4705 IdentifierInfo *ScopeName =
nullptr, *
AttrName =
nullptr;
4707 AttrName = TryParseCXX11AttributeIdentifier(
4719 AttrName = TryParseCXX11AttributeIdentifier(
4723 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4729 if (CommonScopeName) {
4731 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4732 << SourceRange(CommonScopeLoc);
4734 ScopeName = CommonScopeName;
4735 ScopeLoc = CommonScopeLoc;
4740 if (Tok.is(tok::l_paren))
4741 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
4742 ScopeName, ScopeLoc, OpenMPTokens);
4750 AttributeScopeInfo(ScopeName, ScopeLoc, CommonScopeLoc),
4753 : ParsedAttr::Form::C23());
4758 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) <<
AttrName;
4761 SourceLocation CloseLoc = Tok.getLocation();
4762 bool IsTokenNotFound = ExpectAndConsume(tok::r_square);
4763 if (IsTokenNotFound)
4765 else if (Tok.is(tok::r_square))
4766 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
4768 *EndLoc = Tok.getLocation();
4769 if (!IsTokenNotFound && ExpectAndConsume(tok::r_square))
4774 SourceLocation StartLoc = Tok.getLocation();
4775 SourceLocation EndLoc = StartLoc;
4778 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
4779 }
while (isAllowedCXX11AttributeSpecifier());
4781 Attrs.
Range = SourceRange(StartLoc, EndLoc);
4784void Parser::DiagnoseAndSkipCXX11Attributes() {
4786 Tok.isRegularKeywordAttribute() ? Tok.getIdentifierInfo() :
nullptr;
4788 SourceLocation StartLoc = Tok.getLocation();
4789 SourceLocation EndLoc = SkipCXX11Attributes();
4792 SourceRange
Range(StartLoc, EndLoc);
4794 :
Diag(StartLoc, diag::err_attributes_not_allowed))
4800 SourceLocation EndLoc;
4806 if (Tok.is(tok::l_square)) {
4810 EndLoc =
T.getCloseLocation();
4811 }
else if (Tok.isRegularKeywordAttribute() &&
4813 EndLoc = Tok.getLocation();
4816 assert((Tok.is(tok::kw_alignas) || Tok.isRegularKeywordAttribute()) &&
4817 "not an attribute specifier");
4820 if (!
T.consumeOpen())
4822 EndLoc =
T.getCloseLocation();
4824 }
while (isCXX11AttributeSpecifier() !=
4831 assert(Tok.is(tok::identifier) &&
"Not a Microsoft attribute list");
4832 IdentifierInfo *UuidIdent = Tok.getIdentifierInfo();
4833 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
4835 SourceLocation UuidLoc = Tok.getLocation();
4840 if (
T.consumeOpen()) {
4841 Diag(Tok, diag::err_expected) << tok::l_paren;
4846 if (isTokenStringLiteral()) {
4851 ArgExprs.push_back(StringResult.
get());
4857 SmallString<42> StrBuffer;
4867 SourceLocation StartLoc = Tok.getLocation();
4868 while (Tok.isNot(tok::r_paren)) {
4869 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4870 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4874 SmallString<16> SpellingBuffer;
4875 SpellingBuffer.resize(Tok.getLength() + 1);
4876 bool Invalid =
false;
4877 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
4882 StrBuffer += TokSpelling;
4887 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4888 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4898 Toks[0].
setKind(tok::string_literal);
4902 StringLiteral *UuidString =
4904 ArgExprs.push_back(UuidString);
4907 if (!
T.consumeClose()) {
4908 Attrs.
addNew(UuidIdent, SourceRange(UuidLoc,
T.getCloseLocation()),
4909 AttributeScopeInfo(), ArgExprs.data(), ArgExprs.size(),
4910 ParsedAttr::Form::Microsoft());
4915 assert(Tok.is(tok::identifier) &&
4916 "Expected an identifier to denote which MS attribute to consider");
4917 IdentifierInfo *RootSignatureIdent = Tok.getIdentifierInfo();
4918 assert(RootSignatureIdent->
getName() ==
"RootSignature" &&
4919 "Expected RootSignature identifier for root signature attribute");
4921 SourceLocation RootSignatureLoc = Tok.getLocation();
4926 if (
T.consumeOpen()) {
4927 Diag(Tok, diag::err_expected) << tok::l_paren;
4931 auto ProcessStringLiteral = [
this]() -> std::optional<StringLiteral *> {
4932 if (!isTokenStringLiteral())
4933 return std::nullopt;
4937 return std::nullopt;
4939 if (
auto Lit = dyn_cast<StringLiteral>(StringResult.
get()))
4942 return std::nullopt;
4945 auto Signature = ProcessStringLiteral();
4946 if (!Signature.has_value()) {
4947 Diag(Tok, diag::err_expected_string_literal)
4948 << 4 <<
"RootSignature";
4954 Actions,
getLangOpts().HLSLRootSigVer, *Signature);
4962 IdentifierLoc *ILoc = ::new (Actions.getASTContext())
4963 IdentifierLoc(RootSignatureLoc, DeclIdent);
4967 if (!
T.consumeClose())
4968 Attrs.
addNew(RootSignatureIdent,
4969 SourceRange(RootSignatureLoc,
T.getCloseLocation()),
4970 AttributeScopeInfo(), Args.data(), Args.size(),
4971 ParsedAttr::Form::Microsoft());
4975 assert(Tok.is(tok::l_square) &&
"Not a Microsoft attribute list");
4977 SourceLocation StartLoc = Tok.getLocation();
4978 SourceLocation EndLoc = StartLoc;
4986 SkipUntil(tok::r_square, tok::identifier,
4988 if (Tok.is(tok::code_completion)) {
4990 Actions.CodeCompletion().CodeCompleteAttribute(
4996 if (Tok.isNot(tok::identifier))
4998 if (Tok.getIdentifierInfo()->getName() ==
"uuid")
4999 ParseMicrosoftUuidAttributeArgs(Attrs);
5000 else if (Tok.getIdentifierInfo()->getName() ==
"RootSignature")
5001 ParseHLSLRootSignatureAttributeArgs(Attrs);
5003 IdentifierInfo *II = Tok.getIdentifierInfo();
5004 SourceLocation NameLoc = Tok.getLocation();
5011 bool AttrParsed =
false;
5012 if (Tok.is(tok::l_paren)) {
5015 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5016 SourceLocation(), OpenMPTokens);
5017 ReplayOpenMPAttributeTokens(OpenMPTokens);
5020 Attrs.
addNew(II, NameLoc, AttributeScopeInfo(),
nullptr, 0,
5021 ParsedAttr::Form::Microsoft());
5028 EndLoc =
T.getCloseLocation();
5029 }
while (Tok.is(tok::l_square));
5031 Attrs.
Range = SourceRange(StartLoc, EndLoc);
5034void Parser::ParseMicrosoftIfExistsClassDeclaration(
5037 IfExistsCondition
Result;
5038 if (ParseMicrosoftIfExistsCondition(
Result))
5042 if (
Braces.consumeOpen()) {
5043 Diag(Tok, diag::err_expected) << tok::l_brace;
5047 switch (
Result.Behavior) {
5053 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5063 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
5065 if (Tok.isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5066 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, CurAS);
5071 if (Tok.is(tok::semi)) {
5080 SourceLocation ASLoc = Tok.getLocation();
5082 if (Tok.is(tok::colon))
5083 Actions.ActOnAccessSpecifier(AS, ASLoc, Tok.getLocation(),
5084 ParsedAttributesView{});
5086 Diag(Tok, diag::err_expected) << tok::colon;
5091 ParsedTemplateInfo TemplateInfo;
5093 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
void setLocation(SourceLocation L)
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)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setLength(unsigned Len)
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
void setLocation(SourceLocation L)
void startToken()
Reset all flags to cleared.
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.
@ Type
The name was classified as a type.
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.