28 #include "llvm/ADT/SmallString.h"
29 using namespace clang;
60 assert(Tok.
is(tok::kw_namespace) &&
"Not a namespace!");
64 if (Tok.
is(tok::code_completion)) {
72 std::vector<SourceLocation> ExtraIdentLoc;
73 std::vector<IdentifierInfo*> ExtraIdent;
74 std::vector<SourceLocation> ExtraNamespaceLoc;
76 ParsedAttributesWithRange attrs(AttrFactory);
83 ParseCXX11Attributes(attrs);
86 if (Tok.
is(tok::identifier)) {
89 while (Tok.
is(tok::coloncolon) &&
NextToken().
is(tok::identifier)) {
97 if (!ExtraNamespaceLoc.empty() && attrLoc.isValid())
98 Diag(attrLoc, diag::err_unexpected_nested_namespace_attribute);
101 if (Tok.
is(tok::kw___attribute)) {
103 ParseGNUAttributes(attrs);
106 if (Tok.
is(tok::equal)) {
108 Diag(Tok, diag::err_expected) << tok::identifier;
113 if (attrLoc.isValid())
114 Diag(attrLoc, diag::err_unexpected_namespace_attributes_alias);
116 Diag(InlineLoc, diag::err_inline_namespace_alias)
118 return ParseNamespaceAlias(NamespaceLoc, IdentLoc, Ident, DeclEnd);
123 if (T.consumeOpen()) {
125 Diag(Tok, diag::err_expected) << tok::l_brace;
127 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
134 Diag(T.getOpenLocation(), diag::err_namespace_nonnamespace_scope);
139 if (ExtraIdent.empty()) {
141 }
else if (InlineLoc.
isValid()) {
142 Diag(InlineLoc, diag::err_inline_nested_namespace_definition);
144 Diag(ExtraNamespaceLoc[0],
145 diag::warn_cxx14_compat_nested_namespace_definition);
147 TentativeParsingAction TPA(*
this);
149 Token rBraceToken = Tok;
152 if (!rBraceToken.
is(tok::r_brace)) {
153 Diag(ExtraNamespaceLoc[0], diag::ext_nested_namespace_definition)
154 <<
SourceRange(ExtraNamespaceLoc.front(), ExtraIdentLoc.back());
156 std::string NamespaceFix;
157 for (std::vector<IdentifierInfo*>::iterator I = ExtraIdent.begin(),
158 E = ExtraIdent.end(); I != E; ++I) {
159 NamespaceFix +=
" { namespace ";
160 NamespaceFix += (*I)->getName();
164 for (
unsigned i = 0, e = ExtraIdent.size(); i != e; ++i)
167 Diag(ExtraNamespaceLoc[0], diag::ext_nested_namespace_definition)
169 ExtraIdentLoc.back()),
178 diag::warn_cxx98_compat_inline_namespace : diag::ext_inline_namespace);
185 IdentLoc, Ident, T.getOpenLocation(),
189 "parsing namespace");
193 ParseInnerNamespace(ExtraIdentLoc, ExtraIdent, ExtraNamespaceLoc, 0,
194 InlineLoc, attrs, T);
197 NamespaceScope.Exit();
199 DeclEnd = T.getCloseLocation();
206 void Parser::ParseInnerNamespace(std::vector<SourceLocation> &IdentLoc,
207 std::vector<IdentifierInfo *> &Ident,
208 std::vector<SourceLocation> &NamespaceLoc,
212 if (index == Ident.size()) {
213 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
214 ParsedAttributesWithRange attrs(AttrFactory);
215 MaybeParseCXX11Attributes(attrs);
216 MaybeParseMicrosoftAttributes(attrs);
217 ParseExternalDeclaration(attrs);
233 NamespaceLoc[index], IdentLoc[index],
237 ParseInnerNamespace(IdentLoc, Ident, NamespaceLoc, ++index, InlineLoc,
240 NamespaceScope.Exit();
252 assert(Tok.
is(tok::equal) &&
"Not equal token");
256 if (Tok.
is(tok::code_completion)) {
264 ParseOptionalCXXScopeSpecifier(SS,
ParsedType(),
false);
267 Diag(Tok, diag::err_expected_namespace_name);
279 if (ExpectAndConsume(tok::semi, diag::err_expected_semi_after_namespace_name))
283 SS, IdentLoc, Ident);
294 assert(isTokenStringLiteral() &&
"Not a string literal!");
295 ExprResult Lang = ParseStringLiteralExpression(
false);
305 ParsedAttributesWithRange attrs(AttrFactory);
306 MaybeParseCXX11Attributes(attrs);
307 MaybeParseMicrosoftAttributes(attrs);
309 if (Tok.
isNot(tok::l_brace)) {
316 ParseExternalDeclaration(attrs, &DS);
324 ProhibitAttributes(attrs);
329 unsigned NestedModules = 0;
332 case tok::annot_module_begin:
337 case tok::annot_module_end:
344 case tok::annot_module_include:
356 ParsedAttributesWithRange attrs(AttrFactory);
357 MaybeParseCXX11Attributes(attrs);
358 MaybeParseMicrosoftAttributes(attrs);
359 ParseExternalDeclaration(attrs);
374 Decl *Parser::ParseUsingDirectiveOrDeclaration(
unsigned Context,
375 const ParsedTemplateInfo &TemplateInfo,
377 ParsedAttributesWithRange &attrs,
379 assert(Tok.
is(tok::kw_using) &&
"Not using token");
385 if (Tok.
is(tok::code_completion)) {
392 if (Tok.
is(tok::kw_namespace)) {
394 if (TemplateInfo.Kind) {
396 Diag(UsingLoc, diag::err_templated_using_directive)
400 return ParseUsingDirective(Context, UsingLoc, DeclEnd, attrs);
406 ProhibitAttributes(attrs);
408 return ParseUsingDeclaration(Context, TemplateInfo, UsingLoc, DeclEnd,
422 Decl *Parser::ParseUsingDirective(
unsigned Context,
426 assert(Tok.
is(tok::kw_namespace) &&
"Not 'namespace' token");
431 if (Tok.
is(tok::code_completion)) {
439 ParseOptionalCXXScopeSpecifier(SS,
ParsedType(),
false);
446 Diag(Tok, diag::err_expected_namespace_name);
458 bool GNUAttr =
false;
459 if (Tok.
is(tok::kw___attribute)) {
461 ParseGNUAttributes(attrs);
466 if (ExpectAndConsume(tok::semi,
467 GNUAttr ? diag::err_expected_semi_after_attribute_list
468 : diag::err_expected_semi_after_namespace_name))
472 IdentLoc, NamespcName, attrs.
getList());
486 Decl *Parser::ParseUsingDeclaration(
unsigned Context,
487 const ParsedTemplateInfo &TemplateInfo,
494 bool HasTypenameKeyword =
false;
498 ParsedAttributesWithRange MisplacedAttrs(AttrFactory);
499 MaybeParseCXX11Attributes(MisplacedAttrs);
504 HasTypenameKeyword =
true;
506 if (Tok.
is(tok::kw___super)) {
514 ParseOptionalCXXScopeSpecifier(SS,
ParsedType(),
false,
555 ParsedAttributesWithRange Attrs(AttrFactory);
556 MaybeParseGNUAttributes(Attrs);
557 MaybeParseCXX11Attributes(Attrs);
561 bool IsAliasDecl = Tok.
is(tok::equal);
562 Decl *DeclFromDeclSpec =
nullptr;
566 if (MisplacedAttrs.Range.isValid()) {
567 Diag(MisplacedAttrs.Range.getBegin(), diag::err_attributes_not_allowed)
572 Attrs.takeAllFrom(MisplacedAttrs);
578 diag::warn_cxx98_compat_alias_declaration :
579 diag::ext_alias_declaration);
583 if (TemplateInfo.Kind == ParsedTemplateInfo::Template &&
586 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization)
588 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
590 if (SpecKind != -1) {
596 Range = TemplateInfo.getSourceRange();
597 Diag(Range.
getBegin(), diag::err_alias_declaration_specialization)
598 << SpecKind << Range;
609 }
else if (HasTypenameKeyword)
610 Diag(TypenameLoc, diag::err_alias_declaration_not_identifier)
620 AS, &DeclFromDeclSpec, &Attrs);
622 *OwnedType = DeclFromDeclSpec;
626 ProhibitAttributes(MisplacedAttrs);
627 ProhibitAttributes(Attrs);
630 MaybeParseGNUAttributes(Attrs);
635 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
636 !Attrs.empty() ?
"attributes list"
637 : IsAliasDecl ?
"alias declaration"
638 :
"using declaration"))
644 if (TemplateInfo.Kind && !IsAliasDecl) {
646 Diag(UsingLoc, diag::err_templated_using_declaration)
661 HasTypenameKeyword =
false;
667 TemplateParams ? TemplateParams->data() :
nullptr,
668 TemplateParams ? TemplateParams->size() : 0);
670 UsingLoc, Name, Attrs.getList(),
671 TypeAlias, DeclFromDeclSpec);
676 SS, Name, Attrs.getList(),
677 HasTypenameKeyword, TypenameLoc);
689 assert(Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert) &&
690 "Not a static_assert declaration");
693 Diag(Tok, diag::ext_c11_static_assert);
694 if (Tok.
is(tok::kw_static_assert))
695 Diag(Tok, diag::warn_cxx98_compat_static_assert);
700 if (T.consumeOpen()) {
701 Diag(Tok, diag::err_expected) << tok::l_paren;
707 if (AssertExpr.isInvalid()) {
713 if (Tok.
is(tok::r_paren)) {
715 ? diag::warn_cxx14_compat_static_assert_no_message
716 : diag::ext_static_assert_no_message)
719 :
FixItHint::CreateInsertion(Tok.getLocation(),
", \"\""));
721 if (ExpectAndConsume(tok::comma)) {
726 if (!isTokenStringLiteral()) {
727 Diag(Tok, diag::err_expected_string_literal)
733 AssertMessage = ParseStringLiteralExpression();
743 ExpectAndConsumeSemi(diag::err_expected_semi_after_static_assert);
748 T.getCloseLocation());
757 assert(Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)
758 &&
"Not a decltype specifier");
764 if (Tok.
is(tok::annot_decltype)) {
765 Result = getExprAnnotation(Tok);
768 if (Result.isInvalid()) {
774 Diag(Tok, diag::warn_cxx98_compat_decltype);
779 if (T.expectAndConsume(diag::err_expected_lparen_after,
780 "decltype", tok::r_paren)) {
783 StartLoc : T.getOpenLocation();
787 if (Tok.
is(tok::kw_auto)) {
793 ? diag::warn_cxx11_compat_decltype_auto_type_specifier
794 : diag::ext_decltype_auto_type_specifier);
807 if (Result.isInvalid()) {
810 EndLoc = ConsumeParen();
816 EndLoc = ConsumeAnyToken();
817 assert(Tok.
is(tok::semi));
830 if (T.getCloseLocation().isInvalid()) {
834 return T.getCloseLocation();
837 if (Result.isInvalid()) {
839 return T.getCloseLocation();
842 EndLoc = T.getCloseLocation();
844 assert(!Result.isInvalid());
846 const char *PrevSpec =
nullptr;
852 DiagID, Result.get(), Policy)
855 Diag(StartLoc, DiagID) << PrevSpec;
861 void Parser::AnnotateExistingDecltypeSpecifier(
const DeclSpec& DS,
870 Tok.
setKind(tok::annot_decltype);
871 setExprAnnotation(Tok,
880 void Parser::ParseUnderlyingTypeSpecifier(
DeclSpec &DS) {
881 assert(Tok.
is(tok::kw___underlying_type) &&
882 "Not an underlying type specifier");
886 if (T.expectAndConsume(diag::err_expected_lparen_after,
887 "__underlying_type", tok::r_paren)) {
899 if (T.getCloseLocation().isInvalid())
902 const char *PrevSpec =
nullptr;
905 DiagID, Result.
get(),
907 Diag(StartLoc, DiagID) << PrevSpec;
932 if (Tok.
is(tok::kw_typename)) {
933 Diag(Tok, diag::err_expected_class_name_not_template)
940 ParseOptionalCXXScopeSpecifier(SS,
ParsedType(),
false);
947 if (Tok.
isOneOf(tok::kw_decltype, tok::annot_decltype)) {
954 EndLocation = ParseDecltypeSpecifier(DS);
961 if (Tok.
is(tok::annot_template_id)) {
965 AnnotateTemplateIdTokenAsType();
967 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
980 if (Tok.
isNot(tok::identifier)) {
981 Diag(Tok, diag::err_expected_class_name);
988 if (Tok.
is(tok::less)) {
994 &SS, Template, TNK)) {
995 Diag(IdLoc, diag::err_unknown_template_name)
1000 TemplateArgList TemplateArgs;
1002 ParseTemplateIdAfterTemplateName(
TemplateTy(), IdLoc, SS,
1003 true, LAngleLoc, TemplateArgs, RAngleLoc);
1013 TemplateName,
true))
1016 AnnotateTemplateIdTokenAsType();
1020 if (Tok.
isNot(tok::annot_typename))
1039 Diag(IdLoc, diag::err_expected_class_name);
1044 EndLocation = IdLoc;
1052 const char *PrevSpec =
nullptr;
1061 void Parser::ParseMicrosoftInheritanceClassAttributes(
ParsedAttributes &attrs) {
1062 while (Tok.
isOneOf(tok::kw___single_inheritance,
1063 tok::kw___multiple_inheritance,
1064 tok::kw___virtual_inheritance)) {
1067 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1075 bool Parser::isValidAfterTypeSpecifier(
bool CouldBeBitfield) {
1083 case tok::identifier:
1085 case tok::annot_cxxscope:
1086 case tok::annot_typename:
1087 case tok::annot_template_id:
1090 case tok::kw_operator:
1091 case tok::kw___declspec:
1096 case tok::kw___attribute:
1099 return CouldBeBitfield;
1102 case tok::kw_volatile:
1103 case tok::kw_restrict:
1104 case tok::kw__Atomic:
1105 case tok::kw___unaligned:
1109 case tok::kw_inline:
1110 case tok::kw_virtual:
1111 case tok::kw_friend:
1113 case tok::kw_static:
1114 case tok::kw_extern:
1115 case tok::kw_typedef:
1116 case tok::kw_register:
1118 case tok::kw_mutable:
1119 case tok::kw_thread_local:
1120 case tok::kw_constexpr:
1136 if (!isKnownToBeTypeSpecifier(
NextToken()))
1193 const ParsedTemplateInfo &TemplateInfo,
1195 bool EnteringContext, DeclSpecContext DSC,
1196 ParsedAttributesWithRange &Attributes) {
1198 if (TagTokKind == tok::kw_struct)
1200 else if (TagTokKind == tok::kw___interface)
1202 else if (TagTokKind == tok::kw_class)
1205 assert(TagTokKind == tok::kw_union &&
"Not a class specifier");
1209 if (Tok.
is(tok::code_completion)) {
1212 return cutOffParsing();
1225 bool shouldDelayDiagsInTag =
1226 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
1227 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
1230 ParsedAttributesWithRange attrs(AttrFactory);
1232 MaybeParseGNUAttributes(attrs);
1233 MaybeParseMicrosoftDeclSpecs(attrs);
1236 if (Tok.
isOneOf(tok::kw___single_inheritance,
1237 tok::kw___multiple_inheritance,
1238 tok::kw___virtual_inheritance))
1239 ParseMicrosoftInheritanceClassAttributes(attrs);
1244 MaybeParseCXX11Attributes(attrs);
1251 Tok.
isNot(tok::identifier) &&
1254 Tok.
isOneOf(tok::kw___is_abstract,
1255 tok::kw___is_arithmetic,
1257 tok::kw___is_base_of,
1259 tok::kw___is_complete_type,
1260 tok::kw___is_compound,
1262 tok::kw___is_constructible,
1263 tok::kw___is_convertible,
1264 tok::kw___is_convertible_to,
1265 tok::kw___is_destructible,
1268 tok::kw___is_floating_point,
1270 tok::kw___is_function,
1271 tok::kw___is_fundamental,
1272 tok::kw___is_integral,
1273 tok::kw___is_interface_class,
1274 tok::kw___is_literal,
1275 tok::kw___is_lvalue_expr,
1276 tok::kw___is_lvalue_reference,
1277 tok::kw___is_member_function_pointer,
1278 tok::kw___is_member_object_pointer,
1279 tok::kw___is_member_pointer,
1280 tok::kw___is_nothrow_assignable,
1281 tok::kw___is_nothrow_constructible,
1282 tok::kw___is_nothrow_destructible,
1283 tok::kw___is_object,
1285 tok::kw___is_pointer,
1286 tok::kw___is_polymorphic,
1287 tok::kw___is_reference,
1288 tok::kw___is_rvalue_expr,
1289 tok::kw___is_rvalue_reference,
1291 tok::kw___is_scalar,
1292 tok::kw___is_sealed,
1293 tok::kw___is_signed,
1294 tok::kw___is_standard_layout,
1295 tok::kw___is_trivial,
1296 tok::kw___is_trivially_assignable,
1297 tok::kw___is_trivially_constructible,
1298 tok::kw___is_trivially_copyable,
1300 tok::kw___is_unsigned,
1302 tok::kw___is_volatile))
1308 TryKeywordIdentFallback(
true);
1318 bool HasValidSpec =
true;
1319 if (ParseOptionalCXXScopeSpecifier(Spec,
ParsedType(), EnteringContext)) {
1321 HasValidSpec =
false;
1324 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::annot_template_id)) {
1325 Diag(Tok, diag::err_expected) << tok::identifier;
1326 HasValidSpec =
false;
1338 if (Tok.
is(tok::identifier)) {
1346 TemplateArgList TemplateArgs;
1348 if (ParseTemplateIdAfterTemplateName(
TemplateTy(), NameLoc, SS,
1350 TemplateArgs, RAngleLoc)) {
1356 Diag(NameLoc, diag::err_explicit_spec_non_template)
1357 << (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation)
1358 << TagTokKind << Name <<
SourceRange(LAngleLoc, RAngleLoc);
1362 if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
1363 if (TemplateParams && TemplateParams->size() > 1) {
1364 TemplateParams->pop_back();
1366 TemplateParams =
nullptr;
1367 const_cast<ParsedTemplateInfo&
>(TemplateInfo).
Kind
1368 = ParsedTemplateInfo::NonTemplate;
1370 }
else if (TemplateInfo.Kind
1371 == ParsedTemplateInfo::ExplicitInstantiation) {
1373 TemplateParams =
nullptr;
1374 const_cast<ParsedTemplateInfo&
>(TemplateInfo).
Kind
1375 = ParsedTemplateInfo::NonTemplate;
1376 const_cast<ParsedTemplateInfo&
>(TemplateInfo).TemplateLoc
1378 const_cast<ParsedTemplateInfo&
>(TemplateInfo).ExternLoc
1382 }
else if (Tok.
is(tok::annot_template_id)) {
1383 TemplateId = takeTemplateIdAnnotation(Tok);
1396 Diag(TemplateId->
LAngleLoc, diag::err_template_spec_syntax_non_template)
1397 << TemplateId->
Name <<
static_cast<int>(TemplateId->
Kind) << Range;
1431 MaybeParseCXX11Attributes(Attributes);
1435 if (DSC == DSC_trailing)
1437 else if (Tok.
is(tok::l_brace) ||
1439 (isCXX11FinalKeyword() &&
1455 }
else if (isCXX11FinalKeyword() && (
NextToken().is(tok::l_square) ||
1459 TentativeParsingAction PA(*
this);
1466 if (Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square)) {
1470 }
else if (Tok.
is(tok::kw_alignas) &&
NextToken().
is(tok::l_paren)) {
1480 if (Tok.
isOneOf(tok::l_brace, tok::colon))
1486 }
else if (!isTypeSpecifier(DSC) &&
1487 (Tok.
is(tok::semi) ||
1490 if (Tok.
isNot(tok::semi)) {
1493 ExpectAndConsume(tok::semi, diag::err_expected_after,
1511 Diag(AttrRange.
getBegin(), diag::err_attributes_not_allowed)
1525 if (shouldDelayDiagsInTag) {
1526 diagsFromTag.done();
1528 diagsFromTag.redelay();
1535 Diag(StartLoc, diag::err_anon_type_definition)
1560 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
1563 ProhibitAttributes(attrs);
1567 TemplateInfo.ExternLoc,
1568 TemplateInfo.TemplateLoc,
1585 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
1586 ProhibitAttributes(attrs);
1599 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1612 "Expected a definition here");
1616 TemplateParams =
nullptr;
1621 diag::err_explicit_instantiation_with_definition)
1629 0,
SourceLocation(), TemplateInfo.TemplateLoc, LAngleLoc,
nullptr,
1631 TemplateParams = &FakedParamLists;
1641 TemplateParams ? TemplateParams->size() : 0),
1644 }
else if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation &&
1651 ProhibitAttributes(attrs);
1655 TemplateInfo.ExternLoc,
1656 TemplateInfo.TemplateLoc,
1657 TagType, StartLoc, SS, Name,
1660 TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
1661 ProhibitAttributes(attrs);
1665 TagType, StartLoc, SS,
1666 Name, NameLoc, attrs.
getList(),
1668 TemplateParams? &(*TemplateParams)[0]
1670 TemplateParams? TemplateParams->size() : 0));
1673 ProhibitAttributes(attrs);
1676 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
1679 Diag(Tok, diag::err_template_defn_explicit_instantiation)
1681 TemplateParams =
nullptr;
1684 bool IsDependent =
false;
1694 handleDeclspecAlignBeforeClassKey(attrs, DS, TUK);
1698 SS, Name, NameLoc, attrs.
getList(), AS,
1700 TParams, Owned, IsDependent,
1703 DSC == DSC_type_specifier,
1711 SS, Name, StartLoc, NameLoc);
1717 assert(Tok.
is(tok::l_brace) ||
1719 isCXX11FinalKeyword());
1721 SkipCXXMemberSpecification(StartLoc, AttrFixitLoc, TagType,
1722 TagOrTempResult.
get());
1724 ParseCXXMemberSpecification(StartLoc, AttrFixitLoc, attrs, TagType,
1725 TagOrTempResult.
get());
1727 ParseStructUnionBody(StartLoc, TagType, TagOrTempResult.
get());
1730 const char *PrevSpec =
nullptr;
1735 NameLoc.isValid() ? NameLoc : StartLoc,
1736 PrevSpec, DiagID, TypeResult.
get(), Policy);
1737 }
else if (!TagOrTempResult.
isInvalid()) {
1739 NameLoc.isValid() ? NameLoc : StartLoc,
1740 PrevSpec, DiagID, TagOrTempResult.
get(), Owned,
1748 Diag(StartLoc, DiagID) << PrevSpec;
1764 (TemplateInfo.Kind || !isValidAfterTypeSpecifier(
false))) {
1765 if (Tok.
isNot(tok::semi)) {
1767 ExpectAndConsume(tok::semi, diag::err_expected_after,
1785 void Parser::ParseBaseClause(
Decl *ClassDecl) {
1786 assert(Tok.
is(tok::colon) &&
"Not a base clause");
1794 BaseResult Result = ParseBaseSpecifier(ClassDecl);
1801 BaseInfo.push_back(Result.
get());
1826 bool IsVirtual =
false;
1829 ParsedAttributesWithRange Attributes(AttrFactory);
1830 MaybeParseCXX11Attributes(Attributes);
1836 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
1843 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
1847 if (Tok.
is(tok::kw_virtual)) {
1851 Diag(VirtualLoc, diag::err_dup_virtual)
1858 CheckMisplacedCXX11Attribute(Attributes, StartLoc);
1863 TypeResult BaseType = ParseBaseTypeSpecifier(BaseLoc, EndLocation);
1879 Access, BaseType.
get(), BaseLoc,
1903 void Parser::HandleMemberFunctionDeclDelays(
Declarator& DeclaratorInfo,
1911 if (!NeedLateParse) {
1913 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx) {
1914 auto Param = cast<ParmVarDecl>(FTI.
Params[ParamIdx].
Param);
1915 if (Param->hasUnparsedDefaultArg()) {
1916 NeedLateParse =
true;
1922 if (NeedLateParse) {
1925 auto LateMethod =
new LateParsedMethodDeclaration(
this, ThisDecl);
1926 getCurrentClass().LateParsedDeclarations.push_back(LateMethod);
1935 LateMethod->DefaultArgs.reserve(FTI.
NumParams);
1936 for (
unsigned ParamIdx = 0; ParamIdx < FTI.
NumParams; ++ParamIdx)
1937 LateMethod->DefaultArgs.push_back(LateParsedDefaultArgument(
1962 if (II == Ident_override)
1965 if (II == Ident_sealed)
1968 if (II == Ident_final)
1979 void Parser::ParseOptionalCXX11VirtSpecifierSeq(
VirtSpecifiers &VS,
1998 const char *PrevSpec =
nullptr;
2013 ? diag::warn_cxx98_compat_override_control_keyword
2014 : diag::ext_override_control_keyword)
2023 bool Parser::isCXX11FinalKeyword()
const {
2031 bool Parser::ParseCXXMemberDeclaratorBeforeInitializer(
2033 LateParsedAttrList &LateParsedAttrs) {
2038 if (Tok.
isNot(tok::colon))
2039 ParseDeclarator(DeclaratorInfo);
2045 "don't know where identifier would go yet?");
2047 if (BitfieldSize.isInvalid())
2050 ParseOptionalCXX11VirtSpecifierSeq(
2051 VS, getCurrentClass().IsInterface,
2054 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo, VS);
2058 if (Tok.
is(tok::kw_asm)) {
2060 ExprResult AsmLabel(ParseSimpleAsm(&Loc));
2061 if (AsmLabel.isInvalid())
2069 MaybeParseGNUAttributes(DeclaratorInfo, &LateParsedAttrs);
2073 if (BitfieldSize.isUnset() && VS.
isUnset()) {
2074 ParseOptionalCXX11VirtSpecifierSeq(
2075 VS, getCurrentClass().IsInterface,
2083 Diag(Attr->
getLoc(), diag::warn_gcc_attribute_location);
2086 MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(DeclaratorInfo, VS);
2092 if (!DeclaratorInfo.
hasName() && BitfieldSize.isUnset()) {
2102 void Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(
2109 ParseTypeQualifierListOpt(DS, AR_NoAttributesParsed,
false);
2116 const char *FixItName,
2118 unsigned* QualifierLoc) {
2121 if (!(Function.TypeQuals & TypeQual)) {
2122 std::string Name(FixItName);
2125 Function.TypeQuals |= TypeQual;
2126 *QualifierLoc = SpecLoc.getRawEncoding();
2128 Diag(SpecLoc, diag::err_declspec_after_virtspec)
2136 &Function.ConstQualifierLoc);
2138 &Function.VolatileQualifierLoc);
2140 &Function.RestrictQualifierLoc);
2144 bool RefQualifierIsLValueRef =
true;
2146 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc)) {
2147 const char *Name = (RefQualifierIsLValueRef ?
"& " :
"&& ");
2149 Function.RefQualifierIsLValueRef = RefQualifierIsLValueRef;
2152 Diag(RefQualifierLoc, diag::err_declspec_after_virtspec)
2153 << (RefQualifierIsLValueRef ?
"&" :
"&&")
2200 const ParsedTemplateInfo &TemplateInfo,
2202 if (Tok.
is(tok::at)) {
2204 Diag(Tok, diag::err_at_defs_cxx);
2206 Diag(Tok, diag::err_at_in_class);
2222 bool MalformedTypeSpec =
false;
2223 if (!TemplateInfo.Kind &&
2224 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw___super)) {
2226 MalformedTypeSpec =
true;
2229 if (Tok.
isNot(tok::annot_cxxscope))
2230 isAccessDecl =
false;
2232 isAccessDecl = GetLookAheadToken(2).
is(tok::semi);
2239 ParseOptionalCXXScopeSpecifier(SS,
ParsedType(),
2251 TemplateKWLoc, Name)) {
2257 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
2258 "access declaration")) {
2276 if (!TemplateInfo.Kind &&
2277 Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2279 ParseStaticAssertDeclaration(DeclEnd);
2283 if (Tok.
is(tok::kw_template)) {
2284 assert(!TemplateInfo.TemplateParams &&
2285 "Nested template improperly parsed?");
2293 if (Tok.
is(tok::kw___extension__)) {
2297 return ParseCXXClassMemberDeclaration(AS, AccessAttrs,
2298 TemplateInfo, TemplateDiags);
2301 ParsedAttributesWithRange attrs(AttrFactory);
2302 ParsedAttributesWithRange FnAttrs(AttrFactory);
2304 MaybeParseCXX11Attributes(attrs);
2307 FnAttrs.addAll(attrs.
getList());
2308 FnAttrs.Range = attrs.Range;
2310 MaybeParseMicrosoftAttributes(attrs);
2312 if (Tok.
is(tok::kw_using)) {
2313 ProhibitAttributes(attrs);
2318 if (Tok.
is(tok::kw_namespace)) {
2319 Diag(UsingLoc, diag::err_using_namespace_in_class);
2325 UsingLoc, DeclEnd, AS);
2331 LateParsedAttrList CommonLateParsedAttrs;
2337 if (MalformedTypeSpec)
2340 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC_class,
2341 &CommonLateParsedAttrs);
2349 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate &&
2350 DiagnoseMissingSemiAfterTagDefinition(DS, AS, DSC_class,
2351 &CommonLateParsedAttrs))
2355 TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->data()
2357 TemplateInfo.TemplateParams? TemplateInfo.TemplateParams->size() : 0);
2361 ProhibitAttributes(FnAttrs);
2365 DS.complete(TheDecl);
2373 LateParsedAttrList LateParsedAttrs;
2378 auto TryConsumePureSpecifier = [&] (
bool AllowDefinition) {
2379 if (Tok.
isNot(tok::equal))
2384 if (Zero.isNot(tok::numeric_constant) || Zero.getLength() != 1 ||
2388 auto &
After = GetLookAheadToken(2);
2389 if (!
After.isOneOf(tok::semi, tok::comma) &&
2390 !(AllowDefinition &&
2391 After.isOneOf(tok::l_brace, tok::colon, tok::kw_try)))
2400 ExprResult BitfieldSize;
2401 bool ExpectSemi =
true;
2404 if (ParseCXXMemberDeclaratorBeforeInitializer(
2405 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs)) {
2415 TryConsumePureSpecifier(
true);
2426 if (Tok.
isOneOf(tok::l_brace, tok::colon, tok::kw_try)) {
2428 }
else if (Tok.
is(tok::equal)) {
2430 if (KW.
is(tok::kw_default))
2432 else if (KW.
is(tok::kw_delete))
2444 ProhibitAttributes(FnAttrs);
2461 diag::err_function_declared_typedef);
2468 ParseCXXInlineMethodDef(AS, AccessAttrs, DeclaratorInfo, TemplateInfo,
2472 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i) {
2473 CommonLateParsedAttrs[i]->addDecl(FunDecl);
2475 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i) {
2476 LateParsedAttrs[i]->addDecl(FunDecl);
2479 LateParsedAttrs.clear();
2482 if (Tok.
is(tok::semi))
2483 ConsumeExtraSemi(AfterMemberFunctionDefinition);
2495 bool HasStaticInitializer =
false;
2497 if (BitfieldSize.
get()) {
2498 Diag(Tok, diag::err_bitfield_member_init);
2502 if (!TryConsumePureSpecifier(
false))
2504 HasStaticInitializer =
true;
2513 HasStaticInitializer =
true;
2531 E = Ranges.end(); I != E; ++I)
2532 Diag((*I).getBegin(), diag::err_attributes_not_allowed) << *I;
2541 VS, HasInClassInit);
2544 ThisDecl ? dyn_cast<VarTemplateDecl>(ThisDecl) :
nullptr)
2547 ThisDecl = VT->getTemplatedDecl();
2549 if (ThisDecl && AccessAttrs)
2559 HasStaticInitializer =
true;
2562 if (ThisDecl && PureSpecLoc.
isValid())
2569 ? diag::warn_cxx98_compat_nonstatic_member_init
2570 : diag::ext_nonstatic_member_init);
2578 Diag(Tok, diag::err_incomplete_array_member_init);
2585 ParseCXXNonStaticMemberInitializer(ThisDecl);
2586 }
else if (HasStaticInitializer) {
2588 ExprResult Init = ParseCXXMemberInitializer(
2603 for (
unsigned i = 0, ni = CommonLateParsedAttrs.size(); i < ni; ++i)
2604 CommonLateParsedAttrs[i]->addDecl(ThisDecl);
2606 for (
unsigned i = 0, ni = LateParsedAttrs.size(); i < ni; ++i)
2607 LateParsedAttrs[i]->addDecl(ThisDecl);
2610 DeclsInGroup.push_back(ThisDecl);
2615 HandleMemberFunctionDeclDelays(DeclaratorInfo, ThisDecl);
2617 LateParsedAttrs.clear();
2619 DeclaratorInfo.complete(ThisDecl);
2632 Diag(CommaLoc, diag::err_expected_semi_declaration)
2639 DeclaratorInfo.
clear();
2646 MaybeParseGNUAttributes(DeclaratorInfo);
2648 if (ParseCXXMemberDeclaratorBeforeInitializer(
2649 DeclaratorInfo, VS, BitfieldSize, LateParsedAttrs))
2654 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list)) {
2685 ExprResult Parser::ParseCXXMemberInitializer(
Decl *D,
bool IsFunction,
2687 assert(Tok.
isOneOf(tok::equal, tok::l_brace)
2688 &&
"Data member initializer not starting with '=' or '{'");
2694 if (Tok.
is(tok::kw_delete)) {
2709 }
else if (Tok.
is(tok::kw_default)) {
2711 Diag(Tok, diag::err_default_delete_in_multiple_declaration)
2718 if (
const auto *PD = dyn_cast_or_null<MSPropertyDecl>(D)) {
2719 Diag(Tok, diag::err_ms_property_initializer) << PD;
2722 return ParseInitializer();
2725 void Parser::SkipCXXMemberSpecification(
SourceLocation RecordLoc,
2730 assert(isCXX11FinalKeyword() &&
"not a class definition");
2735 ParsedAttributesWithRange Attrs(AttrFactory);
2736 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
2741 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_brace))
2748 if (Tok.
is(tok::colon)) {
2751 ParsingClassDefinition ParsingDef(*
this, TagDecl,
true,
2757 ParseBaseClause(
nullptr);
2761 if (!Tok.
is(tok::l_brace)) {
2763 diag::err_expected_lbrace_after_base_specifiers);
2769 assert(Tok.
is(tok::l_brace));
2776 if (Tok.
is(tok::kw___attribute))
2777 MaybeParseGNUAttributes(Attrs);
2786 void Parser::ParseCXXMemberSpecification(
SourceLocation RecordLoc,
2788 ParsedAttributesWithRange &Attrs,
2789 unsigned TagType,
Decl *TagDecl) {
2796 "parsing struct/union/class body");
2800 bool NonNestedClass =
true;
2801 if (!ClassStack.empty()) {
2803 if (
S->isClassScope()) {
2805 NonNestedClass =
false;
2808 if (getCurrentClass().IsInterface) {
2809 Diag(RecordLoc, diag::err_invalid_member_in_interface)
2811 << (isa<NamedDecl>(TagDecl)
2812 ? cast<NamedDecl>(TagDecl)->getQualifiedNameAsString()
2829 ParsingClassDefinition ParsingDef(*
this, TagDecl, NonNestedClass,
2836 bool IsFinalSpelledSealed =
false;
2843 "not a class definition");
2848 Diag(FinalLoc, diag::err_override_control_interface)
2852 ? diag::warn_cxx98_compat_override_control_keyword
2853 : diag::ext_override_control_keyword)
2856 Diag(FinalLoc, diag::ext_ms_sealed_keyword);
2862 CheckMisplacedCXX11Attribute(Attrs, AttrFixitLoc);
2871 if (!Tok.
is(tok::colon) && !Tok.
is(tok::l_brace)) {
2878 if (Tok.
is(tok::colon)) {
2879 ParseBaseClause(TagDecl);
2880 if (!Tok.
is(tok::l_brace)) {
2881 bool SuggestFixIt =
false;
2885 case tok::kw_private:
2886 case tok::kw_protected:
2887 case tok::kw_public:
2890 case tok::kw_static_assert:
2894 case tok::kw_template:
2895 SuggestFixIt =
true;
2897 case tok::identifier:
2898 SuggestFixIt = isConstructorDeclarator(
true);
2901 SuggestFixIt = isCXXSimpleDeclaration(
false);
2906 Diag(BraceLoc, diag::err_expected_lbrace_after_base_specifiers);
2920 assert(Tok.
is(tok::l_brace));
2926 IsFinalSpelledSealed,
2927 T.getOpenLocation());
2941 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
2945 tok::kw___if_not_exists)) {
2946 ParseMicrosoftIfExistsClassDeclaration((
DeclSpec::TST)TagType, CurAS);
2951 if (Tok.
is(tok::semi)) {
2952 ConsumeExtraSemi(InsideStruct, TagType);
2956 if (Tok.
is(tok::annot_pragma_vis)) {
2957 HandlePragmaVisibility();
2961 if (Tok.
is(tok::annot_pragma_pack)) {
2966 if (Tok.
is(tok::annot_pragma_align)) {
2967 HandlePragmaAlign();
2971 if (Tok.
is(tok::annot_pragma_openmp)) {
2972 ParseOpenMPDeclarativeDirective();
2976 if (Tok.
is(tok::annot_pragma_ms_pointers_to_members)) {
2977 HandlePragmaMSPointersToMembers();
2981 if (Tok.
is(tok::annot_pragma_ms_pragma)) {
2982 HandlePragmaMSPragma();
2987 if (Tok.
is(tok::kw_namespace)) {
2988 DiagnoseUnexpectedNamespace(cast<NamedDecl>(TagDecl));
2999 AccessAttrs.clear();
3000 MaybeParseGNUAttributes(AccessAttrs);
3005 Diag(EndLoc, diag::err_expected)
3009 Diag(EndLoc, diag::err_expected)
3016 Diag(ASLoc, diag::err_access_specifier_interface)
3021 AccessAttrs.getList())) {
3023 AccessAttrs.clear();
3030 ParseCXXClassMemberDeclaration(CurAS, AccessAttrs.getList());
3040 MaybeParseGNUAttributes(attrs);
3044 T.getOpenLocation(),
3045 T.getCloseLocation(),
3053 if (TagDecl && NonNestedClass) {
3059 ParseLexedAttributes(getCurrentClass());
3060 ParseLexedMethodDeclarations(getCurrentClass());
3065 ParseLexedMemberInitializers(getCurrentClass());
3066 ParseLexedMethodDefs(getCurrentClass());
3067 PrevTokLocation = SavedPrevTokLocation;
3076 T.getCloseLocation());
3083 void Parser::DiagnoseUnexpectedNamespace(
NamedDecl *D) {
3084 assert(Tok.
is(tok::kw_namespace));
3089 diag::err_missing_end_of_definition) << D;
3091 diag::note_missing_end_of_definition_before) << D;
3125 void Parser::ParseConstructorInitializer(
Decl *ConstructorDecl) {
3126 assert(Tok.
is(tok::colon) &&
3127 "Constructor initializer always starts with ':'");
3135 bool AnyErrors =
false;
3138 if (Tok.
is(tok::code_completion)) {
3141 return cutOffParsing();
3143 MemInitResult MemInit = ParseMemInitializer(ConstructorDecl);
3145 MemInitializers.push_back(MemInit.
get());
3150 if (Tok.
is(tok::comma))
3152 else if (Tok.
is(tok::l_brace))
3156 else if (Tok.
isOneOf(tok::identifier, tok::coloncolon)) {
3158 Diag(Loc, diag::err_ctor_init_missing_comma)
3188 ParseOptionalCXXScopeSpecifier(SS,
ParsedType(),
false);
3190 if (Tok.
is(tok::annot_template_id)) {
3194 AnnotateTemplateIdTokenAsType();
3195 assert(Tok.
is(tok::annot_typename) &&
"template-id -> type failed");
3201 if (!TemplateTypeTy && Tok.
isNot(tok::identifier)
3202 && Tok.
isNot(tok::annot_decltype)) {
3203 Diag(Tok, diag::err_expected_member_or_base_name);
3210 if (Tok.
is(tok::annot_decltype)) {
3212 ParseDecltypeSpecifier(DS);
3214 if (Tok.
is(tok::identifier))
3224 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3226 ExprResult InitList = ParseBraceInitializer();
3234 TemplateTypeTy, DS, IdLoc,
3235 InitList.
get(), EllipsisLoc);
3236 }
else if(Tok.
is(tok::l_paren)) {
3241 ExprVector ArgExprs;
3242 CommaLocsTy CommaLocs;
3243 if (Tok.
isNot(tok::r_paren) && ParseExpressionList(ArgExprs, CommaLocs)) {
3254 TemplateTypeTy, DS, IdLoc,
3255 T.getOpenLocation(), ArgExprs,
3256 T.getCloseLocation(), EllipsisLoc);
3260 return Diag(Tok, diag::err_expected_either) << tok::l_paren << tok::l_brace;
3262 return Diag(Tok, diag::err_expected) << tok::l_paren;
3275 Parser::tryParseExceptionSpecification(
bool Delayed,
3279 ExprResult &NoexceptExpr,
3282 ExceptionSpecTokens = 0;
3286 if (Tok.
isNot(tok::kw_throw) && Tok.
isNot(tok::kw_noexcept))
3290 bool IsNoexcept = Tok.
is(tok::kw_noexcept);
3291 Token StartTok = Tok;
3295 if (!Tok.
is(tok::l_paren)) {
3298 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
3303 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
3309 ExceptionSpecTokens->push_back(StartTok);
3310 ExceptionSpecTokens->push_back(Tok);
3311 SpecificationRange.
setEnd(ConsumeParen());
3313 ConsumeAndStoreUntil(tok::r_paren, *ExceptionSpecTokens,
3321 if (Tok.
is(tok::kw_throw)) {
3322 Result = ParseDynamicExceptionSpecification(SpecificationRange,
3324 DynamicExceptionRanges);
3325 assert(DynamicExceptions.size() == DynamicExceptionRanges.size() &&
3326 "Produced different number of exception types and ranges.");
3330 if (Tok.
isNot(tok::kw_noexcept))
3333 Diag(Tok, diag::warn_cxx98_compat_noexcept_decl);
3341 if (Tok.
is(tok::l_paren)) {
3352 NoexceptExpr.
get());
3353 NoexceptRange =
SourceRange(KeywordLoc, T.getCloseLocation());
3360 NoexceptRange =
SourceRange(KeywordLoc, KeywordLoc);
3364 SpecificationRange = NoexceptRange;
3365 Result = NoexceptType;
3369 if (Tok.
is(tok::kw_throw)) {
3370 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
3371 ParseDynamicExceptionSpecification(NoexceptRange, DynamicExceptions,
3372 DynamicExceptionRanges);
3375 Diag(Tok.
getLocation(), diag::err_dynamic_and_noexcept_specification);
3384 const char *Replacement = IsNoexcept ?
"noexcept" :
"noexcept(false)";
3385 P.
Diag(Range.
getBegin(), diag::warn_exception_spec_deprecated) << Range;
3386 P.
Diag(Range.
getBegin(), diag::note_exception_spec_deprecated)
3406 assert(Tok.
is(tok::kw_throw) &&
"expected throw");
3410 if (T.consumeOpen()) {
3411 Diag(Tok, diag::err_expected_lparen_after) <<
"throw";
3418 if (Tok.
is(tok::ellipsis)) {
3421 Diag(EllipsisLoc, diag::ext_ellipsis_exception_spec);
3423 SpecificationRange.
setEnd(T.getCloseLocation());
3430 while (Tok.
isNot(tok::r_paren)) {
3433 if (Tok.
is(tok::ellipsis)) {
3439 if (!Res.isInvalid())
3443 if (!Res.isInvalid()) {
3444 Exceptions.push_back(Res.get());
3445 Ranges.push_back(Range);
3453 SpecificationRange.
setEnd(T.getCloseLocation());
3455 Exceptions.empty());
3461 TypeResult Parser::ParseTrailingReturnType(
SourceRange &Range) {
3462 assert(Tok.
is(tok::arrow) &&
"expected arrow");
3473 Parser::PushParsingClass(
Decl *ClassDecl,
bool NonNestedClass,
3475 assert((NonNestedClass || !ClassStack.empty()) &&
3476 "Nested class without outer class");
3477 ClassStack.push(
new ParsingClass(ClassDecl, NonNestedClass, IsInterface));
3483 void Parser::DeallocateParsedClasses(Parser::ParsingClass *Class) {
3484 for (
unsigned I = 0, N = Class->LateParsedDeclarations.size(); I != N; ++I)
3485 delete Class->LateParsedDeclarations[I];
3496 assert(!ClassStack.empty() &&
"Mismatched push/pop for class parsing");
3500 ParsingClass *Victim = ClassStack.top();
3502 if (Victim->TopLevelClass) {
3505 DeallocateParsedClasses(Victim);
3508 assert(!ClassStack.empty() &&
"Missing top-level class?");
3510 if (Victim->LateParsedDeclarations.empty()) {
3515 DeallocateParsedClasses(Victim);
3522 assert(
getCurScope()->isClassScope() &&
"Nested class outside of class scope?");
3523 ClassStack.top()->LateParsedDeclarations.push_back(
new LateParsedClass(
this, Victim));
3555 case tok::pipeequal:
3556 case tok::caretequal:
3558 case tok::exclaimequal:
3564 StringRef Spelling = PP.
getSpelling(SpellingLoc, SpellingBuf);
3577 case AttributeList::AT_CarriesDependency:
3578 case AttributeList::AT_Deprecated:
3579 case AttributeList::AT_FallThrough:
3580 case AttributeList::AT_CXX11NoReturn: {
3609 assert(Tok.
is(tok::l_paren) &&
"Not a C++11 attribute argument list");
3622 if (ScopeName && ScopeName->
getName() ==
"gnu")
3625 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
3629 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
3641 Diag(LParenLoc, diag::err_attribute_requires_arguments) << AttrName;
3646 Diag(LParenLoc, diag::err_cxx11_attribute_forbids_arguments)
3681 if (Tok.
is(tok::kw_alignas)) {
3683 ParseAlignmentSpecifier(attrs, endLoc);
3687 assert(Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square)
3688 &&
"Not a C++11 attribute list");
3695 llvm::SmallDenseMap<IdentifierInfo*, SourceLocation, 4> SeenAttrs;
3697 while (Tok.
isNot(tok::r_square)) {
3705 AttrName = TryParseCXX11AttributeIdentifier(AttrLoc);
3712 ScopeName = AttrName;
3715 AttrName = TryParseCXX11AttributeIdentifier(AttrLoc);
3724 bool AttrParsed =
false;
3727 !SeenAttrs.insert(std::make_pair(AttrName, AttrLoc)).second)
3728 Diag(AttrLoc, diag::err_cxx11_attribute_repeated)
3732 if (Tok.
is(tok::l_paren))
3733 AttrParsed = ParseCXX11AttributeArgs(AttrName, AttrLoc, attrs, endLoc,
3734 ScopeName, ScopeLoc);
3743 Diag(Tok, diag::err_cxx11_attribute_forbids_ellipsis)
3747 if (ExpectAndConsume(tok::r_square))
3751 if (ExpectAndConsume(tok::r_square))
3759 void Parser::ParseCXX11Attributes(ParsedAttributesWithRange &attrs,
3768 ParseCXX11AttributeSpecifier(attrs, endLoc);
3769 }
while (isCXX11AttributeSpecifier());
3774 void Parser::DiagnoseAndSkipCXX11Attributes() {
3781 Diag(StartLoc, diag::err_attributes_not_allowed)
3789 if (!isCXX11AttributeSpecifier())
3793 if (Tok.
is(tok::l_square)) {
3797 EndLoc = T.getCloseLocation();
3799 assert(Tok.
is(tok::kw_alignas) &&
"not an attribute specifier");
3802 if (!T.consumeOpen())
3804 EndLoc = T.getCloseLocation();
3806 }
while (isCXX11AttributeSpecifier());
3821 assert(Tok.
is(tok::l_square) &&
"Not a Microsoft attribute list");
3830 *endLoc = T.getCloseLocation();
3831 }
while (Tok.
is(tok::l_square));
3834 void Parser::ParseMicrosoftIfExistsClassDeclaration(
DeclSpec::TST TagType,
3836 IfExistsCondition
Result;
3837 if (ParseMicrosoftIfExistsCondition(Result))
3841 if (Braces.consumeOpen()) {
3842 Diag(Tok, diag::err_expected) << tok::l_brace;
3846 switch (Result.Behavior) {
3852 Diag(Result.KeywordLoc, diag::warn_microsoft_dependent_exists)
3853 << Result.IsIfExists;
3861 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
3863 if (Tok.
isOneOf(tok::kw___if_exists, tok::kw___if_not_exists)) {
3864 ParseMicrosoftIfExistsClassDeclaration((
DeclSpec::TST)TagType, CurAS);
3869 if (Tok.
is(tok::semi)) {
3870 ConsumeExtraSemi(InsideStruct, TagType);
3880 if (Tok.
is(tok::colon))
3883 Diag(Tok, diag::err_expected) << tok::colon;
3889 ParseCXXClassMemberDeclaration(CurAS,
nullptr);
3892 Braces.consumeClose();
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
bool isAtStartOfLine() const
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()
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)
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
bool isArrayOfUnknownBound() const
SourceLocation getSpellingLoc(SourceLocation Loc) const
Given a SourceLocation object, return the spelling location referenced by the ID. ...
CachedTokens * DefaultArgTokens
const Scope * getParent() const
static CharSourceRange getTokenRange(SourceRange R)
ActionResult< Expr * > ExprResult
void ActOnFinishCXXMemberDefaultArgs(Decl *D)
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. This is active when parsing a variable's initializer, but not when parsing the body of a class or function definition.
void CodeCompleteUsing(Scope *S)
A RAII object used to temporarily suppress access-like checking. Access-like checks are those associa...
Defines the C++ template declaration subclasses.
SCS getStorageClassSpec() const
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
This indicates that the scope corresponds to a function, which means that labels are set here...
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.
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...
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. ...
static void diagnoseDynamicExceptionSpecification(Parser &P, const SourceRange &Range, bool IsNoexcept)
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, Decl **Params, unsigned NumParams, SourceLocation RAngleLoc)
friend class ObjCDeclContextSwitch
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
void ActOnUninitializedDecl(Decl *dcl, bool TypeMayContainAuto)
Information about a template-id annotation token.
Decl * ActOnAliasDeclaration(Scope *CurScope, AccessSpecifier AS, MultiTemplateParamsArg TemplateParams, SourceLocation UsingLoc, UnqualifiedId &Name, AttributeList *AttrList, TypeResult Type, Decl *DeclFromDeclSpec)
const Token & NextToken()
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 ...
Decl * ActOnNamespaceAliasDef(Scope *CurScope, SourceLocation NamespaceLoc, SourceLocation AliasLoc, IdentifierInfo *Alias, CXXScopeSpec &SS, SourceLocation IdentLoc, IdentifierInfo *Ident)
OpaquePtr< QualType > ParsedType
Decl * ActOnUsingDeclaration(Scope *CurScope, AccessSpecifier AS, bool HasUsingKeyword, SourceLocation UsingLoc, CXXScopeSpec &SS, UnqualifiedId &Name, AttributeList *AttrList, bool HasTypenameKeyword, SourceLocation TypenameLoc)
AttributeList * getList() const
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
BaseResult ActOnBaseSpecifier(Decl *classdecl, SourceRange SpecifierRange, ParsedAttributes &Attrs, bool Virtual, AccessSpecifier Access, ParsedType basetype, SourceLocation BaseLoc, SourceLocation EllipsisLoc)
static const TST TST_class
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const llvm::Triple &T, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
void ActOnBaseSpecifiers(Decl *ClassDecl, CXXBaseSpecifier **Bases, unsigned NumBases)
static const TST TST_error
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()
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 {'. In the former case, Name will be non-null...
const TargetInfo & getTargetInfo() const
ExprResult ActOnBooleanCondition(Scope *S, SourceLocation Loc, Expr *SubExpr)
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.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=ParsedType(), 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...
Microsoft throw(...) extension.
void takeAllFrom(ParsedAttributes &attrs)
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
SourceLocation getEndLoc() const
Represents a C++ nested-name-specifier or a global scope specifier.
tok::TokenKind getKind() const
Decl * ActOnStartLinkageSpecification(Scope *S, SourceLocation ExternLoc, Expr *LangStr, SourceLocation LBraceLoc)
const SourceRange & getSourceRange() const LLVM_READONLY
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, bool IncludeCXX11Attributes=true)
SourceLocation TemplateKWLoc
ParsingClassState PushParsingClass()
bool isFunctionDeclarator(unsigned &idx) const
A little helper class used to produce diagnostics.
TST getTypeSpecType() const
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit, bool TypeMayContainAuto)
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
TypeResult ParseTypeName(SourceRange *Range=nullptr, Declarator::TheContext Context=Declarator::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
Decl * ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, Expr *AssertExpr, Expr *AssertMessageExpr, SourceLocation RParenLoc)
StringRef getName() const
Return the actual identifier string.
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)
This file defines the classes used to store parsed information about declaration-specifiers and decla...
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)
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
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. Be careful when changing this: this...
bool isNot(tok::TokenKind K) const
const SourceRange & getRange() 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. 'NS::X::X' and 'NS::X<...>::X' are treated as constructor names in member using declarations, even if 'X' is not the name of the corresponding type.
ExceptionSpecificationType getExceptionSpecType() const
Get the type of exception specification this function has.
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
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)
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Decl * ActOnFinishLinkageSpecification(Scope *S, Decl *LinkageSpec, SourceLocation RBraceLoc)
Specifier getLastSpecifier() const
Expr * getRepAsExpr() const
void FinalizeDeclaration(Decl *D)
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.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
bool isTemplateParamScope() const
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)
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
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.
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
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceLocation RBraceLoc)
bool isInvalidDecl() const
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.
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, SourceLocation LBraceLoc)
void CodeCompleteNamespaceAliasDecl(Scope *S)
void CodeCompleteUsingDirective(Scope *S)
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)
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)
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. Some scopes just contain loop constructs but don't co...
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.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS)
void getCXX11AttributeRanges(SmallVectorImpl< SourceRange > &Ranges)
Return a source range list of C++11 attributes associated with the declarator.
bool isCXX11Attribute() const
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
Captures information about "declaration specifiers".
SourceLocation getIdentifierLoc() const
void setEnd(SourceLocation e)
SourceLocation ConsumeToken()
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...
Defines the clang::TargetInfo interface.
void ExtendWithDeclSpec(const DeclSpec &DS)
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.
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.
SourceLocation getLocation() const
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
unsigned NumArgs
NumArgs - The number of template arguments.
void SetRangeEnd(SourceLocation Loc)
SourceLocation ColonLoc
Location of ':'.
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void setCommaLoc(SourceLocation CL)
Attr - This represents one attribute.
void startToken()
Reset all flags to cleared.
ParsedTemplateTy Template
const DeclSpec & getDeclSpec() const
Decl * ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, SourceLocation NamespaceLoc, SourceLocation IdentLoc, IdentifierInfo *Ident, SourceLocation LBrace, AttributeList *AttrList)
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