28 #include "llvm/ADT/SmallString.h" 30 using namespace clang;
61 assert(Tok.
is(tok::kw_namespace) &&
"Not a namespace!");
65 if (Tok.
is(tok::code_completion)) {
73 std::vector<SourceLocation> ExtraIdentLoc;
74 std::vector<IdentifierInfo*> ExtraIdent;
75 std::vector<SourceLocation> ExtraNamespaceLoc;
77 ParsedAttributesWithRange attrs(AttrFactory);
81 ? diag::warn_cxx14_compat_ns_enum_attribute
82 : diag::ext_ns_enum_attribute)
85 ParseCXX11Attributes(attrs);
88 if (Tok.
is(tok::identifier)) {
91 while (Tok.
is(tok::coloncolon) &&
NextToken().
is(tok::identifier)) {
99 if (!ExtraNamespaceLoc.empty() && attrLoc.isValid())
100 Diag(attrLoc, diag::err_unexpected_nested_namespace_attribute);
103 if (Tok.
is(tok::kw___attribute)) {
105 ParseGNUAttributes(attrs);
108 if (Tok.
is(tok::equal)) {
110 Diag(Tok, diag::err_expected) << tok::identifier;
115 if (attrLoc.isValid())
116 Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
118 Diag(InlineLoc, diag::err_inline_namespace_alias)
120 Decl *NSAlias = ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd);
125 if (
T.consumeOpen()) {
127 Diag(Tok, diag::err_expected) << tok::l_brace;
129 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
136 Diag(
T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
141 if (ExtraIdent.empty()) {
143 }
else if (InlineLoc.
isValid()) {
144 Diag(InlineLoc, diag::err_inline_nested_namespace_definition);
146 Diag(ExtraNamespaceLoc[0],
147 diag::warn_cxx14_compat_nested_namespace_definition);
149 TentativeParsingAction TPA(*
this);
151 Token rBraceToken = Tok;
154 if (!rBraceToken.
is(tok::r_brace)) {
155 Diag(ExtraNamespaceLoc[0], diag::ext_nested_namespace_definition)
156 <<
SourceRange(ExtraNamespaceLoc.front(), ExtraIdentLoc.back());
158 std::string NamespaceFix;
159 for (std::vector<IdentifierInfo*>::iterator I = ExtraIdent.begin(),
160 E = ExtraIdent.end(); I != E; ++I) {
161 NamespaceFix +=
" { namespace ";
162 NamespaceFix += (*I)->getName();
166 for (
unsigned i = 0, e = ExtraIdent.size(); i != e; ++i)
169 Diag(ExtraNamespaceLoc[0], diag::ext_nested_namespace_definition)
171 ExtraIdentLoc.back()),
180 diag::warn_cxx98_compat_inline_namespace : diag::ext_inline_namespace);
188 IdentLoc, Ident,
T.getOpenLocation(),
189 attrs.getList(), ImplicitUsingDirectiveDecl);
192 "parsing namespace");
196 ParseInnerNamespace(ExtraIdentLoc, ExtraIdent, ExtraNamespaceLoc, 0,
197 InlineLoc, attrs,
T);
200 NamespaceScope.Exit();
202 DeclEnd =
T.getCloseLocation();
206 ImplicitUsingDirectiveDecl);
210 void Parser::ParseInnerNamespace(std::vector<SourceLocation> &IdentLoc,
211 std::vector<IdentifierInfo *> &Ident,
212 std::vector<SourceLocation> &NamespaceLoc,
216 if (index == Ident.size()) {
217 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
219 ParsedAttributesWithRange attrs(AttrFactory);
220 MaybeParseCXX11Attributes(attrs);
221 ParseExternalDeclaration(attrs);
238 NamespaceLoc[index], IdentLoc[index],
240 attrs.
getList(), ImplicitUsingDirectiveDecl);
241 assert(!ImplicitUsingDirectiveDecl &&
242 "nested namespace definition cannot define anonymous namespace");
244 ParseInnerNamespace(IdentLoc, Ident, NamespaceLoc, ++index, InlineLoc,
247 NamespaceScope.Exit();
258 assert(Tok.
is(tok::equal) &&
"Not equal token");
262 if (Tok.
is(tok::code_completion)) {
270 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false,
276 if (Tok.
isNot(tok::identifier)) {
277 Diag(Tok, diag::err_expected_namespace_name);
296 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name))
300 Alias, SS, IdentLoc, Ident);
311 assert(isTokenStringLiteral() &&
"Not a string literal!");
312 ExprResult Lang = ParseStringLiteralExpression(
false);
322 ParsedAttributesWithRange attrs(AttrFactory);
323 MaybeParseCXX11Attributes(attrs);
325 if (Tok.
isNot(tok::l_brace)) {
332 ParseExternalDeclaration(attrs, &DS);
340 ProhibitAttributes(attrs);
345 unsigned NestedModules = 0;
348 case tok::annot_module_begin:
353 case tok::annot_module_end:
360 case tok::annot_module_include:
372 ParsedAttributesWithRange attrs(AttrFactory);
373 MaybeParseCXX11Attributes(attrs);
374 ParseExternalDeclaration(attrs);
393 Decl *Parser::ParseExportDeclaration() {
394 assert(Tok.
is(tok::kw_export));
402 if (Tok.
isNot(tok::l_brace)) {
404 ParsedAttributesWithRange Attrs(AttrFactory);
405 MaybeParseCXX11Attributes(Attrs);
406 MaybeParseMicrosoftAttributes(Attrs);
407 ParseExternalDeclaration(Attrs);
417 if (Tok.
is(tok::r_brace))
418 Diag(ExportLoc, diag::err_export_empty)
421 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
423 ParsedAttributesWithRange Attrs(AttrFactory);
424 MaybeParseCXX11Attributes(Attrs);
425 MaybeParseMicrosoftAttributes(Attrs);
426 ParseExternalDeclaration(Attrs);
431 T.getCloseLocation());
438 const ParsedTemplateInfo &TemplateInfo,
440 ParsedAttributesWithRange &attrs) {
441 assert(Tok.
is(tok::kw_using) &&
"Not using token");
447 if (Tok.
is(tok::code_completion)) {
454 if (Tok.
is(tok::kw_namespace)) {
456 if (TemplateInfo.Kind) {
458 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
462 Decl *UsingDir = ParseUsingDirective(Context, UsingLoc, DeclEnd, attrs);
469 ProhibitAttributes(attrs);
471 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd,
489 assert(Tok.
is(tok::kw_namespace) &&
"Not 'namespace' token");
494 if (Tok.
is(tok::code_completion)) {
502 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false,
512 if (Tok.
isNot(tok::identifier)) {
513 Diag(Tok, diag::err_expected_namespace_name);
532 bool GNUAttr =
false;
533 if (Tok.
is(tok::kw___attribute)) {
535 ParseGNUAttributes(attrs);
540 if (ExpectAndConsume(tok::semi,
541 GNUAttr ? diag::err_expected_semi_after_attribute_list
542 : diag::err_expected_semi_after_namespace_name))
546 IdentLoc, NamespcName, attrs.
getList());
555 UsingDeclarator &D) {
562 if (Tok.
is(tok::kw___super)) {
569 ParseOptionalCXXScopeSpecifier(D.SS,
nullptr,
false,
573 if (D.SS.isInvalid())
588 Tok.
is(tok::identifier) &&
592 !D.SS.getScopeRep()->getAsNamespace() &&
593 !D.SS.getScopeRep()->getAsNamespaceAlias()) {
597 D.Name.setConstructorName(Type, IdLoc, IdLoc);
602 !(Tok.
is(tok::identifier) &&
605 nullptr, D.TemplateKWLoc, D.Name))
611 diag::warn_cxx17_compat_using_declaration_pack :
612 diag::ext_using_declaration_pack);
635 const ParsedTemplateInfo &TemplateInfo,
640 ParsedAttributesWithRange MisplacedAttrs(AttrFactory);
641 MaybeParseCXX11Attributes(MisplacedAttrs);
644 bool InvalidDeclarator = ParseUsingDeclarator(Context, D);
646 ParsedAttributesWithRange Attrs(AttrFactory);
647 MaybeParseGNUAttributes(Attrs);
648 MaybeParseCXX11Attributes(Attrs);
651 if (Tok.
is(tok::equal)) {
652 if (InvalidDeclarator) {
659 if (MisplacedAttrs.Range.isValid()) {
660 Diag(MisplacedAttrs.Range.getBegin(), diag::err_attributes_not_allowed)
665 Attrs.takeAllFrom(MisplacedAttrs);
668 Decl *DeclFromDeclSpec =
nullptr;
669 Decl *AD = ParseAliasDeclarationAfterDeclarator(
670 TemplateInfo, UsingLoc, D, DeclEnd, AS, Attrs, &DeclFromDeclSpec);
676 ProhibitAttributes(MisplacedAttrs);
677 ProhibitAttributes(Attrs);
682 if (TemplateInfo.Kind) {
684 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
696 MaybeParseGNUAttributes(Attrs);
698 if (InvalidDeclarator)
703 if (D.TypenameLoc.isValid() &&
705 Diag(D.Name.getSourceRange().getBegin(),
706 diag::err_typename_identifiers_only)
713 D.TypenameLoc, D.SS, D.Name,
714 D.EllipsisLoc, Attrs.getList());
716 DeclsInGroup.push_back(UD);
724 InvalidDeclarator = ParseUsingDeclarator(Context, D);
727 if (DeclsInGroup.size() > 1)
729 diag::warn_cxx17_compat_multi_using_declaration :
730 diag::ext_multi_using_declaration);
734 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
735 !Attrs.empty() ?
"attributes list" 736 :
"using declaration"))
742 Decl *Parser::ParseAliasDeclarationAfterDeclarator(
746 if (ExpectAndConsume(tok::equal)) {
752 diag::warn_cxx98_compat_alias_declaration :
753 diag::ext_alias_declaration);
757 if (TemplateInfo.Kind == ParsedTemplateInfo::Template &&
760 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization)
762 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
764 if (SpecKind != -1) {
768 D.Name.TemplateId->RAngleLoc);
770 Range = TemplateInfo.getSourceRange();
771 Diag(Range.
getBegin(), diag::err_alias_declaration_specialization)
772 << SpecKind << Range;
779 Diag(D.Name.StartLocation, diag::err_alias_declaration_not_identifier);
783 }
else if (D.TypenameLoc.isValid())
784 Diag(D.TypenameLoc, diag::err_alias_declaration_not_identifier)
787 D.SS.isNotEmpty() ? D.SS.getEndLoc() : D.TypenameLoc));
788 else if (D.SS.isNotEmpty())
789 Diag(D.SS.getBeginLoc(), diag::err_alias_declaration_not_identifier)
791 if (D.EllipsisLoc.isValid())
792 Diag(D.EllipsisLoc, diag::err_alias_declaration_pack_expansion)
795 Decl *DeclFromDeclSpec =
nullptr;
800 AS, &DeclFromDeclSpec, &Attrs);
802 *OwnedType = DeclFromDeclSpec;
806 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
807 !Attrs.
empty() ?
"attributes list" 808 :
"alias declaration"))
813 TemplateParams ? TemplateParams->data() :
nullptr,
814 TemplateParams ? TemplateParams->size() : 0);
816 UsingLoc, D.Name, Attrs.
getList(),
817 TypeAlias, DeclFromDeclSpec);
829 assert(Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
830 "Not a static_assert declaration");
833 Diag(Tok, diag::ext_c11_static_assert);
834 if (Tok.
is(tok::kw_static_assert))
835 Diag(Tok, diag::warn_cxx98_compat_static_assert);
840 if (
T.consumeOpen()) {
841 Diag(Tok, diag::err_expected) << tok::l_paren;
849 if (AssertExpr.isInvalid()) {
855 if (Tok.
is(tok::r_paren)) {
857 ? diag::warn_cxx14_compat_static_assert_no_message
858 : diag::ext_static_assert_no_message)
861 :
FixItHint::CreateInsertion(Tok.getLocation(),
", \"\""));
863 if (ExpectAndConsume(tok::comma)) {
868 if (!isTokenStringLiteral()) {
869 Diag(Tok, diag::err_expected_string_literal)
875 AssertMessage = ParseStringLiteralExpression();
885 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert);
890 T.getCloseLocation());
899 assert(Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)
900 &&
"Not a decltype specifier");
906 if (Tok.
is(tok::annot_decltype)) {
907 Result = getExprAnnotation(Tok);
909 ConsumeAnnotationToken();
910 if (Result.isInvalid()) {
916 Diag(Tok, diag::warn_cxx98_compat_decltype);
921 if (
T.expectAndConsume(diag::err_expected_lparen_after,
922 "decltype", tok::r_paren)) {
925 StartLoc :
T.getOpenLocation();
929 if (Tok.
is(tok::kw_auto)) {
935 ? diag::warn_cxx11_compat_decltype_auto_type_specifier
936 : diag::ext_decltype_auto_type_specifier);
950 if (Result.isInvalid()) {
953 EndLoc = ConsumeParen();
960 assert(Tok.
is(tok::semi));
973 if (
T.getCloseLocation().isInvalid()) {
977 return T.getCloseLocation();
980 if (Result.isInvalid()) {
982 return T.getCloseLocation();
985 EndLoc =
T.getCloseLocation();
987 assert(!Result.isInvalid());
989 const char *PrevSpec =
nullptr;
995 DiagID, Result.get(), Policy)
998 Diag(StartLoc, DiagID) << PrevSpec;
1004 void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec& DS,
1013 Tok.
setKind(tok::annot_decltype);
1014 setExprAnnotation(Tok,
1023 void Parser::ParseUnderlyingTypeSpecifier(
DeclSpec &DS) {
1024 assert(Tok.
is(tok::kw___underlying_type) &&
1025 "Not an underlying type specifier");
1029 if (
T.expectAndConsume(diag::err_expected_lparen_after,
1030 "__underlying_type", tok::r_paren)) {
1042 if (
T.getCloseLocation().isInvalid())
1045 const char *PrevSpec =
nullptr;
1048 DiagID, Result.
get(),
1050 Diag(StartLoc, DiagID) << PrevSpec;
1075 if (Tok.
is(tok::kw_typename)) {
1076 Diag(Tok, diag::err_expected_class_name_not_template)
1083 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false);
1090 if (Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
1097 EndLocation = ParseDecltypeSpecifier(DS);
1104 if (Tok.
is(tok::annot_template_id)) {
1108 AnnotateTemplateIdTokenAsType(
true);
1110 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
1113 ConsumeAnnotationToken();
1123 if (Tok.
isNot(tok::identifier)) {
1124 Diag(Tok, diag::err_expected_class_name);
1131 if (Tok.
is(tok::less)) {
1137 &SS, Template, TNK)) {
1138 Diag(IdLoc, diag::err_unknown_template_name)
1143 TemplateArgList TemplateArgs;
1145 ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1159 AnnotateTemplateIdTokenAsType(
true);
1163 if (Tok.
isNot(tok::annot_typename))
1170 ConsumeAnnotationToken();
1177 *Id, IdLoc,
getCurScope(), &SS,
true,
false,
nullptr,
1180 false, &CorrectedII);
1182 Diag(IdLoc, diag::err_expected_class_name);
1187 EndLocation = IdLoc;
1195 const char *PrevSpec =
nullptr;
1204 void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1205 while (Tok.
isOneOf(tok::kw___single_inheritance,
1206 tok::kw___multiple_inheritance,
1207 tok::kw___virtual_inheritance)) {
1210 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1218 bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1226 case tok::identifier:
1228 case tok::annot_cxxscope:
1229 case tok::annot_typename:
1230 case tok::annot_template_id:
1233 case tok::kw_operator:
1234 case tok::kw___declspec:
1239 case tok::kw___attribute:
1240 case tok::annot_pragma_pack:
1242 case tok::annot_pragma_ms_pragma:
1244 case tok::annot_pragma_ms_vtordisp:
1246 case tok::annot_pragma_ms_pointers_to_members:
1249 return CouldBeBitfield;
1251 case tok::kw___cdecl:
1252 case tok::kw___fastcall:
1253 case tok::kw___stdcall:
1254 case tok::kw___thiscall:
1255 case tok::kw___vectorcall:
1261 case tok::kw_volatile:
1262 case tok::kw_restrict:
1263 case tok::kw__Atomic:
1264 case tok::kw___unaligned:
1268 case tok::kw_inline:
1269 case tok::kw_virtual:
1270 case tok::kw_friend:
1272 case tok::kw_static:
1273 case tok::kw_extern:
1274 case tok::kw_typedef:
1275 case tok::kw_register:
1277 case tok::kw_mutable:
1278 case tok::kw_thread_local:
1279 case tok::kw_constexpr:
1295 if (!isKnownToBeTypeSpecifier(
NextToken()))
1352 const ParsedTemplateInfo &TemplateInfo,
1354 bool EnteringContext, DeclSpecContext DSC,
1355 ParsedAttributesWithRange &Attributes) {
1357 if (TagTokKind == tok::kw_struct)
1359 else if (TagTokKind == tok::kw___interface)
1361 else if (TagTokKind == tok::kw_class)
1364 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1368 if (Tok.
is(tok::code_completion)) {
1371 return cutOffParsing();
1384 bool shouldDelayDiagsInTag =
1385 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
1386 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
1389 ParsedAttributesWithRange attrs(AttrFactory);
1391 MaybeParseGNUAttributes(attrs);
1392 MaybeParseMicrosoftDeclSpecs(attrs);
1395 if (Tok.
isOneOf(tok::kw___single_inheritance,
1396 tok::kw___multiple_inheritance,
1397 tok::kw___virtual_inheritance))
1398 ParseMicrosoftInheritanceClassAttributes(attrs);
1403 MaybeParseCXX11Attributes(attrs);
1410 Tok.
isNot(tok::identifier) &&
1413 Tok.
isOneOf(tok::kw___is_abstract,
1414 tok::kw___is_aggregate,
1415 tok::kw___is_arithmetic,
1417 tok::kw___is_assignable,
1418 tok::kw___is_base_of,
1420 tok::kw___is_complete_type,
1421 tok::kw___is_compound,
1423 tok::kw___is_constructible,
1424 tok::kw___is_convertible,
1425 tok::kw___is_convertible_to,
1426 tok::kw___is_destructible,
1429 tok::kw___is_floating_point,
1431 tok::kw___is_function,
1432 tok::kw___is_fundamental,
1433 tok::kw___is_integral,
1434 tok::kw___is_interface_class,
1435 tok::kw___is_literal,
1436 tok::kw___is_lvalue_expr,
1437 tok::kw___is_lvalue_reference,
1438 tok::kw___is_member_function_pointer,
1439 tok::kw___is_member_object_pointer,
1440 tok::kw___is_member_pointer,
1441 tok::kw___is_nothrow_assignable,
1442 tok::kw___is_nothrow_constructible,
1443 tok::kw___is_nothrow_destructible,
1444 tok::kw___is_object,
1446 tok::kw___is_pointer,
1447 tok::kw___is_polymorphic,
1448 tok::kw___is_reference,
1449 tok::kw___is_rvalue_expr,
1450 tok::kw___is_rvalue_reference,
1452 tok::kw___is_scalar,
1453 tok::kw___is_sealed,
1454 tok::kw___is_signed,
1455 tok::kw___is_standard_layout,
1456 tok::kw___is_trivial,
1457 tok::kw___is_trivially_assignable,
1458 tok::kw___is_trivially_constructible,
1459 tok::kw___is_trivially_copyable,
1461 tok::kw___is_unsigned,
1463 tok::kw___is_volatile))
1469 TryKeywordIdentFallback(
true);
1471 struct PreserveAtomicIdentifierInfoRAII {
1472 PreserveAtomicIdentifierInfoRAII(
Token &Tok,
bool Enabled)
1473 : AtomicII(nullptr) {
1476 assert(Tok.
is(tok::kw__Atomic));
1481 ~PreserveAtomicIdentifierInfoRAII() {
1484 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1494 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1495 Tok.
is(tok::kw__Atomic) &&
1497 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1498 Tok, ShouldChangeAtomicToIdentifier);
1508 bool HasValidSpec =
true;
1509 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr, EnteringContext)) {
1511 HasValidSpec =
false;
1514 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::annot_template_id)) {
1515 Diag(Tok, diag::err_expected) << tok::identifier;
1516 HasValidSpec =
false;
1528 if (Tok.
is(tok::identifier)) {
1536 TemplateArgList TemplateArgs;
1538 if (ParseTemplateIdAfterTemplateName(
true, LAngleLoc, TemplateArgs,
1545 Diag(NameLoc, diag::err_explicit_spec_non_template)
1546 << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
1547 << TagTokKind << Name <<
SourceRange(LAngleLoc, RAngleLoc);
1551 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1552 if (TemplateParams->size() > 1) {
1553 TemplateParams->pop_back();
1555 TemplateParams =
nullptr;
1556 const_cast<ParsedTemplateInfo&
>(TemplateInfo).
Kind 1557 = ParsedTemplateInfo::NonTemplate;
1559 }
else if (TemplateInfo.Kind
1560 == ParsedTemplateInfo::ExplicitInstantiation) {
1562 TemplateParams =
nullptr;
1563 const_cast<ParsedTemplateInfo&
>(TemplateInfo).
Kind 1564 = ParsedTemplateInfo::NonTemplate;
1565 const_cast<ParsedTemplateInfo&
>(TemplateInfo).TemplateLoc
1567 const_cast<ParsedTemplateInfo&
>(TemplateInfo).ExternLoc
1571 }
else if (Tok.
is(tok::annot_template_id)) {
1572 TemplateId = takeTemplateIdAnnotation(Tok);
1573 NameLoc = ConsumeAnnotationToken();
1585 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1586 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1621 MaybeParseCXX11Attributes(Attributes);
1623 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
1625 if (DSC == DeclSpecContext::DSC_trailing)
1627 else if (Tok.
is(tok::l_brace) ||
1629 (isCXX11FinalKeyword() &&
1645 }
else if (isCXX11FinalKeyword() && (
NextToken().is(tok::l_square) ||
1649 TentativeParsingAction PA(*
this);
1656 if (Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square)) {
1660 }
else if (Tok.
is(tok::kw_alignas) &&
NextToken().
is(tok::l_paren)) {
1670 if (Tok.
isOneOf(tok::l_brace, tok::colon))
1676 }
else if (!isTypeSpecifier(DSC) &&
1677 (Tok.
is(tok::semi) ||
1680 if (Tok.
isNot(tok::semi)) {
1681 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
1683 ExpectAndConsume(tok::semi, diag::err_expected_after,
1701 Diag(AttrRange.
getBegin(), diag::err_attributes_not_allowed)
1715 if (shouldDelayDiagsInTag) {
1716 diagsFromTag.done();
1718 diagsFromTag.redelay();
1725 Diag(StartLoc, diag::err_anon_type_definition)
1750 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
1753 ProhibitAttributes(attrs);
1756 = Actions.ActOnExplicitInstantiation(
getCurScope(),
1757 TemplateInfo.ExternLoc,
1758 TemplateInfo.TemplateLoc,
1775 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
1776 ProhibitAttributes(attrs);
1777 TypeResult = Actions.ActOnTagTemplateIdType(TUK, TagType, StartLoc,
1789 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1802 "Expected a definition here");
1806 TemplateParams =
nullptr;
1809 PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
1811 diag::err_explicit_instantiation_with_definition)
1818 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
1820 LAngleLoc,
nullptr));
1821 TemplateParams = &FakedParamLists;
1826 TagOrTempResult = Actions.ActOnClassTemplateSpecialization(
1831 TemplateParams ? TemplateParams->size() : 0),
1834 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
1841 ProhibitAttributes(attrs);
1844 = Actions.ActOnExplicitInstantiation(
getCurScope(),
1845 TemplateInfo.ExternLoc,
1846 TemplateInfo.TemplateLoc,
1847 TagType, StartLoc, SS, Name,
1850 TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
1851 ProhibitAttributes(attrs);
1855 TagType, StartLoc, SS,
1856 Name, NameLoc, attrs.
getList(),
1858 TemplateParams? &(*TemplateParams)[0]
1860 TemplateParams? TemplateParams->size() : 0));
1863 ProhibitAttributes(attrs);
1866 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1869 Diag(Tok, diag::err_template_defn_explicit_instantiation)
1871 TemplateParams =
nullptr;
1874 bool IsDependent =
false;
1884 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
1887 TagOrTempResult = Actions.ActOnTag(
1888 getCurScope(), TagType, TUK, StartLoc, SS, Name, NameLoc,
1891 DSC == DeclSpecContext::DSC_type_specifier,
1892 DSC == DeclSpecContext::DSC_template_param ||
1893 DSC == DeclSpecContext::DSC_template_type_arg,
1900 TypeResult = Actions.ActOnDependentTag(
getCurScope(), TagType, TUK,
1901 SS, Name, StartLoc, NameLoc);
1907 assert(Tok.
is(tok::l_brace) ||
1909 isCXX11FinalKeyword());
1911 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc, TagType,
1912 TagOrTempResult.
get());
1914 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs, TagType,
1915 TagOrTempResult.
get());
1920 ParseStructUnionBody(StartLoc, TagType, D);
1922 !Actions.ActOnDuplicateDefinition(DS, TagOrTempResult.
get(),
1932 Actions.ProcessDeclAttributeDelayed(TagOrTempResult.
get(), attrs.
getList());
1934 const char *PrevSpec =
nullptr;
1939 NameLoc.isValid() ? NameLoc : StartLoc,
1940 PrevSpec, DiagID, TypeResult.
get(), Policy);
1941 }
else if (!TagOrTempResult.
isInvalid()) {
1943 NameLoc.isValid() ? NameLoc : StartLoc,
1944 PrevSpec, DiagID, TagOrTempResult.
get(), Owned,
1952 Diag(StartLoc, DiagID) << PrevSpec;
1968 (TemplateInfo.Kind || !isValidAfterTypeSpecifier(
false))) {
1969 if (Tok.
isNot(tok::semi)) {
1970 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
1971 ExpectAndConsume(tok::semi, diag::err_expected_after,
1989 void Parser::ParseBaseClause(
Decl *ClassDecl) {
1990 assert(Tok.
is(tok::colon) &&
"Not a base clause");
1998 BaseResult Result = ParseBaseSpecifier(ClassDecl);
2005 BaseInfo.push_back(Result.
get());
2015 Actions.ActOnBaseSpecifiers(ClassDecl, BaseInfo);
2030 bool IsVirtual =
false;
2033 ParsedAttributesWithRange Attributes(AttrFactory);
2034 MaybeParseCXX11Attributes(Attributes);
2040 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2047 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2051 if (Tok.
is(tok::kw_virtual)) {
2055 Diag(VirtualLoc, diag::err_dup_virtual)
2062 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
2076 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
2091 return Actions.ActOnBaseSpecifier(ClassDecl, Range, Attributes, IsVirtual,
2092 Access, BaseType.
get(), BaseLoc,
2116 void Parser::HandleMemberFunctionDeclDelays(
Declarator& DeclaratorInfo,
2124 if (!NeedLateParse) {
2126 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx) {
2127 auto Param = cast<ParmVarDecl>(FTI.
Params[ParamIdx].
Param);
2128 if (Param->hasUnparsedDefaultArg()) {
2129 NeedLateParse =
true;
2135 if (NeedLateParse) {
2138 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
2139 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
2148 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
2149 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx)
2150 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2171 Ident_final = &PP.getIdentifierTable().get(
"final");
2173 Ident_GNU_final = &PP.getIdentifierTable().get(
"__final");
2175 Ident_sealed = &PP.getIdentifierTable().get(
"sealed");
2176 Ident_override = &PP.getIdentifierTable().get(
"override");
2179 if (II == Ident_override)
2182 if (II == Ident_sealed)
2185 if (II == Ident_final)
2188 if (II == Ident_GNU_final)
2199 void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2218 const char *PrevSpec =
nullptr;
2235 ? diag::warn_cxx98_compat_override_control_keyword
2236 : diag::ext_override_control_keyword)
2245 bool Parser::isCXX11FinalKeyword()
const {
2254 bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2256 LateParsedAttrList &LateParsedAttrs) {
2261 if (Tok.
isNot(tok::colon))
2262 ParseDeclarator(DeclaratorInfo);
2268 "don't know where identifier would go yet?");
2270 if (BitfieldSize.isInvalid())
2273 ParseOptionalCXX11VirtSpecifierSeq(
2274 VS, getCurrentClass().IsInterface,
2277 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo, VS);
2281 if (Tok.
is(tok::kw_asm)) {
2283 ExprResult AsmLabel(ParseSimpleAsm(&Loc));
2284 if (AsmLabel.isInvalid())
2292 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2296 if (BitfieldSize.isUnset() && VS.
isUnset()) {
2297 ParseOptionalCXX11VirtSpecifierSeq(
2298 VS, getCurrentClass().IsInterface,
2306 Diag(Attr->
getLoc(), diag::warn_gcc_attribute_location);
2309 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo, VS);
2315 if (!DeclaratorInfo.
hasName() && BitfieldSize.isUnset()) {
2325 void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2332 ParseTypeQualifierListOpt(
2333 DS, AR_NoAttributesParsed,
false,
2334 false, llvm::function_ref<
void()>([&]() {
2335 Actions.CodeCompleteFunctionQualifiers(DS, D, &VS);
2343 const char *FixItName,
2345 unsigned* QualifierLoc) {
2348 if (!(
Function.TypeQuals & TypeQual)) {
2349 std::string Name(FixItName);
2353 *QualifierLoc = SpecLoc.getRawEncoding();
2355 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2371 bool RefQualifierIsLValueRef =
true;
2373 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2374 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2376 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2379 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2380 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2428 const ParsedTemplateInfo &TemplateInfo,
2430 if (Tok.
is(tok::at)) {
2432 Diag(Tok, diag::err_at_defs_cxx);
2434 Diag(Tok, diag::err_at_in_class);
2450 bool MalformedTypeSpec =
false;
2451 if (!TemplateInfo.Kind &&
2452 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2454 MalformedTypeSpec =
true;
2457 if (Tok.
isNot(tok::annot_cxxscope))
2458 isAccessDecl =
false;
2460 isAccessDecl = GetLookAheadToken(2).is(tok::semi);
2467 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2479 TemplateKWLoc, Name)) {
2485 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2486 "access declaration")) {
2500 if (!TemplateInfo.Kind &&
2501 Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2507 if (Tok.
is(tok::kw_template)) {
2508 assert(!TemplateInfo.TemplateParams &&
2509 "Nested template improperly parsed?");
2518 if (Tok.
is(tok::kw___extension__)) {
2522 return ParseCXXClassMemberDeclaration(AS, AccessAttrs,
2523 TemplateInfo, TemplateDiags);
2526 ParsedAttributesWithRange attrs(AttrFactory);
2527 ParsedAttributesWithRange FnAttrs(AttrFactory);
2529 MaybeParseCXX11Attributes(attrs);
2532 FnAttrs.addAll(attrs.
getList());
2533 FnAttrs.Range = attrs.Range;
2535 MaybeParseMicrosoftAttributes(attrs);
2537 if (Tok.
is(tok::kw_using)) {
2538 ProhibitAttributes(attrs);
2543 if (Tok.
is(tok::kw_namespace)) {
2544 Diag(UsingLoc, diag::err_using_namespace_in_class);
2551 UsingLoc, DeclEnd, AS);
2555 LateParsedAttrList CommonLateParsedAttrs;
2561 if (MalformedTypeSpec)
2564 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DeclSpecContext::DSC_class,
2565 &CommonLateParsedAttrs);
2573 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate &&
2574 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DeclSpecContext::DSC_class,
2575 &CommonLateParsedAttrs))
2579 TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->data()
2581 TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->size() : 0);
2585 ProhibitAttributes(FnAttrs);
2588 Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(
2589 getCurScope(), AS, DS, TemplateParams,
false, AnonRecord);
2590 DS.complete(TheDecl);
2592 Decl* decls[] = {AnonRecord, TheDecl};
2593 return Actions.BuildDeclaratorGroup(decls);
2595 return Actions.ConvertDeclToDeclGroup(TheDecl);
2602 LateParsedAttrList LateParsedAttrs;
2607 auto TryConsumePureSpecifier = [&] (
bool AllowDefinition) {
2608 if (Tok.
isNot(tok::equal))
2613 if (Zero.isNot(tok::numeric_constant) || Zero.getLength() != 1 ||
2614 PP.getSpelling(Zero, Buffer) !=
"0")
2617 auto &
After = GetLookAheadToken(2);
2618 if (!
After.isOneOf(tok::semi, tok::comma) &&
2619 !(AllowDefinition &&
2620 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
2629 ExprResult BitfieldSize;
2630 bool ExpectSemi =
true;
2633 if (ParseCXXMemberDeclaratorBeforeInitializer(
2634 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
2644 TryConsumePureSpecifier(
true);
2655 if (Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
2657 }
else if (Tok.
is(tok::equal)) {
2659 if (KW.
is(tok::kw_default))
2661 else if (KW.
is(tok::kw_delete))
2673 ProhibitAttributes(FnAttrs);
2690 diag::err_function_declared_typedef);
2697 ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo, TemplateInfo,
2701 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
2702 CommonLateParsedAttrs[i]->addDecl(FunDecl);
2704 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
2705 LateParsedAttrs[i]->addDecl(FunDecl);
2708 LateParsedAttrs.clear();
2711 if (Tok.
is(tok::semi))
2712 ConsumeExtraSemi(AfterMemberFunctionDefinition);
2724 bool HasStaticInitializer =
false;
2728 if (!TryConsumePureSpecifier(
false))
2730 HasStaticInitializer =
true;
2737 if (BitfieldSize.
get())
2739 ? diag::warn_cxx17_compat_bitfield_member_init
2740 : diag::ext_bitfield_member_init);
2743 HasStaticInitializer =
true;
2761 E = Ranges.end(); I != E; ++I)
2762 Diag((*I).getBegin(), diag::err_attributes_not_allowed) << *I;
2764 ThisDecl = Actions.ActOnFriendFunctionDecl(
getCurScope(), DeclaratorInfo,
2767 ThisDecl = Actions.ActOnCXXMemberDeclarator(
getCurScope(), AS,
2771 VS, HasInClassInit);
2774 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
2777 ThisDecl = VT->getTemplatedDecl();
2779 if (ThisDecl && AccessAttrs)
2780 Actions.ProcessDeclAttributeList(
getCurScope(), ThisDecl, AccessAttrs);
2789 HasStaticInitializer =
true;
2792 if (ThisDecl && PureSpecLoc.
isValid())
2793 Actions.ActOnPureSpecifier(ThisDecl, PureSpecLoc);
2799 ? diag::warn_cxx98_compat_nonstatic_member_init
2800 : diag::ext_nonstatic_member_init);
2808 Diag(Tok, diag::err_incomplete_array_member_init);
2815 ParseCXXNonStaticMemberInitializer(ThisDecl);
2816 }
else if (HasStaticInitializer) {
2818 ExprResult Init = ParseCXXMemberInitializer(
2824 Actions.AddInitializerToDecl(ThisDecl, Init.
get(), EqualLoc.
isInvalid());
2827 Actions.ActOnUninitializedDecl(ThisDecl);
2832 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
2833 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
2835 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
2836 LateParsedAttrs[i]->addDecl(ThisDecl);
2838 Actions.FinalizeDeclaration(ThisDecl);
2839 DeclsInGroup.push_back(ThisDecl);
2844 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
2846 LateParsedAttrs.clear();
2848 DeclaratorInfo.complete(ThisDecl);
2861 Diag(CommaLoc, diag::err_expected_semi_declaration)
2868 DeclaratorInfo.
clear();
2875 MaybeParseGNUAttributes(DeclaratorInfo);
2877 if (ParseCXXMemberDeclaratorBeforeInitializer(
2878 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
2883 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
2891 return Actions.FinalizeDeclaratorGroup(
getCurScope(), DS, DeclsInGroup);
2914 ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
2916 assert(Tok.
isOneOf(tok::equal, tok::l_brace)
2917 &&
"Data member initializer not starting with '=' or '{'");
2922 if (Tok.
is(tok::kw_delete)) {
2937 }
else if (Tok.
is(tok::kw_default)) {
2939 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
2946 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
2947 Diag(Tok, diag::err_ms_property_initializer) << PD;
2950 return ParseInitializer();
2953 void Parser::SkipCXXMemberSpecification(
SourceLocation RecordLoc,
2958 assert(isCXX11FinalKeyword() &&
"not a class definition");
2963 ParsedAttributesWithRange Attrs(AttrFactory);
2964 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
2969 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_brace))
2976 if (Tok.
is(tok::colon)) {
2979 ParsingClassDefinition ParsingDef(*
this, TagDecl,
true,
2982 Actions.ActOnTagStartSkippedDefinition(
getCurScope(), TagDecl);
2985 ParseBaseClause(
nullptr);
2987 Actions.ActOnTagFinishSkippedDefinition(OldContext);
2989 if (!Tok.
is(tok::l_brace)) {
2990 Diag(PP.getLocForEndOfToken(PrevTokLocation),
2991 diag::err_expected_lbrace_after_base_specifiers);
2997 assert(Tok.
is(tok::l_brace));
3004 if (Tok.
is(tok::kw___attribute))
3005 MaybeParseGNUAttributes(Attrs);
3012 case tok::kw___if_exists:
3013 case tok::kw___if_not_exists:
3014 ParseMicrosoftIfExistsClassDeclaration(TagType, AS);
3019 ConsumeExtraSemi(InsideStruct, TagType);
3023 case tok::annot_pragma_vis:
3024 HandlePragmaVisibility();
3026 case tok::annot_pragma_pack:
3029 case tok::annot_pragma_align:
3030 HandlePragmaAlign();
3032 case tok::annot_pragma_ms_pointers_to_members:
3033 HandlePragmaMSPointersToMembers();
3035 case tok::annot_pragma_ms_pragma:
3036 HandlePragmaMSPragma();
3038 case tok::annot_pragma_ms_vtordisp:
3039 HandlePragmaMSVtorDisp();
3041 case tok::annot_pragma_dump:
3045 case tok::kw_namespace:
3047 DiagnoseUnexpectedNamespace(cast<NamedDecl>(TagDecl));
3050 case tok::kw_public:
3051 case tok::kw_protected:
3052 case tok::kw_private: {
3060 AccessAttrs.clear();
3061 MaybeParseGNUAttributes(AccessAttrs);
3066 Diag(EndLoc, diag::err_expected)
3070 Diag(EndLoc, diag::err_expected)
3080 if (Actions.ActOnAccessSpecifier(NewAS, ASLoc, EndLoc,
3081 AccessAttrs.getList())) {
3083 AccessAttrs.clear();
3089 case tok::annot_pragma_openmp:
3090 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, AccessAttrs, TagType,
3094 return ParseCXXClassMemberDeclaration(AS, AccessAttrs.getList());
3104 void Parser::ParseCXXMemberSpecification(
SourceLocation RecordLoc,
3106 ParsedAttributesWithRange &Attrs,
3107 unsigned TagType,
Decl *TagDecl) {
3114 "parsing struct/union/class body");
3118 bool NonNestedClass =
true;
3119 if (!ClassStack.empty()) {
3121 if (S->isClassScope()) {
3123 NonNestedClass =
false;
3126 if (getCurrentClass().IsInterface) {
3127 Diag(RecordLoc, diag::err_invalid_member_in_interface)
3129 << (isa<NamedDecl>(TagDecl)
3130 ? cast<NamedDecl>(TagDecl)->getQualifiedNameAsString()
3147 ParsingClassDefinition ParsingDef(*
this, TagDecl, NonNestedClass,
3151 Actions.ActOnTagStartDefinition(
getCurScope(), TagDecl);
3154 bool IsFinalSpelledSealed =
false;
3162 "not a class definition");
3167 Diag(FinalLoc, diag::err_override_control_interface)
3171 ? diag::warn_cxx98_compat_override_control_keyword
3172 : diag::ext_override_control_keyword)
3175 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3177 Diag(FinalLoc, diag::ext_warn_gnu_final);
3183 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3192 if (!Tok.
is(tok::colon) && !Tok.
is(tok::l_brace)) {
3194 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3199 if (Tok.
is(tok::colon)) {
3200 ParseScope InheritanceScope(
this,
getCurScope()->getFlags() |
3203 ParseBaseClause(TagDecl);
3204 if (!Tok.
is(tok::l_brace)) {
3205 bool SuggestFixIt =
false;
3206 SourceLocation BraceLoc = PP.getLocForEndOfToken(PrevTokLocation);
3209 case tok::kw_private:
3210 case tok::kw_protected:
3211 case tok::kw_public:
3214 case tok::kw_static_assert:
3218 case tok::kw_template:
3219 SuggestFixIt =
true;
3221 case tok::identifier:
3222 SuggestFixIt = isConstructorDeclarator(
true);
3225 SuggestFixIt = isCXXSimpleDeclaration(
false);
3230 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3238 Actions.ActOnTagDefinitionError(
getCurScope(), TagDecl);
3244 assert(Tok.
is(tok::l_brace));
3249 Actions.ActOnStartCXXMemberDeclarations(
getCurScope(), TagDecl, FinalLoc,
3250 IsFinalSpelledSealed,
3251 T.getOpenLocation());
3261 ParsedAttributesWithRange AccessAttrs(AttrFactory);
3265 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3268 ParseCXXClassMemberDeclarationWithPragmas(
3269 CurAS, AccessAttrs, static_cast<DeclSpec::TST>(TagType), TagDecl);
3278 MaybeParseGNUAttributes(attrs);
3281 Actions.ActOnFinishCXXMemberSpecification(
getCurScope(), RecordLoc, TagDecl,
3282 T.getOpenLocation(),
3283 T.getCloseLocation(),
3291 if (TagDecl && NonNestedClass) {
3297 ParseLexedAttributes(getCurrentClass());
3298 ParseLexedMethodDeclarations(getCurrentClass());
3301 Actions.ActOnFinishCXXMemberDecls();
3303 ParseLexedMemberInitializers(getCurrentClass());
3304 ParseLexedMethodDefs(getCurrentClass());
3305 PrevTokLocation = SavedPrevTokLocation;
3309 Actions.ActOnFinishCXXNonNestedClass(TagDecl);
3313 Actions.ActOnTagFinishDefinition(
getCurScope(), TagDecl,
T.getRange());
3320 void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3321 assert(Tok.
is(tok::kw_namespace));
3326 diag::err_missing_end_of_definition) << D;
3328 diag::note_missing_end_of_definition_before) << D;
3334 Tok.
setLocation(PP.getLocForEndOfToken(PrevTokLocation));
3362 void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3363 assert(Tok.
is(tok::colon) &&
3364 "Constructor initializer always starts with ':'");
3372 bool AnyErrors =
false;
3375 if (Tok.
is(tok::code_completion)) {
3376 Actions.CodeCompleteConstructorInitializer(ConstructorDecl,
3378 return cutOffParsing();
3381 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3383 MemInitializers.push_back(MemInit.
get());
3387 if (Tok.
is(tok::comma))
3389 else if (Tok.
is(tok::l_brace))
3394 Tok.
isOneOf(tok::identifier, tok::coloncolon)) {
3396 Diag(Loc, diag::err_ctor_init_missing_comma)
3408 Actions.ActOnMemInitializers(ConstructorDecl, ColonLoc, MemInitializers,
3427 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false);
3437 if (Tok.
is(tok::identifier)) {
3442 }
else if (Tok.
is(tok::annot_decltype)) {
3447 ParseDecltypeSpecifier(DS);
3450 ? takeTemplateIdAnnotation(Tok)
3454 AnnotateTemplateIdTokenAsType(
true);
3455 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
3457 ConsumeAnnotationToken();
3459 Diag(Tok, diag::err_expected_member_or_base_name);
3466 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3468 ExprResult InitList = ParseBraceInitializer();
3475 return Actions.ActOnMemInitializer(ConstructorDecl,
getCurScope(), SS, II,
3476 TemplateTypeTy, DS, IdLoc,
3477 InitList.
get(), EllipsisLoc);
3478 }
else if(Tok.
is(tok::l_paren)) {
3483 ExprVector ArgExprs;
3484 CommaLocsTy CommaLocs;
3485 if (Tok.
isNot(tok::r_paren) && ParseExpressionList(ArgExprs, CommaLocs)) {
3495 return Actions.ActOnMemInitializer(ConstructorDecl,
getCurScope(), SS, II,
3496 TemplateTypeTy, DS, IdLoc,
3497 T.getOpenLocation(), ArgExprs,
3498 T.getCloseLocation(), EllipsisLoc);
3502 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
3504 return Diag(Tok, diag::err_expected) << tok::l_paren;
3517 Parser::tryParseExceptionSpecification(
bool Delayed,
3521 ExprResult &NoexceptExpr,
3524 ExceptionSpecTokens =
nullptr;
3528 if (Tok.
isNot(tok::kw_throw) && Tok.
isNot(tok::kw_noexcept))
3532 bool IsNoexcept = Tok.
is(tok::kw_noexcept);
3533 Token StartTok = Tok;
3537 if (!Tok.
is(tok::l_paren)) {
3540 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
3541 NoexceptExpr =
nullptr;
3545 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
3551 ExceptionSpecTokens->push_back(StartTok);
3552 ExceptionSpecTokens->push_back(Tok);
3553 SpecificationRange.
setEnd(ConsumeParen());
3555 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
3558 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
3564 if (Tok.
is(tok::kw_throw)) {
3565 Result = ParseDynamicExceptionSpecification(SpecificationRange,
3567 DynamicExceptionRanges);
3568 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
3569 "Produced different number of exception types and ranges.");
3573 if (Tok.
isNot(tok::kw_noexcept))
3576 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
3584 if (Tok.
is(tok::l_paren)) {
3596 Actions.CheckBooleanCondition(KeywordLoc, NoexceptExpr.
get());
3597 NoexceptRange =
SourceRange(KeywordLoc,
T.getCloseLocation());
3604 NoexceptRange =
SourceRange(KeywordLoc, KeywordLoc);
3608 SpecificationRange = NoexceptRange;
3609 Result = NoexceptType;
3613 if (Tok.
is(tok::kw_throw)) {
3614 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
3615 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
3616 DynamicExceptionRanges);
3619 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
3628 const char *
Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
3631 ? diag::ext_dynamic_exception_spec
3632 : diag::warn_exception_spec_deprecated)
3634 P.
Diag(Range.
getBegin(), diag::note_exception_spec_deprecated)
3654 assert(Tok.
is(tok::kw_throw) &&
"expected throw");
3659 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
3666 if (Tok.
is(tok::ellipsis)) {
3669 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
3678 while (Tok.
isNot(tok::r_paren)) {
3681 if (Tok.
is(tok::ellipsis)) {
3688 Res = Actions.ActOnPackExpansion(Res.
get(), Ellipsis);
3692 Exceptions.push_back(Res.
get());
3693 Ranges.push_back(Range);
3703 Exceptions.empty());
3709 TypeResult Parser::ParseTrailingReturnType(
SourceRange &Range) {
3710 assert(Tok.
is(tok::arrow) &&
"expected arrow");
3721 Parser::PushParsingClass(
Decl *ClassDecl,
bool NonNestedClass,
3723 assert((NonNestedClass || !ClassStack.empty()) &&
3724 "Nested class without outer class");
3725 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
3726 return Actions.PushParsingClass();
3731 void Parser::DeallocateParsedClasses(Parser::ParsingClass *Class) {
3732 for (
unsigned I = 0, N = Class->LateParsedDeclarations.size(); I != N; ++I)
3733 delete Class->LateParsedDeclarations[I];
3744 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
3746 Actions.PopParsingClass(state);
3748 ParsingClass *Victim = ClassStack.top();
3750 if (Victim->TopLevelClass) {
3753 DeallocateParsedClasses(Victim);
3756 assert(!ClassStack.empty() &&
"Missing top-level class?");
3758 if (Victim->LateParsedDeclarations.empty()) {
3763 DeallocateParsedClasses(Victim);
3770 assert(
getCurScope()->isClassScope() &&
"Nested class outside of class scope?");
3771 ClassStack.top()->LateParsedDeclarations.push_back(
new LateParsedClass(
this, Victim));
3803 case tok::pipeequal:
3804 case tok::caretequal:
3806 case tok::exclaimequal:
3811 PP.getSourceManager().getSpellingLoc(Tok.
getLocation());
3812 StringRef Spelling = PP.getSpelling(SpellingLoc, SpellingBuf);
3815 return &PP.getIdentifierTable().get(Spelling);
3825 case AttributeList::AT_CarriesDependency:
3826 case AttributeList::AT_Deprecated:
3827 case AttributeList::AT_FallThrough:
3828 case AttributeList::AT_CXX11NoReturn:
3830 case AttributeList::AT_WarnUnusedResult:
3831 return !ScopeName && AttrName->
getName().equals(
"nodiscard");
3832 case AttributeList::AT_Unused:
3833 return !ScopeName && AttrName->
getName().equals(
"maybe_unused");
3859 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
3875 if (ScopeName && ScopeName->
getName() ==
"gnu") {
3878 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
3879 ScopeLoc, Syntax,
nullptr);
3885 if (ScopeName && ScopeName->
getName() ==
"clang")
3887 ParseClangAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
3891 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
3892 ScopeName, ScopeLoc, Syntax);
3903 Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
3909 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
3944 if (Tok.
is(tok::kw_alignas)) {
3946 ParseAlignmentSpecifier(attrs, endLoc);
3950 assert(Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square) &&
3951 "Not a double square bracket attribute list");
3960 if (Tok.
is(tok::kw_using)) {
3962 ? diag::warn_cxx14_compat_using_attribute_ns
3963 : diag::ext_using_attribute_ns);
3966 CommonScopeName = TryParseCXX11AttributeIdentifier(CommonScopeLoc);
3967 if (!CommonScopeName) {
3975 llvm::SmallDenseMap<IdentifierInfo*, SourceLocation, 4> SeenAttrs;
3977 while (Tok.
isNot(tok::r_square)) {
3985 AttrName = TryParseCXX11AttributeIdentifier(AttrLoc);
3992 ScopeName = AttrName;
3995 AttrName = TryParseCXX11AttributeIdentifier(AttrLoc);
4003 if (CommonScopeName) {
4005 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
4008 ScopeName = CommonScopeName;
4009 ScopeLoc = CommonScopeLoc;
4014 bool AttrParsed =
false;
4017 !SeenAttrs.insert(std::make_pair(AttrName, AttrLoc)).second)
4018 Diag(AttrLoc, diag::err_cxx11_attribute_repeated)
4022 if (Tok.
is(tok::l_paren))
4023 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, attrs, endLoc,
4024 ScopeName, ScopeLoc);
4029 SourceRange(ScopeLoc.
isValid() ? ScopeLoc : AttrLoc, AttrLoc),
4030 ScopeName, ScopeLoc,
nullptr, 0,
4035 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis)
4036 << AttrName->getName();
4039 if (ExpectAndConsume(tok::r_square))
4043 if (ExpectAndConsume(tok::r_square))
4051 void Parser::ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
4053 assert(standardAttributesAllowed());
4060 ParseCXX11AttributeSpecifier(attrs, endLoc);
4061 }
while (isCXX11AttributeSpecifier());
4066 void Parser::DiagnoseAndSkipCXX11Attributes() {
4073 Diag(StartLoc, diag::err_attributes_not_allowed)
4081 if (!isCXX11AttributeSpecifier())
4085 if (Tok.
is(tok::l_square)) {
4091 assert(Tok.
is(tok::kw_alignas) &&
"not an attribute specifier");
4098 }
while (isCXX11AttributeSpecifier());
4105 assert(Tok.
is(tok::identifier) &&
"Not a Microsoft attribute list");
4107 assert(UuidIdent->getName() ==
"uuid" &&
"Not a Microsoft attribute list");
4115 Diag(Tok, diag::err_expected) << tok::l_paren;
4120 if (Tok.
is(tok::string_literal)) {
4122 ExprResult StringResult = ParseStringLiteralExpression();
4125 ArgExprs.push_back(StringResult.
get());
4142 while (Tok.
isNot(tok::r_paren)) {
4144 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4149 SpellingBuffer.resize(Tok.
getLength() + 1);
4150 bool Invalid =
false;
4151 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
4156 StrBuffer += TokSpelling;
4162 Diag(Tok, diag::err_attribute_uuid_malformed_guid);
4172 Toks[0].
setKind(tok::string_literal);
4177 cast<StringLiteral>(Actions.ActOnStringLiteral(Toks,
nullptr).get());
4178 ArgExprs.push_back(UuidString);
4198 assert(Tok.
is(tok::l_square) &&
"Not a Microsoft attribute list");
4208 if (Tok.
isNot(tok::identifier))
4211 ParseMicrosoftUuidAttributeArgs(attrs);
4219 }
while (Tok.
is(tok::l_square));
4222 void Parser::ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
4224 IfExistsCondition
Result;
4225 if (ParseMicrosoftIfExistsCondition(Result))
4230 Diag(Tok, diag::err_expected) << tok::l_brace;
4234 switch (Result.Behavior) {
4240 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
4241 << Result.IsIfExists;
4250 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
4252 if (Tok.
isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
4253 ParseMicrosoftIfExistsClassDeclaration((
DeclSpec::TST)TagType, CurAS);
4258 if (Tok.
is(tok::semi)) {
4259 ConsumeExtraSemi(InsideStruct, TagType);
4269 if (Tok.
is(tok::colon))
4270 Actions.ActOnAccessSpecifier(AS, ASLoc, Tok.
getLocation());
4272 Diag(Tok, diag::err_expected) << tok::colon;
4278 ParseCXXClassMemberDeclaration(CurAS,
nullptr);
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
Defines the clang::ASTContext interface.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
no exception specification
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
void clear()
Reset the contents of this Declarator.
AttributeList * getNext() const
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
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)) {...
static CharSourceRange getTokenRange(SourceRange R)
The name refers to a dependent template name:
ActionResult< Expr * > ExprResult
Decl - This represents one declaration (or definition), e.g.
RAII object used to inform the actions that we're currently parsing a declaration.
void CodeCompleteUsing(Scope *S)
A RAII object used to temporarily suppress access-like checking.
Defines the C++ template declaration subclasses.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
The base class of the type hierarchy.
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
SourceLocation getCloseLocation() const
This indicates that the scope corresponds to a function, which means that labels are set here...
Declaration of a variable template.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
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 const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
std::unique_ptr< CachedTokens > DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
static const char * getSpecifierName(Specifier VS)
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
TemplateNameKind Kind
The kind of template that Template refers to.
const NestedNameSpecifier * Specifier
Wrapper for void* pointer.
Parser - This implements a parser for the C family of languages.
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
RAII object that enters a new expression evaluation context.
void EnterToken(const Token &Tok)
Enters a token in the token stream to be lexed next.
static const TST TST_underlyingType
Information about one declarator, including the parsed type information and the identifier.
void setTypeofParensRange(SourceRange range)
TypeSpecifierType
Specifies the kind of type.
static const TST TST_interface
bool isInvalidDecl() const
Like System, but searched after the system directories.
void setBegin(SourceLocation b)
Describes how types, statements, expressions, and declarations should be printed. ...
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
friend class ObjCDeclContextSwitch
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
AttributeList * getList() const
tok::TokenKind getKind() const
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 ...
Information about a template-id annotation token.
SourceLocation getFriendSpecLoc() const
RecordDecl - Represents a struct/union/class.
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, AttributeList *AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation getLoc() const
bool TryConsumeToken(tok::TokenKind Expected)
__ptr16, alignas(...), etc.
One of these records is kept for each identifier that is lexed.
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
SourceLocation getAnnotationEndLoc() const
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
static const TST TST_class
The current expression is potentially evaluated at run time, which means that code may be generated t...
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
static const TST TST_error
Token - This structure provides full information about a lexed token.
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, ParsedType ObjectType, SourceLocation &TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
void setKind(tok::TokenKind K)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, SourceLocation IILoc, Scope *S, const CXXScopeSpec *SS, TemplateTy &SuggestedTemplate, TemplateNameKind &SuggestedKind)
bool hasTagDefinition() const
void ClearStorageClassSpecs()
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
void setExternInLinkageSpec(bool Value)
Represents a C++ unqualified-id that has been parsed.
static ParsedType getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
Microsoft throw(...) extension.
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl *> Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
const clang::PrintingPolicy & getPrintingPolicy() const
void takeAllFrom(ParsedAttributes &attrs)
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
Scope - A scope is a transient data structure that is used while parsing the program.
Represents a C++ nested-name-specifier or a global scope specifier.
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type...
SourceLocation getConstSpecLoc() const
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
ActOnStartLinkageSpecification - Parsed the beginning of a C++ linkage specification, including the language and (if present) the '{'.
SourceRange getSourceRange() const LLVM_READONLY
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
A little helper class used to produce diagnostics.
A class for parsing a declarator.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear...
void SetRangeStart(SourceLocation Loc)
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
SourceRange getRange() const
TST getTypeSpecType() const
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
Expr - This represents one expression.
static bool IsBuiltInOrStandardCXX11Attribute(IdentifierInfo *AttrName, IdentifierInfo *ScopeName)
Represents a character-granular source range.
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
const FunctionProtoType * T
bool isKnownToGCC() const
This file defines the classes used to store parsed information about declaration-specifiers and decla...
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
Specifier getLastSpecifier() const
TypeResult ActOnTypeName(Scope *S, Declarator &D)
void RevertCachedTokens(unsigned N)
When backtracking is enabled and tokens are cached, this allows to revert a specific number of tokens...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
SourceLocation getVolatileSpecLoc() const
OpaquePtr< TemplateName > TemplateTy
Defines an enumeration for C++ overloaded operators.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
void setAsmLabel(Expr *E)
SourceLocation getBeginLoc() const
Decl * ActOnFinishExportDecl(Scope *S, Decl *ExportDecl, SourceLocation RBraceLoc)
Complete the definition of an export declaration.
Represents a C++ template name within the type system.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
CachedTokens * ExceptionSpecTokens
Pointer to the cached tokens for an exception-specification that has not yet been parsed...
TemplateNameKind
Specifies the kind of template name that an identifier refers to.
InClassInitStyle
In-class initialization styles for non-static data members.
SourceLocation getOpenLocation() const
ParsedType getInheritingConstructorName(CXXScopeSpec &SS, SourceLocation NameLoc, IdentifierInfo &Name)
Handle the result of the special case name lookup for inheriting constructor declarations.
bool isFriendSpecified() const
The result type of a method or function.
bool isCXX11Attribute() const
void CodeCompleteNamespaceDecl(Scope *S)
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
const LangOptions & getLangOpts() const
A class for parsing a DeclSpec.
Represents a C++ Modules TS module export declaration.
ExprResult ActOnDecltypeExpression(Expr *E)
Process the expression contained within a decltype.
const AttributeList * getAttributes() const
bool isArrayOfUnknownBound() const
isArrayOfUnknownBound - This method returns true if the declarator is a declarator for an array of un...
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
SCS getStorageClassSpec() const
ASTContext & getASTContext() const
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
Encodes a location in the source.
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
void setLength(unsigned Len)
TagDecl - Represents the declaration of a struct/union/class/enum.
static const TST TST_union
IdentifierInfo * getIdentifierInfo() const
void setAnnotationEndLoc(SourceLocation L)
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them...
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Direct list-initialization.
Represents a C++11 virt-specifier-seq.
Decl * ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc, SourceLocation LBraceLoc)
We have parsed the start of an export declaration, including the '{' (if present).
FunctionDefinitionKind
Described the kind of function definition (if any) provided for a function.
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, SourceLocation UsingLoc, SourceLocation TypenameLoc, CXXScopeSpec &SS, UnqualifiedId &Name, SourceLocation EllipsisLoc, AttributeList *AttrList)
Scope * getCurScope() const
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
bool isInvalid() const
An error occurred during parsing of the scope specifier.
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, AttributeList *AttrList)
SourceLocation getModulePrivateSpecLoc() const
StringRef getName() const
Return the actual identifier string.
The scope of a struct/union/class definition.
bool isNot(tok::TokenKind K) const
bool isBacktrackEnabled() const
True if EnableBacktrackAtThisPos() was called and caching of tokens is on.
static const TST TST_decltype_auto
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
static const TST TST_decltype
const Scope * getParent() const
getParent - Return the scope that this is nested in.
static void diagnoseDynamicExceptionSpecification(Parser &P, SourceRange Range, bool IsNoexcept)
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
void CodeCompleteTag(Scope *S, unsigned TagSpec)
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
The name refers to a template whose specialization produces a type.
unsigned getLength() const
void CodeCompleteNamespaceAliasDecl(Scope *S)
void setLiteralData(const char *Ptr)
void CodeCompleteUsingDirective(Scope *S)
Syntax
The style used to specify an attribute.
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, AttributeList *AttrList, UsingDirectiveDecl *&UsingDecl)
ActOnStartNamespaceDef - This is called at the start of a namespace definition.
const TargetInfo & getTargetInfo() const
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void takeAttributesFrom(ParsedAttributes &attrs)
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
void setInvalid(bool b=true) const
static const TST TST_typename
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
ActionResult< ParsedType > TypeResult
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.
We are between inheritance colon and the real class/struct definition scope.
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
CXXScopeSpec & getTypeSpecScope()
AttributeList * addNew(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, AttributeList::Syntax syntax, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
This is a scope that can contain a declaration.
unsigned getMaxArgs() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
SourceLocation getIdentifierLoc() const
bool isSet() const
Deprecated.
void getCXX11AttributeRanges(SmallVectorImpl< SourceRange > &Ranges)
Return a source range list of C++11 attributes associated with the declarator.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
Captures information about "declaration specifiers".
SourceLocation getRestrictSpecLoc() const
void setEnd(SourceLocation e)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
A template-id, e.g., f<int>.
SourceLocation getFirstLocation() const
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
void ExtendWithDeclSpec(const DeclSpec &DS)
ExtendWithDeclSpec - Extend the declarator source range to include the given declspec, unless its location is invalid.
static OpaquePtr make(PtrTy P)
static const TST TST_struct
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
void setLocation(SourceLocation L)
A trivial tuple used to represent a source range.
NamedDecl - This represents a decl with a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
Expr * getRepAsExpr() const
Represents C++ using-directive.
unsigned NumArgs
NumArgs - The number of template arguments.
void SetRangeEnd(SourceLocation Loc)
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
void setCommaLoc(SourceLocation CL)
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
Attr - This represents one attribute.
SourceLocation getLocation() const
void startToken()
Reset all flags to cleared.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
AttributeList - Represents a syntactic attribute.
Stop skipping at specified token, but don't skip the token itself.