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()) {
61 ? diag::warn_cxx14_compat_ns_enum_attribute
62 : diag::ext_ns_enum_attribute)
64 ParseCXX11Attributes(attrs);
68 if (Tok.is(tok::identifier)) {
69 Ident = Tok.getIdentifierInfo();
71 while (Tok.is(tok::coloncolon) &&
76 InnerNamespaceInfo Info;
79 if (Tok.is(tok::kw_inline)) {
82 FirstNestedInlineLoc = Info.InlineLoc;
85 Info.Ident = Tok.getIdentifierInfo();
88 ExtraNSs.push_back(Info);
92 DiagnoseAndSkipCXX11Attributes();
93 MaybeParseGNUAttributes(attrs);
94 DiagnoseAndSkipCXX11Attributes();
96 SourceLocation attrLoc = attrs.Range.getBegin();
99 if (!ExtraNSs.empty() && attrLoc.
isValid())
100 Diag(attrLoc, diag::err_unexpected_nested_namespace_attribute);
102 if (Tok.is(tok::equal)) {
104 Diag(Tok, diag::err_expected) << tok::identifier;
109 if (!ExtraNSs.empty()) {
110 Diag(ExtraNSs.front().NamespaceLoc,
111 diag::err_unexpected_qualified_namespace_alias)
112 << SourceRange(ExtraNSs.front().NamespaceLoc,
113 ExtraNSs.back().IdentLoc);
118 Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
120 Diag(InlineLoc, diag::err_inline_namespace_alias)
122 Decl *NSAlias = ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd);
123 return Actions.ConvertDeclToDeclGroup(NSAlias);
127 if (
T.consumeOpen()) {
129 Diag(Tok, diag::err_expected) << tok::l_brace;
131 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
138 Diag(
T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
143 if (ExtraNSs.empty()) {
145 }
else if (InlineLoc.
isValid()) {
146 Diag(InlineLoc, diag::err_inline_nested_namespace_definition);
148 Diag(ExtraNSs[0].NamespaceLoc,
149 diag::warn_cxx14_compat_nested_namespace_definition);
150 if (FirstNestedInlineLoc.
isValid())
151 Diag(FirstNestedInlineLoc,
152 diag::warn_cxx17_compat_inline_nested_namespace_definition);
154 Diag(ExtraNSs[0].NamespaceLoc,
155 diag::warn_cxx14_compat_nested_namespace_definition);
156 if (FirstNestedInlineLoc.
isValid())
157 Diag(FirstNestedInlineLoc, diag::ext_inline_nested_namespace_definition);
159 TentativeParsingAction TPA(*
this);
161 Token rBraceToken = Tok;
164 if (!rBraceToken.
is(tok::r_brace)) {
165 Diag(ExtraNSs[0].NamespaceLoc, diag::ext_nested_namespace_definition)
166 << SourceRange(ExtraNSs.front().NamespaceLoc,
167 ExtraNSs.back().IdentLoc);
169 std::string NamespaceFix;
170 for (
const auto &ExtraNS : ExtraNSs) {
171 NamespaceFix +=
" { ";
172 if (ExtraNS.InlineLoc.isValid())
173 NamespaceFix +=
"inline ";
174 NamespaceFix +=
"namespace ";
175 NamespaceFix += ExtraNS.Ident->getName();
179 for (
unsigned i = 0, e = ExtraNSs.size(); i != e; ++i)
182 Diag(ExtraNSs[0].NamespaceLoc, diag::ext_nested_namespace_definition)
184 SourceRange(ExtraNSs.front().NamespaceLoc,
185 ExtraNSs.back().IdentLoc),
191 if (FirstNestedInlineLoc.
isValid())
192 Diag(FirstNestedInlineLoc, diag::ext_inline_nested_namespace_definition);
198 ? diag::warn_cxx98_compat_inline_namespace
199 : diag::ext_inline_namespace);
204 UsingDirectiveDecl *ImplicitUsingDirectiveDecl =
nullptr;
205 Decl *NamespcDecl = Actions.ActOnStartNamespaceDef(
206 getCurScope(), InlineLoc, NamespaceLoc, IdentLoc, Ident,
207 T.getOpenLocation(), attrs, ImplicitUsingDirectiveDecl,
false);
209 PrettyDeclStackTraceEntry CrashInfo(Actions.Context, NamespcDecl,
210 NamespaceLoc,
"parsing namespace");
214 ParseInnerNamespace(ExtraNSs, 0, InlineLoc, attrs,
T);
217 NamespaceScope.Exit();
219 DeclEnd =
T.getCloseLocation();
220 Actions.ActOnFinishNamespaceDef(NamespcDecl, DeclEnd);
222 return Actions.ConvertDeclToDeclGroup(NamespcDecl,
223 ImplicitUsingDirectiveDecl);
226void Parser::ParseInnerNamespace(
const InnerNamespaceInfoList &InnerNSs,
230 if (index == InnerNSs.size()) {
231 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
232 Tok.isNot(tok::eof)) {
233 ParsedAttributes DeclAttrs(AttrFactory);
234 MaybeParseCXX11Attributes(DeclAttrs);
235 ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
236 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
250 UsingDirectiveDecl *ImplicitUsingDirectiveDecl =
nullptr;
251 Decl *NamespcDecl = Actions.ActOnStartNamespaceDef(
252 getCurScope(), InnerNSs[index].InlineLoc, InnerNSs[index].NamespaceLoc,
253 InnerNSs[index].IdentLoc, InnerNSs[index].Ident,
255 assert(!ImplicitUsingDirectiveDecl &&
256 "nested namespace definition cannot define anonymous namespace");
258 ParseInnerNamespace(InnerNSs, ++index, InlineLoc, attrs, Tracker);
260 NamespaceScope.Exit();
268 assert(Tok.is(tok::equal) &&
"Not equal token");
272 if (Tok.is(tok::code_completion)) {
274 Actions.CodeCompletion().CodeCompleteNamespaceAliasDecl(
getCurScope());
280 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
288 if (Tok.isNot(tok::identifier)) {
289 Diag(Tok, diag::err_expected_namespace_name);
303 IdentifierInfo *Ident = Tok.getIdentifierInfo();
307 DeclEnd = Tok.getLocation();
308 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name))
311 return Actions.ActOnNamespaceAliasDef(
getCurScope(), NamespaceLoc, AliasLoc,
312 Alias, SS, IdentLoc, Ident);
316 assert(isTokenStringLiteral() &&
"Not a string literal!");
323 : Actions.ActOnStartLinkageSpecification(
325 Tok.is(tok::l_brace) ? Tok.getLocation() : SourceLocation());
327 ParsedAttributes DeclAttrs(AttrFactory);
328 ParsedAttributes DeclSpecAttrs(AttrFactory);
330 while (MaybeParseCXX11Attributes(DeclAttrs) ||
331 MaybeParseGNUAttributes(DeclSpecAttrs))
334 if (Tok.isNot(tok::l_brace)) {
341 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs, &DS);
342 return LinkageSpec ? Actions.ActOnFinishLinkageSpecification(
349 ProhibitAttributes(DeclAttrs);
354 unsigned NestedModules = 0;
356 switch (Tok.getKind()) {
357 case tok::annot_module_begin:
362 case tok::annot_module_end:
369 case tok::annot_module_include:
381 ParsedAttributes DeclAttrs(AttrFactory);
382 ParsedAttributes DeclSpecAttrs(AttrFactory);
383 while (MaybeParseCXX11Attributes(DeclAttrs) ||
384 MaybeParseGNUAttributes(DeclSpecAttrs))
386 ParseExternalDeclaration(DeclAttrs, DeclSpecAttrs);
394 return LinkageSpec ? Actions.ActOnFinishLinkageSpecification(
399Decl *Parser::ParseExportDeclaration() {
400 assert(Tok.is(tok::kw_export));
403 if (Tok.is(tok::code_completion)) {
405 Actions.CodeCompletion().CodeCompleteOrdinaryName(
413 Decl *ExportDecl = Actions.ActOnStartExportDecl(
415 Tok.is(tok::l_brace) ? Tok.getLocation() : SourceLocation());
417 if (Tok.isNot(tok::l_brace)) {
419 ParsedAttributes DeclAttrs(AttrFactory);
420 MaybeParseCXX11Attributes(DeclAttrs);
421 ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
422 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
423 return Actions.ActOnFinishExportDecl(
getCurScope(), ExportDecl,
430 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
431 Tok.isNot(tok::eof)) {
432 ParsedAttributes DeclAttrs(AttrFactory);
433 MaybeParseCXX11Attributes(DeclAttrs);
434 ParsedAttributes EmptyDeclSpecAttrs(AttrFactory);
435 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs);
439 return Actions.ActOnFinishExportDecl(
getCurScope(), ExportDecl,
440 T.getCloseLocation());
446 assert(Tok.is(tok::kw_using) &&
"Not using token");
447 ObjCDeclContextSwitch ObjCDC(*
this);
452 if (Tok.is(tok::code_completion)) {
454 Actions.CodeCompletion().CodeCompleteUsing(
getCurScope());
459 while (Tok.is(tok::kw_template)) {
461 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
466 if (Tok.is(tok::kw_namespace)) {
469 SourceRange R = TemplateInfo.getSourceRange();
470 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
474 Decl *UsingDir = ParseUsingDirective(Context, UsingLoc, DeclEnd, Attrs);
475 return Actions.ConvertDeclToDeclGroup(UsingDir);
479 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd, Attrs,
487 assert(Tok.is(tok::kw_namespace) &&
"Not 'namespace' token");
492 if (Tok.is(tok::code_completion)) {
494 Actions.CodeCompletion().CodeCompleteUsingDirective(
getCurScope());
500 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
508 IdentifierInfo *NamespcName =
nullptr;
509 SourceLocation IdentLoc = SourceLocation();
512 if (Tok.isNot(tok::identifier)) {
513 Diag(Tok, diag::err_expected_namespace_name);
528 NamespcName = Tok.getIdentifierInfo();
532 bool GNUAttr =
false;
533 if (Tok.is(tok::kw___attribute)) {
535 ParseGNUAttributes(attrs);
539 DeclEnd = Tok.getLocation();
540 if (ExpectAndConsume(tok::semi,
541 GNUAttr ? diag::err_expected_semi_after_attribute_list
542 : diag::err_expected_semi_after_namespace_name))
545 return Actions.ActOnUsingDirective(
getCurScope(), UsingLoc, NamespcLoc, SS,
546 IdentLoc, NamespcName, attrs);
550 UsingDeclarator &D) {
557 if (Tok.is(tok::kw___super)) {
558 Diag(Tok.getLocation(), diag::err_super_in_using_declaration);
563 const IdentifierInfo *LastII =
nullptr;
564 if (ParseOptionalCXXScopeSpecifier(D.SS,
nullptr,
574 if (D.SS.isInvalid())
588 Tok.is(tok::identifier) &&
593 D.SS.isNotEmpty() && LastII == Tok.getIdentifierInfo() &&
597 Actions.getInheritingConstructorName(D.SS, IdLoc, *LastII);
598 D.Name.setConstructorName(
Type, IdLoc, IdLoc);
605 !(Tok.is(tok::identifier) &&
NextToken().
is(tok::equal)),
606 false,
nullptr, D.Name))
612 ? diag::warn_cxx17_compat_using_declaration_pack
613 : diag::ext_using_declaration_pack);
622 SourceLocation UELoc;
629 ? diag::warn_cxx17_compat_using_enum_declaration
630 : diag::ext_using_enum_declaration);
632 DiagnoseCXX11AttributeExtension(PrefixAttrs);
635 SourceRange R = TemplateInfo.getSourceRange();
636 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
642 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
654 if (Tok.is(tok::code_completion)) {
656 Actions.CodeCompletion().CodeCompleteUsing(
getCurScope());
664 if (Tok.is(tok::identifier)) {
665 IdentifierInfo *IdentInfo = Tok.getIdentifierInfo();
674 UED = Actions.ActOnUsingEnumDeclaration(
676 }
else if (Tok.is(tok::annot_template_id)) {
677 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
683 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
685 SourceRange Loc = Tok.getAnnotationRange();
686 ConsumeAnnotationToken();
688 UED = Actions.ActOnUsingEnumDeclaration(
getCurScope(), AS, UsingLoc,
689 UELoc, Loc, *TemplateId->
Name,
692 Diag(Tok.getLocation(), diag::err_using_enum_not_enum)
697 Diag(Tok.getLocation(), diag::err_using_enum_expect_identifier)
698 << Tok.is(tok::kw_enum);
708 DeclEnd = Tok.getLocation();
709 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
710 "using-enum declaration"))
713 return Actions.ConvertDeclToDeclGroup(UED);
718 ParsedAttributes MisplacedAttrs(AttrFactory);
719 MaybeParseCXX11Attributes(MisplacedAttrs);
721 if (InInitStatement && Tok.isNot(tok::identifier))
725 bool InvalidDeclarator = ParseUsingDeclarator(Context, D);
727 ParsedAttributes Attrs(AttrFactory);
728 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
732 if (MisplacedAttrs.Range.isValid()) {
734 MisplacedAttrs.empty() ?
nullptr : &MisplacedAttrs.front();
735 auto &
Range = MisplacedAttrs.Range;
736 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
737 ?
Diag(
Range.getBegin(), diag::err_keyword_not_allowed) << FirstAttr
738 :
Diag(
Range.getBegin(), diag::err_attributes_not_allowed))
746 if (Tok.is(tok::equal) || InInitStatement) {
747 if (InvalidDeclarator) {
752 ProhibitAttributes(PrefixAttrs);
754 Decl *DeclFromDeclSpec =
nullptr;
760 Decl *AD = ParseAliasDeclarationAfterDeclarator(
761 TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
766 return Actions.ConvertDeclToDeclGroup(AD, DeclFromDeclSpec);
769 DiagnoseCXX11AttributeExtension(PrefixAttrs);
775 SourceRange R = TemplateInfo.getSourceRange();
776 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
785 SmallVector<Decl *, 8> DeclsInGroup;
788 MaybeParseAttributes(PAKM_GNU | PAKM_CXX11, Attrs);
789 DiagnoseCXX11AttributeExtension(Attrs);
792 if (InvalidDeclarator)
797 if (D.TypenameLoc.isValid() &&
799 Diag(D.Name.getSourceRange().getBegin(),
800 diag::err_typename_identifiers_only)
803 D.TypenameLoc = SourceLocation();
807 D.TypenameLoc, D.SS, D.Name,
808 D.EllipsisLoc, Attrs);
810 DeclsInGroup.push_back(UD);
818 InvalidDeclarator = ParseUsingDeclarator(Context, D);
821 if (DeclsInGroup.size() > 1)
822 Diag(Tok.getLocation(),
824 ? diag::warn_cxx17_compat_multi_using_declaration
825 : diag::ext_multi_using_declaration);
828 DeclEnd = Tok.getLocation();
829 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
830 !Attrs.
empty() ?
"attributes list"
831 : UELoc.
isValid() ?
"using-enum declaration"
832 :
"using declaration"))
835 return Actions.BuildDeclaratorGroup(DeclsInGroup);
838Decl *Parser::ParseAliasDeclarationAfterDeclarator(
842 if (ExpectAndConsume(tok::equal)) {
848 ? diag::warn_cxx98_compat_alias_declaration
849 : diag::ext_alias_declaration);
860 if (SpecKind != -1) {
863 Range = SourceRange(D.Name.TemplateId->LAngleLoc,
864 D.Name.TemplateId->RAngleLoc);
866 Range = TemplateInfo.getSourceRange();
867 Diag(
Range.getBegin(), diag::err_alias_declaration_specialization)
868 << SpecKind <<
Range;
875 Diag(D.Name.StartLocation, diag::err_alias_declaration_not_identifier);
879 }
else if (D.TypenameLoc.isValid())
880 Diag(D.TypenameLoc, diag::err_alias_declaration_not_identifier)
882 SourceRange(D.TypenameLoc, D.SS.isNotEmpty() ? D.SS.getEndLoc()
884 else if (D.SS.isNotEmpty())
885 Diag(D.SS.getBeginLoc(), diag::err_alias_declaration_not_identifier)
887 if (D.EllipsisLoc.isValid())
888 Diag(D.EllipsisLoc, diag::err_alias_declaration_pack_expansion)
891 Decl *DeclFromDeclSpec =
nullptr;
896 AS, &DeclFromDeclSpec, &Attrs);
898 *OwnedType = DeclFromDeclSpec;
901 DeclEnd = Tok.getLocation();
902 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
903 !Attrs.
empty() ?
"attributes list"
904 :
"alias declaration"))
909 TemplateParams ? TemplateParams->data() :
nullptr,
910 TemplateParams ? TemplateParams->size() : 0);
911 return Actions.ActOnAliasDeclaration(
getCurScope(), AS, TemplateParamsArg,
918 if (
const auto *BO = dyn_cast_or_null<BinaryOperator>(AssertExpr)) {
919 if (BO->getOpcode() == BO_LAnd &&
927 assert(Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
928 "Not a static_assert declaration");
931 const char *TokName = Tok.getName();
933 if (Tok.is(tok::kw__Static_assert))
934 diagnoseUseOfC11Keyword(Tok);
935 else if (Tok.is(tok::kw_static_assert)) {
938 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.getName();
940 Diag(Tok, diag::warn_cxx98_compat_static_assert);
946 if (
T.consumeOpen()) {
947 Diag(Tok, diag::err_expected) << tok::l_paren;
952 EnterExpressionEvaluationContext ConstantEvaluated(
955 if (AssertExpr.isInvalid()) {
961 if (Tok.is(tok::r_paren)) {
964 DiagVal = diag::warn_cxx14_compat_static_assert_no_message;
966 DiagVal = diag::ext_cxx_static_assert_no_message;
968 DiagVal = diag::warn_c17_compat_static_assert_no_message;
970 DiagVal = diag::ext_c_static_assert_no_message;
974 if (ExpectAndConsume(tok::comma)) {
979 bool ParseAsExpression =
false;
981 for (
unsigned I = 0;; ++I) {
983 if (
T.is(tok::r_paren))
986 ParseAsExpression =
true;
992 if (ParseAsExpression) {
995 ? diag::warn_cxx20_compat_static_assert_user_generated_message
996 : diag::ext_cxx_static_assert_user_generated_message);
1001 Diag(Tok, diag::err_expected_string_literal)
1013 if (
T.consumeClose())
1016 DeclEnd = Tok.getLocation();
1017 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert, TokName);
1019 return Actions.ActOnStaticAssertDeclaration(StaticAssertLoc, AssertExpr.get(),
1020 AssertMessage.
get(),
1021 T.getCloseLocation());
1025 assert(Tok.isOneOf(tok::kw_decltype, tok::annot_decltype) &&
1026 "Not a decltype specifier");
1029 SourceLocation StartLoc = Tok.getLocation();
1030 SourceLocation EndLoc;
1032 if (Tok.is(tok::annot_decltype)) {
1033 Result = getExprAnnotation(Tok);
1034 EndLoc = Tok.getAnnotationEndLoc();
1038 ConsumeAnnotationToken();
1039 if (
Result.isInvalid()) {
1044 if (Tok.getIdentifierInfo()->isStr(
"decltype"))
1045 Diag(Tok, diag::warn_cxx98_compat_decltype);
1050 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"decltype",
1053 return T.getOpenLocation() == Tok.getLocation() ? StartLoc
1054 :
T.getOpenLocation();
1058 if (Tok.is(tok::kw_auto) &&
NextToken().
is(tok::r_paren)) {
1061 Diag(Tok.getLocation(),
1063 ? diag::warn_cxx11_compat_decltype_auto_type_specifier
1064 : diag::ext_decltype_auto_type_specifier);
1075 if (
Result.isInvalid()) {
1078 EndLoc = ConsumeParen();
1080 if (PP.isBacktrackEnabled() && Tok.is(tok::semi)) {
1082 PP.RevertCachedTokens(2);
1085 assert(Tok.is(tok::semi));
1087 EndLoc = Tok.getLocation();
1093 Result = Actions.ActOnDecltypeExpression(
Result.get());
1099 if (
T.getCloseLocation().isInvalid()) {
1103 return T.getCloseLocation();
1106 if (
Result.isInvalid()) {
1108 return T.getCloseLocation();
1111 EndLoc =
T.getCloseLocation();
1113 assert(!
Result.isInvalid());
1115 const char *PrevSpec =
nullptr;
1117 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1120 PrevSpec, DiagID,
Result.get(), Policy)
1122 PrevSpec, DiagID, Policy)) {
1123 Diag(StartLoc, DiagID) << PrevSpec;
1129void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec &DS,
1133 if (PP.isBacktrackEnabled()) {
1134 PP.RevertCachedTokens(1);
1136 PP.EnterToken(Tok,
true);
1138 Tok.setKind(tok::annot_decltype);
1139 setExprAnnotation(Tok,
1143 Tok.setAnnotationEndLoc(EndLoc);
1144 Tok.setLocation(StartLoc);
1145 PP.AnnotateCachedTokens(Tok);
1149 assert(Tok.isOneOf(tok::annot_pack_indexing_type, tok::identifier) &&
1150 "Expected an identifier");
1153 SourceLocation StartLoc;
1154 SourceLocation EllipsisLoc;
1155 const char *PrevSpec;
1157 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1159 if (Tok.is(tok::annot_pack_indexing_type)) {
1160 StartLoc = Tok.getLocation();
1161 SourceLocation EndLoc;
1163 EndLoc = Tok.getAnnotationEndLoc();
1167 ConsumeAnnotationToken();
1168 if (
Type.isInvalid()) {
1173 DiagID,
Type, Policy);
1179 return Tok.getEndLoc();
1182 ParsedType Ty = Actions.getTypeName(*Tok.getIdentifierInfo(),
1186 return Tok.getEndLoc();
1201 ASTContext &
C = Actions.getASTContext();
1203 C.getSizeType(), SourceLocation());
1209 return T.getCloseLocation();
1212void Parser::AnnotateExistingIndexedTypeNamePack(
ParsedType T,
1216 if (PP.isBacktrackEnabled()) {
1217 PP.RevertCachedTokens(1);
1223 EndLoc = PP.getLastCachedTokenLocation();
1226 PP.EnterToken(Tok,
true);
1228 Tok.setKind(tok::annot_pack_indexing_type);
1229 setTypeAnnotation(Tok,
T);
1230 Tok.setAnnotationEndLoc(EndLoc);
1231 Tok.setLocation(StartLoc);
1232 PP.AnnotateCachedTokens(Tok);
1236 switch (Tok.getKind()) {
1237#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) \
1238 case tok::kw___##Trait: \
1239 return DeclSpec::TST_##Trait;
1240#include "clang/Basic/TransformTypeTraits.def"
1242 llvm_unreachable(
"passed in an unhandled type transformation built-in");
1246bool Parser::MaybeParseTypeTransformTypeSpecifier(
DeclSpec &DS) {
1248 Tok.setKind(tok::identifier);
1251 DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
1255 if (
T.expectAndConsume(diag::err_expected_lparen_after, Tok.getName(),
1260 if (
Result.isInvalid()) {
1266 if (
T.getCloseLocation().isInvalid())
1269 const char *PrevSpec =
nullptr;
1273 Actions.getASTContext().getPrintingPolicy()))
1274 Diag(StartLoc, DiagID) << PrevSpec;
1282 if (Tok.is(tok::kw_typename)) {
1283 Diag(Tok, diag::err_expected_class_name_not_template)
1290 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
1295 BaseLoc = Tok.getLocation();
1300 if (Tok.isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1305 DeclSpec DS(AttrFactory);
1307 EndLocation = ParseDecltypeSpecifier(DS);
1311 return Actions.ActOnTypeName(DeclaratorInfo);
1314 if (Tok.is(tok::annot_pack_indexing_type)) {
1315 DeclSpec DS(AttrFactory);
1316 ParsePackIndexingType(DS);
1319 return Actions.ActOnTypeName(DeclaratorInfo);
1325 if (Tok.is(tok::annot_template_id)) {
1326 TemplateIdAnnotation *TemplateId = takeTemplateIdAnnotation(Tok);
1331 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
1333 EndLocation = Tok.getAnnotationEndLoc();
1334 ConsumeAnnotationToken();
1341 if (Tok.isNot(tok::identifier)) {
1342 Diag(Tok, diag::err_expected_class_name);
1346 IdentifierInfo *Id = Tok.getIdentifierInfo();
1349 if (Tok.is(tok::less)) {
1356 if (!Actions.DiagnoseUnknownTemplateName(*Id, IdLoc,
getCurScope(), &SS,
1358 Diag(IdLoc, diag::err_unknown_template_name) << Id;
1366 if (AnnotateTemplateIdToken(
Template, TNK, SS, SourceLocation(),
1369 if (Tok.is(tok::annot_template_id) &&
1370 takeTemplateIdAnnotation(Tok)->mightBeType())
1376 if (Tok.isNot(tok::annot_typename))
1381 EndLocation = Tok.getAnnotationEndLoc();
1383 ConsumeAnnotationToken();
1388 IdentifierInfo *CorrectedII =
nullptr;
1390 *Id, IdLoc,
getCurScope(), &SS,
true,
false,
nullptr,
1396 Diag(IdLoc, diag::err_expected_class_name);
1401 EndLocation = IdLoc;
1404 DeclSpec DS(AttrFactory);
1409 const char *PrevSpec =
nullptr;
1412 Actions.getASTContext().getPrintingPolicy());
1416 return Actions.ActOnTypeName(DeclaratorInfo);
1419void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1420 while (Tok.isOneOf(tok::kw___single_inheritance,
1421 tok::kw___multiple_inheritance,
1422 tok::kw___virtual_inheritance)) {
1423 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
1424 auto Kind = Tok.getKind();
1426 attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0, Kind);
1431 while (Tok.is(tok::kw__Nullable)) {
1432 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
1433 auto Kind = Tok.getKind();
1435 attrs.
addNew(AttrName, AttrNameLoc, AttributeScopeInfo(),
nullptr, 0, Kind);
1439bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1441 switch (Tok.getKind()) {
1443 if (Tok.isRegularKeywordAttribute())
1450 case tok::identifier:
1452 case tok::coloncolon:
1453 case tok::annot_cxxscope:
1454 case tok::annot_typename:
1455 case tok::annot_template_id:
1456 case tok::kw_decltype:
1459 case tok::kw_operator:
1460 case tok::kw___declspec:
1465 case tok::kw___attribute:
1466 case tok::annot_pragma_pack:
1468 case tok::annot_pragma_ms_pragma:
1470 case tok::annot_pragma_ms_vtordisp:
1472 case tok::annot_pragma_ms_pointers_to_members:
1475 return CouldBeBitfield ||
1478 case tok::kw___cdecl:
1479 case tok::kw___fastcall:
1480 case tok::kw___stdcall:
1481 case tok::kw___thiscall:
1482 case tok::kw___vectorcall:
1488 case tok::kw_volatile:
1489 case tok::kw_restrict:
1490 case tok::kw__Atomic:
1491 case tok::kw___unaligned:
1495 case tok::kw_inline:
1496 case tok::kw_virtual:
1497 case tok::kw_friend:
1499 case tok::kw_static:
1500 case tok::kw_extern:
1501 case tok::kw_typedef:
1502 case tok::kw_register:
1504 case tok::kw_mutable:
1505 case tok::kw_thread_local:
1506 case tok::kw_constexpr:
1507 case tok::kw_consteval:
1508 case tok::kw_constinit:
1524 if (!isKnownToBeTypeSpecifier(
NextToken()))
1541 ParsedTemplateInfo &TemplateInfo,
1543 DeclSpecContext DSC,
1546 if (TagTokKind == tok::kw_struct)
1548 else if (TagTokKind == tok::kw___interface)
1550 else if (TagTokKind == tok::kw_class)
1553 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1557 if (Tok.is(tok::code_completion)) {
1560 Actions.CodeCompletion().CodeCompleteTag(
getCurScope(), TagType);
1571 const bool shouldDelayDiagsInTag =
1573 SuppressAccessChecks diagsFromTag(*
this, shouldDelayDiagsInTag);
1575 ParsedAttributes attrs(AttrFactory);
1578 MaybeParseAttributes(PAKM_CXX11 | PAKM_Declspec | PAKM_GNU, attrs);
1580 if (Tok.isOneOf(tok::kw___single_inheritance,
1581 tok::kw___multiple_inheritance,
1582 tok::kw___virtual_inheritance)) {
1583 ParseMicrosoftInheritanceClassAttributes(attrs);
1586 if (Tok.is(tok::kw__Nullable)) {
1587 ParseNullabilityClassAttributes(attrs);
1595 SourceLocation AttrFixitLoc = Tok.getLocation();
1598 !Tok.isAnnotation() && Tok.getIdentifierInfo() &&
1601#include
"clang/Basic/TransformTypeTraits.def"
1602 tok::kw___is_abstract,
1603 tok::kw___is_aggregate,
1604 tok::kw___is_arithmetic,
1606 tok::kw___is_assignable,
1607 tok::kw___is_base_of,
1608 tok::kw___is_bounded_array,
1610 tok::kw___is_complete_type,
1611 tok::kw___is_compound,
1613 tok::kw___is_constructible,
1614 tok::kw___is_convertible,
1615 tok::kw___is_convertible_to,
1616 tok::kw___is_destructible,
1619 tok::kw___is_floating_point,
1621 tok::kw___is_function,
1622 tok::kw___is_fundamental,
1623 tok::kw___is_integral,
1624 tok::kw___is_interface_class,
1625 tok::kw___is_literal,
1626 tok::kw___is_lvalue_expr,
1627 tok::kw___is_lvalue_reference,
1628 tok::kw___is_member_function_pointer,
1629 tok::kw___is_member_object_pointer,
1630 tok::kw___is_member_pointer,
1631 tok::kw___is_nothrow_assignable,
1632 tok::kw___is_nothrow_constructible,
1633 tok::kw___is_nothrow_convertible,
1634 tok::kw___is_nothrow_destructible,
1635 tok::kw___is_object,
1637 tok::kw___is_pointer,
1638 tok::kw___is_polymorphic,
1639 tok::kw___is_reference,
1640 tok::kw___is_rvalue_expr,
1641 tok::kw___is_rvalue_reference,
1643 tok::kw___is_scalar,
1644 tok::kw___is_scoped_enum,
1645 tok::kw___is_sealed,
1646 tok::kw___is_signed,
1647 tok::kw___is_standard_layout,
1648 tok::kw___is_trivial,
1649 tok::kw___is_trivially_equality_comparable,
1650 tok::kw___is_trivially_assignable,
1651 tok::kw___is_trivially_constructible,
1652 tok::kw___is_trivially_copyable,
1653 tok::kw___is_unbounded_array,
1655 tok::kw___is_unsigned,
1657 tok::kw___is_volatile
1664 TryKeywordIdentFallback(
true);
1666 struct PreserveAtomicIdentifierInfoRAII {
1667 PreserveAtomicIdentifierInfoRAII(Token &
Tok,
bool Enabled)
1671 assert(
Tok.
is(tok::kw__Atomic));
1676 ~PreserveAtomicIdentifierInfoRAII() {
1679 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1681 IdentifierInfo *AtomicII;
1689 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1690 Tok.is(tok::kw__Atomic) &&
1692 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1693 Tok, ShouldChangeAtomicToIdentifier);
1703 if (TemplateInfo.TemplateParams)
1706 bool HasValidSpec =
true;
1707 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
1711 HasValidSpec =
false;
1714 if (Tok.isNot(tok::identifier) && Tok.isNot(tok::annot_template_id)) {
1715 Diag(Tok, diag::err_expected) << tok::identifier;
1716 HasValidSpec =
false;
1724 auto RecoverFromUndeclaredTemplateName = [&](IdentifierInfo *Name,
1725 SourceLocation NameLoc,
1726 SourceRange TemplateArgRange,
1727 bool KnownUndeclared) {
1728 Diag(NameLoc, diag::err_explicit_spec_non_template)
1730 << TagTokKind << Name << TemplateArgRange << KnownUndeclared;
1734 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1735 if (TemplateParams->size() > 1) {
1736 TemplateParams->pop_back();
1738 TemplateParams =
nullptr;
1743 TemplateParams =
nullptr;
1745 TemplateInfo.TemplateLoc = SourceLocation();
1746 TemplateInfo.ExternLoc = SourceLocation();
1751 IdentifierInfo *Name =
nullptr;
1752 SourceLocation NameLoc;
1753 TemplateIdAnnotation *TemplateId =
nullptr;
1754 if (Tok.is(tok::identifier)) {
1755 Name = Tok.getIdentifierInfo();
1763 TemplateArgList TemplateArgs;
1764 SourceLocation LAngleLoc, RAngleLoc;
1765 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1769 LAngleLoc = RAngleLoc = SourceLocation();
1771 RecoverFromUndeclaredTemplateName(
1772 Name, NameLoc, SourceRange(LAngleLoc, RAngleLoc),
false);
1774 }
else if (Tok.is(tok::annot_template_id)) {
1775 TemplateId = takeTemplateIdAnnotation(Tok);
1776 NameLoc = ConsumeAnnotationToken();
1780 Actions.ActOnUndeclaredTypeTemplateName(
1783 RecoverFromUndeclaredTemplateName(
1786 TemplateId =
nullptr;
1794 SourceRange
Range(NameLoc);
1799 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1800 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1835 MaybeParseCXX11Attributes(Attributes);
1837 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1844 Tok.isOneOf(tok::comma, tok::ellipsis))
1847 AllowDefiningTypeSpec::No ||
1850 else if (Tok.is(tok::l_brace) ||
1851 (DSC != DeclSpecContext::DSC_association &&
1853 (isClassCompatibleKeyword() &&
1855 isClassCompatibleKeyword(
NextToken())))) {
1859 Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
1870 }
else if (isClassCompatibleKeyword() &&
1875 isCXX2CTriviallyRelocatableKeyword())) {
1878 TentativeParsingAction PA(*
this);
1881 while (isClassCompatibleKeyword())
1886 if (Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square)) {
1890 }
else if (Tok.is(tok::kw_alignas) &&
NextToken().
is(tok::l_paren)) {
1895 }
else if (Tok.isRegularKeywordAttribute()) {
1900 if (!
T.consumeOpen())
1908 if (Tok.isOneOf(tok::l_brace, tok::colon))
1914 }
else if (!isTypeSpecifier(DSC) &&
1915 (Tok.is(tok::semi) ||
1916 (Tok.isAtStartOfLine() && !isValidAfterTypeSpecifier(
false)))) {
1918 if (Tok.isNot(tok::semi)) {
1919 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
1921 ExpectAndConsume(tok::semi, diag::err_expected_after,
1923 PP.EnterToken(Tok,
true);
1924 Tok.setKind(tok::semi);
1937 SourceRange AttrRange = Attributes.
Range;
1941 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
1942 ?
Diag(Loc, diag::err_keyword_not_allowed) << FirstAttr
1943 :
Diag(Loc, diag::err_attributes_not_allowed))
1946 AttrFixitLoc, CharSourceRange(AttrRange,
true))
1955 if (!Name && !TemplateId &&
1960 Diag(StartLoc, diag::err_anon_type_definition)
1979 SkipBodyInfo SkipBody;
1990 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
1991 diag::err_keyword_not_allowed,
1994 TagOrTempResult = Actions.ActOnExplicitInstantiation(
1995 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
1996 TagType, StartLoc, SS, TemplateId->
Template,
2007 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2008 diag::err_keyword_not_allowed,
2031 "Expected a definition here");
2035 TemplateParams =
nullptr;
2037 SourceLocation LAngleLoc =
2038 PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
2040 diag::err_explicit_instantiation_with_definition)
2041 << SourceRange(TemplateInfo.TemplateLoc)
2047 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
2048 0, SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc, {},
2049 LAngleLoc,
nullptr));
2050 TemplateParams = &FakedParamLists;
2055 TagOrTempResult = Actions.ActOnClassTemplateSpecialization(
2057 SS, *TemplateId, attrs,
2060 TemplateParams ? TemplateParams->size() : 0),
2070 ProhibitAttributes(attrs);
2072 TagOrTempResult = Actions.ActOnExplicitInstantiation(
2073 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
2074 TagType, StartLoc, SS, Name, NameLoc, attrs);
2077 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2078 diag::err_keyword_not_allowed,
2082 SourceLocation EllipsisLoc;
2094 if (Tok.is(tok::comma)) {
2095 Diag(Tok.getLocation(),
2096 diag::err_friend_template_decl_multiple_specifiers);
2100 TagOrTempResult = Actions.ActOnTemplatedFriendTag(
2102 NameLoc, EllipsisLoc, attrs,
2104 TemplateParams ? TemplateParams->size() : 0));
2107 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
2108 diag::err_keyword_not_allowed,
2115 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2117 TemplateParams =
nullptr;
2120 bool IsDependent =
false;
2130 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
2133 TagOrTempResult = Actions.ActOnTag(
2134 getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc, attrs, AS,
2137 DSC == DeclSpecContext::DSC_type_specifier,
2138 DSC == DeclSpecContext::DSC_template_param ||
2139 DSC == DeclSpecContext::DSC_template_type_arg,
2140 OffsetOfState, &SkipBody);
2147 Name, StartLoc, NameLoc);
2154 if (shouldDelayDiagsInTag) {
2155 diagsFromTag.done();
2158 diagsFromTag.redelay();
2163 assert(Tok.is(tok::l_brace) ||
2165 isClassCompatibleKeyword());
2167 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc, TagType,
2168 TagOrTempResult.
get());
2170 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs, TagType,
2171 TagOrTempResult.
get());
2179 TagOrTempResult.
get(), SkipBody)) {
2188 Actions.ProcessDeclAttributeDelayed(TagOrTempResult.
get(), attrs);
2190 const char *PrevSpec =
nullptr;
2195 NameLoc.
isValid() ? NameLoc : StartLoc,
2197 }
else if (!TagOrTempResult.
isInvalid()) {
2199 TagType, StartLoc, NameLoc.
isValid() ? NameLoc : StartLoc, PrevSpec,
2200 DiagID, TagOrTempResult.
get(), Owned, Policy);
2207 Diag(StartLoc, DiagID) << PrevSpec;
2224 if (Tok.isNot(tok::semi)) {
2225 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
2226 ExpectAndConsume(tok::semi, diag::err_expected_after,
2231 PP.EnterToken(Tok,
true);
2232 Tok.setKind(tok::semi);
2237void Parser::ParseBaseClause(
Decl *ClassDecl) {
2238 assert(Tok.is(tok::colon) &&
"Not a base clause");
2242 SmallVector<CXXBaseSpecifier *, 8> BaseInfo;
2247 if (!
Result.isUsable()) {
2253 BaseInfo.push_back(
Result.get());
2263 Actions.ActOnBaseSpecifiers(ClassDecl, BaseInfo);
2267 bool IsVirtual =
false;
2268 SourceLocation StartLoc = Tok.getLocation();
2270 ParsedAttributes Attributes(AttrFactory);
2271 MaybeParseCXX11Attributes(Attributes);
2277 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2284 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
2287 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2291 if (Tok.is(tok::kw_virtual)) {
2295 Diag(VirtualLoc, diag::err_dup_virtual)
2303 Diag(Tok.getLocation(), diag::err_hlsl_virtual_inheritance);
2305 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2313 if (
getLangOpts().MSVCCompat && Tok.is(tok::kw__Atomic) &&
2315 Tok.setKind(tok::identifier);
2317 SourceLocation EndLocation;
2318 SourceLocation BaseLoc;
2319 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2326 SourceLocation EllipsisLoc;
2330 SourceRange
Range(StartLoc, EndLocation);
2334 return Actions.ActOnBaseSpecifier(ClassDecl, Range, Attributes, IsVirtual,
2335 Access, BaseType.
get(), BaseLoc,
2340 switch (Tok.getKind()) {
2343 case tok::kw_private:
2345 case tok::kw_protected:
2347 case tok::kw_public:
2352void Parser::HandleMemberFunctionDeclDelays(
Declarator &DeclaratorInfo,
2359 if (!NeedLateParse) {
2361 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx) {
2363 if (Param->hasUnparsedDefaultArg()) {
2364 NeedLateParse =
true;
2370 if (NeedLateParse) {
2373 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2374 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2379 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2380 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx)
2381 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2397 const IdentifierInfo *II = Tok.getIdentifierInfo();
2401 Ident_final = &PP.getIdentifierTable().get(
"final");
2403 Ident_GNU_final = &PP.getIdentifierTable().get(
"__final");
2405 Ident_sealed = &PP.getIdentifierTable().get(
"sealed");
2406 Ident_abstract = &PP.getIdentifierTable().get(
"abstract");
2408 Ident_override = &PP.getIdentifierTable().get(
"override");
2411 if (II == Ident_override)
2414 if (II == Ident_sealed)
2417 if (II == Ident_abstract)
2420 if (II == Ident_final)
2423 if (II == Ident_GNU_final)
2429void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2438 Diag(Tok.getLocation(), diag::err_friend_decl_spec)
2441 << SourceRange(FriendLoc, FriendLoc);
2448 const char *PrevSpec =
nullptr;
2449 if (VS.
SetSpecifier(Specifier, Tok.getLocation(), PrevSpec))
2450 Diag(Tok.getLocation(), diag::err_duplicate_virt_specifier)
2455 Diag(Tok.getLocation(), diag::err_override_control_interface)
2458 Diag(Tok.getLocation(), diag::ext_ms_sealed_keyword);
2460 Diag(Tok.getLocation(), diag::ext_ms_abstract_keyword);
2462 Diag(Tok.getLocation(), diag::ext_warn_gnu_final);
2464 Diag(Tok.getLocation(),
2466 ? diag::warn_cxx98_compat_override_control_keyword
2467 : diag::ext_override_control_keyword)
2474bool Parser::isCXX11FinalKeyword()
const {
2481bool Parser::isCXX2CTriviallyRelocatableKeyword(
Token Tok)
const {
2484 if (!Ident_trivially_relocatable_if_eligible)
2485 Ident_trivially_relocatable_if_eligible =
2486 &PP.getIdentifierTable().get(
"trivially_relocatable_if_eligible");
2487 IdentifierInfo *II = Tok.getIdentifierInfo();
2488 return II == Ident_trivially_relocatable_if_eligible;
2491bool Parser::isCXX2CTriviallyRelocatableKeyword()
const {
2492 return isCXX2CTriviallyRelocatableKeyword(Tok);
2495void Parser::ParseCXX2CTriviallyRelocatableSpecifier(
SourceLocation &TRS) {
2496 assert(isCXX2CTriviallyRelocatableKeyword() &&
2497 "expected a trivially_relocatable specifier");
2500 ? diag::warn_relocatable_keyword
2501 : diag::ext_relocatable_keyword)
2507bool Parser::isCXX2CReplaceableKeyword(
Token Tok)
const {
2510 if (!Ident_replaceable_if_eligible)
2511 Ident_replaceable_if_eligible =
2512 &PP.getIdentifierTable().get(
"replaceable_if_eligible");
2513 IdentifierInfo *II = Tok.getIdentifierInfo();
2514 return II == Ident_replaceable_if_eligible;
2517bool Parser::isCXX2CReplaceableKeyword()
const {
2518 return isCXX2CReplaceableKeyword(Tok);
2521void Parser::ParseCXX2CReplaceableSpecifier(
SourceLocation &MRS) {
2522 assert(isCXX2CReplaceableKeyword() &&
2523 "expected a replaceable_if_eligible specifier");
2526 ? diag::warn_relocatable_keyword
2527 : diag::ext_relocatable_keyword)
2533bool Parser::isClassCompatibleKeyword(
Token Tok)
const {
2534 if (isCXX2CTriviallyRelocatableKeyword(Tok) || isCXX2CReplaceableKeyword(Tok))
2543bool Parser::isClassCompatibleKeyword()
const {
2544 return isClassCompatibleKeyword(Tok);
2549bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2551 LateParsedAttrList &LateParsedAttrs) {
2562 if (Tok.isNot(tok::colon))
2563 ParseDeclarator(DeclaratorInfo);
2568 MaybeParseHLSLAnnotations(DeclaratorInfo,
nullptr,
2573 "don't know where identifier would go yet?");
2577 }
else if (Tok.is(tok::kw_requires)) {
2578 ParseTrailingRequiresClause(DeclaratorInfo);
2580 ParseOptionalCXX11VirtSpecifierSeq(
2581 VS, getCurrentClass().IsInterface,
2584 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2589 if (Tok.is(tok::kw_asm)) {
2591 ExprResult AsmLabel(ParseSimpleAsm(
true, &Loc));
2592 if (AsmLabel.isInvalid())
2602 DiagnoseAndSkipCXX11Attributes();
2603 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2604 DiagnoseAndSkipCXX11Attributes();
2609 ParseOptionalCXX11VirtSpecifierSeq(
2610 VS, getCurrentClass().IsInterface,
2616 if (AL.isKnownToGCC() && !AL.isCXX11Attribute())
2617 Diag(AL.getLoc(), diag::warn_gcc_attribute_location);
2619 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo,
2634void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2636 DeclSpec DS(AttrFactory);
2640 ParseTypeQualifierListOpt(
2641 DS, AR_NoAttributesParsed,
false,
2643 Actions.CodeCompletion().CodeCompleteFunctionQualifiers(DS, D, &VS);
2650 auto DeclSpecCheck = [&](
DeclSpec::TQ TypeQual, StringRef FixItName,
2651 SourceLocation SpecLoc) {
2652 FixItHint Insertion;
2653 auto &MQ =
Function.getOrCreateMethodQualifiers();
2654 if (!(MQ.getTypeQualifiers() & TypeQual)) {
2655 std::string Name(FixItName.data());
2658 MQ.SetTypeQual(TypeQual, SpecLoc);
2660 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2669 bool RefQualifierIsLValueRef =
true;
2670 SourceLocation RefQualifierLoc;
2671 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2672 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2673 FixItHint Insertion =
2675 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2676 Function.RefQualifierLoc = RefQualifierLoc;
2678 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2679 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2691 "ParseCXXClassMemberDeclaration should only be called in C++ mode");
2692 if (Tok.is(tok::at)) {
2694 Diag(Tok, diag::err_at_defs_cxx);
2696 Diag(Tok, diag::err_at_in_class);
2712 bool MalformedTypeSpec =
false;
2714 Tok.isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2716 MalformedTypeSpec =
true;
2719 if (Tok.isNot(tok::annot_cxxscope))
2720 isAccessDecl =
false;
2729 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2739 SourceLocation TemplateKWLoc;
2742 false,
false,
true,
true,
2743 false, &TemplateKWLoc, Name)) {
2749 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2750 "access declaration")) {
2758 SourceLocation(), SS, Name,
2760 ParsedAttributesView())));
2767 Tok.isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2768 SourceLocation DeclEnd;
2770 DeclGroupRef(ParseStaticAssertDeclaration(DeclEnd)));
2773 if (Tok.is(tok::kw_template)) {
2774 assert(!TemplateInfo.TemplateParams &&
2775 "Nested template improperly parsed?");
2776 ObjCDeclContextSwitch ObjCDC(*
this);
2777 SourceLocation DeclEnd;
2779 DeclEnd, AccessAttrs, AS);
2783 if (Tok.is(tok::kw___extension__)) {
2785 ExtensionRAIIObject O(Diags);
2787 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo,
2791 ParsedAttributes DeclAttrs(AttrFactory);
2793 MaybeParseCXX11Attributes(DeclAttrs);
2798 if (Tok.is(tok::annot_attr_openmp))
2799 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, DeclAttrs);
2801 if (Tok.is(tok::kw_using)) {
2806 while (Tok.is(tok::kw_template)) {
2808 Diag(TemplateLoc, diag::err_unexpected_template_after_using)
2812 if (Tok.is(tok::kw_namespace)) {
2813 Diag(UsingLoc, diag::err_using_namespace_in_class);
2817 SourceLocation DeclEnd;
2820 UsingLoc, DeclEnd, DeclAttrs, AS);
2823 ParsedAttributes DeclSpecAttrs(AttrFactory);
2825 LateParsedAttrList CommonLateParsedAttrs;
2827 while (MaybeParseCXX11Attributes(DeclAttrs) ||
2828 MaybeParseGNUAttributes(DeclSpecAttrs, &CommonLateParsedAttrs) ||
2829 MaybeParseMicrosoftAttributes(DeclSpecAttrs))
2832 SourceLocation DeclStart;
2833 if (DeclAttrs.Range.isValid()) {
2834 DeclStart = DeclSpecAttrs.Range.
isInvalid()
2835 ? DeclAttrs.Range.getBegin()
2836 : std::min(DeclAttrs.Range.getBegin(),
2837 DeclSpecAttrs.Range.getBegin());
2839 DeclStart = DeclSpecAttrs.Range.getBegin();
2844 ParsingDeclSpec DS(*
this, TemplateDiags);
2847 if (MalformedTypeSpec)
2855 bool IsTemplateSpecOrInst =
2858 SuppressAccessChecks diagsFromTag(*
this, IsTemplateSpecOrInst);
2860 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
2861 &CommonLateParsedAttrs);
2863 if (IsTemplateSpecOrInst)
2864 diagsFromTag.done();
2876 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
2877 &CommonLateParsedAttrs))
2881 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->data()
2883 TemplateInfo.TemplateParams ? TemplateInfo.TemplateParams->size() : 0);
2887 ProhibitAttributes(DeclAttrs);
2889 RecordDecl *AnonRecord =
nullptr;
2890 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(
2891 getCurScope(), AS, DS, DeclAttrs, TemplateParams,
false, AnonRecord);
2892 Actions.ActOnDefinedDeclarationSpecifier(TheDecl);
2893 DS.complete(TheDecl);
2895 Decl *decls[] = {AnonRecord, TheDecl};
2896 return Actions.BuildDeclaratorGroup(decls);
2898 return Actions.ConvertDeclToDeclGroup(TheDecl);
2902 Actions.ActOnDefinedDeclarationSpecifier(DS.
getRepAsDecl());
2908 ? diag::warn_cxx23_variadic_friends
2909 : diag::ext_variadic_friends);
2912 SmallVector<Decl *> Decls;
2915 auto ParsedFriendDecl = [&](ParsingDeclSpec &DeclSpec) {
2916 SourceLocation VariadicLoc;
2919 RecordDecl *AnonRecord =
nullptr;
2920 Decl *D = Actions.ParsedFreeStandingDeclSpec(
2921 getCurScope(), AS, DeclSpec, DeclAttrs, TemplateParams,
false,
2922 AnonRecord, VariadicLoc);
2923 DeclSpec.complete(D);
2933 if (ParsedFriendDecl(DS))
2937 ParsingDeclSpec DeclSpec(*
this, TemplateDiags);
2938 const char *PrevSpec =
nullptr;
2939 unsigned DiagId = 0;
2940 DeclSpec.SetFriendSpec(FriendLoc, PrevSpec, DiagId);
2941 ParseDeclarationSpecifiers(DeclSpec, TemplateInfo, AS,
2942 DeclSpecContext::DSC_class,
nullptr);
2943 if (ParsedFriendDecl(DeclSpec))
2947 ExpectAndConsume(tok::semi, diag::err_expected_semi_after_stmt,
2948 "friend declaration");
2950 return Actions.BuildDeclaratorGroup(Decls);
2956 if (Tok.is(tok::kw_concept)) {
2960 ? llvm::to_underlying(diag::err_friend_concept)
2961 : llvm::to_underlying(
2963 err_concept_decls_may_only_appear_in_global_namespace_scope));
2968 ParsingDeclarator DeclaratorInfo(*
this, DS, DeclAttrs,
2970 if (TemplateInfo.TemplateParams)
2975 LateParsedAttrList LateParsedAttrs;
2977 SourceLocation EqualLoc;
2978 SourceLocation PureSpecLoc;
2980 auto TryConsumePureSpecifier = [&](
bool AllowDefinition) {
2981 if (Tok.isNot(tok::equal))
2985 SmallString<8> Buffer;
2986 if (
Zero.isNot(tok::numeric_constant) ||
2987 PP.getSpelling(
Zero, Buffer) !=
"0")
2991 if (!
After.isOneOf(tok::semi, tok::comma) &&
2992 !(AllowDefinition &&
2993 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
3001 SmallVector<Decl *, 8> DeclsInGroup;
3004 bool ExpectSemi =
true;
3009 SuppressAccessChecks SAC(*
this, IsTemplateSpecOrInst);
3012 if (ParseCXXMemberDeclaratorBeforeInitializer(
3013 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
3018 if (IsTemplateSpecOrInst)
3026 TryConsumePureSpecifier(
true);
3037 if (Tok.isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
3039 }
else if (Tok.is(tok::equal)) {
3041 if (KW.
is(tok::kw_default))
3043 else if (KW.
is(tok::kw_delete))
3045 else if (KW.
is(tok::code_completion)) {
3047 Actions.CodeCompletion().CodeCompleteAfterFunctionEquals(
3062 ProhibitAttributes(DeclAttrs);
3079 diag::err_function_declared_typedef);
3085 Decl *FunDecl = ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo,
3086 TemplateInfo, VS, PureSpecLoc);
3089 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
3090 CommonLateParsedAttrs[i]->addDecl(FunDecl);
3092 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
3093 LateParsedAttrs[i]->addDecl(FunDecl);
3096 LateParsedAttrs.clear();
3099 if (Tok.is(tok::semi))
3112 bool HasStaticInitializer =
false;
3113 if (Tok.isOneOf(tok::equal, tok::l_brace) && PureSpecLoc.
isInvalid()) {
3117 Diag(Tok, diag::err_anon_bitfield_member_init);
3121 if (!TryConsumePureSpecifier(
false))
3123 HasStaticInitializer =
true;
3131 if (BitfieldSize.
get())
3133 ? diag::warn_cxx17_compat_bitfield_member_init
3134 : diag::ext_bitfield_member_init);
3137 HasStaticInitializer =
true;
3145 NamedDecl *ThisDecl =
nullptr;
3153 if (AL.isCXX11Attribute() || AL.isRegularKeywordAttribute()) {
3154 auto Loc = AL.getRange().getBegin();
3155 (AL.isRegularKeywordAttribute()
3156 ?
Diag(Loc, diag::err_keyword_not_allowed) << AL
3157 :
Diag(Loc, diag::err_attributes_not_allowed))
3161 ThisDecl = Actions.ActOnFriendFunctionDecl(
getCurScope(), DeclaratorInfo,
3164 ThisDecl = Actions.ActOnCXXMemberDeclarator(
3165 getCurScope(), AS, DeclaratorInfo, TemplateParams, BitfieldSize.
get(),
3166 VS, HasInClassInit);
3168 if (VarTemplateDecl *VT =
3169 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
3172 ThisDecl = VT->getTemplatedDecl();
3175 Actions.ProcessDeclAttributeList(
getCurScope(), ThisDecl, AccessAttrs);
3184 HasStaticInitializer =
true;
3188 Diag(PureSpecLoc, diag::err_duplicate_virt_specifier) <<
"abstract";
3190 if (ThisDecl && PureSpecLoc.
isValid())
3191 Actions.ActOnPureSpecifier(ThisDecl, PureSpecLoc);
3199 ? diag::warn_cxx98_compat_nonstatic_member_init
3200 : diag::ext_nonstatic_member_init);
3208 Diag(Tok, diag::err_incomplete_array_member_init);
3215 ParseCXXNonStaticMemberInitializer(ThisDecl);
3216 }
else if (HasStaticInitializer) {
3221 if (
Init.isInvalid()) {
3223 Actions.ActOnUninitializedDecl(ThisDecl);
3225 }
else if (ThisDecl)
3226 Actions.AddInitializerToDecl(ThisDecl,
Init.get(),
3230 Actions.ActOnUninitializedDecl(ThisDecl);
3235 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
3236 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
3238 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
3239 LateParsedAttrs[i]->addDecl(ThisDecl);
3241 Actions.FinalizeDeclaration(ThisDecl);
3242 DeclsInGroup.push_back(ThisDecl);
3247 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
3249 LateParsedAttrs.clear();
3251 DeclaratorInfo.complete(ThisDecl);
3255 SourceLocation CommaLoc;
3259 if (Tok.isAtStartOfLine() &&
3264 Diag(CommaLoc, diag::err_expected_semi_declaration)
3276 Diag(CommaLoc, diag::err_multiple_template_declarators)
3277 << TemplateInfo.Kind;
3281 DeclaratorInfo.
clear();
3284 EqualLoc = PureSpecLoc = SourceLocation();
3290 DiagnoseAndSkipCXX11Attributes();
3291 MaybeParseGNUAttributes(DeclaratorInfo);
3292 DiagnoseAndSkipCXX11Attributes();
3294 if (ParseCXXMemberDeclaratorBeforeInitializer(
3295 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
3300 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
3308 return Actions.FinalizeDeclaratorGroup(
getCurScope(), DS, DeclsInGroup);
3311ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
3313 assert(Tok.isOneOf(tok::equal, tok::l_brace) &&
3314 "Data member initializer not starting with '=' or '{'");
3316 bool IsFieldInitialization = isa_and_present<FieldDecl>(D);
3318 EnterExpressionEvaluationContext Context(
3320 IsFieldInitialization
3328 Actions.ExprEvalContexts.back().InImmediateEscalatingFunctionContext =
3329 IsFieldInitialization;
3332 if (Tok.is(tok::kw_delete)) {
3339 if (IsFunction ||
Next.isOneOf(tok::semi, tok::comma, tok::eof)) {
3345 SkipDeletedFunctionBody();
3348 }
else if (Tok.is(tok::kw_default)) {
3350 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
3358 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
3359 Diag(Tok, diag::err_ms_property_initializer) << PD;
3362 return ParseInitializer();
3369 while (isClassCompatibleKeyword())
3374 ParsedAttributes Attrs(AttrFactory);
3375 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3380 if (Tok.isNot(tok::colon) && Tok.isNot(tok::l_brace))
3386 if (Tok.is(tok::colon)) {
3389 ParsingClassDefinition ParsingDef(*
this, TagDecl,
true,
3392 Actions.ActOnTagStartSkippedDefinition(
getCurScope(), TagDecl);
3395 ParseBaseClause(
nullptr);
3397 Actions.ActOnTagFinishSkippedDefinition(OldContext);
3399 if (!Tok.is(tok::l_brace)) {
3400 Diag(PP.getLocForEndOfToken(PrevTokLocation),
3401 diag::err_expected_lbrace_after_base_specifiers);
3407 assert(Tok.is(tok::l_brace));
3413 if (Tok.is(tok::kw___attribute)) {
3414 ParsedAttributes Attrs(AttrFactory);
3415 MaybeParseGNUAttributes(Attrs);
3424 switch (Tok.getKind()) {
3425 case tok::kw___if_exists:
3426 case tok::kw___if_not_exists:
3427 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, AS);
3436 case tok::annot_pragma_vis:
3437 HandlePragmaVisibility();
3439 case tok::annot_pragma_pack:
3442 case tok::annot_pragma_align:
3443 HandlePragmaAlign();
3445 case tok::annot_pragma_ms_pointers_to_members:
3446 HandlePragmaMSPointersToMembers();
3448 case tok::annot_pragma_ms_pragma:
3449 HandlePragmaMSPragma();
3451 case tok::annot_pragma_ms_vtordisp:
3452 HandlePragmaMSVtorDisp();
3454 case tok::annot_pragma_dump:
3458 case tok::kw_namespace:
3463 case tok::kw_private:
3467 ParsedTemplateInfo TemplateInfo;
3468 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3471 case tok::kw_public:
3472 case tok::kw_protected: {
3474 Diag(Tok.getLocation(), diag::ext_hlsl_access_specifiers);
3479 SourceLocation ASLoc = Tok.getLocation();
3480 unsigned TokLength = Tok.getLength();
3482 AccessAttrs.
clear();
3483 MaybeParseGNUAttributes(AccessAttrs);
3485 SourceLocation EndLoc;
3488 Diag(EndLoc, diag::err_expected)
3492 Diag(EndLoc, diag::err_expected)
3502 if (Actions.ActOnAccessSpecifier(NewAS, ASLoc, EndLoc, AccessAttrs)) {
3504 AccessAttrs.
clear();
3510 case tok::annot_attr_openmp:
3511 case tok::annot_pragma_openmp:
3512 return ParseOpenMPDeclarativeDirectiveWithExtDecl(
3513 AS, AccessAttrs,
true, TagType, TagDecl);
3514 case tok::annot_pragma_openacc:
3519 Diag(Tok.getLocation(), diag::err_pragma_misplaced_in_decl)
3521 TagType, Actions.getASTContext().getPrintingPolicy());
3522 ConsumeAnnotationToken();
3525 ParsedTemplateInfo TemplateInfo;
3526 return ParseCXXClassMemberDeclaration(AS, AccessAttrs, TemplateInfo);
3537 "Invalid TagType!");
3539 llvm::TimeTraceScope TimeScope(
"ParseClass", [&]() {
3540 if (
auto *TD = dyn_cast_or_null<NamedDecl>(TagDecl))
3541 return TD->getQualifiedNameAsString();
3542 return std::string(
"<anonymous>");
3545 PrettyDeclStackTraceEntry CrashInfo(Actions.Context, TagDecl,
RecordLoc,
3546 "parsing struct/union/class body");
3550 bool NonNestedClass =
true;
3551 if (!ClassStack.empty()) {
3553 if (S->isClassScope()) {
3555 NonNestedClass =
false;
3558 if (getCurrentClass().IsInterface) {
3568 if (S->isFunctionScope())
3579 ParsingClassDefinition ParsingDef(*
this, TagDecl, NonNestedClass,
3583 Actions.ActOnTagStartDefinition(
getCurScope(), TagDecl);
3585 SourceLocation FinalLoc;
3586 SourceLocation AbstractLoc;
3587 bool IsFinalSpelledSealed =
false;
3588 bool IsAbstract =
false;
3589 SourceLocation TriviallyRelocatable;
3590 SourceLocation Replaceable;
3597 if (isCXX2CTriviallyRelocatableKeyword(Tok)) {
3598 if (TriviallyRelocatable.
isValid()) {
3601 Diag(Skipped, diag::err_duplicate_class_relocation_specifier)
3602 << 0 << TriviallyRelocatable;
3604 ParseCXX2CTriviallyRelocatableSpecifier(TriviallyRelocatable);
3608 if (isCXX2CReplaceableKeyword(Tok)) {
3612 Diag(Skipped, diag::err_duplicate_class_relocation_specifier)
3613 << 1 << Replaceable;
3615 ParseCXX2CReplaceableSpecifier(Replaceable);
3621 if (isCXX11FinalKeyword()) {
3624 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3629 IsFinalSpelledSealed =
true;
3634 Diag(Skipped, diag::err_duplicate_class_virt_specifier)
3642 Diag(FinalLoc, diag::err_override_control_interface)
3646 ? diag::warn_cxx98_compat_override_control_keyword
3647 : diag::ext_override_control_keyword)
3650 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3652 Diag(AbstractLoc, diag::ext_ms_abstract_keyword);
3654 Diag(FinalLoc, diag::ext_warn_gnu_final);
3658 "not a class definition");
3664 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3673 if (!Tok.is(tok::colon) && !Tok.is(tok::l_brace)) {
3675 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3680 if (Tok.is(tok::colon)) {
3684 ParseBaseClause(TagDecl);
3685 if (!Tok.is(tok::l_brace)) {
3686 bool SuggestFixIt =
false;
3687 SourceLocation BraceLoc = PP.getLocForEndOfToken(PrevTokLocation);
3688 if (Tok.isAtStartOfLine()) {
3689 switch (Tok.getKind()) {
3690 case tok::kw_private:
3691 case tok::kw_protected:
3692 case tok::kw_public:
3695 case tok::kw_static_assert:
3699 case tok::kw_template:
3700 SuggestFixIt =
true;
3702 case tok::identifier:
3703 SuggestFixIt = isConstructorDeclarator(
true);
3706 SuggestFixIt = isCXXSimpleDeclaration(
false);
3710 DiagnosticBuilder LBraceDiag =
3711 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3715 PP.EnterToken(Tok,
true);
3716 Tok.setKind(tok::l_brace);
3719 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3725 assert(Tok.is(tok::l_brace));
3730 Actions.ActOnStartCXXMemberDeclarations(
3731 getCurScope(), TagDecl, FinalLoc, IsFinalSpelledSealed, IsAbstract,
3732 TriviallyRelocatable, Replaceable,
T.getOpenLocation());
3743 ParsedAttributes AccessAttrs(AttrFactory);
3747 while (!tryParseMisplacedModuleImport() && Tok.isNot(tok::r_brace) &&
3748 Tok.isNot(tok::eof)) {
3750 ParseCXXClassMemberDeclarationWithPragmas(
3751 CurAS, AccessAttrs,
static_cast<DeclSpec::TST>(TagType), TagDecl);
3752 MaybeDestroyTemplateIds();
3760 ParsedAttributes attrs(AttrFactory);
3761 MaybeParseGNUAttributes(attrs);
3765 T.getOpenLocation(),
3766 T.getCloseLocation(), attrs);
3773 if (TagDecl && NonNestedClass) {
3779 SourceLocation SavedPrevTokLocation = PrevTokLocation;
3780 ParseLexedPragmas(getCurrentClass());
3781 ParseLexedAttributes(getCurrentClass());
3782 ParseLexedMethodDeclarations(getCurrentClass());
3785 Actions.ActOnFinishCXXMemberDecls();
3787 ParseLexedMemberInitializers(getCurrentClass());
3788 ParseLexedMethodDefs(getCurrentClass());
3789 PrevTokLocation = SavedPrevTokLocation;
3793 Actions.ActOnFinishCXXNonNestedClass();
3797 Actions.ActOnTagFinishDefinition(
getCurScope(), TagDecl,
T.getRange());
3804void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3805 assert(Tok.is(tok::kw_namespace));
3810 Diag(Tok.getLocation(), diag::note_missing_end_of_definition_before) << D;
3813 PP.EnterToken(Tok,
true);
3816 Tok.
setLocation(PP.getLocForEndOfToken(PrevTokLocation));
3817 Tok.setKind(tok::semi);
3818 PP.EnterToken(Tok,
true);
3820 Tok.setKind(tok::r_brace);
3823void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3824 assert(Tok.is(tok::colon) &&
3825 "Constructor initializer always starts with ':'");
3832 SmallVector<CXXCtorInitializer *, 4> MemInitializers;
3833 bool AnyErrors =
false;
3836 if (Tok.is(tok::code_completion)) {
3838 Actions.CodeCompletion().CodeCompleteConstructorInitializer(
3839 ConstructorDecl, MemInitializers);
3843 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3845 MemInitializers.push_back(MemInit.
get());
3849 if (Tok.is(tok::comma))
3851 else if (Tok.is(tok::l_brace))
3856 Tok.isOneOf(tok::identifier, tok::coloncolon)) {
3857 SourceLocation Loc = PP.getLocForEndOfToken(PrevTokLocation);
3858 Diag(Loc, diag::err_ctor_init_missing_comma)
3863 Diag(Tok.getLocation(), diag::err_expected_either)
3864 << tok::l_brace << tok::comma;
3870 Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc, MemInitializers,
3877 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
3883 IdentifierInfo *II =
nullptr;
3884 SourceLocation IdLoc = Tok.getLocation();
3886 DeclSpec DS(AttrFactory);
3890 if (Tok.is(tok::identifier)) {
3893 II = Tok.getIdentifierInfo();
3895 }
else if (Tok.is(tok::annot_decltype)) {
3900 ParseDecltypeSpecifier(DS);
3901 }
else if (Tok.is(tok::annot_pack_indexing_type)) {
3904 ParsePackIndexingType(DS);
3906 TemplateIdAnnotation *TemplateId = Tok.is(tok::annot_template_id)
3907 ? takeTemplateIdAnnotation(Tok)
3912 assert(Tok.is(tok::annot_typename) &&
"template-id -> type failed");
3914 ConsumeAnnotationToken();
3916 Diag(Tok, diag::err_expected_member_or_base_name);
3923 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3926 ExprResult InitList = ParseBraceInitializer();
3930 SourceLocation EllipsisLoc;
3935 return Actions.ActOnMemInitializer(ConstructorDecl,
getCurScope(), SS, II,
3936 TemplateTypeTy.
get(), DS, IdLoc,
3937 InitList.
get(), EllipsisLoc);
3938 }
else if (Tok.is(tok::l_paren)) {
3943 ExprVector ArgExprs;
3944 auto RunSignatureHelp = [&] {
3947 QualType PreferredType =
3948 Actions.CodeCompletion().ProduceCtorInitMemberSignatureHelp(
3949 ConstructorDecl, SS, TemplateTypeTy.
get(), ArgExprs, II,
3950 T.getOpenLocation(),
false);
3951 CalledSignatureHelp =
true;
3952 return PreferredType;
3954 if (Tok.isNot(tok::r_paren) && ParseExpressionList(ArgExprs, [&] {
3955 PreferredType.enterFunctionArgument(Tok.getLocation(),
3958 if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
3966 SourceLocation EllipsisLoc;
3971 return Actions.ActOnMemInitializer(
3972 ConstructorDecl,
getCurScope(), SS, II, TemplateTypeTy.
get(), DS, IdLoc,
3973 T.getOpenLocation(), ArgExprs,
T.getCloseLocation(), EllipsisLoc);
3980 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
3982 return Diag(Tok, diag::err_expected) << tok::l_paren;
3991 ExceptionSpecTokens =
nullptr;
3995 if (Tok.isNot(tok::kw_throw) && Tok.isNot(tok::kw_noexcept))
3999 bool IsNoexcept = Tok.is(tok::kw_noexcept);
4000 Token StartTok = Tok;
4004 if (!Tok.is(tok::l_paren)) {
4007 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4008 NoexceptExpr =
nullptr;
4012 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4018 ExceptionSpecTokens->push_back(StartTok);
4019 ExceptionSpecTokens->push_back(Tok);
4020 SpecificationRange.
setEnd(ConsumeParen());
4022 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
4025 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
4031 if (Tok.is(tok::kw_throw)) {
4032 Result = ParseDynamicExceptionSpecification(
4033 SpecificationRange, DynamicExceptions, DynamicExceptionRanges);
4034 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
4035 "Produced different number of exception types and ranges.");
4039 if (Tok.isNot(tok::kw_noexcept))
4042 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
4046 SourceRange NoexceptRange;
4050 if (Tok.is(tok::l_paren)) {
4055 EnterExpressionEvaluationContext ConstantEvaluated(
4062 Actions.ActOnNoexceptSpec(NoexceptExpr.
get(), NoexceptType);
4063 NoexceptRange = SourceRange(KeywordLoc,
T.getCloseLocation());
4070 NoexceptRange = SourceRange(KeywordLoc, KeywordLoc);
4074 SpecificationRange = NoexceptRange;
4079 if (Tok.is(tok::kw_throw)) {
4080 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4081 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
4082 DynamicExceptionRanges);
4085 Diag(Tok.getLocation(), diag::err_dynamic_and_noexcept_specification);
4094 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
4096 ? diag::ext_dynamic_exception_spec
4097 : diag::warn_exception_spec_deprecated)
4099 P.
Diag(Range.getBegin(), diag::note_exception_spec_deprecated)
4107 assert(Tok.is(tok::kw_throw) &&
"expected throw");
4111 if (
T.consumeOpen()) {
4112 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
4119 if (Tok.is(tok::ellipsis)) {
4122 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
4124 SpecificationRange.
setEnd(
T.getCloseLocation());
4131 while (Tok.isNot(tok::r_paren)) {
4134 if (Tok.is(tok::ellipsis)) {
4139 Range.setEnd(Ellipsis);
4140 if (!Res.isInvalid())
4141 Res = Actions.ActOnPackExpansion(Res.get(), Ellipsis);
4144 if (!Res.isInvalid()) {
4145 Exceptions.push_back(Res.get());
4146 Ranges.push_back(Range);
4154 SpecificationRange.
setEnd(
T.getCloseLocation());
4156 Exceptions.empty());
4161 bool MayBeFollowedByDirectInit) {
4162 assert(Tok.is(tok::arrow) &&
"expected arrow");
4171void Parser::ParseTrailingRequiresClause(
Declarator &D) {
4172 assert(Tok.is(tok::kw_requires) &&
"expected requires");
4190 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4192 DeclScopeObj.EnterDeclaratorScope();
4199 Actions.ActOnStartTrailingRequiresClause(
getCurScope(), D);
4201 std::optional<Sema::CXXThisScopeRAII> ThisScope;
4202 InitCXXThisScopeForDeclaratorIfRelevant(D, D.
getDeclSpec(), ThisScope);
4204 TrailingRequiresClause =
4207 TrailingRequiresClause =
4208 Actions.ActOnFinishTrailingRequiresClause(TrailingRequiresClause);
4212 diag::err_requires_clause_on_declarator_not_declaring_a_function);
4217 SkipUntil({tok::l_brace, tok::arrow, tok::kw_try, tok::comma, tok::colon},
4225 SourceLocation ArrowLoc = Tok.getLocation();
4228 ParseTrailingReturnType(Range,
false);
4232 diag::err_requires_clause_must_appear_after_trailing_return)
4236 FunctionChunk.TrailingReturnType = TrailingReturnType.
get();
4237 FunctionChunk.TrailingReturnTypeLoc =
Range.getBegin();
4239 SkipUntil({tok::equal, tok::l_brace, tok::arrow, tok::kw_try, tok::comma},
4245 bool NonNestedClass,
4247 assert((NonNestedClass || !ClassStack.empty()) &&
4248 "Nested class without outer class");
4249 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
4250 return Actions.PushParsingClass();
4253void Parser::DeallocateParsedClasses(Parser::ParsingClass *
Class) {
4254 for (
unsigned I = 0, N =
Class->LateParsedDeclarations.size(); I != N; ++I)
4255 delete Class->LateParsedDeclarations[I];
4260 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
4262 Actions.PopParsingClass(state);
4264 ParsingClass *Victim = ClassStack.top();
4266 if (Victim->TopLevelClass) {
4269 DeallocateParsedClasses(Victim);
4272 assert(!ClassStack.empty() &&
"Missing top-level class?");
4274 if (Victim->LateParsedDeclarations.empty()) {
4279 DeallocateParsedClasses(Victim);
4287 "Nested class outside of class scope?");
4288 ClassStack.top()->LateParsedDeclarations.push_back(
4289 new LateParsedClass(
this, Victim));
4295 switch (Tok.getKind()) {
4298 if (!Tok.isAnnotation()) {
4299 if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
4306 case tok::code_completion:
4308 Actions.CodeCompletion().CodeCompleteAttribute(
4313 case tok::numeric_constant: {
4317 if (Tok.getLocation().isMacroID()) {
4318 SmallString<8> ExpansionBuf;
4319 SourceLocation ExpansionLoc =
4320 PP.getSourceManager().getExpansionLoc(Tok.getLocation());
4321 StringRef Spelling = PP.getSpelling(ExpansionLoc, ExpansionBuf);
4322 if (Spelling ==
"__clang__") {
4323 SourceRange TokRange(
4325 PP.getSourceManager().getExpansionLoc(Tok.getEndLoc()));
4326 Diag(Tok, diag::warn_wrong_clang_attr_namespace)
4329 return &PP.getIdentifierTable().get(
"_Clang");
4342 case tok::pipeequal:
4343 case tok::caretequal:
4345 case tok::exclaimequal:
4348 SmallString<8> SpellingBuf;
4349 SourceLocation SpellingLoc =
4350 PP.getSourceManager().getSpellingLoc(Tok.getLocation());
4351 StringRef Spelling = PP.getSpelling(SpellingLoc, SpellingBuf);
4354 return &PP.getIdentifierTable().get(Spelling);
4360void Parser::ParseOpenMPAttributeArgs(
const IdentifierInfo *AttrName,
4365 if (
T.consumeOpen()) {
4366 Diag(Tok, diag::err_expected) << tok::l_paren;
4370 if (
AttrName->isStr(
"directive")) {
4376 OMPBeginTok.
setKind(tok::annot_attr_openmp);
4378 OpenMPTokens.push_back(OMPBeginTok);
4380 ConsumeAndStoreUntil(tok::r_paren, OpenMPTokens,
false,
4384 OMPEndTok.
setKind(tok::annot_pragma_openmp_end);
4386 OpenMPTokens.push_back(OMPEndTok);
4388 assert(
AttrName->isStr(
"sequence") &&
4389 "Expected either 'directive' or 'sequence'");
4397 SourceLocation IdentLoc;
4398 const IdentifierInfo *Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4402 if (Ident && Ident->
isStr(
"omp") && !ExpectAndConsume(tok::coloncolon))
4403 Ident = TryParseCXX11AttributeIdentifier(IdentLoc);
4407 if (!Ident || (!Ident->
isStr(
"directive") && !Ident->
isStr(
"sequence"))) {
4408 Diag(Tok.getLocation(), diag::err_expected_sequence_or_directive);
4414 ParseOpenMPAttributeArgs(Ident, OpenMPTokens);
4428 case ParsedAttr::AT_CarriesDependency:
4429 case ParsedAttr::AT_Deprecated:
4430 case ParsedAttr::AT_FallThrough:
4431 case ParsedAttr::AT_CXX11NoReturn:
4432 case ParsedAttr::AT_NoUniqueAddress:
4433 case ParsedAttr::AT_Likely:
4434 case ParsedAttr::AT_Unlikely:
4436 case ParsedAttr::AT_WarnUnusedResult:
4437 return !ScopeName && AttrName->getName() ==
"nodiscard";
4438 case ParsedAttr::AT_Unused:
4439 return !ScopeName && AttrName->getName() ==
"maybe_unused";
4445bool Parser::ParseCXXAssumeAttributeArg(
4449 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4457 TentativeParsingAction TPA(*
this);
4462 if (Tok.is(tok::r_paren))
4467 if (!Tok.isOneOf(tok::r_paren, tok::r_square)) {
4473 auto *E = Res.
get();
4474 Diag(E->getExprLoc(), diag::err_assume_attr_expects_cond_expr)
4478 << E->getSourceRange();
4487 auto RParen = Tok.getLocation();
4489 Attrs.
addNew(AttrName, SourceRange(AttrNameLoc, RParen),
4490 AttributeScopeInfo(ScopeName, ScopeLoc), &Assumption, 1, Form);
4498bool Parser::ParseCXX11AttributeArgs(
4502 assert(Tok.is(tok::l_paren) &&
"Not a C++11 attribute argument list");
4503 SourceLocation LParenLoc = Tok.getLocation();
4505 ParsedAttr::Form Form =
4506 LO.CPlusPlus ? ParsedAttr::Form::CXX11() : ParsedAttr::Form::
C23();
4512 Form = ParsedAttr::Form::Microsoft();
4516 TentativeParsingAction TPA(*this);
4517 bool HasInvalidArgument = false;
4518 while (Tok.isNot(tok::r_paren) && Tok.isNot(tok::eof)) {
4519 if (Tok.isOneOf(tok::hash, tok::hashhash)) {
4520 Diag(Tok.getLocation(), diag::ext_invalid_attribute_argument)
4521 << PP.getSpelling(Tok);
4522 HasInvalidArgument = true;
4527 if (HasInvalidArgument) {
4541 ScopeName, AttrName, getTargetInfo(), getLangOpts())) {
4544 SkipUntil(tok::r_paren);
4548 if (ScopeName && (ScopeName->
isStr(
"gnu") || ScopeName->
isStr(
"__gnu__"))) {
4551 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
4552 ScopeLoc, Form, nullptr);
4557 if (ScopeName && ScopeName->
isStr(
"omp") &&
4559 Diag(AttrNameLoc, getLangOpts().OpenMP >= 51
4560 ? diag::warn_omp51_compat_attributes
4561 : diag::ext_omp_attributes);
4563 ParseOpenMPAttributeArgs(AttrName, OpenMPTokens);
4572 if (ScopeName && (ScopeName->
isStr(
"clang") || ScopeName->
isStr(
"_Clang")))
4573 NumArgs = ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc,
4574 ScopeName, ScopeLoc, Form);
4576 else if (!ScopeName &&
AttrName->isStr(
"assume")) {
4577 if (ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, nullptr,
4578 SourceLocation{}, EndLoc, Form))
4582 NumArgs = ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
4583 ScopeName, ScopeLoc, Form);
4585 if (!Attrs.
empty() &&
4590 if (!
Attr.existsInTarget(getTargetInfo())) {
4591 Actions.DiagnoseUnknownAttribute(
Attr);
4592 Attr.setInvalid(
true);
4600 if (
Attr.getMaxArgs() && !NumArgs) {
4603 Diag(LParenLoc, diag::err_attribute_requires_arguments) <<
AttrName;
4604 Attr.setInvalid(
true);
4605 }
else if (!
Attr.getMaxArgs()) {
4609 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
4612 Attr.setInvalid(
true);
4621 if (Tok.is(tok::kw_alignas)) {
4627 Diag(Tok.getLocation(), diag::warn_cxx98_compat_alignas);
4628 ParseAlignmentSpecifier(Attrs, EndLoc);
4632 if (Tok.isRegularKeywordAttribute()) {
4633 SourceLocation Loc = Tok.getLocation();
4634 IdentifierInfo *
AttrName = Tok.getIdentifierInfo();
4635 ParsedAttr::Form Form = ParsedAttr::Form(Tok.getKind());
4639 if (!Tok.is(tok::l_paren))
4640 Diag(Tok.getLocation(), diag::err_expected_lparen_after) <<
AttrName;
4642 ParseAttributeArgsCommon(AttrName, Loc, Attrs, EndLoc,
4646 Attrs.
addNew(AttrName, Loc, AttributeScopeInfo(),
nullptr, 0, Form);
4650 assert(Tok.is(tok::l_square) &&
NextToken().
is(tok::l_square) &&
4651 "Not a double square bracket attribute list");
4653 SourceLocation OpenLoc = Tok.getLocation();
4656 : diag::warn_ext_cxx11_attributes);
4659 : diag::warn_ext_c23_attributes);
4663 checkCompoundToken(OpenLoc, tok::l_square, CompoundToken::AttrBegin);
4666 SourceLocation CommonScopeLoc;
4667 IdentifierInfo *CommonScopeName =
nullptr;
4668 if (Tok.is(tok::kw_using)) {
4670 ? diag::warn_cxx14_compat_using_attribute_ns
4671 : diag::ext_using_attribute_ns);
4674 CommonScopeName = TryParseCXX11AttributeIdentifier(
4676 if (!CommonScopeName) {
4677 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4681 Diag(Tok.getLocation(), diag::err_expected) << tok::colon;
4684 bool AttrParsed =
false;
4685 while (!Tok.isOneOf(tok::r_square, tok::semi, tok::eof)) {
4689 if (ExpectAndConsume(tok::comma)) {
4700 SourceLocation ScopeLoc, AttrLoc;
4701 IdentifierInfo *ScopeName =
nullptr, *
AttrName =
nullptr;
4703 AttrName = TryParseCXX11AttributeIdentifier(
4715 AttrName = TryParseCXX11AttributeIdentifier(
4719 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4725 if (CommonScopeName) {
4727 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4728 << SourceRange(CommonScopeLoc);
4730 ScopeName = CommonScopeName;
4731 ScopeLoc = CommonScopeLoc;
4736 if (Tok.is(tok::l_paren))
4737 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, Attrs, EndLoc,
4738 ScopeName, ScopeLoc, OpenMPTokens);
4746 AttributeScopeInfo(ScopeName, ScopeLoc, CommonScopeLoc),
4749 : ParsedAttr::Form::C23());
4754 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis) <<
AttrName;
4759 if (Tok.is(tok::semi)) {
4764 SourceLocation CloseLoc = Tok.getLocation();
4765 if (ExpectAndConsume(tok::r_square))
4767 else if (Tok.is(tok::r_square))
4768 checkCompoundToken(CloseLoc, tok::r_square, CompoundToken::AttrEnd);
4770 *EndLoc = Tok.getLocation();
4771 if (ExpectAndConsume(tok::r_square))
4776 SourceLocation StartLoc = Tok.getLocation();
4777 SourceLocation EndLoc = StartLoc;
4780 ParseCXX11AttributeSpecifier(Attrs, &EndLoc);
4781 }
while (isAllowedCXX11AttributeSpecifier());
4783 Attrs.
Range = SourceRange(StartLoc, EndLoc);
4786void Parser::DiagnoseAndSkipCXX11Attributes() {
4788 Tok.isRegularKeywordAttribute() ? Tok.getIdentifierInfo() :
nullptr;
4790 SourceLocation StartLoc = Tok.getLocation();
4791 SourceLocation EndLoc = SkipCXX11Attributes();
4794 SourceRange
Range(StartLoc, EndLoc);
4796 :
Diag(StartLoc, diag::err_attributes_not_allowed))
4802 SourceLocation EndLoc;
4808 if (Tok.is(tok::l_square)) {
4812 EndLoc =
T.getCloseLocation();
4813 }
else if (Tok.isRegularKeywordAttribute() &&
4815 EndLoc = Tok.getLocation();
4818 assert((Tok.is(tok::kw_alignas) || Tok.isRegularKeywordAttribute()) &&
4819 "not an attribute specifier");
4822 if (!
T.consumeOpen())
4824 EndLoc =
T.getCloseLocation();
4826 }
while (isCXX11AttributeSpecifier() !=
4833 assert(Tok.is(tok::identifier) &&
"Not a Microsoft attribute list");
4834 IdentifierInfo *UuidIdent = Tok.getIdentifierInfo();
4835 assert(UuidIdent->
getName() ==
"uuid" &&
"Not a Microsoft attribute list");
4837 SourceLocation UuidLoc = Tok.getLocation();
4842 if (
T.consumeOpen()) {
4843 Diag(Tok, diag::err_expected) << tok::l_paren;
4848 if (isTokenStringLiteral()) {
4853 ArgExprs.push_back(StringResult.
get());
4859 SmallString<42> StrBuffer;
4869 SourceLocation StartLoc = Tok.getLocation();
4870 while (Tok.isNot(tok::r_paren)) {
4871 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4872 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4876 SmallString<16> SpellingBuffer;
4877 SpellingBuffer.resize(Tok.getLength() + 1);
4878 bool Invalid =
false;
4879 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
4884 StrBuffer += TokSpelling;
4889 if (Tok.hasLeadingSpace() || Tok.isAtStartOfLine()) {
4890 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4900 Toks[0].
setKind(tok::string_literal);
4904 StringLiteral *UuidString =
4906 ArgExprs.push_back(UuidString);
4909 if (!
T.consumeClose()) {
4910 Attrs.
addNew(UuidIdent, SourceRange(UuidLoc,
T.getCloseLocation()),
4911 AttributeScopeInfo(), ArgExprs.data(), ArgExprs.size(),
4912 ParsedAttr::Form::Microsoft());
4917 assert(Tok.is(tok::identifier) &&
4918 "Expected an identifier to denote which MS attribute to consider");
4919 IdentifierInfo *RootSignatureIdent = Tok.getIdentifierInfo();
4920 assert(RootSignatureIdent->
getName() ==
"RootSignature" &&
4921 "Expected RootSignature identifier for root signature attribute");
4923 SourceLocation RootSignatureLoc = Tok.getLocation();
4928 if (
T.consumeOpen()) {
4929 Diag(Tok, diag::err_expected) << tok::l_paren;
4933 auto ProcessStringLiteral = [
this]() -> std::optional<StringLiteral *> {
4934 if (!isTokenStringLiteral())
4935 return std::nullopt;
4939 return std::nullopt;
4941 if (
auto Lit = dyn_cast<StringLiteral>(StringResult.
get()))
4944 return std::nullopt;
4947 auto Signature = ProcessStringLiteral();
4948 if (!Signature.has_value()) {
4949 Diag(Tok, diag::err_expected_string_literal)
4950 << 4 <<
"RootSignature";
4956 Actions,
getLangOpts().HLSLRootSigVer, *Signature);
4964 IdentifierLoc *ILoc = ::new (Actions.getASTContext())
4965 IdentifierLoc(RootSignatureLoc, DeclIdent);
4969 if (!
T.consumeClose())
4970 Attrs.
addNew(RootSignatureIdent,
4971 SourceRange(RootSignatureLoc,
T.getCloseLocation()),
4972 AttributeScopeInfo(), Args.data(), Args.size(),
4973 ParsedAttr::Form::Microsoft());
4977 assert(Tok.is(tok::l_square) &&
"Not a Microsoft attribute list");
4979 SourceLocation StartLoc = Tok.getLocation();
4980 SourceLocation EndLoc = StartLoc;
4988 SkipUntil(tok::r_square, tok::identifier,
4990 if (Tok.is(tok::code_completion)) {
4992 Actions.CodeCompletion().CodeCompleteAttribute(
4998 if (Tok.isNot(tok::identifier))
5000 if (Tok.getIdentifierInfo()->getName() ==
"uuid")
5001 ParseMicrosoftUuidAttributeArgs(Attrs);
5002 else if (Tok.getIdentifierInfo()->getName() ==
"RootSignature")
5003 ParseHLSLRootSignatureAttributeArgs(Attrs);
5005 IdentifierInfo *II = Tok.getIdentifierInfo();
5006 SourceLocation NameLoc = Tok.getLocation();
5013 bool AttrParsed =
false;
5014 if (Tok.is(tok::l_paren)) {
5017 ParseCXX11AttributeArgs(II, NameLoc, Attrs, &EndLoc,
nullptr,
5018 SourceLocation(), OpenMPTokens);
5019 ReplayOpenMPAttributeTokens(OpenMPTokens);
5022 Attrs.
addNew(II, NameLoc, AttributeScopeInfo(),
nullptr, 0,
5023 ParsedAttr::Form::Microsoft());
5030 EndLoc =
T.getCloseLocation();
5031 }
while (Tok.is(tok::l_square));
5033 Attrs.
Range = SourceRange(StartLoc, EndLoc);
5036void Parser::ParseMicrosoftIfExistsClassDeclaration(
5039 IfExistsCondition
Result;
5040 if (ParseMicrosoftIfExistsCondition(
Result))
5044 if (
Braces.consumeOpen()) {
5045 Diag(Tok, diag::err_expected) << tok::l_brace;
5049 switch (
Result.Behavior) {
5055 Diag(
Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
5065 while (Tok.isNot(tok::r_brace) && !isEofOrEom()) {
5067 if (Tok.isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
5068 ParseMicrosoftIfExistsClassDeclaration(TagType, AccessAttrs, CurAS);
5073 if (Tok.is(tok::semi)) {
5082 SourceLocation ASLoc = Tok.getLocation();
5084 if (Tok.is(tok::colon))
5085 Actions.ActOnAccessSpecifier(AS, ASLoc, Tok.getLocation(),
5086 ParsedAttributesView{});
5088 Diag(Tok, diag::err_expected) << tok::colon;
5093 ParsedTemplateInfo TemplateInfo;
5095 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
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
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
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
void takeAttributesFrom(ParsedAttributes &attrs)
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.
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...
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(DeclGroupRef P)
ParsedAttr - Represents a syntactic attribute.
static const ParsedAttributesView & none()
void addAll(iterator B, iterator E)
ParsedAttributes - A collection of parsed attributes.
void takeAllFrom(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)
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.
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++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.
The JSON file list parser is used to communicate input to InstallAPI.
bool doesKeywordAttributeTakeArgs(tok::TokenKind Kind)
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_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.