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(
1235 if (Tok.is(tok::less))
1236 return AnnotateTemplateIdToken(
Template, TNK, SS,
1237 SourceLocation(), Name,
1242 if (PP.isBacktrackEnabled())
1243 PP.RevertCachedTokens(1);
1245 PP.EnterToken(Tok,
true);
1253 Actions.ActOnPackIndexingDeducedTemplateSpecializationType(Indexed,
1255 Tok.setKind(tok::annot_typename);
1256 setTypeAnnotation(Tok,
Type);
1259 Tok.setKind(tok::annot_template_id);
1263 SourceLocation(), {},
1264 false, TemplateIds));
1266 Tok.setLocation(NameLoc);
1267 Tok.setAnnotationEndLoc(
T.getCloseLocation());
1268 PP.AnnotateCachedTokens(Tok);
1272void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1276 if (PP.isBacktrackEnabled()) {
1277 PP.RevertCachedTokens(1);
1283 EndLoc = PP.getLastCachedTokenLocation();
1286 PP.EnterToken(Tok,
true);
1288 Tok.setKind(tok::annot_pack_indexing_type);
1289 setTypeAnnotation(Tok,
T);
1290 Tok.setAnnotationEndLoc(EndLoc);
1291 Tok.setLocation(StartLoc);
1292 PP.AnnotateCachedTokens(Tok);
1296 switch (Tok.getKind()) {
1297#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1298 case tok::kw___##Trait: \
1299 return DeclSpec::TST_##Trait;
1300#include "clang/Basic/BuiltinTraits.inc"
1302 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1306bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1308 Tok.setKind(tok::identifier);
1311 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1315 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.getName(),
1320 if (
Result.isInvalid()) {
1326 if (
T.getCloseLocation().isInvalid())
1329 const char *PrevSpec =
nullptr;
1333 Actions.getASTContext().getPrintingPolicy()))
1334 Diag(StartLoc, DiagID) << PrevSpec;
1342 if (Tok.is(tok::kw_typename)) {
1343 Diag(Tok, diag::err_expected_class_name_not_template)
1350 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1355 BaseLoc = Tok.getLocation();
1360 if (Tok.isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1365 DeclSpec DS(AttrFactory);
1367 EndLocation = ParseDecltypeSpecifier(DS);
1371 return Actions.ActOnTypeName(DeclaratorInfo);
1374 if (Tok.is(tok::annot_pack_indexing_type)) {
1375 DeclSpec DS(AttrFactory);
1376 ParsePackIndexingType(DS);
1379 return Actions.ActOnTypeName(DeclaratorInfo);
1385 if (Tok.is(tok::annot_template_id)) {
1386 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1391 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
1393 EndLocation = Tok.getAnnotationEndLoc();
1394 ConsumeAnnotationToken();
1401 if (Tok.isNot(tok::identifier)) {
1402 Diag(Tok, diag::err_expected_class_name);
1406 IdentifierInfo *Id = Tok.getIdentifierInfo();
1409 if (Tok.is(tok::less)) {
1416 if (!Actions.DiagnoseUnknownTemplateName(*Id, IdLoc,
getCurScope(), &SS,
1418 Diag(IdLoc, diag::err_unknown_template_name) << Id;
1426 if (AnnotateTemplateIdToken(
Template, TNK, SS, SourceLocation(),
1429 if (Tok.is(tok::annot_template_id) &&
1430 takeTemplateIdAnnotation(Tok)->mightBeType())
1436 if (Tok.isNot(tok::annot_typename))
1441 EndLocation = Tok.getAnnotationEndLoc();
1443 ConsumeAnnotationToken();
1448 IdentifierInfo *CorrectedII =
nullptr;
1450 *Id, IdLoc,
getCurScope(), &SS,
true,
false,
nullptr,
1456 Diag(IdLoc, diag::err_expected_class_name);
1461 EndLocation = IdLoc;
1464 DeclSpec DS(AttrFactory);
1469 const char *PrevSpec =
nullptr;
1472 Actions.getASTContext().getPrintingPolicy());
1476 return Actions.ActOnTypeName(DeclaratorInfo);
1479void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1480 while (Tok.isOneOf(tok::kw___single_inheritance,
1481 tok::kw___multiple_inheritance,
1482 tok::kw___virtual_inheritance)) {
1483 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
1484 auto Kind = Tok.getKind();
1486 attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0, Kind);
1491 while (Tok.is(tok::kw__Nullable)) {
1492 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
1493 auto Kind = Tok.getKind();
1495 attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0, Kind);
1499bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1501 switch (Tok.getKind()) {
1503 if (Tok.isRegularKeywordAttribute())
1510 case tok::identifier:
1512 case tok::coloncolon:
1513 case tok::annot_cxxscope:
1514 case tok::annot_typename:
1515 case tok::annot_template_id:
1516 case tok::kw_decltype:
1519 case tok::kw_operator:
1520 case tok::kw___declspec:
1525 case tok::kw___attribute:
1526 case tok::annot_pragma_pack:
1528 case tok::annot_pragma_ms_pragma:
1530 case tok::annot_pragma_ms_vtordisp:
1532 case tok::annot_pragma_ms_pointers_to_members:
1534 case tok::annot_pragma_export:
1537 return CouldBeBitfield ||
1540 case tok::kw___cdecl:
1541 case tok::kw___fastcall:
1542 case tok::kw___stdcall:
1543 case tok::kw___thiscall:
1544 case tok::kw___vectorcall:
1550 case tok::kw_volatile:
1551 case tok::kw_restrict:
1552 case tok::kw__Atomic:
1553 case tok::kw___unaligned:
1557 case tok::kw_inline:
1558 case tok::kw_virtual:
1559 case tok::kw_friend:
1561 case tok::kw_static:
1562 case tok::kw_extern:
1563 case tok::kw_typedef:
1564 case tok::kw_register:
1566 case tok::kw_mutable:
1567 case tok::kw_thread_local:
1568 case tok::kw_constexpr:
1569 case tok::kw_consteval:
1570 case tok::kw_constinit:
1586 if (!isKnownToBeTypeSpecifier(
NextToken()))
1603 ParsedTemplateInfo &TemplateInfo,
1605 DeclSpecContext DSC,
1608 if (TagTokKind == tok::kw_struct)
1610 else if (TagTokKind == tok::kw___interface)
1612 else if (TagTokKind == tok::kw_class)
1615 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1619 if (Tok.is(tok::code_completion)) {
1622 Actions.CodeCompletion().CodeCompleteTag(
getCurScope(), TagType);
1633 const bool shouldDelayDiagsInTag =
1635 SuppressAccessChecks diagsFromTag(*
this, shouldDelayDiagsInTag);
1637 ParsedAttributes attrs(AttrFactory);
1640 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1642 if (Tok.isOneOf(tok::kw___single_inheritance,
1643 tok::kw___multiple_inheritance,
1644 tok::kw___virtual_inheritance)) {
1645 ParseMicrosoftInheritanceClassAttributes(attrs);
1648 if (Tok.is(tok::kw__Nullable)) {
1649 ParseNullabilityClassAttributes(attrs);
1657 SourceLocation AttrFixitLoc = Tok.getLocation();
1660 !Tok.isAnnotation() && Tok.getIdentifierInfo() &&
1663#include
"clang/Basic/BuiltinTraits.inc"
1664 tok::kw___is_abstract,
1665 tok::kw___is_aggregate,
1666 tok::kw___is_arithmetic,
1668 tok::kw___is_assignable,
1669 tok::kw___is_base_of,
1670 tok::kw___is_bounded_array,
1672 tok::kw___is_complete_type,
1673 tok::kw___is_compound,
1675 tok::kw___is_constructible,
1676 tok::kw___is_convertible,
1677 tok::kw___is_convertible_to,
1678 tok::kw___is_destructible,
1681 tok::kw___is_floating_point,
1683 tok::kw___is_function,
1684 tok::kw___is_fundamental,
1685 tok::kw___is_integral,
1686 tok::kw___is_interface_class,
1687 tok::kw___is_literal,
1688 tok::kw___is_lvalue_expr,
1689 tok::kw___is_lvalue_reference,
1690 tok::kw___is_member_function_pointer,
1691 tok::kw___is_member_object_pointer,
1692 tok::kw___is_member_pointer,
1693 tok::kw___is_nothrow_assignable,
1694 tok::kw___is_nothrow_constructible,
1695 tok::kw___is_nothrow_convertible,
1696 tok::kw___is_nothrow_destructible,
1697 tok::kw___is_object,
1699 tok::kw___is_pointer,
1700 tok::kw___is_polymorphic,
1701 tok::kw___is_reference,
1702 tok::kw___is_rvalue_expr,
1703 tok::kw___is_rvalue_reference,
1705 tok::kw___is_scalar,
1706 tok::kw___is_scoped_enum,
1707 tok::kw___is_sealed,
1708 tok::kw___is_signed,
1709 tok::kw___is_standard_layout,
1710 tok::kw___is_trivial,
1711 tok::kw___is_trivially_equality_comparable,
1712 tok::kw___is_trivially_assignable,
1713 tok::kw___is_trivially_constructible,
1714 tok::kw___is_trivially_copyable,
1715 tok::kw___is_unbounded_array,
1717 tok::kw___is_unsigned,
1719 tok::kw___is_volatile
1726 TryKeywordIdentFallback(
true);
1728 struct PreserveAtomicIdentifierInfoRAII {
1729 PreserveAtomicIdentifierInfoRAII(Token &
Tok,
bool Enabled)
1733 assert(
Tok.
is(tok::kw__Atomic));
1738 ~PreserveAtomicIdentifierInfoRAII() {
1741 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1743 IdentifierInfo *AtomicII;
1751 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1752 Tok.is(tok::kw__Atomic) &&
1754 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1755 Tok, ShouldChangeAtomicToIdentifier);
1759 CXXScopeSpec InvalidDeclScope;
1769 if (TemplateInfo.TemplateParams)
1772 bool HasValidSpec =
true;
1773 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1777 HasValidSpec =
false;
1780 if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id)) {
1781 Diag(Tok, diag::err_expected) << tok::identifier;
1782 HasValidSpec =
false;
1790 auto RecoverFromUndeclaredTemplateName = [&](IdentifierInfo *Name,
1791 SourceLocation NameLoc,
1792 SourceRange TemplateArgRange,
1793 bool KnownUndeclared) {
1794 Diag(NameLoc, diag::err_explicit_spec_non_template)
1796 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1800 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1801 if (TemplateParams->size() > 1) {
1802 TemplateParams->pop_back();
1804 TemplateParams =
nullptr;
1809 TemplateParams =
nullptr;
1811 TemplateInfo.TemplateLoc = SourceLocation();
1812 TemplateInfo.ExternLoc = SourceLocation();
1817 IdentifierInfo *Name =
nullptr;
1818 SourceLocation NameLoc;
1819 TemplateIdAnnotation *TemplateId =
nullptr;
1820 if (Tok.is(tok::identifier)) {
1821 Name = Tok.getIdentifierInfo();
1829 TemplateArgList TemplateArgs;
1830 SourceLocation LAngleLoc, RAngleLoc;
1831 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1835 LAngleLoc = RAngleLoc = SourceLocation();
1837 RecoverFromUndeclaredTemplateName(
1838 Name, NameLoc, SourceRange(LAngleLoc, RAngleLoc),
false);
1840 }
else if (Tok.is(tok::annot_template_id)) {
1841 TemplateId = takeTemplateIdAnnotation(Tok);
1842 NameLoc = ConsumeAnnotationToken();
1846 Actions.ActOnUndeclaredTypeTemplateName(
1849 RecoverFromUndeclaredTemplateName(
1852 TemplateId =
nullptr;
1860 SourceRange
Range(NameLoc);
1865 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1866 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1901 MaybeParseCXX11Attributes(Attributes);
1903 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1910 Tok.isOneOf(tok::comma, tok::ellipsis))
1913 AllowDefiningTypeSpec::No ||
1916 else if (Tok.is(tok::l_brace) ||
1917 (DSC != DeclSpecContext::DSC_association &&
1919 (isClassCompatibleKeyword() &&
1921 isClassCompatibleKeyword(
NextToken())))) {
1925 Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
1936 }
else if (isClassCompatibleKeyword() &&
1943 TentativeParsingAction PA(*
this);
1946 while (isClassCompatibleKeyword())
1951 if (Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square)) {
1955 }
else if (Tok.is(tok::kw_alignas) &&
NextToken().
is(tok::l_paren)) {
1960 }
else if (Tok.isRegularKeywordAttribute()) {
1965 if (!
T.consumeOpen())
1973 if (Tok.isOneOf(tok::l_brace, tok::colon))
1979 }
else if (!isTypeSpecifier(DSC) &&
1980 (Tok.is(tok::semi) ||
1981 (Tok.isAtStartOfLine() && !isValidAfterTypeSpecifier(
false)))) {
1983 if (Tok.isNot(tok::semi)) {
1984 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
1986 ExpectAndConsume(tok::semi, diag::err_expected_after,
1988 PP.EnterToken(Tok,
true);
1989 Tok.setKind(tok::semi);
2002 SourceRange AttrRange = Attributes.
Range;
2006 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
2007 ?
Diag(Loc, diag::err_keyword_not_allowed) << FirstAttr
2008 :
Diag(Loc, diag::err_attributes_not_allowed))
2011 AttrFixitLoc, CharSourceRange(AttrRange,
true))
2020 if (!Name && !TemplateId &&
2025 Diag(StartLoc, diag::err_anon_type_definition)
2044 SkipBodyInfo SkipBody;
2058 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2059 diag::err_keyword_not_allowed,
2062 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2063 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2064 TagType, StartLoc, SS, TemplateId->
Template,
2071 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2072 diag::err_keyword_not_allowed,
2095 "Expected a definition here");
2099 TemplateParams =
nullptr;
2101 SourceLocation LAngleLoc =
2102 PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
2104 diag::err_explicit_instantiation_with_definition)
2105 << SourceRange(TemplateInfo.TemplateLoc)
2111 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
2112 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, {},
2113 LAngleLoc,
nullptr));
2114 TemplateParams = &FakedParamLists;
2119 TagOrTempResult = Actions.ActOnClassTemplateSpecialization(
2121 SS, *TemplateId, attrs,
2124 TemplateParams ? TemplateParams->size() : 0),
2134 ProhibitAttributes(attrs);
2136 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2137 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2138 TagType, StartLoc, SS, Name, NameLoc, attrs);
2141 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2142 diag::err_keyword_not_allowed,
2146 SourceLocation EllipsisLoc;
2158 if (Tok.is(tok::comma)) {
2159 Diag(Tok.getLocation(),
2160 diag::err_friend_template_decl_multiple_specifiers);
2169 TagOrTempResult = Actions.ActOnTemplatedFriendTag(
2171 NameLoc, EllipsisLoc, attrs,
2173 TemplateParams ? TemplateParams->size() : 0),
2177 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2178 diag::err_keyword_not_allowed,
2185 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2187 TemplateParams =
nullptr;
2190 bool IsDependent =
false;
2200 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2203 TagOrTempResult = Actions.ActOnTag(
2204 getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, AS,
2207 DSC == DeclSpecContext::DSC_type_specifier,
2208 DSC == DeclSpecContext::DSC_template_param ||
2209 DSC == DeclSpecContext::DSC_template_type_arg,
2210 OffsetOfState, &SkipBody);
2217 Name, StartLoc, NameLoc);
2224 if (shouldDelayDiagsInTag) {
2225 diagsFromTag.done();
2228 diagsFromTag.redelay();
2233 assert(Tok.is(tok::l_brace) ||
2235 isClassCompatibleKeyword());
2237 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc, TagType,
2238 TagOrTempResult.
get());
2240 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs, TagType,
2241 TagOrTempResult.
get());
2249 TagOrTempResult.
get(), SkipBody)) {
2258 Actions.ProcessDeclAttributeDelayed(TagOrTempResult.
get(), attrs);
2260 const char *PrevSpec =
nullptr;
2265 NameLoc.
isValid() ? NameLoc : StartLoc,
2267 }
else if (!TagOrTempResult.
isInvalid()) {
2269 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2270 DiagID, TagOrTempResult.
get(), Owned, Policy);
2277 Diag(StartLoc, DiagID) << PrevSpec;
2294 if (Tok.isNot(tok::semi)) {
2295 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
2296 ExpectAndConsume(tok::semi, diag::err_expected_after,
2301 PP.EnterToken(Tok,
true);
2302 Tok.setKind(tok::semi);
2307void Parser::ParseBaseClause(
Decl *ClassDecl) {
2308 assert(Tok.is(tok::colon) &&
"Not a base clause");
2312 SmallVector<CXXBaseSpecifier *, 8> BaseInfo;
2317 if (!
Result.isUsable()) {
2323 BaseInfo.push_back(
Result.get());
2333 Actions.ActOnBaseSpecifiers(ClassDecl, BaseInfo);
2337 bool IsVirtual =
false;
2338 SourceLocation StartLoc = Tok.getLocation();
2340 ParsedAttributes Attributes(AttrFactory);
2341 MaybeParseCXX11Attributes(Attributes);
2347 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2354 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
2357 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2361 if (Tok.is(tok::kw_virtual)) {
2365 Diag(VirtualLoc, diag::err_dup_virtual)
2373 Diag(Tok.getLocation(), diag::err_hlsl_virtual_inheritance);
2375 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2383 if (
getLangOpts().MSVCCompat && Tok.is(tok::kw__Atomic) &&
2385 Tok.setKind(tok::identifier);
2387 SourceLocation EndLocation;
2388 SourceLocation BaseLoc;
2389 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2396 SourceLocation EllipsisLoc;
2400 SourceRange
Range(StartLoc, EndLocation);
2404 return Actions.ActOnBaseSpecifier(ClassDecl, Range, Attributes, IsVirtual,
2405 Access, BaseType.
get(), BaseLoc,
2410 switch (Tok.getKind()) {
2413 case tok::kw_private:
2415 case tok::kw_protected:
2417 case tok::kw_public:
2422void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2429 if (!NeedLateParse) {
2431 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx) {
2433 if (Param->hasUnparsedDefaultArg()) {
2434 NeedLateParse =
true;
2440 if (NeedLateParse) {
2443 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2444 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2449 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2450 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx)
2451 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2467 const IdentifierInfo *II = Tok.getIdentifierInfo();
2471 Ident_final = &PP.getIdentifierTable().get(
"final");
2473 Ident_GNU_final = &PP.getIdentifierTable().get(
"__final");
2475 Ident_sealed = &PP.getIdentifierTable().get(
"sealed");
2476 Ident_abstract = &PP.getIdentifierTable().get(
"abstract");
2478 Ident_override = &PP.getIdentifierTable().get(
"override");
2481 if (II == Ident_override)
2484 if (II == Ident_sealed)
2487 if (II == Ident_abstract)
2490 if (II == Ident_final)
2493 if (II == Ident_GNU_final)
2499void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2508 Diag(Tok.getLocation(), diag::err_friend_decl_spec)
2511 << SourceRange(FriendLoc, FriendLoc);
2518 const char *PrevSpec =
nullptr;
2519 if (VS.
SetSpecifier(Specifier, Tok.getLocation(), PrevSpec))
2520 Diag(Tok.getLocation(), diag::err_duplicate_virt_specifier)
2525 Diag(Tok.getLocation(), diag::err_override_control_interface)
2528 Diag(Tok.getLocation(), diag::ext_ms_sealed_keyword);
2530 Diag(Tok.getLocation(), diag::ext_ms_abstract_keyword);
2532 Diag(Tok.getLocation(), diag::ext_warn_gnu_final);
2534 DiagCompat(Tok.getLocation(), diag_compat::override_control_keyword)
2541bool Parser::isCXX11FinalKeyword()
const {
2548bool Parser::isClassCompatibleKeyword(
Token Tok)
const {
2556bool Parser::isClassCompatibleKeyword()
const {
2557 return isClassCompatibleKeyword(Tok);
2562bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2575 if (Tok.isNot(tok::colon))
2576 ParseDeclarator(DeclaratorInfo);
2581 if (!IsFunctionDeclarator && !
getLangOpts().MSVCCompat)
2582 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2585 MaybeParseHLSLAnnotations(DeclaratorInfo,
nullptr,
2590 "don't know where identifier would go yet?");
2594 }
else if (Tok.is(tok::kw_requires)) {
2595 TemplateParameterDepthRAII CurTemplateDepthTracker(TemplateParameterDepth);
2600 ++CurTemplateDepthTracker;
2601 ParseTrailingRequiresClauseWithScope(DeclaratorInfo);
2603 ParseOptionalCXX11VirtSpecifierSeq(
2604 VS, getCurrentClass().IsInterface,
2607 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2612 if (Tok.is(tok::kw_asm)) {
2614 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2615 if (AsmLabel.isInvalid())
2625 DiagnoseAndSkipCXX11Attributes();
2626 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2627 DiagnoseAndSkipCXX11Attributes();
2632 ParseOptionalCXX11VirtSpecifierSeq(
2633 VS, getCurrentClass().IsInterface,
2639 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2640 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2642 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2657void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2659 DeclSpec DS(AttrFactory);
2663 ParseTypeQualifierListOpt(
2664 DS, AR_NoAttributesParsed,
false,
2666 Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
2673 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2674 SourceLocation SpecLoc) {
2675 FixItHint Insertion;
2676 auto &MQ =
Function.getOrCreateMethodQualifiers();
2677 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2678 std::string Name(FixItName.data());
2681 MQ.SetTypeQual(TypeQual, SpecLoc);
2683 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2692 bool RefQualifierIsLValueRef =
true;
2693 SourceLocation RefQualifierLoc;
2694 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2695 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2696 FixItHint Insertion =
2698 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2699 Function.RefQualifierLoc = RefQualifierLoc;
2701 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2702 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2714 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2715 if (Tok.is(tok::at)) {
2717 Diag(Tok, diag::err_at_defs_cxx);
2719 Diag(Tok, diag::err_at_in_class);
2735 bool MalformedTypeSpec =
false;
2737 Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2739 MalformedTypeSpec =
true;
2742 if (Tok.isNot(tok::annot_cxxscope))
2743 isAccessDecl =
false;
2752 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2762 SourceLocation TemplateKWLoc;
2765 false,
false,
true,
true,
2766 false, &TemplateKWLoc, Name)) {
2772 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2773 "access declaration")) {
2781 SourceLocation(), SS, Name,
2783 ParsedAttributesView())));
2790 Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2791 SourceLocation DeclEnd;
2793 DeclGroupRef(ParseStaticAssertDeclaration(DeclEnd)));
2796 if (Tok.is(tok::kw_template)) {
2797 assert(!TemplateInfo.TemplateParams &&
2798 "Nested template improperly parsed?");
2799 ObjCDeclContextSwitch ObjCDC(*
this);
2800 SourceLocation DeclEnd;
2802 DeclEnd, AccessAttrs, AS);
2806 if (Tok.is(tok::kw___extension__)) {
2808 ExtensionRAIIObject O(Diags);
2810 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2814 ParsedAttributes DeclAttrs(AttrFactory);
2816 MaybeParseCXX11Attributes(DeclAttrs);
2821 if (Tok.is(tok::annot_attr_openmp))
2822 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
2824 if (Tok.is(tok::kw_using)) {
2829 while (Tok.is(tok::kw_template)) {
2831 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
2835 if (Tok.is(tok::kw_namespace)) {
2836 Diag(UsingLoc, diag::err_using_namespace_in_class);
2840 SourceLocation DeclEnd;
2843 UsingLoc, DeclEnd, DeclAttrs, AS);
2846 ParsedAttributes DeclSpecAttrs(AttrFactory);
2848 LateParsedAttrList CommonLateParsedAttrs;
2850 while (MaybeParseCXX11Attributes(DeclAttrs) ||
2851 MaybeParseGNUAttributes(DeclSpecAttrs, &CommonLateParsedAttrs) ||
2852 MaybeParseMicrosoftAttributes(DeclSpecAttrs))
2855 SourceLocation DeclStart;
2856 if (DeclAttrs.Range.isValid()) {
2857 DeclStart = DeclSpecAttrs.Range.
isInvalid()
2858 ? DeclAttrs.Range.getBegin()
2859 : std::min(DeclAttrs.Range.getBegin(),
2860 DeclSpecAttrs.Range.getBegin());
2862 DeclStart = DeclSpecAttrs.Range.getBegin();
2867 ParsingDeclSpec DS(*
this, TemplateDiags);
2870 if (MalformedTypeSpec)
2878 bool IsTemplateSpecOrInst =
2881 SuppressAccessChecks diagsFromTag(*
this, IsTemplateSpecOrInst);
2883 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
2884 &CommonLateParsedAttrs);
2886 if (IsTemplateSpecOrInst)
2887 diagsFromTag.done();
2899 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
2900 &CommonLateParsedAttrs))
2904 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
2906 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
2910 ProhibitAttributes(DeclAttrs);
2912 RecordDecl *AnonRecord =
nullptr;
2913 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(
2914 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
2915 Actions.ActOnDefinedDeclarationSpecifier(TheDecl);
2916 DS.complete(TheDecl);
2918 Decl *decls[] = {AnonRecord, TheDecl};
2919 return Actions.BuildDeclaratorGroup(decls);
2921 return Actions.ConvertDeclToDeclGroup(TheDecl);
2925 Actions.ActOnDefinedDeclarationSpecifier(DS.
getRepAsDecl());
2930 DiagCompat(Tok.getLocation(), diag_compat::variadic_friends);
2933 SmallVector<Decl *> Decls;
2936 auto ParsedFriendDecl = [&](ParsingDeclSpec &DeclSpec) {
2937 SourceLocation VariadicLoc;
2940 RecordDecl *AnonRecord =
nullptr;
2941 Decl *D = Actions.ParsedFreeStandingDeclSpec(
2942 getCurScope(), AS, DeclSpec, DeclAttrs, TemplateParams,
false,
2943 AnonRecord, VariadicLoc);
2944 DeclSpec.complete(D);
2954 if (ParsedFriendDecl(DS))
2958 ParsingDeclSpec DeclSpec(*
this, TemplateDiags);
2959 const char *PrevSpec =
nullptr;
2960 unsigned DiagId = 0;
2961 DeclSpec.SetFriendSpec(FriendLoc, PrevSpec, DiagId);
2962 ParseDeclarationSpecifiers(DeclSpec, TemplateInfo, AS,
2963 DeclSpecContext::DSC_class,
nullptr);
2964 if (ParsedFriendDecl(DeclSpec))
2968 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_stmt,
2969 "friend declaration");
2971 return Actions.BuildDeclaratorGroup(Decls);
2977 if (Tok.is(tok::kw_concept)) {
2981 ? llvm::to_underlying(diag::err_friend_concept)
2982 : llvm::to_underlying(
2984 err_concept_decls_may_only_appear_in_global_namespace_scope));
2989 ParsingDeclarator DeclaratorInfo(*
this, DS, DeclAttrs,
2991 if (TemplateInfo.TemplateParams)
2996 LateParsedAttrList LateParsedAttrs;
2998 SourceLocation EqualLoc;
2999 SourceLocation PureSpecLoc;
3001 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
3002 if (Tok.isNot(tok::equal))
3006 SmallString<8> Buffer;
3007 if (
Zero.isNot(tok::numeric_constant) ||
3008 PP.getSpelling(
Zero, Buffer) !=
"0")
3012 if (!
After.isOneOf(tok::semi, tok::comma) &&
3013 !(AllowDefinition &&
3014 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3022 SmallVector<Decl *, 8> DeclsInGroup;
3025 bool ExpectSemi =
true;
3030 SuppressAccessChecks SAC(*
this, IsTemplateSpecOrInst);
3033 if (ParseCXXMemberDeclaratorBeforeInitializer(
3034 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3039 if (IsTemplateSpecOrInst)
3047 TryConsumePureSpecifier(
true);
3058 if (Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3060 }
else if (Tok.is(tok::equal)) {
3062 if (KW.
is(tok::kw_default))
3064 else if (KW.
is(tok::kw_delete))
3066 else if (KW.
is(tok::code_completion)) {
3068 Actions.CodeCompletion().CodeCompleteAfterFunctionEquals(
3083 ProhibitAttributes(DeclAttrs);
3100 diag::err_function_declared_typedef);
3106 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3107 TemplateInfo, VS, PureSpecLoc);
3110 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3111 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3113 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3114 LateParsedAttrs[i]->addDecl(FunDecl);
3117 LateParsedAttrs.clear();
3120 if (Tok.is(tok::semi))
3133 bool HasStaticInitializer =
false;
3134 if (Tok.isOneOf(tok::equal, tok::l_brace) && PureSpecLoc.
isInvalid()) {
3138 Diag(Tok, diag::err_anon_bitfield_member_init);
3142 if (!TryConsumePureSpecifier(
false))
3144 HasStaticInitializer =
true;
3152 if (BitfieldSize.
get())
3153 DiagCompat(Tok, diag_compat::bitfield_member_init);
3156 HasStaticInitializer =
true;
3164 NamedDecl *ThisDecl =
nullptr;
3172 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3173 auto Loc = AL.getRange().getBegin();
3174 (AL.isRegularKeywordAttribute()
3175 ?
Diag(Loc, diag::err_keyword_not_allowed) << AL
3176 :
Diag(Loc, diag::err_attributes_not_allowed))
3180 ThisDecl = Actions.ActOnFriendFunctionDecl(
getCurScope(), DeclaratorInfo,
3183 ThisDecl = Actions.ActOnCXXMemberDeclarator(
3184 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3185 VS, HasInClassInit);
3187 if (VarTemplateDecl *VT =
3188 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3191 ThisDecl = VT->getTemplatedDecl();
3194 Actions.ProcessDeclAttributeList(
getCurScope(), ThisDecl, AccessAttrs);
3203 HasStaticInitializer =
true;
3207 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3209 if (ThisDecl && PureSpecLoc.
isValid())
3210 Actions.ActOnPureSpecifier(ThisDecl, PureSpecLoc);
3217 DiagCompat(Tok, diag_compat::nonstatic_member_init);
3225 Diag(Tok, diag::err_incomplete_array_member_init);
3232 ParseCXXNonStaticMemberInitializer(ThisDecl);
3233 }
else if (HasStaticInitializer) {
3238 if (
Init.isInvalid()) {
3240 Actions.ActOnUninitializedDecl(ThisDecl);
3242 }
else if (ThisDecl)
3243 Actions.AddInitializerToDecl(ThisDecl,
Init.get(),
3247 Actions.ActOnUninitializedDecl(ThisDecl);
3252 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3253 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3255 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3256 LateParsedAttrs[i]->addDecl(ThisDecl);
3258 Actions.FinalizeDeclaration(ThisDecl);
3259 DeclsInGroup.push_back(ThisDecl);
3264 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3266 LateParsedAttrs.clear();
3268 DeclaratorInfo.complete(ThisDecl);
3272 SourceLocation CommaLoc;
3276 if (Tok.isAtStartOfLine() &&
3281 Diag(CommaLoc, diag::err_expected_semi_declaration)
3293 Diag(CommaLoc, diag::err_multiple_template_declarators)
3294 << TemplateInfo.Kind;
3298 DeclaratorInfo.
clear();
3301 EqualLoc = PureSpecLoc = SourceLocation();
3307 DiagnoseAndSkipCXX11Attributes();
3308 MaybeParseGNUAttributes(DeclaratorInfo);
3309 DiagnoseAndSkipCXX11Attributes();
3311 if (ParseCXXMemberDeclaratorBeforeInitializer(
3312 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3317 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list) &&
3318 !isLikelyAtStartOfNewDeclaration()) {
3326 return Actions.FinalizeDeclaratorGroup(
getCurScope(), DS, DeclsInGroup);
3329ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
3331 assert(Tok.isOneOf(tok::equal, tok::l_brace) &&
3332 "Data member initializer not starting with '=' or '{'");
3334 bool IsFieldInitialization = isa_and_present<FieldDecl>(D);
3336 EnterExpressionEvaluationContext Context(
3338 IsFieldInitialization
3346 Actions.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
3347 IsFieldInitialization;
3350 if (Tok.is(tok::kw_delete)) {
3357 if (IsFunction ||
Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3363 SkipDeletedFunctionBody();
3366 }
else if (Tok.is(tok::kw_default)) {
3368 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3376 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
3377 Diag(Tok, diag::err_ms_property_initializer) << PD;
3380 return ParseInitializer(D);
3387 while (isClassCompatibleKeyword())
3392 ParsedAttributes Attrs(AttrFactory);
3393 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3398 if (Tok.isNot(tok::colon) && Tok.isNot(tok::l_brace))
3404 if (Tok.is(tok::colon)) {
3407 ParsingClassDefinition ParsingDef(*
this, TagDecl,
true,
3410 Actions.ActOnTagStartSkippedDefinition(
getCurScope(), TagDecl);
3413 ParseBaseClause(
nullptr);
3415 Actions.ActOnTagFinishSkippedDefinition(OldContext);
3417 if (!Tok.is(tok::l_brace)) {
3418 Diag(PP.getLocForEndOfToken(PrevTokLocation),
3419 diag::err_expected_lbrace_after_base_specifiers);
3425 assert(Tok.is(tok::l_brace));
3431 if (Tok.is(tok::kw___attribute)) {
3432 ParsedAttributes Attrs(AttrFactory);
3433 MaybeParseGNUAttributes(Attrs);
3442 switch (Tok.getKind()) {
3443 case tok::kw___if_exists:
3444 case tok::kw___if_not_exists:
3445 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, AS);
3454 case tok::annot_pragma_vis:
3455 HandlePragmaVisibility();
3457 case tok::annot_pragma_pack:
3460 case tok::annot_pragma_align:
3461 HandlePragmaAlign();
3463 case tok::annot_pragma_ms_pointers_to_members:
3464 HandlePragmaMSPointersToMembers();
3466 case tok::annot_pragma_ms_pragma:
3467 HandlePragmaMSPragma();
3469 case tok::annot_pragma_ms_vtordisp:
3470 HandlePragmaMSVtorDisp();
3472 case tok::annot_pragma_export:
3473 HandlePragmaExport();
3475 case tok::annot_pragma_dump:
3479 case tok::kw_namespace:
3484 case tok::kw_private:
3488 ParsedTemplateInfo TemplateInfo;
3489 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3492 case tok::kw_public:
3493 case tok::kw_protected: {
3495 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
3500 SourceLocation ASLoc = Tok.getLocation();
3501 unsigned TokLength = Tok.getLength();
3503 AccessAttrs.
clear();
3504 MaybeParseGNUAttributes(AccessAttrs);
3506 SourceLocation EndLoc;
3509 Diag(EndLoc, diag::err_expected)
3513 Diag(EndLoc, diag::err_expected)
3523 if (Actions.ActOnAccessSpecifier(NewAS, ASLoc, EndLoc, AccessAttrs)) {
3525 AccessAttrs.
clear();
3531 case tok::annot_attr_openmp:
3532 case tok::annot_pragma_openmp:
3533 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3534 AS, AccessAttrs,
true, TagType, TagDecl);
3535 case tok::annot_pragma_openacc:
3540 Diag(Tok.getLocation(), diag::err_pragma_misplaced_in_decl)
3542 TagType, Actions.getASTContext().getPrintingPolicy());
3543 ConsumeAnnotationToken();
3546 ParsedTemplateInfo TemplateInfo;
3547 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3558 "Invalid TagType!");
3560 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3561 if (
auto *TD = dyn_cast_or_null<NamedDecl>(TagDecl))
3562 return TD->getQualifiedNameAsString();
3563 return std::string(
"<anonymous>");
3566 PrettyDeclStackTraceEntry CrashInfo(Actions.Context, TagDecl,
RecordLoc,
3567 "parsing struct/union/class body");
3571 bool NonNestedClass =
true;
3572 if (!ClassStack.empty()) {
3574 if (S->isClassScope()) {
3576 NonNestedClass =
false;
3579 if (getCurrentClass().IsInterface) {
3589 if (S->isFunctionScope())
3600 ParsingClassDefinition ParsingDef(*
this, TagDecl, NonNestedClass,
3604 Actions.ActOnTagStartDefinition(
getCurScope(), TagDecl);
3606 SourceLocation FinalLoc;
3607 SourceLocation AbstractLoc;
3608 bool IsFinalSpelledSealed =
false;
3609 bool IsAbstract =
false;
3618 if (isCXX11FinalKeyword()) {
3621 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3626 IsFinalSpelledSealed =
true;
3631 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3639 Diag(FinalLoc, diag::err_override_control_interface)
3642 DiagCompat(FinalLoc, diag_compat::override_control_keyword)
3645 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3647 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3649 Diag(FinalLoc, diag::ext_warn_gnu_final);
3652 "not a class definition");
3658 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3667 if (!Tok.is(tok::colon) && !Tok.is(tok::l_brace)) {
3669 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3674 if (Tok.is(tok::colon)) {
3678 ParseBaseClause(TagDecl);
3679 if (!Tok.is(tok::l_brace)) {
3680 bool SuggestFixIt =
false;
3681 SourceLocation BraceLoc = PP.getLocForEndOfToken(PrevTokLocation);
3682 if (Tok.isAtStartOfLine()) {
3683 switch (Tok.getKind()) {
3684 case tok::kw_private:
3685 case tok::kw_protected:
3686 case tok::kw_public:
3689 case tok::kw_static_assert:
3693 case tok::kw_template:
3694 SuggestFixIt =
true;
3696 case tok::identifier:
3697 SuggestFixIt = isConstructorDeclarator(
true);
3700 SuggestFixIt = isCXXSimpleDeclaration(
false);
3704 DiagnosticBuilder LBraceDiag =
3705 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3709 PP.EnterToken(Tok,
true);
3710 Tok.setKind(tok::l_brace);
3713 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3719 assert(Tok.is(tok::l_brace));
3724 Actions.ActOnStartCXXMemberDeclarations(
getCurScope(), TagDecl, FinalLoc,
3725 IsFinalSpelledSealed, IsAbstract,
3726 T.getOpenLocation());
3737 ParsedAttributes AccessAttrs(AttrFactory);
3741 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
3742 Tok.isNot(tok::eof)) {
3744 ParseCXXClassMemberDeclarationWithPragmas(
3745 CurAS, AccessAttrs,
static_cast<DeclSpec::TST>(TagType), TagDecl);
3746 MaybeDestroyTemplateIds();
3754 ParsedAttributes attrs(AttrFactory);
3755 MaybeParseGNUAttributes(attrs);
3759 T.getOpenLocation(),
3760 T.getCloseLocation(), attrs);
3767 if (TagDecl && NonNestedClass) {
3773 SourceLocation SavedPrevTokLocation = PrevTokLocation;
3774 ParseLexedPragmas(getCurrentClass());
3775 ParseLexedAttributes(getCurrentClass());
3776 ParseLexedMethodDeclarations(getCurrentClass());
3779 Actions.ActOnFinishCXXMemberDecls();
3781 ParseLexedMemberInitializers(getCurrentClass());
3782 ParseLexedMethodDefs(getCurrentClass());
3783 PrevTokLocation = SavedPrevTokLocation;
3787 Actions.ActOnFinishCXXNonNestedClass();
3791 Actions.ActOnTagFinishDefinition(
getCurScope(), TagDecl,
T.getRange());
3798void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3799 assert(Tok.is(tok::kw_namespace));
3804 Diag(Tok.getLocation(), diag::note_missing_end_of_definition_before) << D;
3807 PP.EnterToken(Tok,
true);
3810 Tok.
setLocation(PP.getLocForEndOfToken(PrevTokLocation));
3811 Tok.setKind(tok::semi);
3812 PP.EnterToken(Tok,
true);
3814 Tok.setKind(tok::r_brace);
3817void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3818 assert(Tok.is(tok::colon) &&
3819 "Constructor initializer always starts with ':'");
3826 SmallVector<CXXCtorInitializer *, 4> MemInitializers;
3827 bool AnyErrors =
false;
3830 if (Tok.is(tok::code_completion)) {
3832 Actions.CodeCompletion().CodeCompleteConstructorInitializer(
3833 ConstructorDecl, MemInitializers);
3837 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3839 MemInitializers.push_back(MemInit.
get());
3843 if (Tok.is(tok::comma))
3845 else if (Tok.is(tok::l_brace))
3850 Tok.isOneOf(tok::identifier, tok::coloncolon)) {
3851 SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
3852 Diag(Loc, diag::err_ctor_init_missing_comma)
3857 Diag(Tok.getLocation(), diag::err_expected_either)
3858 << tok::l_brace << tok::comma;
3864 Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc, MemInitializers,
3871 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
3877 IdentifierInfo *II =
nullptr;
3878 SourceLocation IdLoc = Tok.getLocation();
3880 DeclSpec DS(AttrFactory);
3884 if (Tok.is(tok::identifier)) {
3887 II = Tok.getIdentifierInfo();
3889 }
else if (Tok.is(tok::annot_decltype)) {
3894 ParseDecltypeSpecifier(DS);
3895 }
else if (Tok.is(tok::annot_pack_indexing_type)) {
3898 ParsePackIndexingType(DS);
3900 TemplateIdAnnotation *TemplateId = Tok.is(tok::annot_template_id)
3901 ? takeTemplateIdAnnotation(Tok)
3906 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
3908 ConsumeAnnotationToken();
3910 Diag(Tok, diag::err_expected_member_or_base_name);
3917 Diag(Tok, diag::compat_cxx11_generalized_initializer_lists);
3920 ExprResult InitList = ParseBraceInitializer();
3924 SourceLocation EllipsisLoc;
3929 return Actions.ActOnMemInitializer(ConstructorDecl,
getCurScope(), SS, II,
3930 TemplateTypeTy.
get(), DS, IdLoc,
3931 InitList.
get(), EllipsisLoc);
3932 }
else if (Tok.is(tok::l_paren)) {
3937 ExprVector ArgExprs;
3938 auto RunSignatureHelp = [&] {
3941 QualType PreferredType =
3942 Actions.CodeCompletion().ProduceCtorInitMemberSignatureHelp(
3943 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
3944 T.getOpenLocation(),
false);
3945 CalledSignatureHelp =
true;
3946 return PreferredType;
3948 if (Tok.isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
3949 PreferredType.enterFunctionArgument(Tok.getLocation(),
3952 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
3960 SourceLocation EllipsisLoc;
3965 return Actions.ActOnMemInitializer(
3966 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
3967 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
3974 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
3976 return Diag(Tok, diag::err_expected) << tok::l_paren;
3985 ExceptionSpecTokens =
nullptr;
3989 if (Tok.isNot(tok::kw_throw) && Tok.isNot(tok::kw_noexcept))
3993 bool IsNoexcept = Tok.is(tok::kw_noexcept);
3994 Token StartTok = Tok;
3998 if (!Tok.is(tok::l_paren)) {
4001 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4002 NoexceptExpr =
nullptr;
4006 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4012 ExceptionSpecTokens->push_back(StartTok);
4013 ExceptionSpecTokens->push_back(Tok);
4014 SpecificationRange.
setEnd(ConsumeParen());
4016 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4019 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4025 if (Tok.is(tok::kw_throw)) {
4026 Result = ParseDynamicExceptionSpecification(
4027 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4028 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4029 "Produced different number of exception types and ranges.");
4033 if (Tok.isNot(tok::kw_noexcept))
4036 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4040 SourceRange NoexceptRange;
4044 if (Tok.is(tok::l_paren)) {
4049 EnterExpressionEvaluationContext ConstantEvaluated(
4056 Actions.ActOnNoexceptSpec(NoexceptExpr.
get(), NoexceptType);
4057 NoexceptRange = SourceRange(KeywordLoc,
T.getCloseLocation());
4064 NoexceptRange = SourceRange(KeywordLoc, KeywordLoc);
4068 SpecificationRange = NoexceptRange;
4073 if (Tok.is(tok::kw_throw)) {
4074 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4075 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4076 DynamicExceptionRanges);
4079 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4088 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4090 ? diag::ext_dynamic_exception_spec
4091 : diag::warn_exception_spec_deprecated)
4093 P.
Diag(Range.getBegin(), diag::note_exception_spec_deprecated)
4101 assert(Tok.is(tok::kw_throw) &&
"expected throw");
4105 if (
T.consumeOpen()) {
4106 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4113 if (Tok.is(tok::ellipsis)) {
4116 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4118 SpecificationRange.
setEnd(
T.getCloseLocation());
4125 while (Tok.isNot(tok::r_paren)) {
4128 if (Tok.is(tok::ellipsis)) {
4133 Range.setEnd(Ellipsis);
4134 if (!Res.isInvalid())
4135 Res = Actions.ActOnPackExpansion(Res.get(), Ellipsis);
4138 if (!Res.isInvalid()) {
4139 Exceptions.push_back(Res.get());
4140 Ranges.push_back(Range);
4148 SpecificationRange.
setEnd(
T.getCloseLocation());
4150 Exceptions.empty());
4155 bool MayBeFollowedByDirectInit) {
4156 assert(Tok.is(tok::arrow) &&
"expected arrow");
4165void Parser::ParseTrailingRequiresClauseWithScope(
Declarator &D) {
4166 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4182 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4184 DeclScopeObj.EnterDeclaratorScope();
4190 ParseTrailingRequiresClause(D);
4193void Parser::ParseTrailingRequiresClause(
Declarator &D) {
4194 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4197 "trailing requires-clause must be parsed in a function prototype scope");
4202 Actions.ActOnStartTrailingRequiresClause(
getCurScope(), D);
4204 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4205 InitCXXThisScopeForDeclaratorIfRelevant(D, D.
getDeclSpec(), ThisScope);
4207 TrailingRequiresClause =
4210 TrailingRequiresClause =
4211 Actions.ActOnFinishTrailingRequiresClause(TrailingRequiresClause);
4215 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4220 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4228 SourceLocation ArrowLoc = Tok.getLocation();
4231 ParseTrailingReturnType(Range,
false);
4235 diag::err_requires_clause_must_appear_after_trailing_return)
4240 FunctionChunk.TrailingReturnTypeLoc =
Range.getBegin();
4242 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4248 bool NonNestedClass,
4250 assert((NonNestedClass || !ClassStack.empty()) &&
4251 "Nested class without outer class");
4252 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4253 return Actions.PushParsingClass();
4256void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4257 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4258 delete Class->LateParsedDeclarations[I];
4263 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4265 Actions.PopParsingClass(state);
4267 ParsingClass *Victim = ClassStack.top();
4269 if (Victim->TopLevelClass) {
4272 DeallocateParsedClasses(Victim);
4275 assert(!ClassStack.empty() &&
"Missing top-level class?");
4277 if (Victim->LateParsedDeclarations.empty()) {
4282 DeallocateParsedClasses(Victim);
4290 "Nested class outside of class scope?");
4291 ClassStack.top()->LateParsedDeclarations.push_back(
4292 new LateParsedClass(
this, Victim));
4298 switch (Tok.getKind()) {
4301 if (!Tok.isAnnotation()) {
4302 if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
4309 case tok::code_completion:
4311 Actions.CodeCompletion().CodeCompleteAttribute(
4316 case tok::numeric_constant: {
4320 if (Tok.getLocation().isMacroID()) {
4321 SmallString<8> ExpansionBuf;
4322 SourceLocation ExpansionLoc =
4323 PP.getSourceManager().getExpansionLoc(Tok.getLocation());
4324 StringRef Spelling = PP.getSpelling(ExpansionLoc, ExpansionBuf);
4325 if (Spelling ==
"__clang__") {
4326 SourceRange TokRange(
4328 PP.getSourceManager().getExpansionLoc(Tok.getEndLoc()));
4329 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4332 return &PP.getIdentifierTable().get(
"_Clang");
4345 case tok::pipeequal:
4346 case tok::caretequal:
4348 case tok::exclaimequal:
4351 SmallString<8> SpellingBuf;
4352 SourceLocation SpellingLoc =
4353 PP.getSourceManager().getSpellingLoc(Tok.getLocation());
4354 StringRef Spelling = PP.getSpelling(SpellingLoc, SpellingBuf);
4357 return &PP.getIdentifierTable().get(Spelling);
4363void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4368 if (
T.consumeOpen()) {
4369 Diag(Tok, diag::err_expected) << tok::l_paren;
4373 if (
AttrName->isStr(
"directive")) {
4379 OMPBeginTok.
setKind(tok::annot_attr_openmp);
4381 OpenMPTokens.push_back(OMPBeginTok);
4383 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4387 OMPEndTok.
setKind(tok::annot_pragma_openmp_end);
4389 OpenMPTokens.push_back(OMPEndTok);
4391 assert(
AttrName->isStr(
"sequence") &&
4392 "Expected either 'directive' or 'sequence'");
4400 SourceLocation IdentLoc;
4401 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4405 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4406 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4410 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4411 Diag(Tok.getLocation(), diag::err_expected_sequence_or_directive);
4417 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4431 case ParsedAttr::AT_Deprecated:
4432 case ParsedAttr::AT_FallThrough:
4433 case ParsedAttr::AT_CXX11NoReturn:
4434 case ParsedAttr::AT_NoUniqueAddress:
4435 case ParsedAttr::AT_Likely:
4436 case ParsedAttr::AT_Unlikely:
4438 case ParsedAttr::AT_WarnUnusedResult:
4439 return !ScopeName && AttrName->getName() ==
"nodiscard";
4440 case ParsedAttr::AT_Unused:
4441 return !ScopeName && AttrName->getName() ==
"maybe_unused";
4447bool Parser::ParseCXXAssumeAttributeArg(
4451 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4459 TentativeParsingAction TPA(*
this);
4464 if (Tok.is(tok::r_paren))
4469 if (!Tok.isOneOf(tok::r_paren, tok::r_square)) {
4475 auto *E = Res.
get();
4476 Diag(E->getExprLoc(), diag::err_assume_attr_expects_cond_expr)
4480 << E->getSourceRange();
4489 auto RParen = Tok.getLocation();
4491 Attrs.
addNew(AttrName, SourceRange(AttrNameLoc, RParen),
4492 AttributeScopeInfo(ScopeName, ScopeLoc), &Assumption, 1, Form);
4500bool Parser::ParseCXX11AttributeArgs(
4504 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4505 SourceLocation LParenLoc = Tok.getLocation();
4507 ParsedAttr::Form Form =
4508 LO.CPlusPlus ? ParsedAttr::Form::CXX11() : ParsedAttr::Form::
C23();
4514 Form = ParsedAttr::Form::Microsoft();
4518 TentativeParsingAction TPA(*this);
4519 bool HasInvalidArgument = false;
4520 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof)) {
4521 if (Tok.isOneOf(tok::hash, tok::hashhash)) {
4522 Diag(Tok.getLocation(), diag::ext_invalid_attribute_argument)
4523 << PP.getSpelling(Tok);
4524 HasInvalidArgument = true;
4529 if (HasInvalidArgument) {
4543 ScopeName, AttrName, getTargetInfo(), getLangOpts())) {
4546 SkipUntil(tok::r_paren);
4550 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4553 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4554 ScopeLoc, Form, nullptr);
4559 if (ScopeName && ScopeName->
isStr(
"omp") &&
4561 Diag(AttrNameLoc, getLangOpts().OpenMP >= 51
4562 ? diag::warn_omp51_compat_attributes
4563 : diag::ext_omp_attributes);
4565 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4574 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4575 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4576 ScopeName, ScopeLoc, Form);
4578 else if (!ScopeName &&
AttrName->isStr(
"assume")) {
4579 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, nullptr,
4580 SourceLocation{}, EndLoc, Form))
4584 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4585 ScopeName, ScopeLoc, Form);
4587 if (!Attrs.
empty() &&
4592 if (!
Attr.existsInTarget(getTargetInfo())) {
4593 Actions.DiagnoseUnknownAttribute(
Attr);
4594 Attr.setInvalid(
true);
4602 if (
Attr.getMaxArgs() && !NumArgs) {
4605 Diag(LParenLoc, diag::err_attribute_requires_arguments) <<
AttrName;
4606 Attr.setInvalid(
true);
4607 }
else if (!
Attr.getMaxArgs()) {
4611 auto D =
Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4615 Attr.setInvalid(
true);
4624 if (Tok.is(tok::kw_alignas)) {
4630 Diag(Tok.getLocation(), diag::warn_cxx98_compat_alignas);
4631 ParseAlignmentSpecifier(Attrs, EndLoc);
4635 if (Tok.isRegularKeywordAttribute()) {
4636 SourceLocation Loc = Tok.getLocation();
4637 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
4638 ParsedAttr::Form Form = ParsedAttr::Form(Tok.getKind());
4642 if (!Tok.is(tok::l_paren))
4643 Diag(Tok.getLocation(), diag::err_expected_lparen_after) <<
AttrName;
4645 ParseAttributeArgsCommon(AttrName, Loc, Attrs, EndLoc,
4649 Attrs.
addNew(AttrName, Loc, AttributeScopeInfo(),
nullptr, 0, Form);
4653 assert(Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square) &&
4654 "Not a double square bracket attribute list");
4656 SourceLocation OpenLoc = Tok.getLocation();
4658 : diag_compat::c23_attributes);
4661 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4664 SourceLocation CommonScopeLoc;
4665 IdentifierInfo *CommonScopeName =
nullptr;
4666 if (Tok.is(tok::kw_using)) {
4667 DiagCompat(Tok.getLocation(), diag_compat::using_attribute_ns);
4670 CommonScopeName = TryParseCXX11AttributeIdentifier(
4672 if (!CommonScopeName) {
4673 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4677 Diag(Tok.getLocation(), diag::err_expected) << tok::colon;
4680 bool AttrParsed =
false;
4681 while (!Tok.isOneOf(tok::r_square, tok::semi, tok::eof)) {
4685 if (ExpectAndConsume(tok::comma)) {
4696 SourceLocation ScopeLoc, AttrLoc;
4697 IdentifierInfo *ScopeName =
nullptr, *
AttrName =
nullptr;
4699 AttrName = TryParseCXX11AttributeIdentifier(
4711 AttrName = TryParseCXX11AttributeIdentifier(
4715 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4721 if (CommonScopeName) {
4723 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4724 << SourceRange(CommonScopeLoc);
4726 ScopeName = CommonScopeName;
4727 ScopeLoc = CommonScopeLoc;
4732 if (Tok.is(tok::l_paren))
4733 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
4734 ScopeName, ScopeLoc, OpenMPTokens);
4742 AttributeScopeInfo(ScopeName, ScopeLoc, CommonScopeLoc),
4745 : ParsedAttr::Form::C23());
4750 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) <<
AttrName;
4753 SourceLocation CloseLoc = Tok.getLocation();
4754 bool IsTokenNotFound = ExpectAndConsume(tok::r_square);
4755 if (IsTokenNotFound)
4757 else if (Tok.is(tok::r_square))
4758 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
4760 *EndLoc = Tok.getLocation();
4761 if (!IsTokenNotFound && ExpectAndConsume(tok::r_square))
4766 SourceLocation StartLoc = Tok.getLocation();
4767 SourceLocation EndLoc = StartLoc;
4770 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
4771 }
while (isAllowedCXX11AttributeSpecifier());
4773 Attrs.
Range = SourceRange(StartLoc, EndLoc);
4776void Parser::DiagnoseAndSkipCXX11Attributes() {
4778 Tok.isRegularKeywordAttribute() ? Tok.getIdentifierInfo() :
nullptr;
4780 SourceLocation StartLoc = Tok.getLocation();
4781 SourceLocation EndLoc = SkipCXX11Attributes();
4784 SourceRange
Range(StartLoc, EndLoc);
4786 :
Diag(StartLoc, diag::err_attributes_not_allowed))
4792 SourceLocation EndLoc;
4798 if (Tok.is(tok::l_square)) {
4802 EndLoc =
T.getCloseLocation();
4803 }
else if (Tok.isRegularKeywordAttribute() &&
4805 EndLoc = Tok.getLocation();
4808 assert((Tok.is(tok::kw_alignas) || Tok.isRegularKeywordAttribute()) &&
4809 "not an attribute specifier");
4812 if (!
T.consumeOpen())
4814 EndLoc =
T.getCloseLocation();
4816 }
while (isCXX11AttributeSpecifier() !=
4823 assert(Tok.is(tok::identifier) &&
"Not a Microsoft attribute list");
4824 IdentifierInfo *UuidIdent = Tok.getIdentifierInfo();
4825 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
4827 SourceLocation UuidLoc = Tok.getLocation();
4832 if (
T.consumeOpen()) {
4833 Diag(Tok, diag::err_expected) << tok::l_paren;
4838 if (isTokenStringLiteral()) {
4843 ArgExprs.push_back(StringResult.
get());
4849 SmallString<42> StrBuffer;
4859 SourceLocation StartLoc = Tok.getLocation();
4860 while (Tok.isNot(tok::r_paren)) {
4861 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4862 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4866 SmallString<16> SpellingBuffer;
4867 SpellingBuffer.resize(Tok.getLength() + 1);
4868 bool Invalid =
false;
4869 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
4874 StrBuffer += TokSpelling;
4879 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4880 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4890 Toks[0].
setKind(tok::string_literal);
4894 StringLiteral *UuidString =
4896 ArgExprs.push_back(UuidString);
4899 if (!
T.consumeClose()) {
4900 Attrs.
addNew(UuidIdent, SourceRange(UuidLoc,
T.getCloseLocation()),
4901 AttributeScopeInfo(), ArgExprs.data(), ArgExprs.size(),
4902 ParsedAttr::Form::Microsoft());
4907 assert(Tok.is(tok::identifier) &&
4908 "Expected an identifier to denote which MS attribute to consider");
4909 IdentifierInfo *RootSignatureIdent = Tok.getIdentifierInfo();
4910 assert(RootSignatureIdent->
getName() ==
"RootSignature" &&
4911 "Expected RootSignature identifier for root signature attribute");
4913 SourceLocation RootSignatureLoc = Tok.getLocation();
4918 if (
T.consumeOpen()) {
4919 Diag(Tok, diag::err_expected) << tok::l_paren;
4923 auto ProcessStringLiteral = [
this]() -> std::optional<StringLiteral *> {
4924 if (!isTokenStringLiteral())
4925 return std::nullopt;
4929 return std::nullopt;
4931 if (
auto Lit = dyn_cast<StringLiteral>(StringResult.
get()))
4934 return std::nullopt;
4937 auto Signature = ProcessStringLiteral();
4938 if (!Signature.has_value()) {
4939 Diag(Tok, diag::err_expected_string_literal)
4940 << 4 <<
"RootSignature";
4946 Actions,
getLangOpts().HLSLRootSigVer, *Signature);
4954 IdentifierLoc *ILoc = ::new (Actions.getASTContext())
4955 IdentifierLoc(RootSignatureLoc, DeclIdent);
4959 if (!
T.consumeClose())
4960 Attrs.
addNew(RootSignatureIdent,
4961 SourceRange(RootSignatureLoc,
T.getCloseLocation()),
4962 AttributeScopeInfo(), Args.data(), Args.size(),
4963 ParsedAttr::Form::Microsoft());
4967 assert(Tok.is(tok::l_square) &&
"Not a Microsoft attribute list");
4969 SourceLocation StartLoc = Tok.getLocation();
4970 SourceLocation EndLoc = StartLoc;
4978 SkipUntil(tok::r_square, tok::identifier,
4980 if (Tok.is(tok::code_completion)) {
4982 Actions.CodeCompletion().CodeCompleteAttribute(
4988 if (Tok.isNot(tok::identifier))
4990 if (Tok.getIdentifierInfo()->getName() ==
"uuid")
4991 ParseMicrosoftUuidAttributeArgs(Attrs);
4992 else if (Tok.getIdentifierInfo()->getName() ==
"RootSignature")
4993 ParseHLSLRootSignatureAttributeArgs(Attrs);
4995 IdentifierInfo *II = Tok.getIdentifierInfo();
4996 SourceLocation NameLoc = Tok.getLocation();
5003 bool AttrParsed =
false;
5004 if (Tok.is(tok::l_paren)) {
5007 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5008 SourceLocation(), OpenMPTokens);
5009 ReplayOpenMPAttributeTokens(OpenMPTokens);
5012 Attrs.
addNew(II, NameLoc, AttributeScopeInfo(),
nullptr, 0,
5013 ParsedAttr::Form::Microsoft());
5020 EndLoc =
T.getCloseLocation();
5021 }
while (Tok.is(tok::l_square));
5023 Attrs.
Range = SourceRange(StartLoc, EndLoc);
5026void Parser::ParseMicrosoftIfExistsClassDeclaration(
5029 IfExistsCondition
Result;
5030 if (ParseMicrosoftIfExistsCondition(
Result))
5034 if (
Braces.consumeOpen()) {
5035 Diag(Tok, diag::err_expected) << tok::l_brace;
5039 switch (
Result.Behavior) {
5045 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5055 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
5057 if (Tok.isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5058 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, CurAS);
5063 if (Tok.is(tok::semi)) {
5072 SourceLocation ASLoc = Tok.getLocation();
5074 if (Tok.is(tok::colon))
5075 Actions.ActOnAccessSpecifier(AS, ASLoc, Tok.getLocation(),
5076 ParsedAttributesView{});
5078 Diag(Tok, diag::err_expected) << tok::colon;
5083 ParsedTemplateInfo TemplateInfo;
5085 ParseCXXClassMemberDeclaration(CurAS, AccessAttrs, TemplateInfo);
Defines the clang::ASTContext interface.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the C++ template declaration subclasses.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
llvm::MachO::RecordLoc RecordLoc
static void diagnoseDynamicExceptionSpecification(Parser &P, SourceRange Range, bool IsNoexcept)
static bool IsBuiltInOrStandardCXX11Attribute(IdentifierInfo *AttrName, IdentifierInfo *ScopeName)
static FixItHint getStaticAssertNoMessageFixIt(const Expr *AssertExpr, SourceLocation EndExprLoc)
This file declares facilities that support code completion.
This file declares semantic analysis for HLSL constructs.
Defines the clang::TokenKind enum and support functions.
#define TRANSFORM_TYPE_TRAIT_DEF(Enum, _)
Attr - This represents one attribute.
@ AS_Microsoft
[uuid("...")] class Foo
Kind getParsedKind() const
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
SourceLocation getOpenLocation() const
SourceLocation getCloseLocation() const
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
SourceRange getRange() const
SourceLocation getBeginLoc() const
bool isSet() const
Deprecated.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
void setTemplateParamLists(ArrayRef< TemplateParameterList * > L)
static CharSourceRange getTokenRange(SourceRange R)
Captures information about "declaration specifiers".
void setTypeArgumentRange(SourceRange range)
static const TST TST_typename
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
void ClearStorageClassSpecs()
TST getTypeSpecType() const
SCS getStorageClassSpec() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
SourceRange getSourceRange() const LLVM_READONLY
void SetPackIndexingExpr(SourceLocation EllipsisLoc, Expr *Pack)
void SetRangeEnd(SourceLocation Loc)
static const TST TST_interface
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void SetRangeStart(SourceLocation Loc)
static const TST TST_union
static const TST TST_typename_pack_indexing
SourceLocation getFriendSpecLoc() const
SourceLocation getModulePrivateSpecLoc() const
bool isFriendSpecifiedFirst() const
Expr * getRepAsExpr() const
static const TST TST_decltype
void takeAttributesAppendingingFrom(ParsedAttributes &attrs)
static const TST TST_class
bool hasTagDefinition() const
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
Decl * getRepAsDecl() const
CXXScopeSpec & getTypeSpecScope()
static const TST TST_decltype_auto
void setExternInLinkageSpec(bool Value)
static const TST TST_error
void forEachQualifier(llvm::function_ref< void(TQ, StringRef, SourceLocation)> Handle)
This method calls the passed in handler on each qual being set.
FriendSpecified isFriendSpecified() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isInvalidDecl() const
SourceLocation getLocation() const
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.