35#include "llvm/ADT/SmallSet.h"
36#include "llvm/ADT/SmallString.h"
37#include "llvm/ADT/StringSwitch.h"
54 DeclSpecContext DSC = getDeclSpecContextFromDeclaratorContext(Context);
55 if (DSC == DeclSpecContext::DSC_normal)
56 DSC = DeclSpecContext::DSC_type_specifier;
62 ParseSpecifierQualifierList(DS, AS, DSC);
70 if (AL.isDeclspecAttribute())
71 ToBeMoved.push_back(&AL);
80 ParseDeclarator(DeclaratorInfo);
92 if (Name.size() >= 4 && Name.starts_with(
"__") && Name.ends_with(
"__"))
93 return Name.drop_front(2).drop_back(2);
100#define CLANG_ATTR_LATE_PARSED_EXPERIMENTAL_EXT_LIST
102#include "clang/Parse/AttrParserStringSwitches.inc"
104#undef CLANG_ATTR_LATE_PARSED_EXPERIMENTAL_EXT_LIST
110#define CLANG_ATTR_LATE_PARSED_LIST
112#include "clang/Parse/AttrParserStringSwitches.inc"
114#undef CLANG_ATTR_LATE_PARSED_LIST
124 if (
SM.getFileID(StartLoc) !=
SM.getFileID(EndLoc))
127 bool AttrStartIsInMacro =
129 bool AttrEndIsInMacro =
131 return AttrStartIsInMacro && AttrEndIsInMacro;
134void Parser::ParseAttributes(
unsigned WhichAttrKinds,
ParsedAttributes &Attrs,
135 LateParsedAttrList *LateAttrs) {
141 if (WhichAttrKinds & PAKM_CXX11)
142 MoreToParse |= MaybeParseCXX11Attributes(Attrs);
143 if (WhichAttrKinds & PAKM_GNU)
144 MoreToParse |= MaybeParseGNUAttributes(Attrs, LateAttrs);
145 if (WhichAttrKinds & PAKM_Declspec)
146 MoreToParse |= MaybeParseMicrosoftDeclSpecs(Attrs);
147 }
while (MoreToParse);
166 LateParsedAttrList *LateAttrs,
174 if (Tok.
isNot(tok::l_paren)) {
175 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
176 ParsedAttr::Form::GNU());
180 bool LateParse =
false;
183 else if (LateAttrs->lateAttrParseExperimentalExtOnly()) {
187 LateParse =
getLangOpts().ExperimentalLateParseAttributes &&
200 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, &EndLoc,
nullptr,
206 LateParsedAttribute *LA =
207 new LateParsedAttribute(
this, *AttrName, AttrNameLoc);
208 LateAttrs->push_back(LA);
212 if (!ClassStack.empty() && !LateAttrs->parseSoon())
213 getCurrentClass().LateParsedDeclarations.push_back(LA);
217 LA->Toks.push_back(Tok);
220 ConsumeAndStoreUntil(tok::r_paren, LA->Toks,
true);
225 LA->Toks.push_back(Eof);
273 assert(Tok.
is(tok::kw___attribute) &&
"Not a GNU attribute list!");
278 while (Tok.
is(tok::kw___attribute)) {
280 unsigned OldNumAttrs = Attrs.
size();
281 unsigned OldNumLateAttrs = LateAttrs ? LateAttrs->size() : 0;
283 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
288 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
"(")) {
301 if (Tok.
is(tok::code_completion)) {
308 if (ParseSingleGNUAttribute(Attrs, EndLoc, LateAttrs,
D))
310 }
while (Tok.
is(tok::comma));
312 if (ExpectAndConsume(tok::r_paren))
315 if (ExpectAndConsume(tok::r_paren))
322 if (!
SM.isWrittenInBuiltinFile(
SM.getSpellingLoc(AttrTokLoc)) &&
325 StringRef FoundName =
329 for (
unsigned i = OldNumAttrs; i < Attrs.
size(); ++i)
330 Attrs[i].setMacroIdentifier(MacroII, ExpansionRange.
getBegin());
333 for (
unsigned i = OldNumLateAttrs; i < LateAttrs->size(); ++i)
334 (*LateAttrs)[i]->MacroII = MacroII;
347#define CLANG_ATTR_IDENTIFIER_ARG_LIST
349#include "clang/Parse/AttrParserStringSwitches.inc"
351#undef CLANG_ATTR_IDENTIFIER_ARG_LIST
359#define CLANG_ATTR_STRING_LITERAL_ARG_LIST
361#include "clang/Parse/AttrParserStringSwitches.inc"
363#undef CLANG_ATTR_STRING_LITERAL_ARG_LIST
370#define CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
372#include "clang/Parse/AttrParserStringSwitches.inc"
374#undef CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
381#define CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
383#include "clang/Parse/AttrParserStringSwitches.inc"
385#undef CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
392#define CLANG_ATTR_ACCEPTS_EXPR_PACK
394#include "clang/Parse/AttrParserStringSwitches.inc"
396#undef CLANG_ATTR_ACCEPTS_EXPR_PACK
403#define CLANG_ATTR_TYPE_ARG_LIST
405#include "clang/Parse/AttrParserStringSwitches.inc"
407#undef CLANG_ATTR_TYPE_ARG_LIST
414#define CLANG_ATTR_STRICT_IDENTIFIER_ARG_LIST
416#include "clang/Parse/AttrParserStringSwitches.inc"
418#undef CLANG_ATTR_STRICT_IDENTIFIER_ARG_LIST
426#define CLANG_ATTR_ARG_CONTEXT_LIST
428#include "clang/Parse/AttrParserStringSwitches.inc"
430#undef CLANG_ATTR_ARG_CONTEXT_LIST
434 assert(Tok.
is(tok::identifier) &&
"expected an identifier");
452 if (Tok.
isNot(tok::r_paren))
455 if (
Parens.consumeClose())
464 ScopeName, ScopeLoc,
T.get(), Form);
467 ScopeName, ScopeLoc,
nullptr, 0, Form);
471Parser::ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName) {
472 if (Tok.
is(tok::l_paren)) {
475 ExprResult Res = ParseUnevaluatedStringInAttribute(AttrName);
476 Paren.consumeClose();
479 if (!isTokenStringLiteral()) {
487bool Parser::ParseAttributeArgumentList(
490 bool SawError =
false;
495 Expr = ParseUnevaluatedStringInAttribute(AttrName);
497 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
498 Expr = ParseBraceInitializer();
504 if (Tok.
is(tok::ellipsis))
506 else if (Tok.
is(tok::code_completion)) {
517 if (
Expr.isInvalid()) {
527 Exprs.push_back(
Expr.get());
529 if (Tok.
isNot(tok::comma))
534 checkPotentialAngleBracketDelimiter(Comma);
541 for (
auto &
E : Exprs) {
550unsigned Parser::ParseAttributeArgsCommon(
559 bool AttributeIsTypeArgAttr =
561 bool AttributeHasVariadicIdentifierArg =
565 if (ChangeKWThisToIdent && Tok.
is(tok::kw_this))
569 if (Tok.
is(tok::identifier)) {
571 bool IsIdentifierArg =
572 AttributeHasVariadicIdentifierArg ||
583 IsIdentifierArg = Next.isOneOf(tok::r_paren, tok::comma);
587 ArgExprs.push_back(ParseIdentifierLoc());
591 if (!ArgExprs.empty() ? Tok.
is(tok::comma) : Tok.
isNot(tok::r_paren)) {
593 if (!ArgExprs.empty())
596 if (AttributeIsTypeArgAttr) {
604 TheParsedType =
T.get();
605 }
else if (AttributeHasVariadicIdentifierArg ||
615 if (ChangeKWThisToIdent && Tok.
is(tok::kw_this))
619 if (Tok.
is(tok::identifier)) {
620 ArgExprs.push_back(ParseIdentifierLoc());
638 ArgExprs.push_back(ArgExpr.
get());
654 ExprVector ParsedExprs;
658 if (ParseAttributeArgumentList(*AttrName, ParsedExprs, ArgProperties)) {
664 for (
size_t I = 0; I < ParsedExprs.size(); ++I) {
665 if (!isa<PackExpansionExpr>(ParsedExprs[I]))
670 diag::err_attribute_argument_parm_pack_not_supported)
677 ArgExprs.insert(ArgExprs.end(), ParsedExprs.begin(), ParsedExprs.end());
682 if (!ExpectAndConsume(tok::r_paren)) {
685 if (AttributeIsTypeArgAttr && !TheParsedType.
get().
isNull()) {
687 ScopeName, ScopeLoc, TheParsedType, Form);
690 ArgExprs.data(), ArgExprs.size(), Form);
697 return static_cast<unsigned>(ArgExprs.size() + !TheParsedType.
get().
isNull());
702void Parser::ParseGNUAttributeArgs(
707 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
712 if (AttrKind == ParsedAttr::AT_Availability) {
713 ParseAvailabilityAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
716 }
else if (AttrKind == ParsedAttr::AT_ExternalSourceSymbol) {
717 ParseExternalSourceSymbolAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
718 ScopeName, ScopeLoc, Form);
720 }
else if (AttrKind == ParsedAttr::AT_ObjCBridgeRelated) {
721 ParseObjCBridgeRelatedAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
722 ScopeName, ScopeLoc, Form);
724 }
else if (AttrKind == ParsedAttr::AT_SwiftNewType) {
725 ParseSwiftNewTypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
728 }
else if (AttrKind == ParsedAttr::AT_TypeTagForDatatype) {
729 ParseTypeTagForDatatypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
730 ScopeName, ScopeLoc, Form);
733 ParseAttributeWithTypeArg(*AttrName, AttrNameLoc, Attrs, ScopeName,
736 }
else if (AttrKind == ParsedAttr::AT_CountedBy ||
737 AttrKind == ParsedAttr::AT_CountedByOrNull ||
738 AttrKind == ParsedAttr::AT_SizedBy ||
739 AttrKind == ParsedAttr::AT_SizedByOrNull) {
740 ParseBoundsAttribute(*AttrName, AttrNameLoc, Attrs, ScopeName, ScopeLoc,
743 }
else if (AttrKind == ParsedAttr::AT_CXXAssume) {
744 ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form);
750 std::optional<ParseScope> PrototypeScope;
752 D &&
D->isFunctionDeclarator()) {
757 for (
unsigned i = 0; i != FTI.
NumParams; ++i) {
763 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
767unsigned Parser::ParseClangAttributeArgs(
771 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
778 return ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
779 ScopeName, ScopeLoc, Form);
780 case ParsedAttr::AT_ExternalSourceSymbol:
781 ParseExternalSourceSymbolAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
782 ScopeName, ScopeLoc, Form);
784 case ParsedAttr::AT_Availability:
785 ParseAvailabilityAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
788 case ParsedAttr::AT_ObjCBridgeRelated:
789 ParseObjCBridgeRelatedAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
790 ScopeName, ScopeLoc, Form);
792 case ParsedAttr::AT_SwiftNewType:
793 ParseSwiftNewTypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
796 case ParsedAttr::AT_TypeTagForDatatype:
797 ParseTypeTagForDatatypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
798 ScopeName, ScopeLoc, Form);
801 case ParsedAttr::AT_CXXAssume:
802 ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form);
805 return !Attrs.
empty() ? Attrs.
begin()->getNumArgs() : 0;
811 unsigned ExistingAttrs = Attrs.
size();
825 if (AttrName->
getName() ==
"property") {
831 T.expectAndConsume(diag::err_expected_lparen_after,
840 bool HasInvalidAccessor =
false;
845 if (!Tok.
is(tok::identifier)) {
847 if (Tok.
is(tok::r_paren) && !HasInvalidAccessor &&
848 AccessorNames[AK_Put] ==
nullptr &&
849 AccessorNames[AK_Get] ==
nullptr) {
850 Diag(AttrNameLoc, diag::err_ms_property_no_getter_or_putter);
861 if (KindStr ==
"get") {
863 }
else if (KindStr ==
"put") {
867 }
else if (KindStr ==
"set") {
868 Diag(KindLoc, diag::err_ms_property_has_set_accessor)
875 Diag(KindLoc, diag::err_ms_property_missing_accessor_kind);
877 HasInvalidAccessor =
true;
878 goto next_property_accessor;
882 Diag(KindLoc, diag::err_ms_property_unknown_accessor);
883 HasInvalidAccessor =
true;
902 if (!Tok.
is(tok::identifier)) {
907 if (Kind == AK_Invalid) {
909 }
else if (AccessorNames[Kind] !=
nullptr) {
911 Diag(KindLoc, diag::err_ms_property_duplicate_accessor) << KindStr;
917 next_property_accessor:
923 if (Tok.
is(tok::r_paren))
926 Diag(Tok.
getLocation(), diag::err_ms_property_expected_comma_or_rparen);
931 if (!HasInvalidAccessor)
933 AccessorNames[AK_Get], AccessorNames[AK_Put],
934 ParsedAttr::Form::Declspec());
936 return !HasInvalidAccessor;
940 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs,
nullptr,
nullptr,
946 Diag(OpenParenLoc, diag::err_attribute_requires_arguments) << AttrName;
959 assert(
getLangOpts().DeclSpecKeyword &&
"__declspec keyword is not enabled");
960 assert(Tok.
is(tok::kw___declspec) &&
"Not a declspec!");
965 while (Tok.
is(tok::kw___declspec)) {
968 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"__declspec",
974 while (Tok.
isNot(tok::r_paren)) {
979 if (Tok.
is(tok::code_completion)) {
988 bool IsString = Tok.
getKind() == tok::string_literal;
989 if (!IsString && Tok.
getKind() != tok::identifier &&
990 Tok.
getKind() != tok::kw_restrict) {
991 Diag(Tok, diag::err_ms_declspec_type);
1001 StringRef Str = PP.
getSpelling(Tok, StrBuffer, &Invalid);
1007 AttrNameLoc = ConsumeStringToken();
1013 bool AttrHandled =
false;
1016 if (Tok.
is(tok::l_paren))
1017 AttrHandled = ParseMicrosoftDeclSpecArgs(AttrName, AttrNameLoc, Attrs);
1018 else if (AttrName->
getName() ==
"property")
1024 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1025 ParsedAttr::Form::Declspec());
1028 EndLoc =
T.getCloseLocation();
1039 case tok::kw___fastcall:
1040 case tok::kw___stdcall:
1041 case tok::kw___thiscall:
1042 case tok::kw___regcall:
1043 case tok::kw___cdecl:
1044 case tok::kw___vectorcall:
1045 case tok::kw___ptr64:
1047 case tok::kw___ptr32:
1048 case tok::kw___sptr:
1049 case tok::kw___uptr: {
1052 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1062void Parser::ParseWebAssemblyFuncrefTypeAttribute(
ParsedAttributes &attrs) {
1063 assert(Tok.
is(tok::kw___funcref));
1067 Diag(StartLoc, diag::err_wasm_funcref_not_wasm);
1073 attrs.
addNew(AttrName, AttrNameLoc,
nullptr,
1078void Parser::DiagnoseAndSkipExtendedMicrosoftTypeAttributes() {
1084 Diag(StartLoc, diag::warn_microsoft_qualifiers_ignored) <<
Range;
1094 case tok::kw_volatile:
1095 case tok::kw___fastcall:
1096 case tok::kw___stdcall:
1097 case tok::kw___thiscall:
1098 case tok::kw___cdecl:
1099 case tok::kw___vectorcall:
1100 case tok::kw___ptr32:
1101 case tok::kw___ptr64:
1103 case tok::kw___unaligned:
1104 case tok::kw___sptr:
1105 case tok::kw___uptr:
1116 while (Tok.
is(tok::kw___pascal)) {
1119 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1126 while (Tok.
is(tok::kw___kernel)) {
1129 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1135 while (Tok.
is(tok::kw___noinline__)) {
1138 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1139 tok::kw___noinline__);
1146 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1150bool Parser::isHLSLQualifier(
const Token &Tok)
const {
1151 return Tok.
is(tok::kw_groupshared);
1158 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1166 case tok::kw__Nonnull:
1167 case tok::kw__Nullable:
1168 case tok::kw__Nullable_result:
1169 case tok::kw__Null_unspecified: {
1173 Diag(AttrNameLoc, diag::ext_nullability)
1175 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1186 return (Separator ==
'.' || Separator ==
'_');
1200 if (!Tok.
is(tok::numeric_constant)) {
1201 Diag(Tok, diag::err_expected_version);
1204 return VersionTuple();
1213 const char *ThisTokBegin = &Buffer[0];
1217 unsigned ActualLength = PP.
getSpelling(Tok, ThisTokBegin, &Invalid);
1219 return VersionTuple();
1222 unsigned AfterMajor = 0;
1224 while (AfterMajor < ActualLength &&
isDigit(ThisTokBegin[AfterMajor])) {
1225 Major = Major * 10 + ThisTokBegin[AfterMajor] -
'0';
1229 if (AfterMajor == 0) {
1230 Diag(Tok, diag::err_expected_version);
1233 return VersionTuple();
1236 if (AfterMajor == ActualLength) {
1241 Diag(Tok, diag::err_zero_version);
1242 return VersionTuple();
1245 return VersionTuple(Major);
1248 const char AfterMajorSeparator = ThisTokBegin[AfterMajor];
1250 || (AfterMajor + 1 == ActualLength)) {
1251 Diag(Tok, diag::err_expected_version);
1254 return VersionTuple();
1258 unsigned AfterMinor = AfterMajor + 1;
1260 while (AfterMinor < ActualLength &&
isDigit(ThisTokBegin[AfterMinor])) {
1261 Minor = Minor * 10 + ThisTokBegin[AfterMinor] -
'0';
1265 if (AfterMinor == ActualLength) {
1269 if (Major == 0 && Minor == 0) {
1270 Diag(Tok, diag::err_zero_version);
1271 return VersionTuple();
1274 return VersionTuple(Major, Minor);
1277 const char AfterMinorSeparator = ThisTokBegin[AfterMinor];
1280 Diag(Tok, diag::err_expected_version);
1283 return VersionTuple();
1287 if (AfterMajorSeparator != AfterMinorSeparator)
1288 Diag(Tok, diag::warn_expected_consistent_version_separator);
1291 unsigned AfterSubminor = AfterMinor + 1;
1292 unsigned Subminor = 0;
1293 while (AfterSubminor < ActualLength &&
isDigit(ThisTokBegin[AfterSubminor])) {
1294 Subminor = Subminor * 10 + ThisTokBegin[AfterSubminor] -
'0';
1298 if (AfterSubminor != ActualLength) {
1299 Diag(Tok, diag::err_expected_version);
1302 return VersionTuple();
1305 return VersionTuple(Major, Minor, Subminor);
1333void Parser::ParseAvailabilityAttribute(
1337 enum { Introduced, Deprecated, Obsoleted,
Unknown };
1344 if (
T.consumeOpen()) {
1345 Diag(Tok, diag::err_expected) << tok::l_paren;
1350 if (Tok.
isNot(tok::identifier)) {
1351 Diag(Tok, diag::err_availability_expected_platform);
1358 if (Ident->getName().contains(
"xrOS") || Ident->getName().contains(
"xros"))
1359 Diag(Platform->
Loc, diag::warn_availability_unknown_platform) << Ident;
1361 else if (Ident->getName() ==
"macosx")
1365 else if (Ident->getName() ==
"macosx_app_extension")
1369 AvailabilityAttr::canonicalizePlatformName(Ident->getName()));
1373 if (ExpectAndConsume(tok::comma)) {
1380 if (!Ident_introduced) {
1395 if (Tok.
isNot(tok::identifier)) {
1396 Diag(Tok, diag::err_availability_expected_change);
1403 if (Keyword == Ident_strict) {
1405 Diag(KeywordLoc, diag::err_availability_redundant)
1408 StrictLoc = KeywordLoc;
1412 if (Keyword == Ident_unavailable) {
1413 if (UnavailableLoc.
isValid()) {
1414 Diag(KeywordLoc, diag::err_availability_redundant)
1417 UnavailableLoc = KeywordLoc;
1421 if (Keyword == Ident_deprecated && Platform->
Ident &&
1424 if (Changes[Deprecated].KeywordLoc.
isValid()) {
1425 Diag(KeywordLoc, diag::err_availability_redundant)
1432 Changes[Deprecated].
Version = VersionTuple(1);
1436 if (Keyword == Ident_environment) {
1437 if (EnvironmentLoc !=
nullptr) {
1438 Diag(KeywordLoc, diag::err_availability_redundant)
1443 if (Tok.
isNot(tok::equal)) {
1444 Diag(Tok, diag::err_expected_after) << Keyword << tok::equal;
1449 if (Keyword == Ident_message || Keyword == Ident_replacement) {
1450 if (!isTokenStringLiteral()) {
1451 Diag(Tok, diag::err_expected_string_literal)
1456 if (Keyword == Ident_message) {
1464 if (Keyword == Ident_environment) {
1465 if (Tok.
isNot(tok::identifier)) {
1466 Diag(Tok, diag::err_availability_expected_environment);
1470 EnvironmentLoc = ParseIdentifierLoc();
1476 if ((Keyword == Ident_introduced || Keyword == Ident_deprecated) &&
1477 Tok.
is(tok::identifier)) {
1481 if (Keyword == Ident_introduced)
1482 UnavailableLoc = KeywordLoc;
1488 VersionTuple Version = ParseVersionTuple(VersionRange);
1490 if (Version.empty()) {
1496 if (Keyword == Ident_introduced)
1498 else if (Keyword == Ident_deprecated)
1500 else if (Keyword == Ident_obsoleted)
1506 if (!Changes[Index].KeywordLoc.
isInvalid()) {
1507 Diag(KeywordLoc, diag::err_availability_redundant)
1510 Changes[Index].VersionRange.
getEnd());
1514 Changes[Index].
Version = Version;
1517 Diag(KeywordLoc, diag::err_availability_unknown_change)
1518 << Keyword << VersionRange;
1524 if (
T.consumeClose())
1528 *endLoc =
T.getCloseLocation();
1532 if (UnavailableLoc.
isValid()) {
1533 bool Complained =
false;
1534 for (
unsigned Index = Introduced; Index !=
Unknown; ++Index) {
1535 if (Changes[Index].KeywordLoc.
isValid()) {
1537 Diag(UnavailableLoc, diag::warn_availability_and_unavailable)
1539 Changes[Index].VersionRange.
getEnd());
1550 attrs.
addNew(&Availability,
1551 SourceRange(AvailabilityLoc,
T.getCloseLocation()), ScopeName,
1552 ScopeLoc, Platform, Changes[Introduced], Changes[Deprecated],
1553 Changes[Obsoleted], UnavailableLoc, MessageExpr.
get(), Form,
1554 StrictLoc, ReplacementExpr.
get(), EnvironmentLoc);
1571void Parser::ParseExternalSourceSymbolAttribute(
1577 if (
T.expectAndConsume())
1581 if (!Ident_language) {
1589 bool HasLanguage =
false;
1591 bool HasDefinedIn =
false;
1594 bool HasUSR =
false;
1598 if (Tok.
isNot(tok::identifier)) {
1599 Diag(Tok, diag::err_external_source_symbol_expected_keyword);
1606 if (Keyword == Ident_generated_declaration) {
1607 if (GeneratedDeclaration) {
1608 Diag(Tok, diag::err_external_source_symbol_duplicate_clause) << Keyword;
1612 GeneratedDeclaration = ParseIdentifierLoc();
1616 if (Keyword != Ident_language && Keyword != Ident_defined_in &&
1617 Keyword != Ident_USR) {
1618 Diag(Tok, diag::err_external_source_symbol_expected_keyword);
1624 if (ExpectAndConsume(tok::equal, diag::err_expected_after,
1630 bool HadLanguage = HasLanguage, HadDefinedIn = HasDefinedIn,
1632 if (Keyword == Ident_language)
1634 else if (Keyword == Ident_USR)
1637 HasDefinedIn =
true;
1639 if (!isTokenStringLiteral()) {
1640 Diag(Tok, diag::err_expected_string_literal)
1643 Keyword == Ident_language
1645 : (Keyword == Ident_defined_in ? 1 : 2));
1649 if (Keyword == Ident_language) {
1651 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1657 }
else if (Keyword == Ident_USR) {
1659 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1666 assert(Keyword == Ident_defined_in &&
"Invalid clause keyword!");
1668 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1678 if (
T.consumeClose())
1681 *EndLoc =
T.getCloseLocation();
1686 ScopeName, ScopeLoc, Args, std::size(Args), Form);
1700void Parser::ParseObjCBridgeRelatedAttribute(
1706 if (
T.consumeOpen()) {
1707 Diag(Tok, diag::err_expected) << tok::l_paren;
1712 if (Tok.
isNot(tok::identifier)) {
1713 Diag(Tok, diag::err_objcbridge_related_expected_related_class);
1718 if (ExpectAndConsume(tok::comma)) {
1727 if (Tok.
is(tok::identifier)) {
1730 Diag(Tok, diag::err_objcbridge_related_selector_name);
1736 if (Tok.
is(tok::colon))
1737 Diag(Tok, diag::err_objcbridge_related_selector_name);
1739 Diag(Tok, diag::err_expected) << tok::comma;
1747 if (Tok.
is(tok::identifier))
1749 else if (Tok.
isNot(tok::r_paren)) {
1750 Diag(Tok, diag::err_expected) << tok::r_paren;
1756 if (
T.consumeClose())
1760 *EndLoc =
T.getCloseLocation();
1763 Attrs.
addNew(&ObjCBridgeRelated,
1764 SourceRange(ObjCBridgeRelatedLoc,
T.getCloseLocation()),
1765 ScopeName, ScopeLoc, RelatedClass, ClassMethod, InstanceMethod,
1769void Parser::ParseSwiftNewTypeAttribute(
1776 if (
T.consumeOpen()) {
1777 Diag(Tok, diag::err_expected) << tok::l_paren;
1781 if (Tok.
is(tok::r_paren)) {
1786 if (Tok.
isNot(tok::kw_struct) && Tok.
isNot(tok::kw_enum)) {
1787 Diag(Tok, diag::warn_attribute_type_not_supported)
1789 if (!isTokenSpecial())
1800 if (
T.consumeClose())
1803 *EndLoc =
T.getCloseLocation();
1807 ScopeName, ScopeLoc, Args, std::size(Args), Form);
1810void Parser::ParseTypeTagForDatatypeAttribute(
1814 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
1819 if (Tok.
isNot(tok::identifier)) {
1820 Diag(Tok, diag::err_expected) << tok::identifier;
1826 if (ExpectAndConsume(tok::comma)) {
1838 bool LayoutCompatible =
false;
1839 bool MustBeNull =
false;
1841 if (Tok.
isNot(tok::identifier)) {
1842 Diag(Tok, diag::err_expected) << tok::identifier;
1847 if (Flag->
isStr(
"layout_compatible"))
1848 LayoutCompatible =
true;
1849 else if (Flag->
isStr(
"must_be_null"))
1852 Diag(Tok, diag::err_type_safety_unknown_flag) << Flag;
1859 if (!
T.consumeClose()) {
1861 ArgumentKind, MatchingCType.
get(),
1862 LayoutCompatible, MustBeNull, Form);
1866 *EndLoc =
T.getCloseLocation();
1877bool Parser::DiagnoseProhibitedCXX11Attribute() {
1878 assert(Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square));
1880 switch (isCXX11AttributeSpecifier(
true)) {
1881 case CAK_NotAttributeSpecifier:
1885 case CAK_InvalidAttributeSpecifier:
1889 case CAK_AttributeSpecifier:
1894 assert(Tok.
is(tok::r_square) &&
"isCXX11AttributeSpecifier lied");
1896 Diag(BeginLoc, diag::err_attributes_not_allowed)
1900 llvm_unreachable(
"All cases handled above.");
1909 assert((Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square)) ||
1916 ParseCXX11Attributes(Attrs);
1919 (Keyword ?
Diag(
Loc, diag::err_keyword_not_allowed) << Keyword
1920 :
Diag(
Loc, diag::err_attributes_not_allowed))
1925void Parser::DiagnoseProhibitedAttributes(
1927 auto *FirstAttr = Attrs.
empty() ? nullptr : &Attrs.
front();
1928 if (CorrectLocation.
isValid()) {
1930 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
1931 ?
Diag(CorrectLocation, diag::err_keyword_misplaced) << FirstAttr
1932 :
Diag(CorrectLocation, diag::err_attributes_misplaced))
1937 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
1945 unsigned AttrDiagID,
1946 unsigned KeywordDiagID,
1947 bool DiagnoseEmptyAttrs,
1948 bool WarnOnUnknownAttrs) {
1958 if (FirstLSquare.
is(tok::l_square)) {
1959 std::optional<Token> SecondLSquare =
1962 if (SecondLSquare && SecondLSquare->is(tok::l_square)) {
1973 if (AL.isRegularKeywordAttribute()) {
1974 Diag(AL.getLoc(), KeywordDiagID) << AL;
1978 if (!AL.isStandardAttributeSyntax())
1981 if (WarnOnUnknownAttrs)
1982 Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
1983 << AL << AL.getRange();
1985 Diag(AL.getLoc(), AttrDiagID) << AL;
1993 if (PA.isStandardAttributeSyntax() || PA.isRegularKeywordAttribute())
1994 Diag(PA.getLoc(), diag::ext_cxx11_attr_placement)
1995 << PA << PA.isRegularKeywordAttribute() << PA.getRange();
2014 if ((AL.getKind() == ParsedAttr::AT_Aligned &&
2015 AL.isDeclspecAttribute()) ||
2016 AL.isMicrosoftAttribute())
2017 ToBeMoved.push_back(&AL);
2052 Decl *SingleDecl =
nullptr;
2054 case tok::kw_template:
2055 case tok::kw_export:
2056 ProhibitAttributes(DeclAttrs);
2057 ProhibitAttributes(DeclSpecAttrs);
2058 return ParseDeclarationStartingWithTemplate(Context, DeclEnd, DeclAttrs);
2059 case tok::kw_inline:
2062 ProhibitAttributes(DeclAttrs);
2063 ProhibitAttributes(DeclSpecAttrs);
2065 return ParseNamespace(Context, DeclEnd, InlineLoc);
2067 return ParseSimpleDeclaration(Context, DeclEnd, DeclAttrs, DeclSpecAttrs,
2068 true,
nullptr, DeclSpecStart);
2070 case tok::kw_cbuffer:
2071 case tok::kw_tbuffer:
2072 SingleDecl = ParseHLSLBuffer(DeclEnd);
2074 case tok::kw_namespace:
2075 ProhibitAttributes(DeclAttrs);
2076 ProhibitAttributes(DeclSpecAttrs);
2077 return ParseNamespace(Context, DeclEnd);
2078 case tok::kw_using: {
2081 return ParseUsingDirectiveOrDeclaration(Context, ParsedTemplateInfo(),
2084 case tok::kw_static_assert:
2085 case tok::kw__Static_assert:
2086 ProhibitAttributes(DeclAttrs);
2087 ProhibitAttributes(DeclSpecAttrs);
2088 SingleDecl = ParseStaticAssertDeclaration(DeclEnd);
2091 return ParseSimpleDeclaration(Context, DeclEnd, DeclAttrs, DeclSpecAttrs,
2092 true,
nullptr, DeclSpecStart);
2124 bool RequireSemi, ForRangeInit *FRI,
SourceLocation *DeclSpecStart) {
2127 OriginalDeclSpecAttrs.
addAll(DeclSpecAttrs.
begin(), DeclSpecAttrs.
end());
2128 OriginalDeclSpecAttrs.
Range = DeclSpecAttrs.
Range;
2134 ParsedTemplateInfo TemplateInfo;
2135 DeclSpecContext DSContext = getDeclSpecContextFromDeclaratorContext(Context);
2136 ParseDeclarationSpecifiers(DS, TemplateInfo,
AS_none, DSContext);
2141 DiagnoseMissingSemiAfterTagDefinition(DS,
AS_none, DSContext))
2146 if (Tok.
is(tok::semi)) {
2147 ProhibitAttributes(DeclAttrs);
2154 DS.complete(TheDecl);
2156 Decl* decls[] = {AnonRecord, TheDecl};
2168 return ParseDeclGroup(DS, Context, DeclAttrs, TemplateInfo, &DeclEnd, FRI);
2175 case tok::annot_cxxscope:
2176 case tok::annot_template_id:
2178 case tok::code_completion:
2179 case tok::coloncolon:
2181 case tok::kw___attribute:
2182 case tok::kw_operator:
2198 case tok::identifier:
2200 case tok::code_completion:
2201 case tok::coloncolon:
2204 case tok::equalequal:
2205 case tok::kw_alignas:
2207 case tok::kw___attribute:
2225 case tok::identifier:
2248 if (Tok.
isOneOf(tok::comma, tok::l_brace, tok::kw_try)) {
2272 case tok::kw_inline:
2277 (!ParsingInObjCContainer || CurParsedObjCImpl))
2281 case tok::kw_namespace:
2286 (!ParsingInObjCContainer || CurParsedObjCImpl))
2292 if (
NextToken().isObjCAtKeyword(tok::objc_end) &&
2293 ParsingInObjCContainer)
2305 case tok::annot_module_begin:
2306 case tok::annot_module_end:
2307 case tok::annot_module_include:
2308 case tok::annot_repl_input_end:
2325 ParsedTemplateInfo &TemplateInfo,
2327 ForRangeInit *FRI) {
2333 LocalAttrs.takeAllFrom(Attrs);
2335 if (TemplateInfo.TemplateParams)
2336 D.setTemplateParameterLists(*TemplateInfo.TemplateParams);
2338 bool IsTemplateSpecOrInst =
2339 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
2340 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
2345 if (IsTemplateSpecOrInst)
2349 if (!
D.hasName() && !
D.mayOmitIdentifier()) {
2355 while (MaybeParseHLSLAnnotations(
D))
2358 if (Tok.
is(tok::kw_requires))
2359 ParseTrailingRequiresClause(
D);
2364 LateParsedAttrList LateParsedAttrs(
true);
2365 if (
D.isFunctionDeclarator()) {
2366 MaybeParseGNUAttributes(
D, &LateParsedAttrs);
2371 if (Tok.
is(tok::kw__Noreturn)) {
2373 const char *PrevSpec;
2379 MaybeParseGNUAttributes(
D, &LateParsedAttrs);
2380 Fixit &= Tok.
isOneOf(tok::semi, tok::l_brace, tok::kw_try);
2382 Diag(
Loc, diag::err_c11_noreturn_misplaced)
2384 << (Fixit ?
FixItHint::CreateInsertion(
D.getBeginLoc(),
"_Noreturn ")
2389 if (Tok.
is(tok::equal) &&
NextToken().is(tok::code_completion)) {
2400 while (
auto Specifier = isCXX11VirtSpecifier()) {
2401 Diag(Tok, diag::err_virt_specifier_outside_class)
2409 if (!isDeclarationAfterDeclarator()) {
2415 if (isStartOfFunctionDefinition(
D)) {
2425 diag::err_function_declared_typedef)
2429 Decl *TheDecl =
nullptr;
2431 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2435 Diag(Tok, diag::err_template_defn_explicit_instantiation) << 0;
2436 TheDecl = ParseFunctionDefinition(
D, ParsedTemplateInfo(),
2441 Diag(
D.getIdentifierLoc(),
2442 diag::err_explicit_instantiation_with_definition)
2450 LAngleLoc,
nullptr));
2452 TheDecl = ParseFunctionDefinition(
2454 ParsedTemplateInfo(&FakedParamLists,
2461 ParseFunctionDefinition(
D, TemplateInfo, &LateParsedAttrs);
2468 Tok.
is(tok::kw_namespace)) {
2478 Diag(Tok, diag::err_expected_fn_body);
2483 if (Tok.
is(tok::l_brace)) {
2484 Diag(Tok, diag::err_function_definition_not_allowed);
2492 if (ParseAsmAttributesAfterDeclarator(
D))
2501 if (FRI && (Tok.
is(tok::colon) || isTokIdentifier_in())) {
2502 bool IsForRangeLoop =
false;
2504 IsForRangeLoop =
true;
2515 LastRecord.RebuildDefaultArgOrDefaultInit =
true;
2520 if (Tok.
is(tok::l_brace))
2521 FRI->RangeExpr = ParseBraceInitializer();
2532 FRI->LifetimeExtendTemps = std::move(
2537 if (IsForRangeLoop) {
2541 if (
auto *VD = dyn_cast_or_null<VarDecl>(ThisDecl))
2542 VD->setObjCForDecl(
true);
2545 D.complete(ThisDecl);
2551 ParseDeclarationAfterDeclaratorAndAttributes(
D, TemplateInfo, FRI);
2552 if (LateParsedAttrs.size() > 0)
2553 ParseLexedAttributeList(LateParsedAttrs, FirstDecl,
true,
false);
2554 D.complete(FirstDecl);
2556 DeclsInGroup.push_back(FirstDecl);
2564 if (Tok.
isAtStartOfLine() && ExpectSemi && !MightBeDeclarator(Context)) {
2568 Diag(CommaLoc, diag::err_expected_semi_declaration)
2578 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
2579 D.isFirstDeclarator()) {
2580 Diag(CommaLoc, diag::err_multiple_template_declarators)
2581 << TemplateInfo.Kind;
2586 D.setCommaLoc(CommaLoc);
2595 MaybeParseGNUAttributes(
D);
2599 DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2604 MaybeParseHLSLAnnotations(
D);
2606 if (!
D.isInvalidType()) {
2611 if (Tok.
is(tok::kw_requires))
2612 ParseTrailingRequiresClause(
D);
2613 Decl *ThisDecl = ParseDeclarationAfterDeclarator(
D, TemplateInfo);
2614 D.complete(ThisDecl);
2616 DeclsInGroup.push_back(ThisDecl);
2623 if (ExpectSemi && ExpectAndConsumeSemi(
2625 ? diag::err_invalid_token_after_toplevel_declarator
2626 : diag::err_expected_semi_declaration)) {
2639bool Parser::ParseAsmAttributesAfterDeclarator(
Declarator &
D) {
2641 if (Tok.
is(tok::kw_asm)) {
2644 if (AsmLabel.isInvalid()) {
2649 D.setAsmLabel(AsmLabel.get());
2653 MaybeParseGNUAttributes(
D);
2679Decl *Parser::ParseDeclarationAfterDeclarator(
2680 Declarator &
D,
const ParsedTemplateInfo &TemplateInfo) {
2681 if (ParseAsmAttributesAfterDeclarator(
D))
2684 return ParseDeclarationAfterDeclaratorAndAttributes(
D, TemplateInfo);
2687Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
2688 Declarator &
D,
const ParsedTemplateInfo &TemplateInfo, ForRangeInit *FRI) {
2690 struct InitializerScopeRAII {
2697 :
P(
P),
D(
D), ThisDecl(ThisDecl), Entered(
false) {
2698 if (ThisDecl &&
P.getLangOpts().CPlusPlus) {
2700 if (
D.getCXXScopeSpec().isSet()) {
2702 S =
P.getCurScope();
2705 P.Actions.ActOnCXXEnterDeclInitializer(S, ThisDecl);
2710 ~InitializerScopeRAII() {
2711 if (ThisDecl &&
P.getLangOpts().CPlusPlus) {
2713 if (
D.getCXXScopeSpec().isSet())
2714 S =
P.getCurScope();
2717 P.Actions.ActOnCXXExitDeclInitializer(S, ThisDecl);
2726 InitKind TheInitKind;
2728 if (isTokenEqualOrEqualTypo())
2729 TheInitKind = InitKind::Equal;
2730 else if (Tok.
is(tok::l_paren))
2731 TheInitKind = InitKind::CXXDirect;
2733 (!CurParsedObjCImpl || !
D.isFunctionDeclarator()))
2734 TheInitKind = InitKind::CXXBraced;
2736 TheInitKind = InitKind::Uninitialized;
2737 if (TheInitKind != InitKind::Uninitialized)
2738 D.setHasInitializer();
2741 Decl *ThisDecl =
nullptr;
2742 Decl *OuterDecl =
nullptr;
2743 switch (TemplateInfo.Kind) {
2744 case ParsedTemplateInfo::NonTemplate:
2748 case ParsedTemplateInfo::Template:
2749 case ParsedTemplateInfo::ExplicitSpecialization: {
2751 *TemplateInfo.TemplateParams,
2753 if (
VarTemplateDecl *VT = dyn_cast_or_null<VarTemplateDecl>(ThisDecl)) {
2756 ThisDecl = VT->getTemplatedDecl();
2761 case ParsedTemplateInfo::ExplicitInstantiation: {
2762 if (Tok.
is(tok::semi)) {
2764 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
D);
2769 ThisDecl = ThisRes.
get();
2777 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2783 Diag(
D.getIdentifierLoc(),
2784 diag::err_explicit_instantiation_with_definition)
2792 LAngleLoc,
nullptr));
2804 switch (TheInitKind) {
2806 case InitKind::Equal: {
2809 if (Tok.
is(tok::kw_delete)) {
2810 if (
D.isFunctionDeclarator())
2815 SkipDeletedFunctionBody();
2816 }
else if (Tok.
is(tok::kw_default)) {
2817 if (
D.isFunctionDeclarator())
2824 InitializerScopeRAII
InitScope(*
this,
D, ThisDecl);
2826 if (Tok.
is(tok::code_completion)) {
2839 if (Tok.
is(tok::r_paren) && FRI &&
D.isFirstDeclarator()) {
2840 Diag(EqualLoc, diag::err_single_decl_assign_in_for_range)
2844 FRI->ColonLoc = EqualLoc;
2846 FRI->RangeExpr =
Init;
2849 if (
Init.isInvalid()) {
2851 StopTokens.push_back(tok::comma);
2854 StopTokens.push_back(tok::r_paren);
2863 case InitKind::CXXDirect: {
2870 InitializerScopeRAII
InitScope(*
this,
D, ThisDecl);
2872 auto ThisVarDecl = dyn_cast_or_null<VarDecl>(ThisDecl);
2873 auto RunSignatureHelp = [&]() {
2876 ThisVarDecl->getType()->getCanonicalTypeInternal(),
2879 CalledSignatureHelp =
true;
2880 return PreferredType;
2882 auto SetPreferredType = [&] {
2883 PreferredType.enterFunctionArgument(Tok.
getLocation(), RunSignatureHelp);
2886 llvm::function_ref<void()> ExpressionStarts;
2892 ExpressionStarts = SetPreferredType;
2895 bool SawError = ParseExpressionList(Exprs, ExpressionStarts);
2900 ThisVarDecl->getType()->getCanonicalTypeInternal(),
2903 CalledSignatureHelp =
true;
2912 T.getCloseLocation(),
2919 case InitKind::CXXBraced: {
2921 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2923 InitializerScopeRAII
InitScope(*
this,
D, ThisDecl);
2925 PreferredType.enterVariableInit(Tok.
getLocation(), ThisDecl);
2928 if (
Init.isInvalid()) {
2934 case InitKind::Uninitialized: {
2941 return OuterDecl ? OuterDecl : ThisDecl;
2950void Parser::ParseSpecifierQualifierList(
2953 ParsedTemplateInfo TemplateInfo;
2957 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC,
nullptr,
2958 AllowImplicitTypename);
2963 Diag(Tok, diag::err_expected_type);
2966 Diag(Tok, diag::err_typename_requires_specqual);
2977 diag::err_typename_invalid_storageclass);
3021 return T.isOneOf(tok::l_square, tok::l_paren, tok::r_paren, tok::semi,
3022 tok::comma, tok::equal, tok::kw_asm, tok::l_brace,
3036 ParsedTemplateInfo &TemplateInfo,
3039 assert(Tok.
is(tok::identifier) &&
"should have identifier");
3061 if (!isTypeSpecifier(DSC) &&
getLangOpts().isImplicitIntAllowed() &&
3079 AnnotateScopeToken(*SS,
false);
3090 DSC == DeclSpecContext::DSC_template_type_arg)) {
3091 const char *PrevSpec;
3107 if (SS ==
nullptr) {
3108 const char *TagName =
nullptr, *FixitTagName =
nullptr;
3114 TagName=
"enum" ; FixitTagName =
"enum " ; TagKind=tok::kw_enum ;
break;
3116 TagName=
"union" ; FixitTagName =
"union " ;TagKind=tok::kw_union ;
break;
3118 TagName=
"struct"; FixitTagName =
"struct ";TagKind=tok::kw_struct;
break;
3120 TagName=
"__interface"; FixitTagName =
"__interface ";
3121 TagKind=tok::kw___interface;
break;
3123 TagName=
"class" ; FixitTagName =
"class " ;TagKind=tok::kw_class ;
break;
3131 Diag(
Loc, diag::err_use_of_tag_name_without_tag)
3132 << TokenName << TagName <<
getLangOpts().CPlusPlus
3138 Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
3139 << TokenName << TagName;
3143 if (TagKind == tok::kw_enum)
3144 ParseEnumSpecifier(
Loc, DS, TemplateInfo, AS,
3145 DeclSpecContext::DSC_normal);
3147 ParseClassSpecifier(TagKind,
Loc, DS, TemplateInfo, AS,
3149 DeclSpecContext::DSC_normal, Attrs);
3156 if (!isTypeSpecifier(DSC) && (!SS || DSC == DeclSpecContext::DSC_top_level ||
3157 DSC == DeclSpecContext::DSC_class)) {
3161 case tok::l_paren: {
3168 TentativeParsingAction PA(*
this);
3170 TPResult TPR = TryParseDeclarator(
false);
3173 if (TPR != TPResult::False) {
3181 if (DSC == DeclSpecContext::DSC_class ||
3182 (DSC == DeclSpecContext::DSC_top_level && SS)) {
3185 Diag(
Loc, diag::err_constructor_bad_name)
3206 AnnotateScopeToken(*SS,
false);
3228 const char *PrevSpec;
3249 if (IsTemplateName) {
3251 TemplateArgList Args;
3252 ParseTemplateIdAfterTemplateName(
true, LAngle, Args, RAngle);
3266Parser::DeclSpecContext
3270 return DeclSpecContext::DSC_class;
3272 return DeclSpecContext::DSC_top_level;
3274 return DeclSpecContext::DSC_template_param;
3276 return DeclSpecContext::DSC_template_arg;
3278 return DeclSpecContext::DSC_template_type_arg;
3281 return DeclSpecContext::DSC_trailing;
3284 return DeclSpecContext::DSC_alias_declaration;
3286 return DeclSpecContext::DSC_association;
3288 return DeclSpecContext::DSC_type_specifier;
3290 return DeclSpecContext::DSC_condition;
3292 return DeclSpecContext::DSC_conv_operator;
3294 return DeclSpecContext::DSC_new;
3309 return DeclSpecContext::DSC_normal;
3312 llvm_unreachable(
"Missing DeclaratorContext case");
3325 if (isTypeIdInParens()) {
3354 assert(Tok.
isOneOf(tok::kw_alignas, tok::kw__Alignas) &&
3355 "Not an alignment-specifier!");
3362 if (
T.expectAndConsume())
3369 ParseAlignArgument(PP.
getSpelling(KWTok),
T.getOpenLocation(),
3378 *EndLoc =
T.getCloseLocation();
3385 ArgExprs.push_back(ArgExpr.
get());
3386 Attrs.
addNew(KWName, KWLoc,
nullptr, KWLoc, ArgExprs.data(), 1, Kind,
3391void Parser::DistributeCLateParsedAttrs(
Decl *Dcl,
3392 LateParsedAttrList *LateAttrs) {
3397 for (
auto *LateAttr : *LateAttrs) {
3398 if (LateAttr->Decls.empty())
3399 LateAttr->addDecl(Dcl);
3412 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
3417 if (Tok.
is(tok::r_paren)) {
3425 using ExpressionKind =
3429 ExpressionKind::EK_AttrArgument);
3439 ArgExprs.push_back(ArgExpr.
get());
3449 ScopeName, ScopeLoc, ArgExprs.data(), ArgExprs.size(), Form);
3452ExprResult Parser::ParseExtIntegerArgument() {
3453 assert(Tok.
isOneOf(tok::kw__ExtInt, tok::kw__BitInt) &&
3454 "Not an extended int type");
3458 if (
T.expectAndConsume())
3467 if(
T.consumeClose())
3481 DeclSpecContext DSContext,
3482 LateParsedAttrList *LateAttrs) {
3485 bool EnteringContext = (DSContext == DeclSpecContext::DSC_class ||
3486 DSContext == DeclSpecContext::DSC_top_level);
3489 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype,
3490 tok::annot_template_id) &&
3496 bool HasScope = Tok.
is(tok::annot_cxxscope);
3502 bool MightBeDeclarator =
true;
3503 if (Tok.
isOneOf(tok::kw_typename, tok::annot_typename)) {
3505 MightBeDeclarator =
false;
3506 }
else if (AfterScope.
is(tok::annot_template_id)) {
3512 MightBeDeclarator =
false;
3513 }
else if (AfterScope.
is(tok::identifier)) {
3514 const Token &Next = HasScope ? GetLookAheadToken(2) :
NextToken();
3518 if (Next.isOneOf(tok::star, tok::amp, tok::ampamp, tok::identifier,
3519 tok::annot_cxxscope, tok::coloncolon)) {
3521 MightBeDeclarator =
false;
3522 }
else if (HasScope) {
3533 switch (Classification.
getKind()) {
3539 llvm_unreachable(
"typo correction is not possible here");
3546 MightBeDeclarator =
false;
3562 if (MightBeDeclarator)
3567 diag::err_expected_after)
3578 ParsedTemplateInfo NotATemplate;
3579 ParseDeclarationSpecifiers(DS, NotATemplate, AS, DSContext, LateAttrs);
3610void Parser::ParseDeclarationSpecifiers(
3612 DeclSpecContext DSContext, LateParsedAttrList *LateAttrs,
3624 if (DSContext == DeclSpecContext::DSC_conv_operator) {
3627 DSContext = DeclSpecContext::DSC_type_specifier;
3630 bool EnteringContext = (DSContext == DeclSpecContext::DSC_class ||
3631 DSContext == DeclSpecContext::DSC_top_level);
3632 bool AttrsLastTime =
false;
3638 bool isStorageClass =
false;
3639 const char *PrevSpec =
nullptr;
3640 unsigned DiagID = 0;
3661 auto handleOpenCLImageKW = [&] (StringRef Ext,
TypeSpecifierType ImageTypeSpec) {
3675 bool IsTemplateSpecOrInst =
3676 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
3677 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
3686 ProhibitAttributes(attrs);
3690 if (!PA.isCXX11Attribute() && !PA.isC23Attribute() &&
3691 !PA.isRegularKeywordAttribute())
3699 if (PA.getKind() == ParsedAttr::AT_VectorSize) {
3700 Diag(PA.getLoc(), diag::warn_attribute_ignored) << PA;
3707 if (PA.isTypeAttr() && PA.getKind() != ParsedAttr::AT_LifetimeBound &&
3708 PA.getKind() != ParsedAttr::AT_AnyX86NoCfCheck)
3711 if (PA.getKind() == ParsedAttr::AT_LifetimeBound)
3712 Diag(PA.getLoc(), diag::err_attribute_wrong_decl_type)
3713 << PA << PA.isRegularKeywordAttribute()
3716 Diag(PA.getLoc(), diag::err_attribute_not_type_attr)
3717 << PA << PA.isRegularKeywordAttribute();
3726 DS.
Finish(Actions, Policy);
3730 case tok::kw__Alignas:
3731 diagnoseUseOfC11Keyword(Tok);
3733 case tok::kw_alignas:
3739 if (Tok.
getKind() == tok::kw_alignas)
3740 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
3746 if (!isAllowedCXX11AttributeSpecifier())
3747 goto DoneWithDeclSpec;
3750 ProhibitAttributes(attrs);
3757 ParseCXX11Attributes(attrs);
3758 AttrsLastTime =
true;
3761 case tok::code_completion: {
3765 bool AllowNonIdentifiers
3771 bool AllowNestedNameSpecifiers
3772 = DSContext == DeclSpecContext::DSC_top_level ||
3777 getCurScope(), DS, AllowNonIdentifiers, AllowNestedNameSpecifiers);
3782 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
3783 CCC = DSContext == DeclSpecContext::DSC_class
3786 else if (DSContext == DeclSpecContext::DSC_class)
3790 else if (CurParsedObjCImpl)
3798 case tok::coloncolon:
3804 goto DoneWithDeclSpec;
3806 if (Tok.
is(tok::coloncolon))
3807 goto DoneWithDeclSpec;
3810 case tok::annot_cxxscope: {
3812 goto DoneWithDeclSpec;
3815 if (TemplateInfo.TemplateParams)
3825 ? takeTemplateIdAnnotation(Next)
3831 ConsumeAnnotationToken();
3845 if ((DSContext == DeclSpecContext::DSC_top_level ||
3846 DSContext == DeclSpecContext::DSC_class) &&
3849 isConstructorDeclarator(
false,
3856 goto DoneWithDeclSpec;
3860 ConsumeAnnotationToken();
3861 assert(Tok.
is(tok::annot_template_id) &&
3862 "ParseOptionalCXXScopeSpecifier not working");
3863 AnnotateTemplateIdTokenAsType(SS, AllowImplicitTypename);
3873 ConsumeAnnotationToken();
3877 if (Next.is(tok::annot_typename)) {
3879 ConsumeAnnotationToken();
3883 PrevSpec, DiagID,
T, Policy);
3887 ConsumeAnnotationToken();
3891 Next.is(tok::annot_template_id) &&
3895 ConsumeAnnotationToken();
3896 AnnotateTemplateIdTokenAsType(SS, AllowImplicitTypename);
3900 if (Next.isNot(tok::identifier))
3901 goto DoneWithDeclSpec;
3906 if ((DSContext == DeclSpecContext::DSC_top_level ||
3907 DSContext == DeclSpecContext::DSC_class) &&
3910 isConstructorDeclarator(
false,
3914 goto DoneWithDeclSpec;
3923 *Next.getIdentifierInfo(), Next.getLocation(),
getCurScope(), &SS,
3924 false,
false,
nullptr,
3927 isClassTemplateDeductionContext(DSContext), AllowImplicitTypename);
3929 if (IsTemplateSpecOrInst)
3937 if (TryAnnotateTypeConstraint())
3938 goto DoneWithDeclSpec;
3939 if (Tok.
isNot(tok::annot_cxxscope) ||
3943 ConsumeAnnotationToken();
3945 if (ParseImplicitInt(DS, &SS, TemplateInfo, AS, DSContext, Attrs)) {
3946 if (!Attrs.
empty()) {
3947 AttrsLastTime =
true;
3948 attrs.takeAllFrom(Attrs);
3952 goto DoneWithDeclSpec;
3956 ConsumeAnnotationToken();
3959 DiagID, TypeRep, Policy);
3969 case tok::annot_typename: {
3973 goto DoneWithDeclSpec;
3982 ConsumeAnnotationToken();
3987 case tok::kw___is_signed:
3998 TryKeywordIdentFallback(
true);
4001 goto DoneWithDeclSpec;
4004 case tok::kw___super:
4005 case tok::kw_decltype:
4006 case tok::identifier:
4012 goto DoneWithDeclSpec;
4018 if (!
getLangOpts().DeclSpecKeyword && Tok.
is(tok::identifier) &&
4020 Diag(
Loc, diag::err_ms_attributes_not_enabled);
4030 if (
T.consumeOpen()) {
4031 assert(
false &&
"Not a left paren?");
4050 if (IsTemplateSpecOrInst)
4054 if (IsTemplateSpecOrInst)
4057 goto DoneWithDeclSpec;
4060 if (!Tok.
is(tok::identifier))
4065 if (TryAltiVecToken(DS,
Loc, PrevSpec, DiagID,
isInvalid))
4071 goto DoneWithDeclSpec;
4073 if (DSContext == DeclSpecContext::DSC_objc_method_result &&
4074 isObjCInstancetype()) {
4078 DiagID, TypeRep, Policy);
4091 isConstructorDeclarator(
true,
4094 goto DoneWithDeclSpec;
4098 false,
false,
nullptr,
false,
false,
4099 isClassTemplateDeductionContext(DSContext));
4104 if (TryAnnotateTypeConstraint())
4105 goto DoneWithDeclSpec;
4106 if (Tok.
isNot(tok::identifier))
4109 if (ParseImplicitInt(DS,
nullptr, TemplateInfo, AS, DSContext, Attrs)) {
4110 if (!Attrs.
empty()) {
4111 AttrsLastTime =
true;
4112 attrs.takeAllFrom(Attrs);
4116 goto DoneWithDeclSpec;
4123 (DSContext == DeclSpecContext::DSC_class ||
4124 DSContext == DeclSpecContext::DSC_top_level) &&
4127 isConstructorDeclarator(
true,
4129 goto DoneWithDeclSpec;
4132 DiagID, TypeRep, Policy);
4144 TypeResult NewTypeRep = parseObjCTypeArgsAndProtocolQualifiers(
4159 case tok::annot_template_id: {
4171 TemplateId =
nullptr;
4179 tok::kw_volatile, tok::kw_restrict, tok::amp,
4181 Diag(
Loc, diag::err_placeholder_expected_auto_or_decltype_auto)
4185 TemplateId, Policy);
4189 goto DoneWithDeclSpec;
4192 TemplateId =
nullptr;
4194 ConsumeAnnotationToken();
4198 if (Tracker.consumeOpen()) {
4200 Diag(Tok, diag::err_expected) << tok::l_paren;
4204 Tracker.skipToEnd();
4205 Diag(Tok, diag::err_placeholder_expected_auto_or_decltype_auto)
4210 Tracker.consumeClose();
4218 DiagID, TemplateId, Policy);
4221 TemplateId, Policy);
4230 goto DoneWithDeclSpec;
4238 isConstructorDeclarator(
true,
4241 goto DoneWithDeclSpec;
4246 AnnotateTemplateIdTokenAsType(SS, AllowImplicitTypename);
4251 case tok::kw___attribute:
4252 case tok::kw___declspec:
4253 ParseAttributes(PAKM_GNU | PAKM_Declspec, DS.
getAttributes(), LateAttrs);
4257 case tok::kw___forceinline: {
4262 nullptr, 0, tok::kw___forceinline);
4266 case tok::kw___unaligned:
4271 case tok::kw___sptr:
4272 case tok::kw___uptr:
4273 case tok::kw___ptr64:
4274 case tok::kw___ptr32:
4276 case tok::kw___cdecl:
4277 case tok::kw___stdcall:
4278 case tok::kw___fastcall:
4279 case tok::kw___thiscall:
4280 case tok::kw___regcall:
4281 case tok::kw___vectorcall:
4285 case tok::kw___funcref:
4290 case tok::kw___pascal:
4295 case tok::kw___kernel:
4300 case tok::kw___noinline__:
4305 case tok::kw__Nonnull:
4306 case tok::kw__Nullable:
4307 case tok::kw__Nullable_result:
4308 case tok::kw__Null_unspecified:
4313 case tok::kw___kindof:
4315 nullptr, 0, tok::kw___kindof);
4320 case tok::kw_typedef:
4322 PrevSpec, DiagID, Policy);
4323 isStorageClass =
true;
4325 case tok::kw_extern:
4327 Diag(Tok, diag::ext_thread_before) <<
"extern";
4329 PrevSpec, DiagID, Policy);
4330 isStorageClass =
true;
4332 case tok::kw___private_extern__:
4334 Loc, PrevSpec, DiagID, Policy);
4335 isStorageClass =
true;
4337 case tok::kw_static:
4339 Diag(Tok, diag::ext_thread_before) <<
"static";
4341 PrevSpec, DiagID, Policy);
4342 isStorageClass =
true;
4346 if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
4348 PrevSpec, DiagID, Policy);
4350 Diag(Tok, diag::ext_auto_storage_class)
4357 PrevSpec, DiagID, Policy);
4358 isStorageClass =
true;
4360 case tok::kw___auto_type:
4361 Diag(Tok, diag::ext_auto_type);
4365 case tok::kw_register:
4367 PrevSpec, DiagID, Policy);
4368 isStorageClass =
true;
4370 case tok::kw_mutable:
4372 PrevSpec, DiagID, Policy);
4373 isStorageClass =
true;
4375 case tok::kw___thread:
4378 isStorageClass =
true;
4380 case tok::kw_thread_local:
4382 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
4391 Loc, PrevSpec, DiagID);
4392 isStorageClass =
true;
4394 case tok::kw__Thread_local:
4395 diagnoseUseOfC11Keyword(Tok);
4397 Loc, PrevSpec, DiagID);
4398 isStorageClass =
true;
4402 case tok::kw_inline:
4405 case tok::kw_virtual:
4409 !
getActions().getOpenCLOptions().isAvailableOption(
4411 DiagID = diag::err_openclcxx_virtual_function;
4418 case tok::kw_explicit: {
4422 ConsumedEnd = ExplicitLoc;
4424 if (Tok.
is(tok::l_paren)) {
4427 ? diag::warn_cxx17_compat_explicit_bool
4428 : diag::ext_explicit_bool);
4432 Tracker.consumeOpen();
4439 if (ExplicitExpr.isUsable()) {
4441 Tracker.consumeClose();
4445 Tracker.skipToEnd();
4451 ExplicitSpec, CloseParenLoc);
4454 case tok::kw__Noreturn:
4455 diagnoseUseOfC11Keyword(Tok);
4460 case tok::kw_friend:
4461 if (DSContext == DeclSpecContext::DSC_class) {
4468 DiagID = diag::err_friend_invalid_in_context;
4474 case tok::kw___module_private__:
4479 case tok::kw_constexpr:
4481 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
4485 case tok::kw_consteval:
4489 case tok::kw_constinit:
4505 PrevSpec, DiagID, Policy);
4507 case tok::kw___int64:
4509 PrevSpec, DiagID, Policy);
4511 case tok::kw_signed:
4515 case tok::kw_unsigned:
4519 case tok::kw__Complex:
4521 Diag(Tok, diag::ext_c99_feature) << Tok.
getName();
4525 case tok::kw__Imaginary:
4527 Diag(Tok, diag::ext_c99_feature) << Tok.
getName();
4543 case tok::kw__ExtInt:
4544 case tok::kw__BitInt: {
4545 DiagnoseBitIntUse(Tok);
4550 ConsumedEnd = PrevTokLocation;
4553 case tok::kw___int128:
4561 case tok::kw___bf16:
4569 case tok::kw_double:
4573 case tok::kw__Float16:
4577 case tok::kw__Accum:
4579 "This keyword is only used when fixed point types are enabled "
4580 "with `-ffixed-point`");
4584 case tok::kw__Fract:
4586 "This keyword is only used when fixed point types are enabled "
4587 "with `-ffixed-point`");
4593 "This keyword is only used when fixed point types are enabled "
4594 "with `-ffixed-point`");
4597 case tok::kw___float128:
4601 case tok::kw___ibm128:
4605 case tok::kw_wchar_t:
4609 case tok::kw_char8_t:
4613 case tok::kw_char16_t:
4617 case tok::kw_char32_t:
4623 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
4627 Diag(Tok, diag::ext_c99_feature) << Tok.
getName();
4629 if (Tok.
is(tok::kw_bool) &&
4633 DiagID = diag::err_bool_redeclaration;
4642 case tok::kw__Decimal32:
4646 case tok::kw__Decimal64:
4650 case tok::kw__Decimal128:
4654 case tok::kw___vector:
4657 case tok::kw___pixel:
4660 case tok::kw___bool:
4665 getLangOpts().getOpenCLCompatibleVersion() < 200) {
4670 goto DoneWithDeclSpec;
4672 DiagID = diag::err_opencl_unknown_type_specifier;
4679#define IMAGE_READ_WRITE_TYPE(Type, Id, Ext)
4680#define IMAGE_WRITE_TYPE(Type, Id, Ext)
4681#define IMAGE_READ_TYPE(ImgType, Id, Ext) \
4682 case tok::kw_##ImgType##_t: \
4683 if (!handleOpenCLImageKW(Ext, DeclSpec::TST_##ImgType##_t)) \
4684 goto DoneWithDeclSpec; \
4686#include "clang/Basic/OpenCLImageTypes.def"
4687 case tok::kw___unknown_anytype:
4689 PrevSpec, DiagID, Policy);
4694 case tok::kw_struct:
4695 case tok::kw___interface:
4696 case tok::kw_union: {
4704 ParseClassSpecifier(Kind,
Loc, DS, TemplateInfo, AS,
4705 EnteringContext, DSContext, Attributes);
4709 if (!Attributes.empty()) {
4710 AttrsLastTime =
true;
4711 attrs.takeAllFrom(Attributes);
4719 ParseEnumSpecifier(
Loc, DS, TemplateInfo, AS, DSContext);
4727 case tok::kw_volatile:
4731 case tok::kw_restrict:
4737 case tok::kw_typename:
4740 goto DoneWithDeclSpec;
4742 if (!Tok.
is(tok::kw_typename))
4747 case tok::kw_typeof:
4748 case tok::kw_typeof_unqual:
4749 ParseTypeofSpecifier(DS);
4752 case tok::annot_decltype:
4753 ParseDecltypeSpecifier(DS);
4756 case tok::annot_pack_indexing_type:
4757 ParsePackIndexingType(DS);
4760 case tok::annot_pragma_pack:
4764 case tok::annot_pragma_ms_pragma:
4765 HandlePragmaMSPragma();
4768 case tok::annot_pragma_ms_vtordisp:
4769 HandlePragmaMSVtorDisp();
4772 case tok::annot_pragma_ms_pointers_to_members:
4773 HandlePragmaMSPointersToMembers();
4776#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
4777#include "clang/Basic/TransformTypeTraits.def"
4781 if (!MaybeParseTypeTransformTypeSpecifier(DS))
4782 goto ParseIdentifier;
4785 case tok::kw__Atomic:
4790 diagnoseUseOfC11Keyword(Tok);
4792 ParseAtomicSpecifier(DS);
4800 case tok::kw___generic:
4805 if (!Actions.
getLangOpts().OpenCLGenericAddressSpace) {
4806 DiagID = diag::err_opencl_unknown_type_specifier;
4812 case tok::kw_private:
4816 goto DoneWithDeclSpec;
4818 case tok::kw___private:
4819 case tok::kw___global:
4820 case tok::kw___local:
4821 case tok::kw___constant:
4823 case tok::kw___read_only:
4824 case tok::kw___write_only:
4825 case tok::kw___read_write:
4829 case tok::kw_groupshared:
4837#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
4838 case tok::kw_##Name: \
4839 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_##Name, Loc, PrevSpec, \
4842#include "clang/Basic/HLSLIntangibleTypes.def"
4849 goto DoneWithDeclSpec;
4854 if (
Type.isUsable()) {
4856 PrevSpec, DiagID,
Type.get(),
4858 Diag(StartLoc, DiagID) << PrevSpec;
4874 assert(PrevSpec &&
"Method did not return previous specifier!");
4877 if (DiagID == diag::ext_duplicate_declspec ||
4878 DiagID == diag::ext_warn_duplicate_declspec ||
4879 DiagID == diag::err_duplicate_declspec)
4883 else if (DiagID == diag::err_opencl_unknown_type_specifier) {
4887 Diag(
Loc, DiagID) << PrevSpec;
4890 if (DiagID != diag::err_bool_redeclaration && ConsumedEnd.
isInvalid())
4894 AttrsLastTime =
false;
4906 if (!RD || !RD->getName().empty() || RD->isAnonymousStructOrUnion())
4909 for (
auto *I : RD->decls()) {
4910 auto *VD = dyn_cast<ValueDecl>(I);
4918 for (
const auto &DD : CAT->dependent_decls()) {
4919 if (!RD->containsDecl(DD.getDecl())) {
4920 P.Diag(VD->getBeginLoc(), diag::err_count_attr_param_not_in_same_struct)
4921 << DD.getDecl() << CAT->getKind() << CAT->isArrayType();
4922 P.Diag(DD.getDecl()->getBeginLoc(),
4923 diag::note_flexible_array_counted_by_attr_field)
4951void Parser::ParseStructDeclaration(
4954 LateParsedAttrList *LateFieldAttrs) {
4956 if (Tok.
is(tok::kw___extension__)) {
4960 return ParseStructDeclaration(DS, FieldsCallback, LateFieldAttrs);
4965 MaybeParseCXX11Attributes(Attrs);
4968 ParseSpecifierQualifierList(DS);
4972 if (Tok.
is(tok::semi)) {
4977 ProhibitAttributes(Attrs);
4981 assert(!AnonRecord &&
"Did not expect anonymous struct or union here");
4987 bool FirstDeclarator =
true;
4991 DeclaratorInfo.D.setCommaLoc(CommaLoc);
4994 if (!FirstDeclarator) {
4997 DiagnoseAndSkipCXX11Attributes();
4998 MaybeParseGNUAttributes(DeclaratorInfo.D);
4999 DiagnoseAndSkipCXX11Attributes();
5004 if (Tok.
isNot(tok::colon)) {
5007 ParseDeclarator(DeclaratorInfo.D);
5009 DeclaratorInfo.D.SetIdentifier(
nullptr, Tok.
getLocation());
5021 DeclaratorInfo.BitfieldSize = Res.
get();
5025 MaybeParseGNUAttributes(DeclaratorInfo.D, LateFieldAttrs);
5028 Decl *
Field = FieldsCallback(DeclaratorInfo);
5030 DistributeCLateParsedAttrs(Field, LateFieldAttrs);
5037 FirstDeclarator =
false;
5043void Parser::ParseLexedCAttributeList(LateParsedAttrList &LAs,
bool EnterScope,
5045 assert(LAs.parseSoon() &&
5046 "Attribute list should be marked for immediate parsing.");
5047 for (
auto *LA : LAs) {
5048 ParseLexedCAttribute(*LA,
EnterScope, OutAttrs);
5059void Parser::ParseLexedCAttribute(LateParsedAttribute &LA,
bool EnterScope,
5068 LA.Toks.push_back(AttrEnd);
5072 LA.Toks.push_back(Tok);
5073 PP.EnterTokenStream(LA.Toks,
true,
5084 assert(LA.Decls.size() <= 1 &&
5085 "late field attribute expects to have at most one declaration.");
5088 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
nullptr,
5091 for (
auto *
D : LA.Decls)
5096 while (Tok.
isNot(tok::eof))
5121 "parsing struct/union body");
5125 if (
T.consumeOpen())
5133 LateParsedAttrList LateFieldAttrs(
true,
5137 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
5138 Tok.
isNot(tok::eof)) {
5142 if (Tok.
is(tok::semi)) {
5143 ConsumeExtraSemi(InsideStruct,
TagType);
5148 if (Tok.
isOneOf(tok::kw__Static_assert, tok::kw_static_assert)) {
5150 ParseStaticAssertDeclaration(DeclEnd);
5154 if (Tok.
is(tok::annot_pragma_pack)) {
5159 if (Tok.
is(tok::annot_pragma_align)) {
5160 HandlePragmaAlign();
5164 if (Tok.
isOneOf(tok::annot_pragma_openmp, tok::annot_attr_openmp)) {
5168 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
5172 if (Tok.
is(tok::annot_pragma_openacc)) {
5181 ConsumeAnnotationToken();
5185 if (!Tok.
is(tok::at)) {
5191 FD.D, FD.BitfieldSize);
5198 ParseStructDeclaration(DS, CFieldCallback, &LateFieldAttrs);
5202 Diag(Tok, diag::err_unexpected_at);
5207 ExpectAndConsume(tok::l_paren);
5208 if (!Tok.
is(tok::identifier)) {
5209 Diag(Tok, diag::err_expected) << tok::identifier;
5217 ExpectAndConsume(tok::r_paren);
5223 if (Tok.
is(tok::r_brace)) {
5224 ExpectAndConsume(tok::semi, diag::ext_expected_semi_decl_list);
5228 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
5239 MaybeParseGNUAttributes(attrs, &LateFieldAttrs);
5242 ParseLexedCAttributeList(LateFieldAttrs,
false);
5247 T.getOpenLocation(),
T.getCloseLocation(), attrs);
5283 const ParsedTemplateInfo &TemplateInfo,
5286 if (Tok.
is(tok::code_completion)) {
5296 MaybeParseAttributes(PAKM_GNU | PAKM_Declspec | PAKM_CXX11, attrs);
5299 bool IsScopedUsingClassTag =
false;
5304 : diag::ext_scoped_enum);
5305 IsScopedUsingClassTag = Tok.
is(tok::kw_class);
5310 ProhibitAttributes(attrs);
5313 MaybeParseAttributes(PAKM_GNU | PAKM_Declspec | PAKM_CXX11, attrs);
5322 bool shouldDelayDiagsInTag =
5323 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
5324 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
5328 AllowDefiningTypeSpec AllowEnumSpecifier =
5330 bool CanBeOpaqueEnumDeclaration =
5331 DS.
isEmpty() && isOpaqueEnumDeclarationContext(DSC);
5334 (AllowEnumSpecifier == AllowDefiningTypeSpec::Yes ||
5335 CanBeOpaqueEnumDeclaration);
5343 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
5348 if (Spec.
isSet() && Tok.
isNot(tok::identifier)) {
5349 Diag(Tok, diag::err_expected) << tok::identifier;
5351 if (Tok.
isNot(tok::l_brace)) {
5363 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::l_brace) &&
5364 Tok.
isNot(tok::colon)) {
5365 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
5376 if (Tok.
is(tok::identifier)) {
5381 if (!Name && ScopedEnumKWLoc.
isValid()) {
5384 Diag(Tok, diag::err_scoped_enum_missing_identifier);
5386 IsScopedUsingClassTag =
false;
5391 if (shouldDelayDiagsInTag)
5392 diagsFromTag.done();
5397 bool CanBeBitfield =
5401 if (Tok.
is(tok::colon)) {
5426 if (CanBeBitfield && !isEnumBase(CanBeOpaqueEnumDeclaration)) {
5431 }
else if (CanHaveEnumBase || !ColonIsSacred) {
5442 DeclSpecContext::DSC_type_specifier);
5447 BaseRange =
SourceRange(ColonLoc, DeclaratorInfo.getSourceRange().getEnd());
5451 Diag(ColonLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type)
5454 Diag(ColonLoc, diag::ext_cxx11_enum_fixed_underlying_type)
5457 Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
5461 ? diag::warn_c17_compat_enum_fixed_underlying_type
5462 : diag::ext_c23_enum_fixed_underlying_type)
5479 if (AllowEnumSpecifier == AllowDefiningTypeSpec::No)
5481 else if (Tok.
is(tok::l_brace)) {
5490 IsScopedUsingClassTag =
false;
5496 }
else if (!isTypeSpecifier(DSC) &&
5497 (Tok.
is(tok::semi) ||
5499 !isValidAfterTypeSpecifier(CanBeBitfield)))) {
5504 if (Tok.
isNot(tok::semi)) {
5506 ExpectAndConsume(tok::semi, diag::err_expected_after,
"enum");
5514 bool IsElaboratedTypeSpecifier =
5520 diagsFromTag.redelay();
5524 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
5528 Diag(Tok, diag::err_enum_template);
5533 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
5536 Diag(StartLoc, diag::err_explicit_instantiation_enum);
5540 assert(TemplateInfo.TemplateParams &&
"no template parameters");
5542 TemplateInfo.TemplateParams->size());
5547 Diag(Tok, diag::err_enumerator_unnamed_no_def);
5563 if (IsElaboratedTypeSpecifier && !
getLangOpts().MicrosoftExt &&
5565 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
5566 diag::err_keyword_not_allowed,
5569 Diag(BaseRange.
getBegin(), diag::ext_enum_base_in_type_specifier)
5570 << (AllowEnumSpecifier == AllowDefiningTypeSpec::Yes) << BaseRange;
5571 else if (ScopedEnumKWLoc.
isValid())
5572 Diag(ScopedEnumKWLoc, diag::ext_elaborated_enum_class)
5576 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
5586 bool IsDependent =
false;
5587 const char *PrevSpec =
nullptr;
5592 TParams, Owned, IsDependent, ScopedEnumKWLoc,
5593 IsScopedUsingClassTag,
5594 BaseType, DSC == DeclSpecContext::DSC_type_specifier,
5595 DSC == DeclSpecContext::DSC_template_param ||
5596 DSC == DeclSpecContext::DSC_template_type_arg,
5597 OffsetOfState, &SkipBody).
get();
5607 NameLoc.
isValid() ? NameLoc : StartLoc,
5608 PrevSpec, DiagID,
TagDecl, Owned,
5610 Diag(StartLoc, DiagID) << PrevSpec;
5619 Diag(Tok, diag::err_expected_type_name_after_typename);
5625 if (
Type.isInvalid()) {
5631 NameLoc.
isValid() ? NameLoc : StartLoc,
5632 PrevSpec, DiagID,
Type.get(),
5634 Diag(StartLoc, DiagID) << PrevSpec;
5653 ParseEnumBody(StartLoc,
D);
5662 NameLoc.
isValid() ? NameLoc : StartLoc,
5663 PrevSpec, DiagID,
TagDecl, Owned,
5665 Diag(StartLoc, DiagID) << PrevSpec;
5688 Diag(Tok, diag::err_empty_enum);
5693 Decl *LastEnumConstDecl =
nullptr;
5696 while (Tok.
isNot(tok::r_brace)) {
5699 if (Tok.
isNot(tok::identifier)) {
5711 MaybeParseGNUAttributes(attrs);
5712 if (isAllowedCXX11AttributeSpecifier()) {
5715 ? diag::warn_cxx14_compat_ns_enum_attribute
5716 : diag::ext_ns_enum_attribute)
5718 ParseCXX11Attributes(attrs);
5723 EnumAvailabilityDiags.emplace_back(*
this);
5736 EqualLoc, AssignedVal.
get());
5737 EnumAvailabilityDiags.back().done();
5739 EnumConstantDecls.push_back(EnumConstDecl);
5740 LastEnumConstDecl = EnumConstDecl;
5742 if (Tok.
is(tok::identifier)) {
5745 Diag(
Loc, diag::err_enumerator_list_missing_comma)
5768 if (Tok.
is(tok::r_brace) && CommaLoc.
isValid()) {
5771 diag::ext_enumerator_list_comma_cxx :
5772 diag::ext_enumerator_list_comma_c)
5775 Diag(CommaLoc, diag::warn_cxx98_compat_enumerator_list_comma)
5786 MaybeParseGNUAttributes(attrs);
5792 assert(EnumConstantDecls.size() == EnumAvailabilityDiags.size());
5793 for (
size_t i = 0, e = EnumConstantDecls.size(); i != e; ++i) {
5795 EnumAvailabilityDiags[i].redelay();
5796 PD.complete(EnumConstantDecls[i]);
5805 if (!isValidAfterTypeSpecifier(CanBeBitfield)) {
5806 ExpectAndConsume(tok::semi, diag::err_expected_after,
"enum");
5818bool Parser::isKnownToBeTypeSpecifier(
const Token &Tok)
const {
5820 default:
return false;
5824 case tok::kw___int64:
5825 case tok::kw___int128:
5826 case tok::kw_signed:
5827 case tok::kw_unsigned:
5828 case tok::kw__Complex:
5829 case tok::kw__Imaginary:
5832 case tok::kw_wchar_t:
5833 case tok::kw_char8_t:
5834 case tok::kw_char16_t:
5835 case tok::kw_char32_t:
5837 case tok::kw__ExtInt:
5838 case tok::kw__BitInt:
5839 case tok::kw___bf16:
5842 case tok::kw_double:
5843 case tok::kw__Accum:
5844 case tok::kw__Fract:
5845 case tok::kw__Float16:
5846 case tok::kw___float128:
5847 case tok::kw___ibm128:
5850 case tok::kw__Decimal32:
5851 case tok::kw__Decimal64:
5852 case tok::kw__Decimal128:
5853 case tok::kw___vector:
5854#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
5855#include "clang/Basic/OpenCLImageTypes.def"
5856#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
5857#include "clang/Basic/HLSLIntangibleTypes.def"
5861 case tok::kw_struct:
5862 case tok::kw___interface:
5868 case tok::annot_typename:
5875bool Parser::isTypeSpecifierQualifier() {
5877 default:
return false;
5879 case tok::identifier:
5880 if (TryAltiVecVectorToken())
5883 case tok::kw_typename:
5888 if (Tok.
is(tok::identifier))
5890 return isTypeSpecifierQualifier();
5892 case tok::coloncolon:
5899 return isTypeSpecifierQualifier();
5902 case tok::kw___attribute:
5904 case tok::kw_typeof:
5905 case tok::kw_typeof_unqual:
5910 case tok::kw___int64:
5911 case tok::kw___int128:
5912 case tok::kw_signed:
5913 case tok::kw_unsigned:
5914 case tok::kw__Complex:
5915 case tok::kw__Imaginary:
5918 case tok::kw_wchar_t:
5919 case tok::kw_char8_t:
5920 case tok::kw_char16_t:
5921 case tok::kw_char32_t:
5923 case tok::kw__ExtInt:
5924 case tok::kw__BitInt:
5926 case tok::kw___bf16:
5928 case tok::kw_double:
5929 case tok::kw__Accum:
5930 case tok::kw__Fract:
5931 case tok::kw__Float16:
5932 case tok::kw___float128:
5933 case tok::kw___ibm128:
5936 case tok::kw__Decimal32:
5937 case tok::kw__Decimal64:
5938 case tok::kw__Decimal128:
5939 case tok::kw___vector:
5940#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
5941#include "clang/Basic/OpenCLImageTypes.def"
5942#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
5943#include "clang/Basic/HLSLIntangibleTypes.def"
5947 case tok::kw_struct:
5948 case tok::kw___interface:
5955 case tok::kw_volatile:
5956 case tok::kw_restrict:
5960 case tok::kw___unknown_anytype:
5963 case tok::annot_typename:
5970 case tok::kw___cdecl:
5971 case tok::kw___stdcall:
5972 case tok::kw___fastcall:
5973 case tok::kw___thiscall:
5974 case tok::kw___regcall:
5975 case tok::kw___vectorcall:
5977 case tok::kw___ptr64:
5978 case tok::kw___ptr32:
5979 case tok::kw___pascal:
5980 case tok::kw___unaligned:
5982 case tok::kw__Nonnull:
5983 case tok::kw__Nullable:
5984 case tok::kw__Nullable_result:
5985 case tok::kw__Null_unspecified:
5987 case tok::kw___kindof:
5989 case tok::kw___private:
5990 case tok::kw___local:
5991 case tok::kw___global:
5992 case tok::kw___constant:
5993 case tok::kw___generic:
5994 case tok::kw___read_only:
5995 case tok::kw___read_write:
5996 case tok::kw___write_only:
5997 case tok::kw___funcref:
6000 case tok::kw_private:
6004 case tok::kw__Atomic:
6008 case tok::kw_groupshared:
6021 ParsedStmtContext SubStmtCtx = ParsedStmtContext();
6025 StmtResult R = ParseStatementOrDeclaration(Stmts, SubStmtCtx);
6031 if (Tok.
is(tok::annot_repl_input_end) &&
6033 ConsumeAnnotationToken();
6038 DeclsInGroup.push_back(TLSD);
6041 for (
Stmt *S : Stmts) {
6046 DeclsInGroup.push_back(
D);
6059bool Parser::isDeclarationSpecifier(
6061 bool DisambiguatingWithExpression) {
6063 default:
return false;
6070 case tok::identifier:
6074 if (TryAltiVecVectorToken())
6077 case tok::kw_decltype:
6078 case tok::kw_typename:
6083 if (TryAnnotateTypeConstraint())
6085 if (Tok.
is(tok::identifier))
6093 if (DisambiguatingWithExpression &&
6094 isStartOfObjCClassMessageMissingOpenBracket())
6097 return isDeclarationSpecifier(AllowImplicitTypename);
6099 case tok::coloncolon:
6113 case tok::kw_typedef:
6114 case tok::kw_extern:
6115 case tok::kw___private_extern__:
6116 case tok::kw_static:
6118 case tok::kw___auto_type:
6119 case tok::kw_register:
6120 case tok::kw___thread:
6121 case tok::kw_thread_local:
6122 case tok::kw__Thread_local:
6125 case tok::kw___module_private__:
6128 case tok::kw___unknown_anytype:
6133 case tok::kw___int64:
6134 case tok::kw___int128:
6135 case tok::kw_signed:
6136 case tok::kw_unsigned:
6137 case tok::kw__Complex:
6138 case tok::kw__Imaginary:
6141 case tok::kw_wchar_t:
6142 case tok::kw_char8_t:
6143 case tok::kw_char16_t:
6144 case tok::kw_char32_t:
6147 case tok::kw__ExtInt:
6148 case tok::kw__BitInt:
6150 case tok::kw___bf16:
6152 case tok::kw_double:
6153 case tok::kw__Accum:
6154 case tok::kw__Fract:
6155 case tok::kw__Float16:
6156 case tok::kw___float128:
6157 case tok::kw___ibm128:
6160 case tok::kw__Decimal32:
6161 case tok::kw__Decimal64:
6162 case tok::kw__Decimal128:
6163 case tok::kw___vector:
6167 case tok::kw_struct:
6169 case tok::kw___interface:
6175 case tok::kw_volatile:
6176 case tok::kw_restrict:
6180 case tok::kw_inline:
6181 case tok::kw_virtual:
6182 case tok::kw_explicit:
6183 case tok::kw__Noreturn:
6186 case tok::kw__Alignas:
6189 case tok::kw_friend:
6192 case tok::kw_static_assert:
6193 case tok::kw__Static_assert:
6196 case tok::kw_typeof:
6197 case tok::kw_typeof_unqual:
6200 case tok::kw___attribute:
6203 case tok::annot_decltype:
6204 case tok::annot_pack_indexing_type:
6205 case tok::kw_constexpr:
6208 case tok::kw_consteval:
6209 case tok::kw_constinit:
6212 case tok::kw__Atomic:
6215 case tok::kw_alignas:
6225 case tok::annot_typename:
6226 return !DisambiguatingWithExpression ||
6227 !isStartOfObjCClassMessageMissingOpenBracket();
6230 case tok::annot_template_id: {
6236 return isTypeConstraintAnnotation() &&
6240 case tok::annot_cxxscope: {
6249 if (
NextToken().is(tok::identifier) && TryAnnotateTypeConstraint())
6251 return isTypeConstraintAnnotation() &&
6252 GetLookAheadToken(2).isOneOf(tok::kw_auto, tok::kw_decltype);
6255 case tok::kw___declspec:
6256 case tok::kw___cdecl:
6257 case tok::kw___stdcall:
6258 case tok::kw___fastcall:
6259 case tok::kw___thiscall:
6260 case tok::kw___regcall:
6261 case tok::kw___vectorcall:
6263 case tok::kw___sptr:
6264 case tok::kw___uptr:
6265 case tok::kw___ptr64:
6266 case tok::kw___ptr32:
6267 case tok::kw___forceinline:
6268 case tok::kw___pascal:
6269 case tok::kw___unaligned:
6271 case tok::kw__Nonnull:
6272 case tok::kw__Nullable:
6273 case tok::kw__Nullable_result:
6274 case tok::kw__Null_unspecified:
6276 case tok::kw___kindof:
6278 case tok::kw___private:
6279 case tok::kw___local:
6280 case tok::kw___global:
6281 case tok::kw___constant:
6282 case tok::kw___generic:
6283 case tok::kw___read_only:
6284 case tok::kw___read_write:
6285 case tok::kw___write_only:
6286#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
6287#include "clang/Basic/OpenCLImageTypes.def"
6288#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
6289#include "clang/Basic/HLSLIntangibleTypes.def"
6291 case tok::kw___funcref:
6292 case tok::kw_groupshared:
6295 case tok::kw_private:
6300bool Parser::isConstructorDeclarator(
bool IsUnqualified,
bool DeductionGuide,
6302 const ParsedTemplateInfo *TemplateInfo) {
6303 RevertingTentativeParsingAction TPA(*
this);
6306 if (TemplateInfo && TemplateInfo->TemplateParams)
6309 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
6316 if (Tok.
is(tok::identifier)) {
6320 }
else if (Tok.
is(tok::annot_template_id)) {
6321 ConsumeAnnotationToken();
6328 SkipCXX11Attributes();
6331 if (Tok.
isNot(tok::l_paren)) {
6338 if (Tok.
is(tok::r_paren) ||
6339 (Tok.
is(tok::ellipsis) &&
NextToken().is(tok::r_paren))) {
6346 isCXX11AttributeSpecifier(
false,
6352 DeclaratorScopeObj DeclScopeObj(*
this, SS);
6354 DeclScopeObj.EnterDeclaratorScope();
6358 MaybeParseMicrosoftAttributes(Attrs);
6367 bool IsConstructor =
false;
6373 if (Tok.
is(tok::kw_this)) {
6375 return isDeclarationSpecifier(ITC);
6378 if (isDeclarationSpecifier(ITC))
6379 IsConstructor =
true;
6380 else if (Tok.
is(tok::identifier) ||
6381 (Tok.
is(tok::annot_cxxscope) &&
NextToken().is(tok::identifier))) {
6386 if (Tok.
is(tok::annot_cxxscope))
6387 ConsumeAnnotationToken();
6399 case tok::coloncolon:
6412 SkipCXX11Attributes();
6414 if (DeductionGuide) {
6416 IsConstructor = Tok.
is(tok::arrow);
6419 if (Tok.
is(tok::colon) || Tok.
is(tok::kw_try)) {
6423 IsConstructor =
true;
6425 if (Tok.
is(tok::semi) || Tok.
is(tok::l_brace)) {
6438 IsConstructor = IsUnqualified;
6443 IsConstructor =
true;
6447 return IsConstructor;
6462void Parser::ParseTypeQualifierListOpt(
6463 DeclSpec &DS,
unsigned AttrReqs,
bool AtomicAllowed,
6464 bool IdentifierRequired,
6466 if ((AttrReqs & AR_CXX11AttributesParsed) &&
6467 isAllowedCXX11AttributeSpecifier()) {
6469 ParseCXX11Attributes(Attrs);
6477 const char *PrevSpec =
nullptr;
6478 unsigned DiagID = 0;
6482 case tok::code_completion:
6485 (*CodeCompletionHandler)();
6494 case tok::kw_volatile:
6498 case tok::kw_restrict:
6502 case tok::kw__Atomic:
6504 goto DoneWithTypeQuals;
6505 diagnoseUseOfC11Keyword(Tok);
6511 case tok::kw_private:
6513 goto DoneWithTypeQuals;
6515 case tok::kw___private:
6516 case tok::kw___global:
6517 case tok::kw___local:
6518 case tok::kw___constant:
6519 case tok::kw___generic:
6520 case tok::kw___read_only:
6521 case tok::kw___write_only:
6522 case tok::kw___read_write:
6526 case tok::kw_groupshared:
6534 case tok::kw___unaligned:
6538 case tok::kw___uptr:
6543 if (TryKeywordIdentFallback(
false))
6547 case tok::kw___sptr:
6549 case tok::kw___ptr64:
6550 case tok::kw___ptr32:
6551 case tok::kw___cdecl:
6552 case tok::kw___stdcall:
6553 case tok::kw___fastcall:
6554 case tok::kw___thiscall:
6555 case tok::kw___regcall:
6556 case tok::kw___vectorcall:
6557 if (AttrReqs & AR_DeclspecAttributesParsed) {
6561 goto DoneWithTypeQuals;
6563 case tok::kw___funcref:
6566 goto DoneWithTypeQuals;
6568 case tok::kw___pascal:
6569 if (AttrReqs & AR_VendorAttributesParsed) {
6573 goto DoneWithTypeQuals;
6576 case tok::kw__Nonnull:
6577 case tok::kw__Nullable:
6578 case tok::kw__Nullable_result:
6579 case tok::kw__Null_unspecified:
6584 case tok::kw___kindof:
6586 nullptr, 0, tok::kw___kindof);
6590 case tok::kw___attribute:
6591 if (AttrReqs & AR_GNUAttributesParsedAndRejected)
6593 Diag(Tok, diag::err_attributes_not_allowed);
6597 if (AttrReqs & AR_GNUAttributesParsed ||
6598 AttrReqs & AR_GNUAttributesParsedAndRejected) {
6616 assert(PrevSpec &&
"Method did not return previous specifier!");
6617 Diag(Tok, DiagID) << PrevSpec;
6628 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
6634 if (Kind == tok::star || Kind == tok::caret)
6638 if (Kind == tok::kw_pipe && Lang.OpenCL &&
6639 Lang.getOpenCLCompatibleVersion() >= 200)
6642 if (!Lang.CPlusPlus)
6645 if (Kind == tok::amp)
6653 if (Kind == tok::ampamp)
6662 const unsigned NumTypes =
D.getNumTypeObjects();
6664 for (
unsigned Idx = 0; Idx != NumTypes; ++Idx)
6696void Parser::ParseDeclaratorInternal(
Declarator &
D,
6697 DirectDeclParseFunction DirectDeclParser) {
6705 (Tok.
is(tok::coloncolon) || Tok.
is(tok::kw_decltype) ||
6706 (Tok.
is(tok::identifier) &&
6708 Tok.
is(tok::annot_cxxscope))) {
6709 TentativeParsingAction TPA(*
this,
true);
6715 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
6725 Tok.
is(tok::star)) {
6729 checkCompoundToken(SS.
getEndLoc(), tok::coloncolon,
6730 CompoundToken::MemberPtr);
6734 D.SetRangeEnd(StarLoc);
6736 ParseTypeQualifierListOpt(DS);
6737 D.ExtendWithDeclSpec(DS);
6741 ParseDeclaratorInternal(D, DirectDeclParser);
6755 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
6762 if (
D.mayHaveIdentifier())
6763 D.getCXXScopeSpec() = SS;
6765 AnnotateScopeToken(SS,
true);
6767 if (DirectDeclParser)
6768 (this->*DirectDeclParser)(
D);
6777 ParseTypeQualifierListOpt(DS);
6786 if (DirectDeclParser)
6787 (this->*DirectDeclParser)(
D);
6796 if (Kind == tok::star || Kind == tok::caret) {
6802 unsigned Reqs = AR_CXX11AttributesParsed | AR_DeclspecAttributesParsed |
6804 ? AR_GNUAttributesParsed
6805 : AR_GNUAttributesParsedAndRejected);
6806 ParseTypeQualifierListOpt(DS, Reqs,
true, !
D.mayOmitIdentifier());
6807 D.ExtendWithDeclSpec(DS);
6811 D.
getBeginLoc(), [&] { ParseDeclaratorInternal(D, DirectDeclParser); });
6812 if (Kind == tok::star)
6830 if (Kind == tok::ampamp)
6832 diag::warn_cxx98_compat_rvalue_reference :
6833 diag::ext_rvalue_reference);
6836 ParseTypeQualifierListOpt(DS);
6837 D.ExtendWithDeclSpec(DS);
6845 diag::err_invalid_reference_qualifier_application) <<
"const";
6848 diag::err_invalid_reference_qualifier_application) <<
"volatile";
6852 diag::err_invalid_reference_qualifier_application) <<
"_Atomic";
6857 D.
getBeginLoc(), [&] { ParseDeclaratorInternal(D, DirectDeclParser); });
6859 if (
D.getNumTypeObjects() > 0) {
6864 Diag(InnerChunk.
Loc, diag::err_illegal_decl_reference_to_reference)
6867 Diag(InnerChunk.
Loc, diag::err_illegal_decl_reference_to_reference)
6889 if (
D.getName().StartLocation.isInvalid() &&
6890 D.getName().EndLocation.isValid())
6891 return D.getName().EndLocation;
6942void Parser::ParseDirectDeclarator(
Declarator &
D) {
6943 DeclaratorScopeObj DeclScopeObj(*
this,
D.getCXXScopeSpec());
6947 if (Tok.
is(tok::l_square) && !
D.mayOmitIdentifier() &&
6948 D.getCXXScopeSpec().isEmpty())
6949 return ParseDecompositionDeclarator(
D);
6960 if (
D.getCXXScopeSpec().isEmpty()) {
6963 ParseOptionalCXXScopeSpecifier(
6964 D.getCXXScopeSpec(),
nullptr,
6965 false, EnteringContext);
6979 if (
D.getCXXScopeSpec().isValid()) {
6981 D.getCXXScopeSpec()))
6984 DeclScopeObj.EnterDeclaratorScope();
6989 D.setInvalidType(
true);
6991 goto PastIdentifier;
7002 if (Tok.
is(tok::ellipsis) &&
D.getCXXScopeSpec().isEmpty() &&
7006 NextToken().is(tok::r_paren) && !
D.hasGroupingParens() &&
7008 D.getDeclSpec().getTypeSpecType() !=
TST_auto)) {
7015 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc,
D);
7018 D.setEllipsisLoc(EllipsisLoc);
7025 if (Tok.
isOneOf(tok::identifier, tok::kw_operator, tok::annot_template_id,
7029 bool AllowConstructorName;
7030 bool AllowDeductionGuide;
7031 if (
D.getDeclSpec().hasTypeSpecifier()) {
7032 AllowConstructorName =
false;
7033 AllowDeductionGuide =
false;
7034 }
else if (
D.getCXXScopeSpec().isSet()) {
7037 AllowDeductionGuide =
false;
7044 bool HadScope =
D.getCXXScopeSpec().isValid();
7050 true, AllowConstructorName,
7051 AllowDeductionGuide, &TemplateKWLoc,
7055 D.getCXXScopeSpec().isInvalid()) {
7057 D.setInvalidType(
true);
7061 if (!HadScope &&
D.getCXXScopeSpec().isValid() &&
7063 D.getCXXScopeSpec()))
7064 DeclScopeObj.EnterDeclaratorScope();
7071 goto PastIdentifier;
7074 if (
D.getCXXScopeSpec().isNotEmpty()) {
7077 diag::err_expected_unqualified_id)
7080 goto PastIdentifier;
7082 }
else if (Tok.
is(tok::identifier) &&
D.mayHaveIdentifier()) {
7084 "There's a C++-specific check for tok::identifier above");
7089 goto PastIdentifier;
7090 }
else if (Tok.
is(tok::identifier) && !
D.mayHaveIdentifier()) {
7094 bool DiagnoseIdentifier =
false;
7095 if (
D.hasGroupingParens())
7098 DiagnoseIdentifier =
true;
7101 DiagnoseIdentifier =
7109 !isCXX11VirtSpecifier(Tok))
7111 tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try);
7112 if (DiagnoseIdentifier) {
7117 goto PastIdentifier;
7121 if (Tok.
is(tok::l_paren)) {
7125 if (
D.mayOmitIdentifier() &&
D.mayBeFollowedByCXXDirectInit()) {
7126 RevertingTentativeParsingAction PA(*
this);
7127 if (TryParseDeclarator(
true,
D.mayHaveIdentifier(),
true,
7128 D.getDeclSpec().getTypeSpecType() ==
TST_auto) ==
7131 goto PastIdentifier;
7138 ParseParenDeclarator(
D);
7143 if (
D.getCXXScopeSpec().isSet()) {
7146 if (!
D.isInvalidType() &&
7148 D.getCXXScopeSpec()))
7151 DeclScopeObj.EnterDeclaratorScope();
7153 }
else if (
D.mayOmitIdentifier()) {
7160 if (
D.hasEllipsis() &&
D.hasGroupingParens())
7162 diag::ext_abstract_pack_declarator_parens);
7164 if (Tok.
getKind() == tok::annot_pragma_parser_crash)
7166 if (Tok.
is(tok::l_square))
7167 return ParseMisplacedBracketDeclarator(
D);
7175 diag::err_expected_member_name_or_semi_objcxx_keyword)
7182 goto PastIdentifier;
7185 diag::err_expected_member_name_or_semi)
7189 if (Tok.
getKind() == tok::TokenKind::kw_while) {
7190 Diag(Tok, diag::err_while_loop_outside_of_a_function);
7192 if (Tok.
isOneOf(tok::period, tok::arrow))
7193 Diag(Tok, diag::err_invalid_operator_on_type) << Tok.
is(tok::arrow);
7201 diag::err_expected_unqualified_id)
7206 diag::err_expected_either)
7207 << tok::identifier << tok::l_paren;
7211 D.setInvalidType(
true);
7215 assert(
D.isPastIdentifier() &&
7216 "Haven't past the location of the identifier yet?");
7219 if (
D.hasName() && !
D.getNumTypeObjects())
7220 MaybeParseCXX11Attributes(
D);
7223 if (Tok.
is(tok::l_paren)) {
7224 bool IsFunctionDeclaration =
D.isFunctionDeclaratorAFunctionDeclaration();
7227 ParseScope PrototypeScope(
this,
7229 (IsFunctionDeclaration
7235 bool IsAmbiguous =
false;
7246 if (
D.getCXXScopeSpec().isSet())
7247 AllowImplicitTypename =
7255 TentativelyDeclaredIdentifiers.push_back(
D.getIdentifier());
7256 bool IsFunctionDecl =
7257 isCXXFunctionDeclarator(&IsAmbiguous, AllowImplicitTypename);
7258 TentativelyDeclaredIdentifiers.pop_back();
7259 if (!IsFunctionDecl)
7265 if (IsFunctionDeclaration)
7267 TemplateParameterDepth);
7268 ParseFunctionDeclarator(
D, attrs,
T, IsAmbiguous);
7269 if (IsFunctionDeclaration)
7271 PrototypeScope.Exit();
7272 }
else if (Tok.
is(tok::l_square)) {
7273 ParseBracketDeclarator(
D);
7281 if (!
T.consumeOpen())
7284 }
else if (Tok.
is(tok::kw_requires) &&
D.hasGroupingParens()) {
7292 Diag(Tok, diag::err_requires_clause_inside_parens);
7296 if (TrailingRequiresClause.
isUsable() &&
D.isFunctionDeclarator() &&
7297 !
D.hasTrailingRequiresClause())
7299 D.setTrailingRequiresClause(TrailingRequiresClause.
get());
7306void Parser::ParseDecompositionDeclarator(
Declarator &
D) {
7307 assert(Tok.
is(tok::l_square));
7309 TentativeParsingAction PA(*
this);
7313 if (isCXX11AttributeSpecifier())
7314 DiagnoseAndSkipCXX11Attributes();
7318 if (!(Tok.
is(tok::identifier) &&
7321 !(Tok.
is(tok::r_square) &&
7324 return ParseMisplacedBracketDeclarator(
D);
7328 while (Tok.
isNot(tok::r_square)) {
7330 if (Tok.
is(tok::comma))
7333 if (Tok.
is(tok::identifier)) {
7335 Diag(EndLoc, diag::err_expected)
7338 Diag(Tok, diag::err_expected_comma_or_rsquare);
7341 SkipUntil(tok::r_square, tok::comma, tok::identifier,
7343 if (Tok.
is(tok::comma))
7345 else if (Tok.
isNot(tok::identifier))
7350 if (isCXX11AttributeSpecifier())
7351 DiagnoseAndSkipCXX11Attributes();
7353 if (Tok.
isNot(tok::identifier)) {
7354 Diag(Tok, diag::err_expected) << tok::identifier;
7363 if (isCXX11AttributeSpecifier()) {
7365 ? diag::warn_cxx23_compat_decl_attrs_on_binding
7366 : diag::ext_decl_attrs_on_binding);
7367 MaybeParseCXX11Attributes(Attrs);
7373 if (Tok.
isNot(tok::r_square))
7387 return D.setDecompositionBindings(
T.getOpenLocation(),
Bindings,
7388 T.getCloseLocation());
7408 assert(!
D.isPastIdentifier() &&
"Should be called before passing identifier");
7421 bool RequiresArg =
false;
7422 if (Tok.
is(tok::kw___attribute)) {
7423 ParseGNUAttributes(attrs);
7431 ParseMicrosoftTypeAttributes(attrs);
7434 if (Tok.
is(tok::kw___pascal))
7435 ParseBorlandTypeAttributes(attrs);
7443 if (!
D.mayOmitIdentifier()) {
7447 }
else if (Tok.
is(tok::r_paren) ||
7450 isDeclarationSpecifier(
7452 isCXX11AttributeSpecifier()) {
7468 bool hadGroupingParens =
D.hasGroupingParens();
7469 D.setGroupingParens(
true);
7470 ParseDeclaratorInternal(
D, &Parser::ParseDirectDeclarator);
7475 std::move(attrs),
T.getCloseLocation());
7477 D.setGroupingParens(hadGroupingParens);
7481 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc,
D);
7494 ParseScope PrototypeScope(
this,
7496 (
D.isFunctionDeclaratorAFunctionDeclaration()
7498 ParseFunctionDeclarator(
D, attrs,
T,
false, RequiresArg);
7499 PrototypeScope.Exit();
7502void Parser::InitCXXThisScopeForDeclaratorIfRelevant(
7504 std::optional<Sema::CXXThisScopeRAII> &ThisScope) {
7512 bool IsCXX11MemberFunction =
7516 ? !
D.getDeclSpec().isFriendSpecified()
7518 D.getCXXScopeSpec().isValid() &&
7520 if (!IsCXX11MemberFunction)
7540 ThisScope.emplace(Actions, dyn_cast<CXXRecordDecl>(Actions.
CurContext), Q,
7541 IsCXX11MemberFunction);
7564void Parser::ParseFunctionDeclarator(
Declarator &
D,
7569 assert(
getCurScope()->isFunctionPrototypeScope() &&
7570 "Should call from a Function scope");
7572 assert(
D.isPastIdentifier() &&
"Should not call before identifier!");
7576 bool HasProto =
false;
7583 bool RefQualifierIsLValueRef =
true;
7601 StartLoc = LParenLoc;
7603 if (isFunctionDeclaratorIdentifierList()) {
7605 Diag(Tok, diag::err_argument_required_after_attribute);
7607 ParseFunctionDeclaratorIdentifierList(
D, ParamInfo);
7611 LocalEndLoc = RParenLoc;
7616 MaybeParseCXX11Attributes(FnAttrs);
7617 ProhibitAttributes(FnAttrs);
7619 if (Tok.
isNot(tok::r_paren))
7620 ParseParameterDeclarationClause(
D, FirstArgAttrs, ParamInfo, EllipsisLoc);
7621 else if (RequiresArg)
7622 Diag(Tok, diag::err_argument_required_after_attribute);
7633 LocalEndLoc = RParenLoc;
7642 ParseTypeQualifierListOpt(
7643 DS, AR_NoAttributesParsed,
7645 false, llvm::function_ref<
void()>([&]() {
7653 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc))
7654 EndLoc = RefQualifierLoc;
7656 std::optional<Sema::CXXThisScopeRAII> ThisScope;
7657 InitCXXThisScopeForDeclaratorIfRelevant(
D, DS, ThisScope);
7673 D.isFunctionDeclaratorAFunctionDeclaration();
7675 GetLookAheadToken(0).is(tok::kw_noexcept) &&
7676 GetLookAheadToken(1).is(tok::l_paren) &&
7677 GetLookAheadToken(2).is(tok::kw_noexcept) &&
7678 GetLookAheadToken(3).is(tok::l_paren) &&
7679 GetLookAheadToken(4).is(tok::identifier) &&
7680 GetLookAheadToken(4).getIdentifierInfo()->isStr(
"swap")) {
7691 ESpecType = tryParseExceptionSpecification(Delayed,
7694 DynamicExceptionRanges,
7696 ExceptionSpecTokens);
7698 EndLoc = ESpecRange.
getEnd();
7702 MaybeParseCXX11Attributes(FnAttrs);
7705 LocalEndLoc = EndLoc;
7707 Diag(Tok, diag::warn_cxx98_compat_trailing_return_type);
7708 if (
D.getDeclSpec().getTypeSpecType() ==
TST_auto)
7709 StartLoc =
D.getDeclSpec().getTypeSpecTypeLoc();
7712 TrailingReturnType =
7713 ParseTrailingReturnType(
Range,
D.mayBeFollowedByCXXDirectInit());
7718 MaybeParseCXX11Attributes(FnAttrs);
7730 if (!ND || isa<ParmVarDecl>(ND))
7732 DeclsInPrototype.push_back(ND);
7739 llvm::sort(DeclsInPrototype, [](
Decl *D1,
Decl *D2) {
7747 HasProto, IsAmbiguous, LParenLoc, ParamInfo.data(),
7748 ParamInfo.size(), EllipsisLoc, RParenLoc,
7749 RefQualifierIsLValueRef, RefQualifierLoc,
7751 ESpecType, ESpecRange, DynamicExceptions.data(),
7752 DynamicExceptionRanges.data(), DynamicExceptions.size(),
7753 NoexceptExpr.
isUsable() ? NoexceptExpr.
get() :
nullptr,
7754 ExceptionSpecTokens, DeclsInPrototype, StartLoc,
7755 LocalEndLoc,
D, TrailingReturnType, TrailingReturnTypeLoc,
7757 std::move(FnAttrs), EndLoc);
7762bool Parser::ParseRefQualifier(
bool &RefQualifierIsLValueRef,
7764 if (Tok.
isOneOf(tok::amp, tok::ampamp)) {
7766 diag::warn_cxx98_compat_ref_qualifier :
7767 diag::ext_ref_qualifier);
7769 RefQualifierIsLValueRef = Tok.
is(tok::amp);
7781bool Parser::isFunctionDeclaratorIdentifierList() {
7783 && Tok.
is(tok::identifier)
7784 && !TryAltiVecVectorToken()
7800 && (!Tok.
is(tok::eof) &&
7813void Parser::ParseFunctionDeclaratorIdentifierList(
7817 assert(!
getLangOpts().requiresStrictPrototypes() &&
7818 "Cannot parse an identifier list in C23 or C++");
7824 if (!
D.getIdentifier())
7825 Diag(Tok, diag::ext_ident_list_in_param);
7828 llvm::SmallSet<const IdentifierInfo*, 16> ParamsSoFar;
7832 if (Tok.
isNot(tok::identifier)) {
7833 Diag(Tok, diag::err_expected) << tok::identifier;
7844 Diag(Tok, diag::err_unexpected_typedef_ident) << ParmII;
7847 if (!ParamsSoFar.insert(ParmII).second) {
7848 Diag(Tok, diag::err_param_redefinition) << ParmII;
7894void Parser::ParseParameterDeclarationClause(
7903 if (
getCurScope()->getFunctionPrototypeDepth() - 1 >
7924 IsACXXFunctionDeclaration) {
7946 ArgDeclSpecAttrs.takeAllFrom(FirstArgAttrs);
7949 MaybeParseCXX11Attributes(ArgDeclAttrs);
7952 MaybeParseMicrosoftAttributes(ArgDeclSpecAttrs);
7963 ParsedTemplateInfo TemplateInfo;
7964 ParseDeclarationSpecifiers(DS, TemplateInfo,
AS_none,
7965 DeclSpecContext::DSC_normal,
7966 nullptr, AllowImplicitTypename);
7979 ParseDeclarator(ParmDeclarator);
7982 ParmDeclarator.SetRangeBegin(ThisLoc);
7985 MaybeParseGNUAttributes(ParmDeclarator);
7989 if (Tok.
is(tok::kw_requires)) {
7994 diag::err_requires_clause_on_declarator_not_declaring_a_function);
8005 std::unique_ptr<CachedTokens> DefArgToks;
8009 if (DS.
isEmpty() && ParmDeclarator.getIdentifier() ==
nullptr &&
8010 ParmDeclarator.getNumTypeObjects() == 0) {
8012 Diag(DSStart, diag::err_missing_param);
8019 if (Tok.
is(tok::ellipsis) &&
8021 (!ParmDeclarator.getEllipsisLoc().isValid() &&
8024 DiagnoseMisplacedEllipsisInDeclarator(
ConsumeToken(), ParmDeclarator);
8043 if (!ParmDeclarator.isInvalidType() && !ParmDeclarator.hasName() &&
8056 Diag(ParmDeclarator.getBeginLoc(),
8057 diag::err_function_parameter_limit_exceeded);
8070 if (Tok.
is(tok::equal)) {
8081 ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument);
8097 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
8098 DefArgResult = ParseBraceInitializer();
8100 if (Tok.
is(tok::l_paren) &&
NextToken().is(tok::l_brace)) {
8101 Diag(Tok, diag::err_stmt_expr_in_default_arg) << 0;
8118 DefArgResult.
get());
8124 ParmDeclarator.getIdentifierLoc(),
8125 Param, std::move(DefArgToks)));
8133 Diag(EllipsisLoc, diag::warn_deprecated_missing_comma_before_ellipsis)
8140 Diag(EllipsisLoc, diag::err_missing_comma_before_ellipsis)
8142 }
else if (ParmDeclarator.getEllipsisLoc().isValid() ||
8147 Diag(EllipsisLoc, diag::warn_misplaced_ellipsis_vararg)
8148 << ParmEllipsis.
isValid() << ParmEllipsis;
8151 diag::note_misplaced_ellipsis_vararg_existing_ellipsis);
8153 Diag(ParmDeclarator.getIdentifierLoc(),
8154 diag::note_misplaced_ellipsis_vararg_add_ellipsis)
8157 << !ParmDeclarator.hasName();
8159 Diag(EllipsisLoc, diag::note_misplaced_ellipsis_vararg_add_comma)
8178void Parser::ParseBracketDeclarator(
Declarator &
D) {
8179 if (CheckProhibitedCXX11Attribute())
8187 if (Tok.
getKind() == tok::r_square) {
8190 MaybeParseCXX11Attributes(attrs);
8194 T.getOpenLocation(),
8195 T.getCloseLocation()),
8196 std::move(attrs),
T.getCloseLocation());
8198 }
else if (Tok.
getKind() == tok::numeric_constant &&
8199 GetLookAheadToken(1).is(tok::r_square)) {
8206 MaybeParseCXX11Attributes(attrs);
8210 T.getOpenLocation(),
8211 T.getCloseLocation()),
8212 std::move(attrs),
T.getCloseLocation());
8214 }
else if (Tok.
getKind() == tok::code_completion) {
8227 ParseTypeQualifierListOpt(DS, AR_CXX11AttributesParsed);
8235 bool isStar =
false;
8242 if (Tok.
is(tok::star) && GetLookAheadToken(1).is(tok::r_square)) {
8246 Diag(StaticLoc, diag::err_unspecified_vla_size_with_static);
8250 }
else if (Tok.
isNot(tok::r_square)) {
8268 Diag(StaticLoc, diag::err_unspecified_size_with_static);
8275 D.setInvalidType(
true);
8288 isStar, NumElements.
get(),
T.getOpenLocation(),
8289 T.getCloseLocation()),
8294void Parser::ParseMisplacedBracketDeclarator(
Declarator &
D) {
8295 assert(Tok.
is(tok::l_square) &&
"Missing opening bracket");
8296 assert(!
D.mayOmitIdentifier() &&
"Declarator cannot omit identifier");
8302 while (Tok.
is(tok::l_square)) {
8303 ParseBracketDeclarator(TempDeclarator);
8309 if (Tok.
is(tok::semi))
8310 D.getName().EndLocation = StartBracketLoc;
8315 ParseDeclaratorInternal(
D, &Parser::ParseDirectDeclarator);
8320 if (TempDeclarator.getNumTypeObjects() == 0)
8324 bool NeedParens =
false;
8325 if (
D.getNumTypeObjects() != 0) {
8326 switch (
D.getTypeObject(
D.getNumTypeObjects() - 1).
Kind) {
8349 for (
unsigned i = 0, e = TempDeclarator.getNumTypeObjects(); i < e; ++i) {
8351 D.AddTypeInfo(Chunk, TempDeclarator.getAttributePool(),
SourceLocation());
8356 if (!
D.getIdentifier() && !NeedParens)
8362 SourceRange BracketRange(StartBracketLoc, EndBracketLoc);
8366 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
8374 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
8394void Parser::ParseTypeofSpecifier(
DeclSpec &DS) {
8395 assert(Tok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
8396 "Not a typeof specifier");
8398 bool IsUnqual = Tok.
is(tok::kw_typeof_unqual);
8405 bool HasParens = Tok.
is(tok::l_paren);
8415 ParseExprAfterUnaryExprOrTypeTrait(OpTok, isCastExpr, CastTy, CastRange));
8431 const char *PrevSpec =
nullptr;
8439 Diag(StartLoc, DiagID) << PrevSpec;
8456 const char *PrevSpec =
nullptr;
8464 Diag(StartLoc, DiagID) << PrevSpec;
8470void Parser::ParseAtomicSpecifier(
DeclSpec &DS) {
8471 assert(Tok.
is(tok::kw__Atomic) &&
NextToken().is(tok::l_paren) &&
8472 "Not an atomic specifier");
8476 if (
T.consumeOpen())
8480 if (
Result.isInvalid()) {
8488 if (
T.getCloseLocation().isInvalid())
8494 const char *PrevSpec =
nullptr;
8499 Diag(StartLoc, DiagID) << PrevSpec;
8504bool Parser::TryAltiVecVectorTokenOutOfLine() {
8506 switch (Next.getKind()) {
8507 default:
return false;
8510 case tok::kw_signed:
8511 case tok::kw_unsigned:
8516 case tok::kw_double:
8519 case tok::kw___bool:
8520 case tok::kw___pixel:
8521 Tok.
setKind(tok::kw___vector);
8523 case tok::identifier:
8524 if (Next.getIdentifierInfo() == Ident_pixel) {
8525 Tok.
setKind(tok::kw___vector);
8528 if (Next.getIdentifierInfo() == Ident_bool ||
8529 Next.getIdentifierInfo() == Ident_Bool) {
8530 Tok.
setKind(tok::kw___vector);
8538 const char *&PrevSpec,
unsigned &DiagID,
8543 switch (Next.getKind()) {
8546 case tok::kw_signed:
8547 case tok::kw_unsigned:
8552 case tok::kw_double:
8555 case tok::kw___bool:
8556 case tok::kw___pixel:
8559 case tok::identifier:
8560 if (Next.getIdentifierInfo() == Ident_pixel) {
8564 if (Next.getIdentifierInfo() == Ident_bool ||
8565 Next.getIdentifierInfo() == Ident_Bool) {
8586TypeResult Parser::ParseTypeFromString(StringRef TypeStr, StringRef Context,
8593 FileID FID = SourceMgr.createFileID(
8594 llvm::MemoryBuffer::getMemBufferCopy(TypeStr, Context),
SrcMgr::C_User,
8598 Lexer L(FID, SourceMgr.getBufferOrFake(FID), PP);
8599 L.setParsingPreprocessorDirective(
true);
8605 Tokens.push_back(Tok);
8606 }
while (Tok.
isNot(tok::eod));
8611 Token &EndToken = Tokens.back();
8618 Tokens.push_back(Tok);
8621 PP.EnterTokenStream(Tokens,
false,
8629 ParseScope LocalScope(
this, 0);
8642 while (Tok.
isNot(tok::eof))
8646 if (Tok.
is(tok::eof) && Tok.
getEofData() == TypeStr.data())
8651void Parser::DiagnoseBitIntUse(
const Token &Tok) {
8655 assert(Tok.
isOneOf(tok::kw__ExtInt, tok::kw__BitInt) &&
8656 "expected either an _ExtInt or _BitInt token!");
8659 if (Tok.
is(tok::kw__ExtInt)) {
8660 Diag(
Loc, diag::warn_ext_int_deprecated)
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
static StringRef normalizeAttrName(const IdentifierInfo *Name, StringRef NormalizedScopeName, AttributeCommonInfo::Syntax SyntaxUsed)
static Decl::Kind getKind(const Decl *D)
Defines the C++ template declaration subclasses.
llvm::MachO::RecordLoc RecordLoc
static bool IsAttributeLateParsedExperimentalExt(const IdentifierInfo &II)
returns true iff attribute is annotated with LateAttrParseExperimentalExt in Attr....
static bool FindLocsWithCommonFileID(Preprocessor &PP, SourceLocation StartLoc, SourceLocation EndLoc)
Check if the a start and end source location expand to the same macro.
static bool IsAttributeLateParsedStandard(const IdentifierInfo &II)
returns true iff attribute is annotated with LateAttrParseStandard in Attr.td.
static ParsedAttributeArgumentsProperties attributeStringLiteralListArg(const llvm::Triple &T, const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
Determine whether the given attribute has string arguments.
static bool attributeHasStrictIdentifierArgs(const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
Determine whether the given attribute takes a strict identifier argument.
static bool attributeIsTypeArgAttr(const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
Determine whether the given attribute parses a type argument.
static bool attributeTreatsKeywordThisAsIdentifier(const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
Determine whether the given attribute treats kw_this as an identifier.
static bool attributeParsedArgsUnevaluated(const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
Determine whether the given attribute requires parsing its arguments in an unevaluated context or not...
static bool attributeHasIdentifierArg(const llvm::Triple &T, const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
Determine whether the given attribute has an identifier argument.
static bool isValidAfterIdentifierInDeclarator(const Token &T)
isValidAfterIdentifierInDeclaratorAfterDeclSpec - Return true if the specified token is valid after t...
static bool attributeHasVariadicIdentifierArg(const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
Determine whether the given attribute has a variadic identifier argument.
static bool isPipeDeclarator(const Declarator &D)
static SourceLocation getMissingDeclaratorIdLoc(Declarator &D, SourceLocation Loc)
static bool attributeAcceptsExprPack(const IdentifierInfo &II, ParsedAttr::Syntax Syntax, IdentifierInfo *ScopeName)
Determine if an attribute accepts parameter packs.
static void DiagnoseCountAttributedTypeInUnnamedAnon(ParsingDeclSpec &DS, Parser &P)
static bool VersionNumberSeparator(const char Separator)
static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang, DeclaratorContext TheContext)
llvm::SmallVector< std::pair< const MemRegion *, SVal >, 4 > Bindings
static constexpr bool isOneOf()
This file declares semantic analysis for CUDA constructs.
This file declares facilities that support code completion.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenMP constructs and clauses.
static bool isInvalid(LocType Loc, bool *Invalid)
Defines the clang::TokenKind enum and support functions.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
const clang::PrintingPolicy & getPrintingPolicy() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
The result of parsing/analyzing an expression, statement etc.
Syntax
The style used to specify an attribute.
@ AS_Declspec
__declspec(...)
Kind getParsedKind() const
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
SourceLocation getOpenLocation() const
SourceLocation getCloseLocation() const
Represents a C++ nested-name-specifier or a global scope specifier.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
SourceLocation getEndLoc() const
bool isSet() const
Deprecated.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
void setTemplateParamLists(ArrayRef< TemplateParameterList * > L)
bool isEmpty() const
No scope specifier.
Represents a character-granular source range.
SourceLocation getBegin() const
Callback handler that receives notifications when performing code completion within the preprocessor.
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
Represents a sugar type with __counted_by or __sized_by annotations, including their _or_null variant...
Captures information about "declaration specifiers".
bool isVirtualSpecified() const
bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, ExplicitSpecifier ExplicitSpec, SourceLocation CloseParenLoc)
bool isTypeSpecPipe() const
static const TSCS TSCS___thread
static const TST TST_typeof_unqualType
void setTypeArgumentRange(SourceRange range)
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
SourceLocation getPipeLoc() const
static const TST TST_typename
SourceLocation getEndLoc() const LLVM_READONLY
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error.
static const TST TST_char8
static const TST TST_BFloat16
void ClearStorageClassSpecs()
bool SetConstexprSpec(ConstexprSpecKind ConstexprKind, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TSCS TSCS__Thread_local
bool SetTypeSpecWidth(TypeSpecifierWidth W, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec, but return true and ignore the request if ...
bool isNoreturnSpecified() const
TST getTypeSpecType() const
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceRange getSourceRange() const LLVM_READONLY
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
void SetRangeEnd(SourceLocation Loc)
bool SetBitIntType(SourceLocation KWLoc, Expr *BitWidth, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
static const TST TST_auto_type
static const TST TST_interface
static const TST TST_double
static const TST TST_typeofExpr
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void SetRangeStart(SourceLocation Loc)
bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceLocation getNoreturnSpecLoc() const
static const TST TST_union
static const TST TST_char
static const TST TST_bool
static const TST TST_char16
SourceLocation getExplicitSpecLoc() const
SourceLocation getFriendSpecLoc() const
SourceLocation getModulePrivateSpecLoc() const
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
void UpdateTypeRep(ParsedType Rep)
TSCS getThreadStorageClassSpec() const
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool hasAttributes() const
static const TST TST_accum
static const TST TST_half
ParsedAttributes & getAttributes()
SourceLocation getConstSpecLoc() const
static const TST TST_ibm128
void addAttributes(const ParsedAttributesView &AL)
Concatenates two attribute lists.
static const TST TST_enum
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
static const TST TST_float128
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Complex" (la...
bool isInlineSpecified() const
SourceLocation getRestrictSpecLoc() const
static const TST TST_typeof_unqualExpr
static const TST TST_class
bool hasTagDefinition() const
static const TST TST_decimal64
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
void ClearFunctionSpecs()
bool SetTypeQual(TQ T, SourceLocation Loc)
static const TST TST_wchar
static const TST TST_void
bool isTypeAltiVecVector() const
void ClearConstexprSpec()
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
static const TST TST_float
static const TST TST_atomic
static const TST TST_fract
SourceLocation getThreadStorageClassSpecLoc() const
Decl * getRepAsDecl() const
static const TST TST_float16
static const TST TST_unspecified
SourceLocation getAtomicSpecLoc() const
SourceLocation getVirtualSpecLoc() const
SourceLocation getConstexprSpecLoc() const
CXXScopeSpec & getTypeSpecScope()
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
static const TSCS TSCS_thread_local
bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_decimal32
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
TypeSpecifierWidth getTypeSpecWidth() const
static const TST TST_char32
bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_decimal128
bool isTypeSpecOwned() const
SourceLocation getInlineSpecLoc() const
SourceLocation getUnalignedSpecLoc() const
static const TST TST_int128
SourceLocation getVolatileSpecLoc() const
FriendSpecified isFriendSpecified() const
bool hasExplicitSpecifier() const
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool hasConstexprSpecifier() const
void takeAttributesFrom(ParsedAttributes &attrs)
static const TST TST_typeofType
bool SetTypeSpecSign(TypeSpecifierSign S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_auto
@ PQ_StorageClassSpecifier
ConstexprSpecKind getConstexprSpecifier() const
static const TST TST_struct
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
Kind
Lists the kind of concrete classes of Decl.
bool isInvalidDecl() const
SourceLocation getLocation() const
SourceLocation getBeginLoc() const LLVM_READONLY
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Information about one declarator, including the parsed type information and the identifier.
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool hasAllExtensionsSilenced()
RAII object that enters a new expression evaluation context.
Store information needed for an explicit specifier.
This represents one expression.
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
One of these records is kept for each identifier that is lexed.
bool isCPlusPlusKeyword(const LangOptions &LangOpts) const
Return true if this token is a C++ keyword in the specified language.
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
bool isKeyword(const LangOptions &LangOpts) const
Return true if this token is a keyword in the specified language.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
StringRef getName() const
Return the actual identifier string.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool requiresStrictPrototypes() const
Returns true if functions without prototypes or functions with an identifier list (aka K&R C function...
std::string getOpenCLVersionString() const
Return the OpenCL C or C++ for OpenCL language name and version as a string.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
Lexer - This provides a simple interface that turns a text buffer into a stream of tokens.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
static bool isAtStartOfMacroExpansion(SourceLocation loc, const SourceManager &SM, const LangOptions &LangOpts, SourceLocation *MacroBegin=nullptr)
Returns true if the given MacroID location points at the first token of the macro expansion.
static bool isAtEndOfMacroExpansion(SourceLocation loc, const SourceManager &SM, const LangOptions &LangOpts, SourceLocation *MacroEnd=nullptr)
Returns true if the given MacroID location points at the last token of the macro expansion.
static bool getRawToken(SourceLocation Loc, Token &Result, const SourceManager &SM, const LangOptions &LangOpts, bool IgnoreWhiteSpace=false)
Relex the token at the specified location.
static std::optional< Token > findNextToken(SourceLocation Loc, const SourceManager &SM, const LangOptions &LangOpts)
Finds the token that comes right after the given location.
Represents the results of name lookup.
This represents a decl that may have a name.
bool isSupported(llvm::StringRef Ext, const LangOptions &LO) const
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing,...
Represents a parameter to a function.
static constexpr unsigned getMaxFunctionScopeDepth()
ParsedAttr - Represents a syntactic attribute.
unsigned getMaxArgs() const
static const ParsedAttributesView & none()
void addAtEnd(ParsedAttr *newAttr)
void addAll(iterator B, iterator E)
void remove(ParsedAttr *ToBeRemoved)
ParsedAttributes - A collection of parsed attributes.
ParsedAttr * addNew(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, ParsedAttr::Form form, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
void takeOneFrom(ParsedAttributes &Other, ParsedAttr *PA)
ParsedAttr * addNewPropertyAttr(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierInfo *getterId, IdentifierInfo *setterId, ParsedAttr::Form formUsed)
Add microsoft __delspec(property) attribute.
void takeAllFrom(ParsedAttributes &Other)
ParsedAttr * addNewTypeTagForDatatype(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierLoc *argumentKind, ParsedType matchingCType, bool layoutCompatible, bool mustBeNull, ParsedAttr::Form form)
Add type_tag_for_datatype attribute.
ParsedAttr * addNewTypeAttr(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ParsedType typeArg, ParsedAttr::Form formUsed, SourceLocation ellipsisLoc=SourceLocation())
Add an attribute with a single type argument.
Parser - This implements a parser for the C family of languages.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
DeclGroupPtrTy ParseOpenACCDirectiveDecl()
Placeholder for now, should just ignore the directives after emitting a diagnostic.
Sema & getActions() const
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
void EnterScope(unsigned ScopeFlags)
EnterScope - Start a new scope.
ExprResult ParseConstraintLogicalOrExpression(bool IsTrailingRequiresClause)
Parse a constraint-logical-or-expression.
bool ParseUnqualifiedId(CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHadErrors, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
ExprResult ParseConstantExpression()
bool TryConsumeToken(tok::TokenKind Expected)
Scope * getCurScope() const
SourceLocation getEndOfPreviousToken()
ExprResult ParseArrayBoundExpression()
const TargetInfo & getTargetInfo() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
friend class ObjCDeclContextSwitch
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExprResult ParseConstantExpressionInExprEvalContext(TypeCastState isTypeCast=NotTypeCast)
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtCodeCompletion
Stop at code completion.
@ StopAtSemi
Stop skipping at semicolon.
bool TryAnnotateTypeOrScopeToken(ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
ExprResult ParseUnevaluatedStringLiteralExpression()
ObjCContainerDecl * getObjCDeclContext() const
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
RAII object used to inform the actions that we're currently parsing a declaration.
A class for parsing a DeclSpec.
A class for parsing a declarator.
A class for parsing a field declarator.
void enterVariableInit(SourceLocation Tok, Decl *D)
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool isIncrementalProcessingEnabled() const
Returns true if incremental processing is enabled.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
SourceManager & getSourceManager() const
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 ...
const LangOptions & getLangOpts() const
bool isCodeCompletionReached() const
Returns true if code-completion is enabled and we have hit the code-completion point.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
The collection of all-type qualifiers we support.
void addAddressSpace(LangAS space)
static Qualifiers fromCVRUMask(unsigned CVRU)
Represents a struct/union/class.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
unsigned getFlags() const
getFlags - Return the flags for this scope.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ BlockScope
This is a scope that corresponds to a block/closure object.
@ FriendScope
This is a scope of friend declaration.
@ ControlScope
The controlling scope in a if/switch/while/for statement.
@ AtCatchScope
This is a scope that corresponds to the Objective-C @catch statement.
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
@ CompoundStmtScope
This is a compound statement scope.
@ ClassScope
The scope of a struct/union/class definition.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ EnumScope
This scope corresponds to an enum.
@ DeclScope
This is a scope that can contain a declaration.
@ CTCK_InitGlobalVar
Unknown context.
void CodeCompleteAttribute(AttributeCommonInfo::Syntax Syntax, AttributeCompletion Completion=AttributeCompletion::Attribute, const IdentifierInfo *Scope=nullptr)
ParserCompletionContext
Describes the context in which code completion occurs.
@ PCC_LocalDeclarationSpecifiers
Code completion occurs within a sequence of declaration specifiers within a function,...
@ PCC_MemberTemplate
Code completion occurs following one or more template headers within a class.
@ PCC_Class
Code completion occurs within a class, struct, or union.
@ PCC_ObjCImplementation
Code completion occurs within an Objective-C implementation or category implementation.
@ PCC_Namespace
Code completion occurs at top-level or namespace context.
@ PCC_Template
Code completion occurs following one or more template headers.
void CodeCompleteTypeQualifiers(DeclSpec &DS)
void CodeCompleteAfterFunctionEquals(Declarator &D)
QualType ProduceConstructorSignatureHelp(QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args, SourceLocation OpenParLoc, bool Braced)
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
void CodeCompleteInitializer(Scope *S, Decl *D)
void CodeCompleteBracketDeclarator(Scope *S)
void CodeCompleteTag(Scope *S, unsigned TagSpec)
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
ParsedType ActOnObjCInstanceType(SourceLocation Loc)
The parser has parsed the context-sensitive type 'instancetype' in an Objective-C message declaration...
void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, const IdentifierInfo *ClassName, SmallVectorImpl< Decl * > &Decls)
Called whenever @defs(ClassName) is encountered in the source.
void startOpenMPCXXRangeFor()
If the current region is a range loop-based region, mark the start of the loop construct.
NameClassificationKind getKind() const
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter,...
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
void ActOnDefinedDeclarationSpecifier(Decl *D)
Called once it is known whether a tag declaration is an anonymous union or struct.
ExplicitSpecifier ActOnExplicitBoolSpecifier(Expr *E)
ActOnExplicitBoolSpecifier - Build an ExplicitSpecifier from an expression found in an explicit(bool)...
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc, Expr *DefaultArg)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
Decl * ActOnParamDeclarator(Scope *S, Declarator &D, SourceLocation ExplicitThisLoc={})
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, const IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
const ExpressionEvaluationContextRecord & currentEvaluationContext() const
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S)
isTagName() - This method is called for error recovery purposes only to determine if the specified na...
void ActOnFinishFunctionDeclarationDeclarator(Declarator &D)
Called after parsing a function declarator belonging to a function declaration.
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
void ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement)
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
ASTContext & getASTContext() const
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
@ NC_Unknown
This name is not a type or template in this context, but might be something else.
@ NC_VarTemplate
The name was classified as a variable template name.
@ NC_NonType
The name was classified as a specific non-type, non-template declaration.
@ NC_TypeTemplate
The name was classified as a template whose specializations are types.
@ NC_Error
Classification failed; an error has been produced.
@ NC_FunctionTemplate
The name was classified as a function template name.
@ NC_DependentNonType
The name denotes a member of a dependent type that could not be resolved.
@ NC_UndeclaredNonType
The name was classified as an ADL-only function name.
@ NC_UndeclaredTemplate
The name was classified as an ADL-only function template name.
@ NC_Keyword
The name has been typo-corrected to a keyword.
@ NC_Type
The name was classified as a type.
@ NC_OverloadSet
The name was classified as an overload set, and an expression representing that overload set has been...
@ NC_Concept
The name was classified as a concept name.
void ActOnStartFunctionDeclarationDeclarator(Declarator &D, unsigned TemplateParameterDepth)
Called before parsing a function declarator belonging to a function declaration.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
const LangOptions & getLangOpts() const
SemaCodeCompletion & CodeCompletion()
bool isUnexpandedParameterPackPermitted()
Determine whether an unexpanded parameter pack might be permitted in this location.
bool ActOnAlignasTypeArgument(StringRef KWName, ParsedType Ty, SourceLocation OpLoc, SourceRange R)
ActOnAlignasTypeArgument - Handle alignas(type-id) and _Alignas(type-name) .
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, CorrectionCandidateCallback *CCC=nullptr)
Perform name lookup on the given name, classifying it based on the results of name lookup and the fol...
bool isLibstdcxxEagerExceptionSpecHack(const Declarator &D)
Determine if we're in a case where we need to (incorrectly) eagerly parse an exception specification ...
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, const ParsedAttributesView &Attrs, SourceLocation EqualLoc, Expr *Val)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
bool isDeclaratorFunctionLike(Declarator &D)
Determine whether.
bool ActOnDuplicateDefinition(Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void RestoreNestedNameSpecifierAnnotation(void *Annotation, SourceRange AnnotationRange, CXXScopeSpec &SS)
Given an annotation pointer for a nested-name-specifier, restore the nested-name-specifier structure.
bool CheckTypeConstraint(TemplateIdAnnotation *TypeConstraint)
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, const ParsedAttributesView &Attr)
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e....
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
TypeResult ActOnTypeName(Declarator &D)
TopLevelStmtDecl * ActOnStartTopLevelStmtDecl(Scope *S)
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool IsTemplateTypeArg)
Attempt to behave like MSVC in situations where lookup of an unqualified type name has failed in a de...
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
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, const ParsedAttributesView &Attr)
@ ConstantEvaluated
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
@ Unevaluated
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7),...
@ PotentiallyEvaluatedIfUsed
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
DeclResult ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, const ParsedAttributesView &Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, OffsetOfKind OOK, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, const ParsedAttributesView &DeclAttrs, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e....
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, CXXScopeSpec &SS, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration.
OpenCLOptions & getOpenCLOptions()
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
void ActOnUninitializedDecl(Decl *dcl)
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
Decl * ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth)
ActOnField - Each field of a C struct/union is passed into this in order to create a FieldDecl object...
void ActOnCXXForRangeDecl(Decl *D)
Decl * ActOnDeclarator(Scope *S, Declarator &D)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false, bool ForceNoCPlusPlus=false)
Perform unqualified name lookup starting from a given scope.
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS)
Determine whether the identifier II is a typo for the name of the class type currently being defined.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, 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...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
UIntTy getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
Stmt - This represents one statement.
A RAII object used to temporarily suppress access-like checking.
Represents the declaration of a struct/union/class/enum.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
SourceLocation getEndLoc() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
const char * getName() const
unsigned getLength() const
void setKind(tok::TokenKind K)
SourceLocation getAnnotationEndLoc() const
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 * getAnnotationValue() const
tok::TokenKind getKind() const
bool isRegularKeywordAttribute() const
Return true if the token is a keyword that is parsed in the same position as a standard attribute,...
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
void setEofData(const void *D)
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
void setLocation(SourceLocation L)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
const void * getEofData() const
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
void startToken()
Reset all flags to cleared.
void setIdentifierInfo(IdentifierInfo *II)
A declaration that models statements at global scope.
void setSemiMissing(bool Missing=true)
Base wrapper for a particular "section" of type source info.
The base class of the type hierarchy.
static constexpr int FunctionTypeNumParamsLimit
The iterator over UnresolvedSets.
Declaration of a variable template.
static const char * getSpecifierName(Specifier VS)
Defines the clang::TargetInfo interface.
const internal::VariadicAllOfMatcher< Attr > attr
Matches attributes.
bool InitScope(InterpState &S, CodePtr OpPC, uint32_t I)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
bool isPragmaAnnotation(TokenKind K)
Return true if this is an annotation token representing a pragma.
The JSON file list parser is used to communicate input to InstallAPI.
TypeSpecifierType
Specifies the kind of type.
bool doesKeywordAttributeTakeArgs(tok::TokenKind Kind)
@ ExpectedParameterOrImplicitObjectParameter
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an ParsedAttr as an argument.
@ IK_TemplateId
A template-id, e.g., f<int>.
void takeAndConcatenateAttrs(ParsedAttributes &First, ParsedAttributes &Second, ParsedAttributes &Result)
Consumes the attributes from First and Second and concatenates them into Result.
Language
The language for the input, used to select and validate the language standard and possible actions.
@ Result
The result type of a method or function.
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
LangAS
Defines the address space values used by the address space qualifier of QualType.
int hasAttribute(AttributeCommonInfo::Syntax 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...
@ TNK_Type_template
The name refers to a template whose specialization produces a type.
@ TNK_Dependent_template_name
The name refers to a dependent template name:
@ TNK_Concept_template
The name refers to a concept.
@ TNK_Undeclared_template
Lookup for the name failed, but we're assuming it was a template name anyway.
ActionResult< ParsedType > TypeResult
const FunctionProtoType * T
@ Parens
New-expression has a C++98 paren-delimited initializer.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
@ EST_None
no exception specification
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Represents information about a change in availability for an entity, which is part of the encoding of...
VersionTuple Version
The version number at which the change occurred.
SourceLocation KeywordLoc
The location of the keyword indicating the kind of change.
SourceRange VersionRange
The source range covering the version number.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed.
One instance of this struct is used for each type in a declarator that is parsed.
enum clang::DeclaratorChunk::@224 Kind
static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, ArrayRef< NamedDecl * > DeclsInPrototype, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult(), SourceLocation TrailingReturnTypeLoc=SourceLocation(), DeclSpec *MethodQualifiers=nullptr)
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
static DeclaratorChunk getPipe(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
SourceLocation Loc
Loc - The place where this type was defined.
static DeclaratorChunk getMemberPointer(const CXXScopeSpec &SS, unsigned TypeQuals, SourceLocation StarLoc, SourceLocation EndLoc)
static DeclaratorChunk getParen(SourceLocation LParenLoc, SourceLocation RParenLoc)
Return a DeclaratorChunk for a paren.
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc, SourceLocation UnalignedQualLoc)
Return a DeclaratorChunk for a pointer.
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
Wraps an identifier and optional source location for the identifier.
static IdentifierLoc * create(ASTContext &Ctx, SourceLocation Loc, IdentifierInfo *Ident)
bool isStringLiteralArg(unsigned I) const
Describes how types, statements, expressions, and declarations should be printed.
bool InLifetimeExtendingContext
Whether we are currently in a context in which all temporaries must be lifetime-extended,...
ExpressionKind
Describes whether we are in an expression constext which we have to handle differently.
Information about a template-id annotation token.
bool hasInvalidName() const
const IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
TemplateNameKind Kind
The kind of template that Template refers to.
bool hasInvalidArgs() const