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);
84 ParseCXX11Attributes(attrs);
87 if (Tok.
is(tok::identifier)) {
90 while (Tok.
is(tok::coloncolon) &&
NextToken().
is(tok::identifier)) {
98 if (!ExtraNamespaceLoc.empty() && attrLoc.isValid())
99 Diag(attrLoc, diag::err_unexpected_nested_namespace_attribute);
102 if (Tok.
is(tok::kw___attribute)) {
104 ParseGNUAttributes(attrs);
107 if (Tok.
is(tok::equal)) {
109 Diag(Tok, diag::err_expected) << tok::identifier;
114 if (attrLoc.isValid())
115 Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
117 Diag(InlineLoc, diag::err_inline_namespace_alias)
119 Decl *NSAlias = ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd);
124 if (T.consumeOpen()) {
126 Diag(Tok, diag::err_expected) << tok::l_brace;
128 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
135 Diag(T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
140 if (ExtraIdent.empty()) {
142 }
else if (InlineLoc.
isValid()) {
143 Diag(InlineLoc, diag::err_inline_nested_namespace_definition);
145 Diag(ExtraNamespaceLoc[0],
146 diag::warn_cxx14_compat_nested_namespace_definition);
148 TentativeParsingAction TPA(*
this);
150 Token rBraceToken = Tok;
153 if (!rBraceToken.
is(tok::r_brace)) {
154 Diag(ExtraNamespaceLoc[0], diag::ext_nested_namespace_definition)
155 <<
SourceRange(ExtraNamespaceLoc.front(), ExtraIdentLoc.back());
157 std::string NamespaceFix;
159 E = ExtraIdent.end();
I !=
E; ++
I) {
160 NamespaceFix +=
" { namespace ";
161 NamespaceFix += (*I)->getName();
165 for (
unsigned i = 0, e = ExtraIdent.size(); i != e; ++i)
168 Diag(ExtraNamespaceLoc[0], diag::ext_nested_namespace_definition)
170 ExtraIdentLoc.back()),
179 diag::warn_cxx98_compat_inline_namespace : diag::ext_inline_namespace);
187 IdentLoc, Ident, T.getOpenLocation(),
188 attrs.getList(), ImplicitUsingDirectiveDecl);
191 "parsing namespace");
195 ParseInnerNamespace(ExtraIdentLoc, ExtraIdent, ExtraNamespaceLoc, 0,
196 InlineLoc, attrs, T);
199 NamespaceScope.Exit();
201 DeclEnd = T.getCloseLocation();
205 ImplicitUsingDirectiveDecl);
209 void Parser::ParseInnerNamespace(std::vector<SourceLocation> &IdentLoc,
210 std::vector<IdentifierInfo *> &Ident,
211 std::vector<SourceLocation> &NamespaceLoc,
215 if (index == Ident.size()) {
216 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
218 ParsedAttributesWithRange attrs(AttrFactory);
219 MaybeParseCXX11Attributes(attrs);
220 MaybeParseMicrosoftAttributes(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);
273 Diag(Tok, diag::err_expected_namespace_name);
285 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name))
289 Alias, SS, IdentLoc, Ident);
300 assert(isTokenStringLiteral() &&
"Not a string literal!");
301 ExprResult Lang = ParseStringLiteralExpression(
false);
311 ParsedAttributesWithRange attrs(AttrFactory);
312 MaybeParseCXX11Attributes(attrs);
313 MaybeParseMicrosoftAttributes(attrs);
315 if (Tok.
isNot(tok::l_brace)) {
322 ParseExternalDeclaration(attrs, &DS);
330 ProhibitAttributes(attrs);
335 unsigned NestedModules = 0;
338 case tok::annot_module_begin:
343 case tok::annot_module_end:
350 case tok::annot_module_include:
362 ParsedAttributesWithRange attrs(AttrFactory);
363 MaybeParseCXX11Attributes(attrs);
364 MaybeParseMicrosoftAttributes(attrs);
365 ParseExternalDeclaration(attrs);
380 Decl *Parser::ParseUsingDirectiveOrDeclaration(
unsigned Context,
381 const ParsedTemplateInfo &TemplateInfo,
383 ParsedAttributesWithRange &attrs,
385 assert(Tok.
is(tok::kw_using) &&
"Not using token");
391 if (Tok.
is(tok::code_completion)) {
398 if (Tok.
is(tok::kw_namespace)) {
400 if (TemplateInfo.Kind) {
402 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
406 return ParseUsingDirective(Context, UsingLoc, DeclEnd, attrs);
412 ProhibitAttributes(attrs);
414 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd,
428 Decl *Parser::ParseUsingDirective(
unsigned Context,
432 assert(Tok.
is(tok::kw_namespace) &&
"Not 'namespace' token");
437 if (Tok.
is(tok::code_completion)) {
445 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false);
452 Diag(Tok, diag::err_expected_namespace_name);
464 bool GNUAttr =
false;
465 if (Tok.
is(tok::kw___attribute)) {
467 ParseGNUAttributes(attrs);
472 if (ExpectAndConsume(tok::semi,
473 GNUAttr ? diag::err_expected_semi_after_attribute_list
474 : diag::err_expected_semi_after_namespace_name))
478 IdentLoc, NamespcName, attrs.
getList());
492 Decl *Parser::ParseUsingDeclaration(
unsigned Context,
493 const ParsedTemplateInfo &TemplateInfo,
500 bool HasTypenameKeyword =
false;
504 ParsedAttributesWithRange MisplacedAttrs(AttrFactory);
505 MaybeParseCXX11Attributes(MisplacedAttrs);
510 HasTypenameKeyword =
true;
512 if (Tok.
is(tok::kw___super)) {
520 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false,
555 !(Tok.
is(tok::identifier) &&
557 nullptr, TemplateKWLoc, Name)) {
562 ParsedAttributesWithRange Attrs(AttrFactory);
563 MaybeParseGNUAttributes(Attrs);
564 MaybeParseCXX11Attributes(Attrs);
568 bool IsAliasDecl = Tok.
is(tok::equal);
569 Decl *DeclFromDeclSpec =
nullptr;
573 if (MisplacedAttrs.Range.isValid()) {
574 Diag(MisplacedAttrs.Range.getBegin(), diag::err_attributes_not_allowed)
579 Attrs.takeAllFrom(MisplacedAttrs);
585 diag::warn_cxx98_compat_alias_declaration :
586 diag::ext_alias_declaration);
590 if (TemplateInfo.Kind == ParsedTemplateInfo::Template &&
593 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization)
595 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
597 if (SpecKind != -1) {
603 Range = TemplateInfo.getSourceRange();
604 Diag(Range.
getBegin(), diag::err_alias_declaration_specialization)
605 << SpecKind << Range;
616 }
else if (HasTypenameKeyword)
617 Diag(TypenameLoc, diag::err_alias_declaration_not_identifier)
627 AS, &DeclFromDeclSpec, &Attrs);
629 *OwnedType = DeclFromDeclSpec;
633 ProhibitAttributes(MisplacedAttrs);
634 ProhibitAttributes(Attrs);
637 MaybeParseGNUAttributes(Attrs);
642 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
643 !Attrs.empty() ?
"attributes list"
644 : IsAliasDecl ?
"alias declaration"
645 :
"using declaration"))
651 if (TemplateInfo.Kind && !IsAliasDecl) {
653 Diag(UsingLoc, diag::err_templated_using_directive_declaration)
668 HasTypenameKeyword =
false;
674 TemplateParams ? TemplateParams->data() :
nullptr,
675 TemplateParams ? TemplateParams->size() : 0);
677 UsingLoc, Name, Attrs.getList(),
683 SS, Name, Attrs.getList(),
684 HasTypenameKeyword, TypenameLoc);
696 assert(Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
697 "Not a static_assert declaration");
700 Diag(Tok, diag::ext_c11_static_assert);
701 if (Tok.
is(tok::kw_static_assert))
702 Diag(Tok, diag::warn_cxx98_compat_static_assert);
707 if (T.consumeOpen()) {
708 Diag(Tok, diag::err_expected) << tok::l_paren;
714 if (AssertExpr.isInvalid()) {
720 if (Tok.
is(tok::r_paren)) {
722 ? diag::warn_cxx14_compat_static_assert_no_message
723 : diag::ext_static_assert_no_message)
726 :
FixItHint::CreateInsertion(Tok.getLocation(),
", \"\""));
728 if (ExpectAndConsume(tok::comma)) {
733 if (!isTokenStringLiteral()) {
734 Diag(Tok, diag::err_expected_string_literal)
740 AssertMessage = ParseStringLiteralExpression();
750 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert);
755 T.getCloseLocation());
764 assert(Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)
765 &&
"Not a decltype specifier");
771 if (Tok.
is(tok::annot_decltype)) {
772 Result = getExprAnnotation(Tok);
775 if (Result.isInvalid()) {
781 Diag(Tok, diag::warn_cxx98_compat_decltype);
786 if (T.expectAndConsume(diag::err_expected_lparen_after,
787 "decltype", tok::r_paren)) {
790 StartLoc : T.getOpenLocation();
794 if (Tok.
is(tok::kw_auto)) {
800 ? diag::warn_cxx11_compat_decltype_auto_type_specifier
801 : diag::ext_decltype_auto_type_specifier);
814 if (Result.isInvalid()) {
817 EndLoc = ConsumeParen();
823 EndLoc = ConsumeAnyToken();
824 assert(Tok.
is(tok::semi));
837 if (T.getCloseLocation().isInvalid()) {
841 return T.getCloseLocation();
844 if (Result.isInvalid()) {
846 return T.getCloseLocation();
849 EndLoc = T.getCloseLocation();
851 assert(!Result.isInvalid());
853 const char *PrevSpec =
nullptr;
859 DiagID, Result.get(), Policy)
862 Diag(StartLoc, DiagID) << PrevSpec;
868 void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec& DS,
877 Tok.
setKind(tok::annot_decltype);
878 setExprAnnotation(Tok,
887 void Parser::ParseUnderlyingTypeSpecifier(
DeclSpec &DS) {
888 assert(Tok.
is(tok::kw___underlying_type) &&
889 "Not an underlying type specifier");
893 if (T.expectAndConsume(diag::err_expected_lparen_after,
894 "__underlying_type", tok::r_paren)) {
906 if (T.getCloseLocation().isInvalid())
909 const char *PrevSpec =
nullptr;
912 DiagID, Result.
get(),
914 Diag(StartLoc, DiagID) << PrevSpec;
939 if (Tok.
is(tok::kw_typename)) {
940 Diag(Tok, diag::err_expected_class_name_not_template)
947 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false);
954 if (Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
961 EndLocation = ParseDecltypeSpecifier(DS);
968 if (Tok.
is(tok::annot_template_id)) {
972 AnnotateTemplateIdTokenAsType();
974 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
987 if (Tok.
isNot(tok::identifier)) {
988 Diag(Tok, diag::err_expected_class_name);
995 if (Tok.
is(tok::less)) {
1001 &SS, Template, TNK)) {
1002 Diag(IdLoc, diag::err_unknown_template_name)
1007 TemplateArgList TemplateArgs;
1009 ParseTemplateIdAfterTemplateName(
nullptr, IdLoc, SS,
true, LAngleLoc,
1010 TemplateArgs, RAngleLoc);
1020 TemplateName,
true))
1023 AnnotateTemplateIdTokenAsType();
1027 if (Tok.
isNot(tok::annot_typename))
1043 true, &CorrectedII);
1045 Diag(IdLoc, diag::err_expected_class_name);
1050 EndLocation = IdLoc;
1058 const char *PrevSpec =
nullptr;
1067 void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1068 while (Tok.
isOneOf(tok::kw___single_inheritance,
1069 tok::kw___multiple_inheritance,
1070 tok::kw___virtual_inheritance)) {
1073 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1081 bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1089 case tok::identifier:
1091 case tok::annot_cxxscope:
1092 case tok::annot_typename:
1093 case tok::annot_template_id:
1096 case tok::kw_operator:
1097 case tok::kw___declspec:
1102 case tok::kw___attribute:
1103 case tok::annot_pragma_pack:
1105 case tok::annot_pragma_ms_pragma:
1107 case tok::annot_pragma_ms_vtordisp:
1109 case tok::annot_pragma_ms_pointers_to_members:
1112 return CouldBeBitfield;
1114 case tok::kw___cdecl:
1115 case tok::kw___fastcall:
1116 case tok::kw___stdcall:
1117 case tok::kw___thiscall:
1118 case tok::kw___vectorcall:
1124 case tok::kw_volatile:
1125 case tok::kw_restrict:
1126 case tok::kw__Atomic:
1127 case tok::kw___unaligned:
1131 case tok::kw_inline:
1132 case tok::kw_virtual:
1133 case tok::kw_friend:
1135 case tok::kw_static:
1136 case tok::kw_extern:
1137 case tok::kw_typedef:
1138 case tok::kw_register:
1140 case tok::kw_mutable:
1141 case tok::kw_thread_local:
1142 case tok::kw_constexpr:
1158 if (!isKnownToBeTypeSpecifier(
NextToken()))
1215 const ParsedTemplateInfo &TemplateInfo,
1217 bool EnteringContext, DeclSpecContext DSC,
1218 ParsedAttributesWithRange &Attributes) {
1220 if (TagTokKind == tok::kw_struct)
1222 else if (TagTokKind == tok::kw___interface)
1224 else if (TagTokKind == tok::kw_class)
1227 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1231 if (Tok.
is(tok::code_completion)) {
1234 return cutOffParsing();
1247 bool shouldDelayDiagsInTag =
1248 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
1249 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
1252 ParsedAttributesWithRange attrs(AttrFactory);
1254 MaybeParseGNUAttributes(attrs);
1255 MaybeParseMicrosoftDeclSpecs(attrs);
1258 if (Tok.
isOneOf(tok::kw___single_inheritance,
1259 tok::kw___multiple_inheritance,
1260 tok::kw___virtual_inheritance))
1261 ParseMicrosoftInheritanceClassAttributes(attrs);
1266 MaybeParseCXX11Attributes(attrs);
1273 Tok.
isNot(tok::identifier) &&
1276 Tok.
isOneOf(tok::kw___is_abstract,
1277 tok::kw___is_arithmetic,
1279 tok::kw___is_assignable,
1280 tok::kw___is_base_of,
1282 tok::kw___is_complete_type,
1283 tok::kw___is_compound,
1285 tok::kw___is_constructible,
1286 tok::kw___is_convertible,
1287 tok::kw___is_convertible_to,
1288 tok::kw___is_destructible,
1291 tok::kw___is_floating_point,
1293 tok::kw___is_function,
1294 tok::kw___is_fundamental,
1295 tok::kw___is_integral,
1296 tok::kw___is_interface_class,
1297 tok::kw___is_literal,
1298 tok::kw___is_lvalue_expr,
1299 tok::kw___is_lvalue_reference,
1300 tok::kw___is_member_function_pointer,
1301 tok::kw___is_member_object_pointer,
1302 tok::kw___is_member_pointer,
1303 tok::kw___is_nothrow_assignable,
1304 tok::kw___is_nothrow_constructible,
1305 tok::kw___is_nothrow_destructible,
1306 tok::kw___is_object,
1308 tok::kw___is_pointer,
1309 tok::kw___is_polymorphic,
1310 tok::kw___is_reference,
1311 tok::kw___is_rvalue_expr,
1312 tok::kw___is_rvalue_reference,
1314 tok::kw___is_scalar,
1315 tok::kw___is_sealed,
1316 tok::kw___is_signed,
1317 tok::kw___is_standard_layout,
1318 tok::kw___is_trivial,
1319 tok::kw___is_trivially_assignable,
1320 tok::kw___is_trivially_constructible,
1321 tok::kw___is_trivially_copyable,
1323 tok::kw___is_unsigned,
1325 tok::kw___is_volatile))
1331 TryKeywordIdentFallback(
true);
1333 struct PreserveAtomicIdentifierInfoRAII {
1334 PreserveAtomicIdentifierInfoRAII(
Token &Tok,
bool Enabled)
1335 : AtomicII(nullptr) {
1338 assert(Tok.
is(tok::kw__Atomic));
1343 ~PreserveAtomicIdentifierInfoRAII() {
1346 AtomicII->revertIdentifierToTokenID(tok::kw__Atomic);
1356 bool ShouldChangeAtomicToIdentifier =
getLangOpts().MSVCCompat &&
1357 Tok.
is(tok::kw__Atomic) &&
1359 PreserveAtomicIdentifierInfoRAII AtomicTokenGuard(
1360 Tok, ShouldChangeAtomicToIdentifier);
1370 bool HasValidSpec =
true;
1371 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr, EnteringContext)) {
1373 HasValidSpec =
false;
1376 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::annot_template_id)) {
1377 Diag(Tok, diag::err_expected) << tok::identifier;
1378 HasValidSpec =
false;
1390 if (Tok.
is(tok::identifier)) {
1398 TemplateArgList TemplateArgs;
1400 if (ParseTemplateIdAfterTemplateName(
1401 nullptr, NameLoc, SS,
true, LAngleLoc, TemplateArgs, RAngleLoc)) {
1407 Diag(NameLoc, diag::err_explicit_spec_non_template)
1408 << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
1409 << TagTokKind << Name <<
SourceRange(LAngleLoc, RAngleLoc);
1413 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1414 if (TemplateParams->size() > 1) {
1415 TemplateParams->pop_back();
1417 TemplateParams =
nullptr;
1418 const_cast<ParsedTemplateInfo&
>(TemplateInfo).
Kind
1419 = ParsedTemplateInfo::NonTemplate;
1421 }
else if (TemplateInfo.Kind
1422 == ParsedTemplateInfo::ExplicitInstantiation) {
1424 TemplateParams =
nullptr;
1425 const_cast<ParsedTemplateInfo&
>(TemplateInfo).
Kind
1426 = ParsedTemplateInfo::NonTemplate;
1427 const_cast<ParsedTemplateInfo&
>(TemplateInfo).TemplateLoc
1429 const_cast<ParsedTemplateInfo&
>(TemplateInfo).ExternLoc
1433 }
else if (Tok.
is(tok::annot_template_id)) {
1434 TemplateId = takeTemplateIdAnnotation(Tok);
1447 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1448 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1482 MaybeParseCXX11Attributes(Attributes);
1486 if (DSC == DSC_trailing)
1488 else if (Tok.
is(tok::l_brace) ||
1490 (isCXX11FinalKeyword() &&
1506 }
else if (isCXX11FinalKeyword() && (
NextToken().is(tok::l_square) ||
1510 TentativeParsingAction PA(*
this);
1517 if (Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square)) {
1521 }
else if (Tok.
is(tok::kw_alignas) &&
NextToken().
is(tok::l_paren)) {
1531 if (Tok.
isOneOf(tok::l_brace, tok::colon))
1537 }
else if (!isTypeSpecifier(DSC) &&
1538 (Tok.
is(tok::semi) ||
1541 if (Tok.
isNot(tok::semi)) {
1544 ExpectAndConsume(tok::semi, diag::err_expected_after,
1562 Diag(AttrRange.
getBegin(), diag::err_attributes_not_allowed)
1576 if (shouldDelayDiagsInTag) {
1577 diagsFromTag.done();
1579 diagsFromTag.redelay();
1586 Diag(StartLoc, diag::err_anon_type_definition)
1611 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
1614 ProhibitAttributes(attrs);
1618 TemplateInfo.ExternLoc,
1619 TemplateInfo.TemplateLoc,
1636 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
1637 ProhibitAttributes(attrs);
1650 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1663 "Expected a definition here");
1667 TemplateParams =
nullptr;
1672 diag::err_explicit_instantiation_with_definition)
1681 LAngleLoc,
nullptr));
1682 TemplateParams = &FakedParamLists;
1692 TemplateParams ? TemplateParams->size() : 0),
1695 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
1702 ProhibitAttributes(attrs);
1706 TemplateInfo.ExternLoc,
1707 TemplateInfo.TemplateLoc,
1708 TagType, StartLoc, SS, Name,
1711 TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
1712 ProhibitAttributes(attrs);
1716 TagType, StartLoc, SS,
1719 TemplateParams? &(*TemplateParams)[0]
1721 TemplateParams? TemplateParams->size() : 0));
1724 ProhibitAttributes(attrs);
1727 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1730 Diag(Tok, diag::err_template_defn_explicit_instantiation)
1732 TemplateParams =
nullptr;
1735 bool IsDependent =
false;
1745 handleDeclspecAlignBeforeClassKey(attrs, DS, TUK);
1749 SS, Name, NameLoc, attrs.
getList(), AS,
1751 TParams, Owned, IsDependent,
1754 DSC == DSC_type_specifier,
1762 SS, Name, StartLoc, NameLoc);
1768 assert(Tok.
is(tok::l_brace) ||
1770 isCXX11FinalKeyword());
1772 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc, TagType,
1773 TagOrTempResult.
get());
1775 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs, TagType,
1776 TagOrTempResult.
get());
1778 ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.
get());
1781 const char *PrevSpec =
nullptr;
1786 NameLoc.isValid() ? NameLoc : StartLoc,
1787 PrevSpec, DiagID, TypeResult.
get(), Policy);
1788 }
else if (!TagOrTempResult.
isInvalid()) {
1790 NameLoc.isValid() ? NameLoc : StartLoc,
1791 PrevSpec, DiagID, TagOrTempResult.
get(), Owned,
1799 Diag(StartLoc, DiagID) << PrevSpec;
1815 (TemplateInfo.Kind || !isValidAfterTypeSpecifier(
false))) {
1816 if (Tok.
isNot(tok::semi)) {
1818 ExpectAndConsume(tok::semi, diag::err_expected_after,
1836 void Parser::ParseBaseClause(
Decl *ClassDecl) {
1837 assert(Tok.
is(tok::colon) &&
"Not a base clause");
1845 BaseResult Result = ParseBaseSpecifier(ClassDecl);
1852 BaseInfo.push_back(Result.
get());
1877 bool IsVirtual =
false;
1880 ParsedAttributesWithRange Attributes(AttrFactory);
1881 MaybeParseCXX11Attributes(Attributes);
1887 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
1894 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
1898 if (Tok.
is(tok::kw_virtual)) {
1902 Diag(VirtualLoc, diag::err_dup_virtual)
1909 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
1923 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
1939 Access, BaseType.
get(), BaseLoc,
1963 void Parser::HandleMemberFunctionDeclDelays(
Declarator& DeclaratorInfo,
1971 if (!NeedLateParse) {
1973 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx) {
1974 auto Param = cast<ParmVarDecl>(FTI.
Params[ParamIdx].
Param);
1975 if (Param->hasUnparsedDefaultArg()) {
1976 NeedLateParse =
true;
1982 if (NeedLateParse) {
1985 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
1986 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
1995 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
1996 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx)
1997 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
2022 if (II == Ident_override)
2025 if (II == Ident_sealed)
2028 if (II == Ident_final)
2039 void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
2058 const char *PrevSpec =
nullptr;
2073 ? diag::warn_cxx98_compat_override_control_keyword
2074 : diag::ext_override_control_keyword)
2083 bool Parser::isCXX11FinalKeyword()
const {
2091 bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2093 LateParsedAttrList &LateParsedAttrs) {
2098 if (Tok.
isNot(tok::colon))
2099 ParseDeclarator(DeclaratorInfo);
2105 "don't know where identifier would go yet?");
2107 if (BitfieldSize.isInvalid())
2110 ParseOptionalCXX11VirtSpecifierSeq(
2111 VS, getCurrentClass().IsInterface,
2114 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo, VS);
2118 if (Tok.
is(tok::kw_asm)) {
2120 ExprResult AsmLabel(ParseSimpleAsm(&Loc));
2121 if (AsmLabel.isInvalid())
2129 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2133 if (BitfieldSize.isUnset() && VS.
isUnset()) {
2134 ParseOptionalCXX11VirtSpecifierSeq(
2135 VS, getCurrentClass().IsInterface,
2143 Diag(Attr->
getLoc(), diag::warn_gcc_attribute_location);
2146 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo, VS);
2152 if (!DeclaratorInfo.
hasName() && BitfieldSize.isUnset()) {
2162 void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2169 ParseTypeQualifierListOpt(DS, AR_NoAttributesParsed,
false);
2176 const char *FixItName,
2178 unsigned* QualifierLoc) {
2181 if (!(
Function.TypeQuals & TypeQual)) {
2182 std::string
Name(FixItName);
2186 *QualifierLoc = SpecLoc.getRawEncoding();
2188 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2204 bool RefQualifierIsLValueRef =
true;
2206 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2207 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2209 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2212 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2213 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2261 const ParsedTemplateInfo &TemplateInfo,
2263 if (Tok.
is(tok::at)) {
2265 Diag(Tok, diag::err_at_defs_cxx);
2267 Diag(Tok, diag::err_at_in_class);
2283 bool MalformedTypeSpec =
false;
2284 if (!TemplateInfo.Kind &&
2285 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2287 MalformedTypeSpec =
true;
2290 if (Tok.
isNot(tok::annot_cxxscope))
2291 isAccessDecl =
false;
2293 isAccessDecl = GetLookAheadToken(2).
is(tok::semi);
2300 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
2318 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2319 "access declaration")) {
2334 if (!TemplateInfo.Kind &&
2335 Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2341 if (Tok.
is(tok::kw_template)) {
2342 assert(!TemplateInfo.TemplateParams &&
2343 "Nested template improperly parsed?");
2351 if (Tok.
is(tok::kw___extension__)) {
2355 return ParseCXXClassMemberDeclaration(AS, AccessAttrs,
2356 TemplateInfo, TemplateDiags);
2359 ParsedAttributesWithRange attrs(AttrFactory);
2360 ParsedAttributesWithRange FnAttrs(AttrFactory);
2362 MaybeParseCXX11Attributes(attrs);
2365 FnAttrs.addAll(attrs.
getList());
2366 FnAttrs.Range = attrs.Range;
2368 MaybeParseMicrosoftAttributes(attrs);
2370 if (Tok.
is(tok::kw_using)) {
2371 ProhibitAttributes(attrs);
2376 if (Tok.
is(tok::kw_namespace)) {
2377 Diag(UsingLoc, diag::err_using_namespace_in_class);
2388 LateParsedAttrList CommonLateParsedAttrs;
2394 if (MalformedTypeSpec)
2397 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC_class,
2398 &CommonLateParsedAttrs);
2406 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate &&
2407 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DSC_class,
2408 &CommonLateParsedAttrs))
2412 TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->data()
2414 TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->size() : 0);
2418 ProhibitAttributes(FnAttrs);
2422 getCurScope(), AS, DS, TemplateParams,
false, AnonRecord);
2423 DS.complete(TheDecl);
2425 Decl* decls[] = {AnonRecord, TheDecl};
2435 LateParsedAttrList LateParsedAttrs;
2440 auto TryConsumePureSpecifier = [&] (
bool AllowDefinition) {
2441 if (Tok.
isNot(tok::equal))
2446 if (Zero.isNot(tok::numeric_constant) || Zero.getLength() != 1 ||
2450 auto &
After = GetLookAheadToken(2);
2451 if (!
After.isOneOf(tok::semi, tok::comma) &&
2452 !(AllowDefinition &&
2453 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
2462 ExprResult BitfieldSize;
2463 bool ExpectSemi =
true;
2466 if (ParseCXXMemberDeclaratorBeforeInitializer(
2467 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
2477 TryConsumePureSpecifier(
true);
2488 if (Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
2490 }
else if (Tok.
is(tok::equal)) {
2492 if (KW.
is(tok::kw_default))
2494 else if (KW.
is(tok::kw_delete))
2506 ProhibitAttributes(FnAttrs);
2523 diag::err_function_declared_typedef);
2530 ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo, TemplateInfo,
2534 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
2535 CommonLateParsedAttrs[i]->addDecl(FunDecl);
2537 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
2538 LateParsedAttrs[i]->addDecl(FunDecl);
2541 LateParsedAttrs.clear();
2544 if (Tok.
is(tok::semi))
2545 ConsumeExtraSemi(AfterMemberFunctionDefinition);
2557 bool HasStaticInitializer =
false;
2559 if (BitfieldSize.
get()) {
2560 Diag(Tok, diag::err_bitfield_member_init);
2564 if (!TryConsumePureSpecifier(
false))
2566 HasStaticInitializer =
true;
2575 HasStaticInitializer =
true;
2593 E = Ranges.end();
I !=
E; ++
I)
2594 Diag((*I).getBegin(), diag::err_attributes_not_allowed) << *
I;
2603 VS, HasInClassInit);
2606 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
2609 ThisDecl = VT->getTemplatedDecl();
2611 if (ThisDecl && AccessAttrs)
2621 HasStaticInitializer =
true;
2624 if (ThisDecl && PureSpecLoc.
isValid())
2631 ? diag::warn_cxx98_compat_nonstatic_member_init
2632 : diag::ext_nonstatic_member_init);
2640 Diag(Tok, diag::err_incomplete_array_member_init);
2645 ThisDecl->setInvalidDecl();
2647 ParseCXXNonStaticMemberInitializer(ThisDecl);
2648 }
else if (HasStaticInitializer) {
2650 ExprResult Init = ParseCXXMemberInitializer(
2663 if (!ThisDecl->isInvalidDecl()) {
2665 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
2666 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
2668 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
2669 LateParsedAttrs[i]->addDecl(ThisDecl);
2672 DeclsInGroup.push_back(ThisDecl);
2677 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
2679 LateParsedAttrs.clear();
2681 DeclaratorInfo.complete(ThisDecl);
2694 Diag(CommaLoc, diag::err_expected_semi_declaration)
2701 DeclaratorInfo.
clear();
2708 MaybeParseGNUAttributes(DeclaratorInfo);
2710 if (ParseCXXMemberDeclaratorBeforeInitializer(
2711 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
2716 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
2747 ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
2749 assert(Tok.
isOneOf(tok::equal, tok::l_brace)
2750 &&
"Data member initializer not starting with '=' or '{'");
2756 if (Tok.
is(tok::kw_delete)) {
2771 }
else if (Tok.
is(tok::kw_default)) {
2773 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
2780 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
2781 Diag(Tok, diag::err_ms_property_initializer) << PD;
2784 return ParseInitializer();
2787 void Parser::SkipCXXMemberSpecification(
SourceLocation RecordLoc,
2792 assert(isCXX11FinalKeyword() &&
"not a class definition");
2797 ParsedAttributesWithRange Attrs(AttrFactory);
2798 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
2803 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_brace))
2810 if (Tok.
is(tok::colon)) {
2813 ParsingClassDefinition ParsingDef(*
this, TagDecl,
true,
2819 ParseBaseClause(
nullptr);
2823 if (!Tok.
is(tok::l_brace)) {
2825 diag::err_expected_lbrace_after_base_specifiers);
2831 assert(Tok.
is(tok::l_brace));
2838 if (Tok.
is(tok::kw___attribute))
2839 MaybeParseGNUAttributes(Attrs);
2846 Tok.
isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
2847 ParseMicrosoftIfExistsClassDeclaration(TagType, AS);
2852 if (Tok.
is(tok::semi)) {
2853 ConsumeExtraSemi(InsideStruct, TagType);
2857 if (Tok.
is(tok::annot_pragma_vis)) {
2858 HandlePragmaVisibility();
2862 if (Tok.
is(tok::annot_pragma_pack)) {
2867 if (Tok.
is(tok::annot_pragma_align)) {
2868 HandlePragmaAlign();
2872 if (Tok.
is(tok::annot_pragma_ms_pointers_to_members)) {
2873 HandlePragmaMSPointersToMembers();
2877 if (Tok.
is(tok::annot_pragma_ms_pragma)) {
2878 HandlePragmaMSPragma();
2882 if (Tok.
is(tok::annot_pragma_ms_vtordisp)) {
2883 HandlePragmaMSVtorDisp();
2888 if (Tok.
is(tok::kw_namespace)) {
2889 DiagnoseUnexpectedNamespace(cast<NamedDecl>(TagDecl));
2900 AccessAttrs.clear();
2901 MaybeParseGNUAttributes(AccessAttrs);
2906 Diag(EndLoc, diag::err_expected)
2910 Diag(EndLoc, diag::err_expected)
2921 AccessAttrs.getList())) {
2923 AccessAttrs.clear();
2929 if (Tok.
is(tok::annot_pragma_openmp))
2930 return ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, AccessAttrs, TagType,
2934 return ParseCXXClassMemberDeclaration(AS, AccessAttrs.getList());
2943 void Parser::ParseCXXMemberSpecification(
SourceLocation RecordLoc,
2945 ParsedAttributesWithRange &Attrs,
2946 unsigned TagType,
Decl *TagDecl) {
2953 "parsing struct/union/class body");
2957 bool NonNestedClass =
true;
2958 if (!ClassStack.empty()) {
2960 if (
S->isClassScope()) {
2962 NonNestedClass =
false;
2965 if (getCurrentClass().IsInterface) {
2966 Diag(RecordLoc, diag::err_invalid_member_in_interface)
2968 << (isa<NamedDecl>(TagDecl)
2969 ? cast<NamedDecl>(TagDecl)->getQualifiedNameAsString()
2986 ParsingClassDefinition ParsingDef(*
this, TagDecl, NonNestedClass,
2993 bool IsFinalSpelledSealed =
false;
3000 "not a class definition");
3005 Diag(FinalLoc, diag::err_override_control_interface)
3009 ? diag::warn_cxx98_compat_override_control_keyword
3010 : diag::ext_override_control_keyword)
3013 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
3019 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
3028 if (!Tok.
is(tok::colon) && !Tok.
is(tok::l_brace)) {
3035 if (Tok.
is(tok::colon)) {
3036 ParseBaseClause(TagDecl);
3037 if (!Tok.
is(tok::l_brace)) {
3038 bool SuggestFixIt =
false;
3042 case tok::kw_private:
3043 case tok::kw_protected:
3044 case tok::kw_public:
3047 case tok::kw_static_assert:
3051 case tok::kw_template:
3052 SuggestFixIt =
true;
3054 case tok::identifier:
3055 SuggestFixIt = isConstructorDeclarator(
true);
3058 SuggestFixIt = isCXXSimpleDeclaration(
false);
3063 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
3077 assert(Tok.
is(tok::l_brace));
3083 IsFinalSpelledSealed,
3084 T.getOpenLocation());
3094 ParsedAttributesWithRange AccessAttrs(AttrFactory);
3098 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3101 ParseCXXClassMemberDeclarationWithPragmas(
3102 CurAS, AccessAttrs, static_cast<DeclSpec::TST>(TagType), TagDecl);
3111 MaybeParseGNUAttributes(attrs);
3115 T.getOpenLocation(),
3116 T.getCloseLocation(),
3124 if (TagDecl && NonNestedClass) {
3130 ParseLexedAttributes(getCurrentClass());
3131 ParseLexedMethodDeclarations(getCurrentClass());
3136 ParseLexedMemberInitializers(getCurrentClass());
3137 ParseLexedMethodDefs(getCurrentClass());
3138 PrevTokLocation = SavedPrevTokLocation;
3153 void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3154 assert(Tok.
is(tok::kw_namespace));
3158 Diag(D->getLocation(),
3159 diag::err_missing_end_of_definition) << D;
3161 diag::note_missing_end_of_definition_before) << D;
3195 void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3196 assert(Tok.
is(tok::colon) &&
3197 "Constructor initializer always starts with ':'");
3205 bool AnyErrors =
false;
3208 if (Tok.
is(tok::code_completion)) {
3211 return cutOffParsing();
3214 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3216 MemInitializers.push_back(MemInit.
get());
3220 if (Tok.
is(tok::comma))
3222 else if (Tok.
is(tok::l_brace))
3227 Tok.
isOneOf(tok::identifier, tok::coloncolon)) {
3229 Diag(Loc, diag::err_ctor_init_missing_comma)
3260 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
false);
3262 if (Tok.
is(tok::annot_template_id)) {
3266 AnnotateTemplateIdTokenAsType();
3267 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
3273 if (!TemplateTypeTy && Tok.
isNot(tok::identifier)
3274 && Tok.
isNot(tok::annot_decltype)) {
3275 Diag(Tok, diag::err_expected_member_or_base_name);
3282 if (Tok.
is(tok::annot_decltype)) {
3284 ParseDecltypeSpecifier(DS);
3286 if (Tok.
is(tok::identifier))
3296 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3298 ExprResult InitList = ParseBraceInitializer();
3306 TemplateTypeTy, DS, IdLoc,
3307 InitList.
get(), EllipsisLoc);
3308 }
else if(Tok.
is(tok::l_paren)) {
3313 ExprVector ArgExprs;
3314 CommaLocsTy CommaLocs;
3315 if (Tok.
isNot(tok::r_paren) && ParseExpressionList(ArgExprs, CommaLocs)) {
3326 TemplateTypeTy, DS, IdLoc,
3327 T.getOpenLocation(), ArgExprs,
3328 T.getCloseLocation(), EllipsisLoc);
3332 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
3334 return Diag(Tok, diag::err_expected) << tok::l_paren;
3347 Parser::tryParseExceptionSpecification(
bool Delayed,
3351 ExprResult &NoexceptExpr,
3354 ExceptionSpecTokens =
nullptr;
3358 if (Tok.
isNot(tok::kw_throw) && Tok.
isNot(tok::kw_noexcept))
3362 bool IsNoexcept = Tok.
is(tok::kw_noexcept);
3363 Token StartTok = Tok;
3367 if (!Tok.
is(tok::l_paren)) {
3370 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
3371 NoexceptExpr =
nullptr;
3375 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
3381 ExceptionSpecTokens->push_back(StartTok);
3382 ExceptionSpecTokens->push_back(Tok);
3383 SpecificationRange.
setEnd(ConsumeParen());
3385 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
3388 SpecificationRange.
setEnd(ExceptionSpecTokens->back().getLocation());
3394 if (Tok.
is(tok::kw_throw)) {
3395 Result = ParseDynamicExceptionSpecification(SpecificationRange,
3397 DynamicExceptionRanges);
3398 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
3399 "Produced different number of exception types and ranges.");
3403 if (Tok.
isNot(tok::kw_noexcept))
3406 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
3414 if (Tok.
is(tok::l_paren)) {
3427 NoexceptRange =
SourceRange(KeywordLoc, T.getCloseLocation());
3434 NoexceptRange =
SourceRange(KeywordLoc, KeywordLoc);
3438 SpecificationRange = NoexceptRange;
3439 Result = NoexceptType;
3443 if (Tok.
is(tok::kw_throw)) {
3444 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
3445 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
3446 DynamicExceptionRanges);
3449 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
3458 const char *
Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
3459 P.
Diag(Range.
getBegin(), diag::warn_exception_spec_deprecated) << Range;
3460 P.
Diag(Range.
getBegin(), diag::note_exception_spec_deprecated)
3480 assert(Tok.
is(tok::kw_throw) &&
"expected throw");
3484 if (T.consumeOpen()) {
3485 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
3492 if (Tok.
is(tok::ellipsis)) {
3495 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
3497 SpecificationRange.
setEnd(T.getCloseLocation());
3504 while (Tok.
isNot(tok::r_paren)) {
3507 if (Tok.
is(tok::ellipsis)) {
3513 if (!Res.isInvalid())
3517 if (!Res.isInvalid()) {
3518 Exceptions.push_back(Res.get());
3519 Ranges.push_back(Range);
3527 SpecificationRange.
setEnd(T.getCloseLocation());
3529 Exceptions.empty());
3535 TypeResult Parser::ParseTrailingReturnType(
SourceRange &Range) {
3536 assert(Tok.
is(tok::arrow) &&
"expected arrow");
3547 Parser::PushParsingClass(
Decl *ClassDecl,
bool NonNestedClass,
3549 assert((NonNestedClass || !ClassStack.empty()) &&
3550 "Nested class without outer class");
3551 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
3557 void Parser::DeallocateParsedClasses(Parser::ParsingClass *Class) {
3558 for (
unsigned I = 0, N = Class->LateParsedDeclarations.size();
I != N; ++
I)
3559 delete Class->LateParsedDeclarations[
I];
3570 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
3574 ParsingClass *Victim = ClassStack.top();
3576 if (Victim->TopLevelClass) {
3579 DeallocateParsedClasses(Victim);
3582 assert(!ClassStack.empty() &&
"Missing top-level class?");
3584 if (Victim->LateParsedDeclarations.empty()) {
3589 DeallocateParsedClasses(Victim);
3596 assert(
getCurScope()->isClassScope() &&
"Nested class outside of class scope?");
3597 ClassStack.top()->LateParsedDeclarations.push_back(
new LateParsedClass(
this, Victim));
3629 case tok::pipeequal:
3630 case tok::caretequal:
3632 case tok::exclaimequal:
3638 StringRef Spelling = PP.
getSpelling(SpellingLoc, SpellingBuf);
3651 case AttributeList::AT_CarriesDependency:
3652 case AttributeList::AT_Deprecated:
3653 case AttributeList::AT_FallThrough:
3654 case AttributeList::AT_CXX11NoReturn:
3656 case AttributeList::AT_WarnUnusedResult:
3657 return !ScopeName && AttrName->
getName().equals(
"nodiscard");
3658 case AttributeList::AT_Unused:
3659 return !ScopeName && AttrName->
getName().equals(
"maybe_unused");
3685 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
3698 if (ScopeName && ScopeName->
getName() ==
"gnu")
3701 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
3705 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
3717 Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
3723 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
3759 if (Tok.
is(tok::kw_alignas)) {
3761 ParseAlignmentSpecifier(attrs, endLoc);
3765 assert(Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square)
3766 &&
"Not a C++11 attribute list");
3775 if (Tok.
is(tok::kw_using)) {
3777 ? diag::warn_cxx14_compat_using_attribute_ns
3778 : diag::ext_using_attribute_ns);
3781 CommonScopeName = TryParseCXX11AttributeIdentifier(CommonScopeLoc);
3782 if (!CommonScopeName) {
3790 llvm::SmallDenseMap<IdentifierInfo*, SourceLocation, 4> SeenAttrs;
3792 while (Tok.
isNot(tok::r_square)) {
3800 AttrName = TryParseCXX11AttributeIdentifier(AttrLoc);
3807 ScopeName = AttrName;
3810 AttrName = TryParseCXX11AttributeIdentifier(AttrLoc);
3818 if (CommonScopeName) {
3820 Diag(ScopeLoc, diag::err_using_attribute_ns_conflict)
3823 ScopeName = CommonScopeName;
3824 ScopeLoc = CommonScopeLoc;
3829 bool AttrParsed =
false;
3832 !SeenAttrs.insert(std::make_pair(AttrName, AttrLoc)).second)
3833 Diag(AttrLoc, diag::err_cxx11_attribute_repeated)
3837 if (Tok.
is(tok::l_paren))
3838 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, attrs, endLoc,
3839 ScopeName, ScopeLoc);
3848 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis)
3852 if (ExpectAndConsume(tok::r_square))
3856 if (ExpectAndConsume(tok::r_square))
3864 void Parser::ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
3873 ParseCXX11AttributeSpecifier(attrs, endLoc);
3874 }
while (isCXX11AttributeSpecifier());
3879 void Parser::DiagnoseAndSkipCXX11Attributes() {
3886 Diag(StartLoc, diag::err_attributes_not_allowed)
3894 if (!isCXX11AttributeSpecifier())
3898 if (Tok.
is(tok::l_square)) {
3902 EndLoc = T.getCloseLocation();
3904 assert(Tok.
is(tok::kw_alignas) &&
"not an attribute specifier");
3907 if (!T.consumeOpen())
3909 EndLoc = T.getCloseLocation();
3911 }
while (isCXX11AttributeSpecifier());
3926 assert(Tok.
is(tok::l_square) &&
"Not a Microsoft attribute list");
3935 *endLoc = T.getCloseLocation();
3936 }
while (Tok.
is(tok::l_square));
3939 void Parser::ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
3941 IfExistsCondition
Result;
3942 if (ParseMicrosoftIfExistsCondition(Result))
3946 if (Braces.consumeOpen()) {
3947 Diag(Tok, diag::err_expected) << tok::l_brace;
3951 switch (Result.Behavior) {
3957 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
3958 << Result.IsIfExists;
3966 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
3968 if (Tok.
isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
3969 ParseMicrosoftIfExistsClassDeclaration((
DeclSpec::TST)TagType, CurAS);
3974 if (Tok.
is(tok::semi)) {
3975 ConsumeExtraSemi(InsideStruct, TagType);
3985 if (Tok.
is(tok::colon))
3988 Diag(Tok, diag::err_expected) << tok::colon;
3994 ParseCXXClassMemberDeclaration(CurAS,
nullptr);
3997 Braces.consumeClose();
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
SourceManager & getSourceManager() const
SourceLocation getCloseLocation() const
Defines the clang::ASTContext interface.
void setConstructorName(ParsedType ClassType, SourceLocation ClassNameLoc, SourceLocation EndLoc)
Specify that this unqualified-id was parsed as a constructor name.
IdKind getKind() const
Determine what kind of name we have.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
DeclResult ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, SourceLocation ModulePrivateLoc, TemplateIdAnnotation &TemplateId, AttributeList *Attr, MultiTemplateParamsArg TemplateParameterLists, SkipBodyInfo *SkipBody=nullptr)
no exception specification
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
SourceLocation getRestrictSpecLoc() const
void clear()
Reset the contents of this Declarator.
SourceLocation getConstSpecLoc() const
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace)
ActOnFinishNamespaceDef - This callback is called after a namespace is exited.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
const LangOptions & getLangOpts() const
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
bool isArrayOfUnknownBound() const
isArrayOfUnknownBound - This method returns true if the declarator is a declarator for an array of un...
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
CachedTokens * DefaultArgTokens
DefaultArgTokens - When the parameter's default argument cannot be parsed immediately (because it occ...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
static CharSourceRange getTokenRange(SourceRange R)
The name refers to a dependent template name.
ActionResult< Expr * > ExprResult
The current expression is potentially evaluated at run time, which means that code may be generated t...
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
void CodeCompleteConstructorInitializer(Decl *Constructor, ArrayRef< CXXCtorInitializer * > Initializers)
static LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
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.
SCS getStorageClassSpec() const
void ActOnBaseSpecifiers(Decl *ClassDecl, MutableArrayRef< CXXBaseSpecifier * > Bases)
ActOnBaseSpecifiers - Attach the given base specifiers to the class, after checking whether there are...
The base class of the type hierarchy.
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
This indicates that the scope corresponds to a function, which means that labels are set here...
std::unique_ptr< llvm::MemoryBuffer > Buffer
Declaration of a variable template.
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".
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.
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.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group, bool TypeMayContainAuto=true)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
void ActOnFinishCXXNonNestedClass(Decl *D)
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.
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
static const TST TST_interface
Like System, but searched after the system directories.
void setBegin(SourceLocation b)
Describes how types, statements, expressions, and declarations should be printed. ...
friend class ObjCDeclContextSwitch
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
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 ActOnUninitializedDecl(Decl *dcl, bool TypeMayContainAuto)
Information about a template-id annotation token.
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 getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool TryConsumeToken(tok::TokenKind Expected)
__ptr16, alignas(...), etc.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
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)
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, bool HasUsingKeyword, SourceLocation UsingLoc, CXXScopeSpec &SS, UnqualifiedId &Name, AttributeList *AttrList, bool HasTypenameKeyword, SourceLocation TypenameLoc)
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
AttributeList * getList() const
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e...
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, ParsedAttributes &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
ActOnBaseSpecifier - Parsed a base specifier.
static const TST TST_class
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
static const TST TST_error
Token - This structure provides full information about a lexed token.
void setKind(tok::TokenKind K)
SourceLocation getFirstLocation() const
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)
void ClearStorageClassSpecs()
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
Decl * ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
const TargetInfo & getTargetInfo() const
void setExternInLinkageSpec(bool Value)
Represents a C++ unqualified-id that has been parsed.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
Microsoft throw(...) extension.
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.
SourceLocation getEndLoc() const
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...
tok::TokenKind getKind() 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
void setInvalid(bool b=true) const
detail::InMemoryDirectory::const_iterator I
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, bool IncludeCXX11Attributes=true)
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
SourceRange getRange() const
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword within the source.
ParsingClassState PushParsingClass()
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
A little helper class used to produce diagnostics.
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< Decl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
TST getTypeSpecType() const
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit, bool TypeMayContainAuto)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
SourceLocation getModulePrivateSpecLoc() const
void ActOnFinishCXXMemberDecls()
Perform any semantic analysis which needs to be delayed until all pending class member declarations h...
A class for parsing a declarator.
void SetRangeStart(SourceLocation Loc)
SourceLocation getFriendSpecLoc() const
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
TypeResult ParseTypeName(SourceRange *Range=nullptr, Declarator::TheContext Context=Declarator::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
Expr - This represents one expression.
StringRef getName() const
Return the actual identifier string.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e...
static bool IsBuiltInOrStandardCXX11Attribute(IdentifierInfo *AttrName, IdentifierInfo *ScopeName)
Represents a character-granular source range.
bool isDeclarationOfFunction() const
Determine whether the declaration that will be produced from this declaration will be a function...
void AnnotateCachedTokens(const Token &Tok)
We notify the Preprocessor that if it is caching tokens (because backtrack is enabled) it should repl...
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, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
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...
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...
OpaquePtr< TemplateName > TemplateTy
Defines an enumeration for C++ overloaded operators.
void setAsmLabel(Expr *E)
SourceLocation getVolatileSpecLoc() const
bool ActOnAccessSpecifier(AccessSpecifier Access, SourceLocation ASLoc, SourceLocation ColonLoc, AttributeList *Attrs=nullptr)
ActOnAccessSpecifier - Parsed an access specifier followed by a colon.
Represents a C++ template name within the type system.
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
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.
bool isNot(tok::TokenKind K) const
InClassInitStyle
In-class initialization styles for non-static data members.
ParsedType getInheritingConstructorName(CXXScopeSpec &SS, SourceLocation NameLoc, IdentifierInfo &Name)
Handle the result of the special case name lookup for inheriting constructor declarations.
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
The result type of a method or function.
void CodeCompleteNamespaceDecl(Scope *S)
SourceLocation getAnnotationEndLoc() const
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion...
const clang::PrintingPolicy & getPrintingPolicy() const
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
void ActOnFinishCXXMemberSpecification(Scope *S, SourceLocation RLoc, Decl *TagDecl, SourceLocation LBrac, SourceLocation RBrac, AttributeList *AttrList)
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
A class for parsing a DeclSpec.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
ExprResult ActOnDecltypeExpression(Expr *E)
Process the expression contained within a decltype.
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
ActOnFinishLinkageSpecification - Complete the definition of the C++ linkage specification LinkageSpe...
const TemplateArgument * iterator
Specifier getLastSpecifier() const
Expr * getRepAsExpr() const
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
bool isValid() const
Return true if this is a valid SourceLocation object.
TagDecl - Represents the declaration of a struct/union/class/enum.
ASTContext & getASTContext() const
static const TST TST_union
void setAnnotationEndLoc(SourceLocation L)
IdentifierTable & getIdentifierTable()
Scope * getCurScope() const
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them...
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Decl * ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, unsigned TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, MultiTemplateParamsArg TempParamLists)
Handle a friend tag declaration where the scope specifier was templated.
Direct list-initialization.
Represents a C++11 virt-specifier-seq.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
SourceLocation getBegin() const
SourceLocation getBeginLoc() const
FunctionDefinitionKind
Described the kind of function definition (if any) provided for a function.
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)) {...
void ActOnMemInitializers(Decl *ConstructorDecl, SourceLocation ColonLoc, ArrayRef< CXXCtorInitializer * > MemInits, bool AnyErrors)
ActOnMemInitializers - Handle the member initializers for a constructor.
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, ParsedType ObjectType, SourceLocation &TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
unsigned TypeAlias
Whether this template specialization type is a substituted type alias.
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
Decl * ActOnUsingDirective(Scope *CurScope, SourceLocation UsingLoc, SourceLocation NamespcLoc, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *NamespcName, AttributeList *AttrList)
bool containsPlaceholderType() const
TypeResult ActOnTagTemplateIdType(TagUseKind TUK, TypeSpecifierType TagSpec, SourceLocation TagLoc, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy TemplateD, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgsIn, SourceLocation RAngleLoc)
Parsed an elaborated-type-specifier that refers to a template-id, such as class T::template apply<U>...
SourceLocation getOpenLocation() const
The scope of a struct/union/class definition.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
static const TST TST_decltype_auto
SmallVector< Token, 4 > CachedTokens
A set of tokens that has been cached for later parsing.
static const TST TST_decltype
bool isFriendSpecified() const
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)
bool hasTagDefinition() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
detail::InMemoryDirectory::const_iterator E
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, SourceLocation LBraceLoc)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
The name refers to a template whose specialization produces a type.
void CodeCompleteNamespaceAliasDecl(Scope *S)
void CodeCompleteUsingDirective(Scope *S)
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.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool SetSpecifier(Specifier VS, SourceLocation Loc, const char *&PrevSpec)
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
void takeAttributesFrom(ParsedAttributes &attrs)
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
bool isKnownToGCC() const
unsigned getMaxArgs() const
NamedDecl * ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, Declarator &D, MultiTemplateParamsArg TemplateParameterLists, Expr *BitfieldWidth, const VirtSpecifiers &VS, InClassInitStyle InitStyle)
ActOnCXXMemberDeclarator - This is invoked when a C++ class member declarator is parsed.
static const TST TST_typename
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, AttributeList *Attr)
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
ActionResult< ParsedType > TypeResult
SourceLocation getLoc() const
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.
A template-id, e.g., f<int>.
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.
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
static ParsedType getTypeAnnotation(Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
void getCXX11AttributeRanges(SmallVectorImpl< SourceRange > &Ranges)
Return a source range list of C++11 attributes associated with the declarator.
bool isCXX11Attribute() const
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 getIdentifierLoc() const
void setEnd(SourceLocation e)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
void ActOnPureSpecifier(Decl *D, SourceLocation PureSpecLoc)
void PopParsingClass(ParsingClassState state)
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...
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.
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.
MemInitResult ActOnMemInitializer(Decl *ConstructorD, Scope *S, CXXScopeSpec &SS, IdentifierInfo *MemberOrBase, ParsedType TemplateTypeTy, const DeclSpec &DS, SourceLocation IdLoc, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc, SourceLocation EllipsisLoc)
Handle a C++ member initializer using parentheses syntax.
static OpaquePtr make(PtrTy P)
bool isSet() const
Deprecated.
unsigned getLength() const
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
static const TST TST_struct
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
void setLocation(SourceLocation L)
AttributeList * getNext() const
A trivial tuple used to represent a source range.
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
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.
Represents C++ using-directive.
unsigned NumArgs
NumArgs - The number of template arguments.
void SetRangeEnd(SourceLocation Loc)
ParsedAttributes - A collection of parsed attributes.
SourceLocation ColonLoc
Location of ':'.
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void setCommaLoc(SourceLocation CL)
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
Attr - This represents one attribute.
void startToken()
Reset all flags to cleared.
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
AttributeList - Represents a syntactic attribute.
bool isBacktrackEnabled() const
True if EnableBacktrackAtThisPos() was called and caching of tokens is on.
Stop skipping at specified token, but don't skip the token itself.
NamedDecl * ActOnFriendFunctionDecl(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParams)
IdentifierInfo * getIdentifierInfo() const
const AttributeList * getAttributes() const