34#include "llvm/ADT/SmallSet.h"
35#include "llvm/ADT/SmallString.h"
36#include "llvm/ADT/StringSwitch.h"
53 DeclSpecContext DSC = getDeclSpecContextFromDeclaratorContext(Context);
54 if (DSC == DeclSpecContext::DSC_normal)
55 DSC = DeclSpecContext::DSC_type_specifier;
61 ParseSpecifierQualifierList(DS, AS, DSC);
69 if (AL.isDeclspecAttribute())
70 ToBeMoved.push_back(&AL);
79 ParseDeclarator(DeclaratorInfo);
91 if (Name.size() >= 4 && Name.starts_with(
"__") && Name.ends_with(
"__"))
92 return Name.drop_front(2).drop_back(2);
99#define CLANG_ATTR_LATE_PARSED_EXPERIMENTAL_EXT_LIST
101#include "clang/Parse/AttrParserStringSwitches.inc"
103#undef CLANG_ATTR_LATE_PARSED_EXPERIMENTAL_EXT_LIST
109#define CLANG_ATTR_LATE_PARSED_LIST
111#include "clang/Parse/AttrParserStringSwitches.inc"
113#undef CLANG_ATTR_LATE_PARSED_LIST
123 if (
SM.getFileID(StartLoc) !=
SM.getFileID(EndLoc))
126 bool AttrStartIsInMacro =
128 bool AttrEndIsInMacro =
130 return AttrStartIsInMacro && AttrEndIsInMacro;
133void Parser::ParseAttributes(
unsigned WhichAttrKinds,
ParsedAttributes &Attrs,
134 LateParsedAttrList *LateAttrs) {
140 if (WhichAttrKinds & PAKM_CXX11)
141 MoreToParse |= MaybeParseCXX11Attributes(Attrs);
142 if (WhichAttrKinds & PAKM_GNU)
143 MoreToParse |= MaybeParseGNUAttributes(Attrs, LateAttrs);
144 if (WhichAttrKinds & PAKM_Declspec)
145 MoreToParse |= MaybeParseMicrosoftDeclSpecs(Attrs);
146 }
while (MoreToParse);
192 assert(Tok.
is(tok::kw___attribute) &&
"Not a GNU attribute list!");
197 while (Tok.
is(tok::kw___attribute)) {
199 unsigned OldNumAttrs = Attrs.
size();
200 unsigned OldNumLateAttrs = LateAttrs ? LateAttrs->size() : 0;
202 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
207 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
"(")) {
220 if (Tok.
is(tok::code_completion)) {
232 if (Tok.
isNot(tok::l_paren)) {
233 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
234 ParsedAttr::Form::GNU());
238 bool LateParse =
false;
241 else if (LateAttrs->lateAttrParseExperimentalExtOnly()) {
245 LateParse =
getLangOpts().ExperimentalLateParseAttributes &&
258 ParseGNUAttributeArgs(AttrName, AttrNameLoc, Attrs, &EndLoc,
nullptr,
264 LateParsedAttribute *LA =
265 new LateParsedAttribute(
this, *AttrName, AttrNameLoc);
266 LateAttrs->push_back(LA);
270 if (!ClassStack.empty() && !LateAttrs->parseSoon())
271 getCurrentClass().LateParsedDeclarations.push_back(LA);
275 LA->Toks.push_back(Tok);
278 ConsumeAndStoreUntil(tok::r_paren, LA->Toks,
true);
283 LA->Toks.push_back(Eof);
284 }
while (Tok.
is(tok::comma));
286 if (ExpectAndConsume(tok::r_paren))
289 if (ExpectAndConsume(tok::r_paren))
296 if (!
SM.isWrittenInBuiltinFile(
SM.getSpellingLoc(AttrTokLoc)) &&
299 StringRef FoundName =
303 for (
unsigned i = OldNumAttrs; i < Attrs.
size(); ++i)
304 Attrs[i].setMacroIdentifier(MacroII, ExpansionRange.
getBegin());
307 for (
unsigned i = OldNumLateAttrs; i < LateAttrs->size(); ++i)
308 (*LateAttrs)[i]->MacroII = MacroII;
321#define CLANG_ATTR_IDENTIFIER_ARG_LIST
323#include "clang/Parse/AttrParserStringSwitches.inc"
325#undef CLANG_ATTR_IDENTIFIER_ARG_LIST
333#define CLANG_ATTR_STRING_LITERAL_ARG_LIST
335#include "clang/Parse/AttrParserStringSwitches.inc"
337#undef CLANG_ATTR_STRING_LITERAL_ARG_LIST
344#define CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
346#include "clang/Parse/AttrParserStringSwitches.inc"
348#undef CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST
355#define CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
357#include "clang/Parse/AttrParserStringSwitches.inc"
359#undef CLANG_ATTR_THIS_ISA_IDENTIFIER_ARG_LIST
366#define CLANG_ATTR_ACCEPTS_EXPR_PACK
368#include "clang/Parse/AttrParserStringSwitches.inc"
370#undef CLANG_ATTR_ACCEPTS_EXPR_PACK
377#define CLANG_ATTR_TYPE_ARG_LIST
379#include "clang/Parse/AttrParserStringSwitches.inc"
381#undef CLANG_ATTR_TYPE_ARG_LIST
388#define CLANG_ATTR_STRICT_IDENTIFIER_ARG_LIST
390#include "clang/Parse/AttrParserStringSwitches.inc"
392#undef CLANG_ATTR_STRICT_IDENTIFIER_ARG_LIST
400#define CLANG_ATTR_ARG_CONTEXT_LIST
402#include "clang/Parse/AttrParserStringSwitches.inc"
404#undef CLANG_ATTR_ARG_CONTEXT_LIST
408 assert(Tok.
is(tok::identifier) &&
"expected an identifier");
426 if (Tok.
isNot(tok::r_paren))
429 if (
Parens.consumeClose())
438 ScopeName, ScopeLoc,
T.get(), Form);
441 ScopeName, ScopeLoc,
nullptr, 0, Form);
445Parser::ParseUnevaluatedStringInAttribute(
const IdentifierInfo &AttrName) {
446 if (Tok.
is(tok::l_paren)) {
449 ExprResult Res = ParseUnevaluatedStringInAttribute(AttrName);
450 Paren.consumeClose();
453 if (!isTokenStringLiteral()) {
461bool Parser::ParseAttributeArgumentList(
464 bool SawError =
false;
469 Expr = ParseUnevaluatedStringInAttribute(AttrName);
471 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
472 Expr = ParseBraceInitializer();
478 if (Tok.
is(tok::ellipsis))
480 else if (Tok.
is(tok::code_completion)) {
491 if (
Expr.isInvalid()) {
501 Exprs.push_back(
Expr.get());
503 if (Tok.
isNot(tok::comma))
508 checkPotentialAngleBracketDelimiter(Comma);
515 for (
auto &
E : Exprs) {
524unsigned Parser::ParseAttributeArgsCommon(
533 bool AttributeIsTypeArgAttr =
535 bool AttributeHasVariadicIdentifierArg =
539 if (ChangeKWThisToIdent && Tok.
is(tok::kw_this))
543 if (Tok.
is(tok::identifier)) {
545 bool IsIdentifierArg =
546 AttributeHasVariadicIdentifierArg ||
557 IsIdentifierArg = Next.isOneOf(tok::r_paren, tok::comma);
561 ArgExprs.push_back(ParseIdentifierLoc());
565 if (!ArgExprs.empty() ? Tok.
is(tok::comma) : Tok.
isNot(tok::r_paren)) {
567 if (!ArgExprs.empty())
570 if (AttributeIsTypeArgAttr) {
578 TheParsedType =
T.get();
579 }
else if (AttributeHasVariadicIdentifierArg ||
589 if (ChangeKWThisToIdent && Tok.
is(tok::kw_this))
593 if (Tok.
is(tok::identifier)) {
594 ArgExprs.push_back(ParseIdentifierLoc());
612 ArgExprs.push_back(ArgExpr.
get());
628 ExprVector ParsedExprs;
632 if (ParseAttributeArgumentList(*AttrName, ParsedExprs, ArgProperties)) {
638 for (
size_t I = 0; I < ParsedExprs.size(); ++I) {
639 if (!isa<PackExpansionExpr>(ParsedExprs[I]))
644 diag::err_attribute_argument_parm_pack_not_supported)
651 ArgExprs.insert(ArgExprs.end(), ParsedExprs.begin(), ParsedExprs.end());
656 if (!ExpectAndConsume(tok::r_paren)) {
659 if (AttributeIsTypeArgAttr && !TheParsedType.
get().
isNull()) {
661 ScopeName, ScopeLoc, TheParsedType, Form);
664 ArgExprs.data(), ArgExprs.size(), Form);
671 return static_cast<unsigned>(ArgExprs.size() + !TheParsedType.
get().
isNull());
676void Parser::ParseGNUAttributeArgs(
681 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
686 if (AttrKind == ParsedAttr::AT_Availability) {
687 ParseAvailabilityAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
690 }
else if (AttrKind == ParsedAttr::AT_ExternalSourceSymbol) {
691 ParseExternalSourceSymbolAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
692 ScopeName, ScopeLoc, Form);
694 }
else if (AttrKind == ParsedAttr::AT_ObjCBridgeRelated) {
695 ParseObjCBridgeRelatedAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
696 ScopeName, ScopeLoc, Form);
698 }
else if (AttrKind == ParsedAttr::AT_SwiftNewType) {
699 ParseSwiftNewTypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
702 }
else if (AttrKind == ParsedAttr::AT_TypeTagForDatatype) {
703 ParseTypeTagForDatatypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
704 ScopeName, ScopeLoc, Form);
707 ParseAttributeWithTypeArg(*AttrName, AttrNameLoc, Attrs, ScopeName,
710 }
else if (AttrKind == ParsedAttr::AT_CountedBy ||
711 AttrKind == ParsedAttr::AT_CountedByOrNull ||
712 AttrKind == ParsedAttr::AT_SizedBy ||
713 AttrKind == ParsedAttr::AT_SizedByOrNull) {
714 ParseBoundsAttribute(*AttrName, AttrNameLoc, Attrs, ScopeName, ScopeLoc,
717 }
else if (AttrKind == ParsedAttr::AT_CXXAssume) {
718 ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form);
724 std::optional<ParseScope> PrototypeScope;
726 D &&
D->isFunctionDeclarator()) {
731 for (
unsigned i = 0; i != FTI.
NumParams; ++i) {
737 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
741unsigned Parser::ParseClangAttributeArgs(
745 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
752 return ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
753 ScopeName, ScopeLoc, Form);
754 case ParsedAttr::AT_ExternalSourceSymbol:
755 ParseExternalSourceSymbolAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
756 ScopeName, ScopeLoc, Form);
758 case ParsedAttr::AT_Availability:
759 ParseAvailabilityAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
762 case ParsedAttr::AT_ObjCBridgeRelated:
763 ParseObjCBridgeRelatedAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
764 ScopeName, ScopeLoc, Form);
766 case ParsedAttr::AT_SwiftNewType:
767 ParseSwiftNewTypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
770 case ParsedAttr::AT_TypeTagForDatatype:
771 ParseTypeTagForDatatypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
772 ScopeName, ScopeLoc, Form);
775 case ParsedAttr::AT_CXXAssume:
776 ParseCXXAssumeAttributeArg(Attrs, AttrName, AttrNameLoc, EndLoc, Form);
779 return !Attrs.
empty() ? Attrs.
begin()->getNumArgs() : 0;
785 unsigned ExistingAttrs = Attrs.
size();
799 if (AttrName->
getName() ==
"property") {
805 T.expectAndConsume(diag::err_expected_lparen_after,
814 bool HasInvalidAccessor =
false;
819 if (!Tok.
is(tok::identifier)) {
821 if (Tok.
is(tok::r_paren) && !HasInvalidAccessor &&
822 AccessorNames[AK_Put] ==
nullptr &&
823 AccessorNames[AK_Get] ==
nullptr) {
824 Diag(AttrNameLoc, diag::err_ms_property_no_getter_or_putter);
835 if (KindStr ==
"get") {
837 }
else if (KindStr ==
"put") {
841 }
else if (KindStr ==
"set") {
842 Diag(KindLoc, diag::err_ms_property_has_set_accessor)
849 Diag(KindLoc, diag::err_ms_property_missing_accessor_kind);
851 HasInvalidAccessor =
true;
852 goto next_property_accessor;
856 Diag(KindLoc, diag::err_ms_property_unknown_accessor);
857 HasInvalidAccessor =
true;
876 if (!Tok.
is(tok::identifier)) {
881 if (Kind == AK_Invalid) {
883 }
else if (AccessorNames[Kind] !=
nullptr) {
885 Diag(KindLoc, diag::err_ms_property_duplicate_accessor) << KindStr;
891 next_property_accessor:
897 if (Tok.
is(tok::r_paren))
900 Diag(Tok.
getLocation(), diag::err_ms_property_expected_comma_or_rparen);
905 if (!HasInvalidAccessor)
907 AccessorNames[AK_Get], AccessorNames[AK_Put],
908 ParsedAttr::Form::Declspec());
910 return !HasInvalidAccessor;
914 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs,
nullptr,
nullptr,
920 Diag(OpenParenLoc, diag::err_attribute_requires_arguments) << AttrName;
933 assert(
getLangOpts().DeclSpecKeyword &&
"__declspec keyword is not enabled");
934 assert(Tok.
is(tok::kw___declspec) &&
"Not a declspec!");
939 while (Tok.
is(tok::kw___declspec)) {
942 if (
T.expectAndConsume(diag::err_expected_lparen_after,
"__declspec",
948 while (Tok.
isNot(tok::r_paren)) {
953 if (Tok.
is(tok::code_completion)) {
962 bool IsString = Tok.
getKind() == tok::string_literal;
963 if (!IsString && Tok.
getKind() != tok::identifier &&
964 Tok.
getKind() != tok::kw_restrict) {
965 Diag(Tok, diag::err_ms_declspec_type);
975 StringRef Str = PP.
getSpelling(Tok, StrBuffer, &Invalid);
981 AttrNameLoc = ConsumeStringToken();
987 bool AttrHandled =
false;
990 if (Tok.
is(tok::l_paren))
991 AttrHandled = ParseMicrosoftDeclSpecArgs(AttrName, AttrNameLoc, Attrs);
992 else if (AttrName->
getName() ==
"property")
998 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
999 ParsedAttr::Form::Declspec());
1002 EndLoc =
T.getCloseLocation();
1013 case tok::kw___fastcall:
1014 case tok::kw___stdcall:
1015 case tok::kw___thiscall:
1016 case tok::kw___regcall:
1017 case tok::kw___cdecl:
1018 case tok::kw___vectorcall:
1019 case tok::kw___ptr64:
1021 case tok::kw___ptr32:
1022 case tok::kw___sptr:
1023 case tok::kw___uptr: {
1026 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1036void Parser::ParseWebAssemblyFuncrefTypeAttribute(
ParsedAttributes &attrs) {
1037 assert(Tok.
is(tok::kw___funcref));
1041 Diag(StartLoc, diag::err_wasm_funcref_not_wasm);
1047 attrs.
addNew(AttrName, AttrNameLoc,
nullptr,
1052void Parser::DiagnoseAndSkipExtendedMicrosoftTypeAttributes() {
1058 Diag(StartLoc, diag::warn_microsoft_qualifiers_ignored) <<
Range;
1068 case tok::kw_volatile:
1069 case tok::kw___fastcall:
1070 case tok::kw___stdcall:
1071 case tok::kw___thiscall:
1072 case tok::kw___cdecl:
1073 case tok::kw___vectorcall:
1074 case tok::kw___ptr32:
1075 case tok::kw___ptr64:
1077 case tok::kw___unaligned:
1078 case tok::kw___sptr:
1079 case tok::kw___uptr:
1090 while (Tok.
is(tok::kw___pascal)) {
1093 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1100 while (Tok.
is(tok::kw___kernel)) {
1103 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1109 while (Tok.
is(tok::kw___noinline__)) {
1112 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1113 tok::kw___noinline__);
1120 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1124bool Parser::isHLSLQualifier(
const Token &Tok)
const {
1125 return Tok.
is(tok::kw_groupshared);
1132 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0, Kind);
1140 case tok::kw__Nonnull:
1141 case tok::kw__Nullable:
1142 case tok::kw__Nullable_result:
1143 case tok::kw__Null_unspecified: {
1147 Diag(AttrNameLoc, diag::ext_nullability)
1149 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
1160 return (Separator ==
'.' || Separator ==
'_');
1174 if (!Tok.
is(tok::numeric_constant)) {
1175 Diag(Tok, diag::err_expected_version);
1178 return VersionTuple();
1187 const char *ThisTokBegin = &Buffer[0];
1191 unsigned ActualLength = PP.
getSpelling(Tok, ThisTokBegin, &Invalid);
1193 return VersionTuple();
1196 unsigned AfterMajor = 0;
1198 while (AfterMajor < ActualLength &&
isDigit(ThisTokBegin[AfterMajor])) {
1199 Major = Major * 10 + ThisTokBegin[AfterMajor] -
'0';
1203 if (AfterMajor == 0) {
1204 Diag(Tok, diag::err_expected_version);
1207 return VersionTuple();
1210 if (AfterMajor == ActualLength) {
1215 Diag(Tok, diag::err_zero_version);
1216 return VersionTuple();
1219 return VersionTuple(Major);
1222 const char AfterMajorSeparator = ThisTokBegin[AfterMajor];
1224 || (AfterMajor + 1 == ActualLength)) {
1225 Diag(Tok, diag::err_expected_version);
1228 return VersionTuple();
1232 unsigned AfterMinor = AfterMajor + 1;
1234 while (AfterMinor < ActualLength &&
isDigit(ThisTokBegin[AfterMinor])) {
1235 Minor = Minor * 10 + ThisTokBegin[AfterMinor] -
'0';
1239 if (AfterMinor == ActualLength) {
1243 if (Major == 0 && Minor == 0) {
1244 Diag(Tok, diag::err_zero_version);
1245 return VersionTuple();
1248 return VersionTuple(Major, Minor);
1251 const char AfterMinorSeparator = ThisTokBegin[AfterMinor];
1254 Diag(Tok, diag::err_expected_version);
1257 return VersionTuple();
1261 if (AfterMajorSeparator != AfterMinorSeparator)
1262 Diag(Tok, diag::warn_expected_consistent_version_separator);
1265 unsigned AfterSubminor = AfterMinor + 1;
1266 unsigned Subminor = 0;
1267 while (AfterSubminor < ActualLength &&
isDigit(ThisTokBegin[AfterSubminor])) {
1268 Subminor = Subminor * 10 + ThisTokBegin[AfterSubminor] -
'0';
1272 if (AfterSubminor != ActualLength) {
1273 Diag(Tok, diag::err_expected_version);
1276 return VersionTuple();
1279 return VersionTuple(Major, Minor, Subminor);
1307void Parser::ParseAvailabilityAttribute(
1311 enum { Introduced, Deprecated, Obsoleted,
Unknown };
1318 if (
T.consumeOpen()) {
1319 Diag(Tok, diag::err_expected) << tok::l_paren;
1324 if (Tok.
isNot(tok::identifier)) {
1325 Diag(Tok, diag::err_availability_expected_platform);
1332 if (Ident->getName().contains(
"xrOS") || Ident->getName().contains(
"xros"))
1333 Diag(Platform->
Loc, diag::warn_availability_unknown_platform) << Ident;
1335 else if (Ident->getName() ==
"macosx")
1339 else if (Ident->getName() ==
"macosx_app_extension")
1343 AvailabilityAttr::canonicalizePlatformName(Ident->getName()));
1347 if (ExpectAndConsume(tok::comma)) {
1354 if (!Ident_introduced) {
1369 if (Tok.
isNot(tok::identifier)) {
1370 Diag(Tok, diag::err_availability_expected_change);
1377 if (Keyword == Ident_strict) {
1379 Diag(KeywordLoc, diag::err_availability_redundant)
1382 StrictLoc = KeywordLoc;
1386 if (Keyword == Ident_unavailable) {
1387 if (UnavailableLoc.
isValid()) {
1388 Diag(KeywordLoc, diag::err_availability_redundant)
1391 UnavailableLoc = KeywordLoc;
1395 if (Keyword == Ident_deprecated && Platform->
Ident &&
1398 if (Changes[Deprecated].KeywordLoc.
isValid()) {
1399 Diag(KeywordLoc, diag::err_availability_redundant)
1406 Changes[Deprecated].
Version = VersionTuple(1);
1410 if (Keyword == Ident_environment) {
1411 if (EnvironmentLoc !=
nullptr) {
1412 Diag(KeywordLoc, diag::err_availability_redundant)
1417 if (Tok.
isNot(tok::equal)) {
1418 Diag(Tok, diag::err_expected_after) << Keyword << tok::equal;
1423 if (Keyword == Ident_message || Keyword == Ident_replacement) {
1424 if (!isTokenStringLiteral()) {
1425 Diag(Tok, diag::err_expected_string_literal)
1430 if (Keyword == Ident_message) {
1438 if (Keyword == Ident_environment) {
1439 if (Tok.
isNot(tok::identifier)) {
1440 Diag(Tok, diag::err_availability_expected_environment);
1444 EnvironmentLoc = ParseIdentifierLoc();
1450 if ((Keyword == Ident_introduced || Keyword == Ident_deprecated) &&
1451 Tok.
is(tok::identifier)) {
1455 if (Keyword == Ident_introduced)
1456 UnavailableLoc = KeywordLoc;
1462 VersionTuple Version = ParseVersionTuple(VersionRange);
1464 if (Version.empty()) {
1470 if (Keyword == Ident_introduced)
1472 else if (Keyword == Ident_deprecated)
1474 else if (Keyword == Ident_obsoleted)
1480 if (!Changes[Index].KeywordLoc.
isInvalid()) {
1481 Diag(KeywordLoc, diag::err_availability_redundant)
1484 Changes[Index].VersionRange.
getEnd());
1488 Changes[Index].
Version = Version;
1491 Diag(KeywordLoc, diag::err_availability_unknown_change)
1492 << Keyword << VersionRange;
1498 if (
T.consumeClose())
1502 *endLoc =
T.getCloseLocation();
1506 if (UnavailableLoc.
isValid()) {
1507 bool Complained =
false;
1508 for (
unsigned Index = Introduced; Index !=
Unknown; ++Index) {
1509 if (Changes[Index].KeywordLoc.
isValid()) {
1511 Diag(UnavailableLoc, diag::warn_availability_and_unavailable)
1513 Changes[Index].VersionRange.
getEnd());
1524 attrs.
addNew(&Availability,
1525 SourceRange(AvailabilityLoc,
T.getCloseLocation()), ScopeName,
1526 ScopeLoc, Platform, Changes[Introduced], Changes[Deprecated],
1527 Changes[Obsoleted], UnavailableLoc, MessageExpr.
get(), Form,
1528 StrictLoc, ReplacementExpr.
get(), EnvironmentLoc);
1545void Parser::ParseExternalSourceSymbolAttribute(
1551 if (
T.expectAndConsume())
1555 if (!Ident_language) {
1563 bool HasLanguage =
false;
1565 bool HasDefinedIn =
false;
1568 bool HasUSR =
false;
1572 if (Tok.
isNot(tok::identifier)) {
1573 Diag(Tok, diag::err_external_source_symbol_expected_keyword);
1580 if (Keyword == Ident_generated_declaration) {
1581 if (GeneratedDeclaration) {
1582 Diag(Tok, diag::err_external_source_symbol_duplicate_clause) << Keyword;
1586 GeneratedDeclaration = ParseIdentifierLoc();
1590 if (Keyword != Ident_language && Keyword != Ident_defined_in &&
1591 Keyword != Ident_USR) {
1592 Diag(Tok, diag::err_external_source_symbol_expected_keyword);
1598 if (ExpectAndConsume(tok::equal, diag::err_expected_after,
1604 bool HadLanguage = HasLanguage, HadDefinedIn = HasDefinedIn,
1606 if (Keyword == Ident_language)
1608 else if (Keyword == Ident_USR)
1611 HasDefinedIn =
true;
1613 if (!isTokenStringLiteral()) {
1614 Diag(Tok, diag::err_expected_string_literal)
1617 Keyword == Ident_language
1619 : (Keyword == Ident_defined_in ? 1 : 2));
1623 if (Keyword == Ident_language) {
1625 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1631 }
else if (Keyword == Ident_USR) {
1633 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1640 assert(Keyword == Ident_defined_in &&
"Invalid clause keyword!");
1642 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1652 if (
T.consumeClose())
1655 *EndLoc =
T.getCloseLocation();
1660 ScopeName, ScopeLoc, Args, std::size(Args), Form);
1674void Parser::ParseObjCBridgeRelatedAttribute(
1680 if (
T.consumeOpen()) {
1681 Diag(Tok, diag::err_expected) << tok::l_paren;
1686 if (Tok.
isNot(tok::identifier)) {
1687 Diag(Tok, diag::err_objcbridge_related_expected_related_class);
1692 if (ExpectAndConsume(tok::comma)) {
1701 if (Tok.
is(tok::identifier)) {
1704 Diag(Tok, diag::err_objcbridge_related_selector_name);
1710 if (Tok.
is(tok::colon))
1711 Diag(Tok, diag::err_objcbridge_related_selector_name);
1713 Diag(Tok, diag::err_expected) << tok::comma;
1721 if (Tok.
is(tok::identifier))
1723 else if (Tok.
isNot(tok::r_paren)) {
1724 Diag(Tok, diag::err_expected) << tok::r_paren;
1730 if (
T.consumeClose())
1734 *EndLoc =
T.getCloseLocation();
1737 Attrs.
addNew(&ObjCBridgeRelated,
1738 SourceRange(ObjCBridgeRelatedLoc,
T.getCloseLocation()),
1739 ScopeName, ScopeLoc, RelatedClass, ClassMethod, InstanceMethod,
1743void Parser::ParseSwiftNewTypeAttribute(
1750 if (
T.consumeOpen()) {
1751 Diag(Tok, diag::err_expected) << tok::l_paren;
1755 if (Tok.
is(tok::r_paren)) {
1760 if (Tok.
isNot(tok::kw_struct) && Tok.
isNot(tok::kw_enum)) {
1761 Diag(Tok, diag::warn_attribute_type_not_supported)
1763 if (!isTokenSpecial())
1774 if (
T.consumeClose())
1777 *EndLoc =
T.getCloseLocation();
1781 ScopeName, ScopeLoc, Args, std::size(Args), Form);
1784void Parser::ParseTypeTagForDatatypeAttribute(
1788 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
1793 if (Tok.
isNot(tok::identifier)) {
1794 Diag(Tok, diag::err_expected) << tok::identifier;
1800 if (ExpectAndConsume(tok::comma)) {
1812 bool LayoutCompatible =
false;
1813 bool MustBeNull =
false;
1815 if (Tok.
isNot(tok::identifier)) {
1816 Diag(Tok, diag::err_expected) << tok::identifier;
1821 if (Flag->
isStr(
"layout_compatible"))
1822 LayoutCompatible =
true;
1823 else if (Flag->
isStr(
"must_be_null"))
1826 Diag(Tok, diag::err_type_safety_unknown_flag) << Flag;
1833 if (!
T.consumeClose()) {
1835 ArgumentKind, MatchingCType.
get(),
1836 LayoutCompatible, MustBeNull, Form);
1840 *EndLoc =
T.getCloseLocation();
1851bool Parser::DiagnoseProhibitedCXX11Attribute() {
1852 assert(Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square));
1854 switch (isCXX11AttributeSpecifier(
true)) {
1855 case CAK_NotAttributeSpecifier:
1859 case CAK_InvalidAttributeSpecifier:
1863 case CAK_AttributeSpecifier:
1868 assert(Tok.
is(tok::r_square) &&
"isCXX11AttributeSpecifier lied");
1870 Diag(BeginLoc, diag::err_attributes_not_allowed)
1874 llvm_unreachable(
"All cases handled above.");
1883 assert((Tok.
is(tok::l_square) &&
NextToken().is(tok::l_square)) ||
1890 ParseCXX11Attributes(Attrs);
1893 (Keyword ?
Diag(
Loc, diag::err_keyword_not_allowed) << Keyword
1894 :
Diag(
Loc, diag::err_attributes_not_allowed))
1899void Parser::DiagnoseProhibitedAttributes(
1901 auto *FirstAttr = Attrs.
empty() ? nullptr : &Attrs.
front();
1902 if (CorrectLocation.
isValid()) {
1904 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
1905 ?
Diag(CorrectLocation, diag::err_keyword_misplaced) << FirstAttr
1906 :
Diag(CorrectLocation, diag::err_attributes_misplaced))
1911 (FirstAttr && FirstAttr->isRegularKeywordAttribute()
1919 unsigned AttrDiagID,
1920 unsigned KeywordDiagID,
1921 bool DiagnoseEmptyAttrs,
1922 bool WarnOnUnknownAttrs) {
1932 if (FirstLSquare.
is(tok::l_square)) {
1933 std::optional<Token> SecondLSquare =
1936 if (SecondLSquare && SecondLSquare->is(tok::l_square)) {
1947 if (AL.isRegularKeywordAttribute()) {
1948 Diag(AL.getLoc(), KeywordDiagID) << AL;
1952 if (!AL.isStandardAttributeSyntax())
1955 if (WarnOnUnknownAttrs)
1956 Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored)
1957 << AL << AL.getRange();
1959 Diag(AL.getLoc(), AttrDiagID) << AL;
1967 if (PA.isStandardAttributeSyntax() || PA.isRegularKeywordAttribute())
1968 Diag(PA.getLoc(), diag::ext_cxx11_attr_placement)
1969 << PA << PA.isRegularKeywordAttribute() << PA.getRange();
1988 if ((AL.getKind() == ParsedAttr::AT_Aligned &&
1989 AL.isDeclspecAttribute()) ||
1990 AL.isMicrosoftAttribute())
1991 ToBeMoved.push_back(&AL);
2026 Decl *SingleDecl =
nullptr;
2028 case tok::kw_template:
2029 case tok::kw_export:
2030 ProhibitAttributes(DeclAttrs);
2031 ProhibitAttributes(DeclSpecAttrs);
2032 return ParseDeclarationStartingWithTemplate(Context, DeclEnd, DeclAttrs);
2033 case tok::kw_inline:
2036 ProhibitAttributes(DeclAttrs);
2037 ProhibitAttributes(DeclSpecAttrs);
2039 return ParseNamespace(Context, DeclEnd, InlineLoc);
2041 return ParseSimpleDeclaration(Context, DeclEnd, DeclAttrs, DeclSpecAttrs,
2042 true,
nullptr, DeclSpecStart);
2044 case tok::kw_cbuffer:
2045 case tok::kw_tbuffer:
2046 SingleDecl = ParseHLSLBuffer(DeclEnd);
2048 case tok::kw_namespace:
2049 ProhibitAttributes(DeclAttrs);
2050 ProhibitAttributes(DeclSpecAttrs);
2051 return ParseNamespace(Context, DeclEnd);
2052 case tok::kw_using: {
2055 return ParseUsingDirectiveOrDeclaration(Context, ParsedTemplateInfo(),
2058 case tok::kw_static_assert:
2059 case tok::kw__Static_assert:
2060 ProhibitAttributes(DeclAttrs);
2061 ProhibitAttributes(DeclSpecAttrs);
2062 SingleDecl = ParseStaticAssertDeclaration(DeclEnd);
2065 return ParseSimpleDeclaration(Context, DeclEnd, DeclAttrs, DeclSpecAttrs,
2066 true,
nullptr, DeclSpecStart);
2098 bool RequireSemi, ForRangeInit *FRI,
SourceLocation *DeclSpecStart) {
2101 OriginalDeclSpecAttrs.
addAll(DeclSpecAttrs.
begin(), DeclSpecAttrs.
end());
2102 OriginalDeclSpecAttrs.
Range = DeclSpecAttrs.
Range;
2108 ParsedTemplateInfo TemplateInfo;
2109 DeclSpecContext DSContext = getDeclSpecContextFromDeclaratorContext(Context);
2110 ParseDeclarationSpecifiers(DS, TemplateInfo,
AS_none, DSContext);
2115 DiagnoseMissingSemiAfterTagDefinition(DS,
AS_none, DSContext))
2120 if (Tok.
is(tok::semi)) {
2121 ProhibitAttributes(DeclAttrs);
2128 DS.complete(TheDecl);
2130 Decl* decls[] = {AnonRecord, TheDecl};
2142 return ParseDeclGroup(DS, Context, DeclAttrs, TemplateInfo, &DeclEnd, FRI);
2149 case tok::annot_cxxscope:
2150 case tok::annot_template_id:
2152 case tok::code_completion:
2153 case tok::coloncolon:
2155 case tok::kw___attribute:
2156 case tok::kw_operator:
2172 case tok::identifier:
2174 case tok::code_completion:
2175 case tok::coloncolon:
2178 case tok::equalequal:
2179 case tok::kw_alignas:
2181 case tok::kw___attribute:
2199 case tok::identifier:
2222 if (Tok.
isOneOf(tok::comma, tok::l_brace, tok::kw_try)) {
2246 case tok::kw_inline:
2251 (!ParsingInObjCContainer || CurParsedObjCImpl))
2255 case tok::kw_namespace:
2260 (!ParsingInObjCContainer || CurParsedObjCImpl))
2266 if (
NextToken().isObjCAtKeyword(tok::objc_end) &&
2267 ParsingInObjCContainer)
2279 case tok::annot_module_begin:
2280 case tok::annot_module_end:
2281 case tok::annot_module_include:
2282 case tok::annot_repl_input_end:
2299 ParsedTemplateInfo &TemplateInfo,
2301 ForRangeInit *FRI) {
2307 LocalAttrs.takeAllFrom(Attrs);
2309 if (TemplateInfo.TemplateParams)
2310 D.setTemplateParameterLists(*TemplateInfo.TemplateParams);
2312 bool IsTemplateSpecOrInst =
2313 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
2314 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
2319 if (IsTemplateSpecOrInst)
2323 if (!
D.hasName() && !
D.mayOmitIdentifier()) {
2329 MaybeParseHLSLAnnotations(
D);
2331 if (Tok.
is(tok::kw_requires))
2332 ParseTrailingRequiresClause(
D);
2337 LateParsedAttrList LateParsedAttrs(
true);
2338 if (
D.isFunctionDeclarator()) {
2339 MaybeParseGNUAttributes(
D, &LateParsedAttrs);
2344 if (Tok.
is(tok::kw__Noreturn)) {
2346 const char *PrevSpec;
2352 MaybeParseGNUAttributes(
D, &LateParsedAttrs);
2353 Fixit &= Tok.
isOneOf(tok::semi, tok::l_brace, tok::kw_try);
2355 Diag(
Loc, diag::err_c11_noreturn_misplaced)
2357 << (Fixit ?
FixItHint::CreateInsertion(
D.getBeginLoc(),
"_Noreturn ")
2362 if (Tok.
is(tok::equal) &&
NextToken().is(tok::code_completion)) {
2373 while (
auto Specifier = isCXX11VirtSpecifier()) {
2374 Diag(Tok, diag::err_virt_specifier_outside_class)
2382 if (!isDeclarationAfterDeclarator()) {
2388 if (isStartOfFunctionDefinition(
D)) {
2398 diag::err_function_declared_typedef)
2402 Decl *TheDecl =
nullptr;
2404 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
2408 Diag(Tok, diag::err_template_defn_explicit_instantiation) << 0;
2409 TheDecl = ParseFunctionDefinition(
D, ParsedTemplateInfo(),
2414 Diag(
D.getIdentifierLoc(),
2415 diag::err_explicit_instantiation_with_definition)
2423 std::nullopt, LAngleLoc,
nullptr));
2425 TheDecl = ParseFunctionDefinition(
2427 ParsedTemplateInfo(&FakedParamLists,
2434 ParseFunctionDefinition(
D, TemplateInfo, &LateParsedAttrs);
2441 Tok.
is(tok::kw_namespace)) {
2451 Diag(Tok, diag::err_expected_fn_body);
2456 if (Tok.
is(tok::l_brace)) {
2457 Diag(Tok, diag::err_function_definition_not_allowed);
2465 if (ParseAsmAttributesAfterDeclarator(
D))
2474 if (FRI && (Tok.
is(tok::colon) || isTokIdentifier_in())) {
2475 bool IsForRangeLoop =
false;
2477 IsForRangeLoop =
true;
2487 LastRecord.InLifetimeExtendingContext =
true;
2492 if (Tok.
is(tok::l_brace))
2493 FRI->RangeExpr = ParseBraceInitializer();
2504 FRI->LifetimeExtendTemps = std::move(
2509 if (IsForRangeLoop) {
2513 if (
auto *VD = dyn_cast_or_null<VarDecl>(ThisDecl))
2514 VD->setObjCForDecl(
true);
2517 D.complete(ThisDecl);
2523 ParseDeclarationAfterDeclaratorAndAttributes(
D, TemplateInfo, FRI);
2524 if (LateParsedAttrs.size() > 0)
2525 ParseLexedAttributeList(LateParsedAttrs, FirstDecl,
true,
false);
2526 D.complete(FirstDecl);
2528 DeclsInGroup.push_back(FirstDecl);
2536 if (Tok.
isAtStartOfLine() && ExpectSemi && !MightBeDeclarator(Context)) {
2540 Diag(CommaLoc, diag::err_expected_semi_declaration)
2550 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
2551 D.isFirstDeclarator()) {
2552 Diag(CommaLoc, diag::err_multiple_template_declarators)
2553 << TemplateInfo.Kind;
2558 D.setCommaLoc(CommaLoc);
2567 MaybeParseGNUAttributes(
D);
2571 DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2576 MaybeParseHLSLAnnotations(
D);
2578 if (!
D.isInvalidType()) {
2583 if (Tok.
is(tok::kw_requires))
2584 ParseTrailingRequiresClause(
D);
2585 Decl *ThisDecl = ParseDeclarationAfterDeclarator(
D, TemplateInfo);
2586 D.complete(ThisDecl);
2588 DeclsInGroup.push_back(ThisDecl);
2595 if (ExpectSemi && ExpectAndConsumeSemi(
2597 ? diag::err_invalid_token_after_toplevel_declarator
2598 : diag::err_expected_semi_declaration)) {
2611bool Parser::ParseAsmAttributesAfterDeclarator(
Declarator &
D) {
2613 if (Tok.
is(tok::kw_asm)) {
2616 if (AsmLabel.isInvalid()) {
2621 D.setAsmLabel(AsmLabel.get());
2625 MaybeParseGNUAttributes(
D);
2651Decl *Parser::ParseDeclarationAfterDeclarator(
2652 Declarator &
D,
const ParsedTemplateInfo &TemplateInfo) {
2653 if (ParseAsmAttributesAfterDeclarator(
D))
2656 return ParseDeclarationAfterDeclaratorAndAttributes(
D, TemplateInfo);
2659Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
2660 Declarator &
D,
const ParsedTemplateInfo &TemplateInfo, ForRangeInit *FRI) {
2662 struct InitializerScopeRAII {
2669 :
P(
P),
D(
D), ThisDecl(ThisDecl), Entered(
false) {
2670 if (ThisDecl &&
P.getLangOpts().CPlusPlus) {
2672 if (
D.getCXXScopeSpec().isSet()) {
2674 S =
P.getCurScope();
2677 P.Actions.ActOnCXXEnterDeclInitializer(S, ThisDecl);
2682 ~InitializerScopeRAII() {
2683 if (ThisDecl &&
P.getLangOpts().CPlusPlus) {
2685 if (
D.getCXXScopeSpec().isSet())
2686 S =
P.getCurScope();
2689 P.Actions.ActOnCXXExitDeclInitializer(S, ThisDecl);
2698 InitKind TheInitKind;
2700 if (isTokenEqualOrEqualTypo())
2701 TheInitKind = InitKind::Equal;
2702 else if (Tok.
is(tok::l_paren))
2703 TheInitKind = InitKind::CXXDirect;
2705 (!CurParsedObjCImpl || !
D.isFunctionDeclarator()))
2706 TheInitKind = InitKind::CXXBraced;
2708 TheInitKind = InitKind::Uninitialized;
2709 if (TheInitKind != InitKind::Uninitialized)
2710 D.setHasInitializer();
2713 Decl *ThisDecl =
nullptr;
2714 Decl *OuterDecl =
nullptr;
2715 switch (TemplateInfo.Kind) {
2716 case ParsedTemplateInfo::NonTemplate:
2720 case ParsedTemplateInfo::Template:
2721 case ParsedTemplateInfo::ExplicitSpecialization: {
2723 *TemplateInfo.TemplateParams,
2725 if (
VarTemplateDecl *VT = dyn_cast_or_null<VarTemplateDecl>(ThisDecl)) {
2728 ThisDecl = VT->getTemplatedDecl();
2733 case ParsedTemplateInfo::ExplicitInstantiation: {
2734 if (Tok.
is(tok::semi)) {
2736 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc,
D);
2741 ThisDecl = ThisRes.
get();
2749 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2755 Diag(
D.getIdentifierLoc(),
2756 diag::err_explicit_instantiation_with_definition)
2764 std::nullopt, LAngleLoc,
nullptr));
2776 switch (TheInitKind) {
2778 case InitKind::Equal: {
2781 if (Tok.
is(tok::kw_delete)) {
2782 if (
D.isFunctionDeclarator())
2787 SkipDeletedFunctionBody();
2788 }
else if (Tok.
is(tok::kw_default)) {
2789 if (
D.isFunctionDeclarator())
2796 InitializerScopeRAII
InitScope(*
this,
D, ThisDecl);
2798 if (Tok.
is(tok::code_completion)) {
2811 if (Tok.
is(tok::r_paren) && FRI &&
D.isFirstDeclarator()) {
2812 Diag(EqualLoc, diag::err_single_decl_assign_in_for_range)
2816 FRI->ColonLoc = EqualLoc;
2818 FRI->RangeExpr =
Init;
2821 if (
Init.isInvalid()) {
2823 StopTokens.push_back(tok::comma);
2826 StopTokens.push_back(tok::r_paren);
2835 case InitKind::CXXDirect: {
2842 InitializerScopeRAII
InitScope(*
this,
D, ThisDecl);
2844 auto ThisVarDecl = dyn_cast_or_null<VarDecl>(ThisDecl);
2845 auto RunSignatureHelp = [&]() {
2848 ThisVarDecl->getType()->getCanonicalTypeInternal(),
2851 CalledSignatureHelp =
true;
2852 return PreferredType;
2854 auto SetPreferredType = [&] {
2855 PreferredType.enterFunctionArgument(Tok.
getLocation(), RunSignatureHelp);
2858 llvm::function_ref<void()> ExpressionStarts;
2864 ExpressionStarts = SetPreferredType;
2867 bool SawError = ParseExpressionList(Exprs, ExpressionStarts);
2872 ThisVarDecl->getType()->getCanonicalTypeInternal(),
2875 CalledSignatureHelp =
true;
2884 T.getCloseLocation(),
2891 case InitKind::CXXBraced: {
2893 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2895 InitializerScopeRAII
InitScope(*
this,
D, ThisDecl);
2897 PreferredType.enterVariableInit(Tok.
getLocation(), ThisDecl);
2900 if (
Init.isInvalid()) {
2906 case InitKind::Uninitialized: {
2913 return OuterDecl ? OuterDecl : ThisDecl;
2922void Parser::ParseSpecifierQualifierList(
2925 ParsedTemplateInfo TemplateInfo;
2929 ParseDeclarationSpecifiers(DS, TemplateInfo, AS, DSC,
nullptr,
2930 AllowImplicitTypename);
2935 Diag(Tok, diag::err_expected_type);
2938 Diag(Tok, diag::err_typename_requires_specqual);
2949 diag::err_typename_invalid_storageclass);
2993 return T.isOneOf(tok::l_square, tok::l_paren, tok::r_paren, tok::semi,
2994 tok::comma, tok::equal, tok::kw_asm, tok::l_brace,
3008 ParsedTemplateInfo &TemplateInfo,
3011 assert(Tok.
is(tok::identifier) &&
"should have identifier");
3033 if (!isTypeSpecifier(DSC) &&
getLangOpts().isImplicitIntAllowed() &&
3051 AnnotateScopeToken(*SS,
false);
3062 DSC == DeclSpecContext::DSC_template_type_arg)) {
3063 const char *PrevSpec;
3079 if (SS ==
nullptr) {
3080 const char *TagName =
nullptr, *FixitTagName =
nullptr;
3086 TagName=
"enum" ; FixitTagName =
"enum " ; TagKind=tok::kw_enum ;
break;
3088 TagName=
"union" ; FixitTagName =
"union " ;TagKind=tok::kw_union ;
break;
3090 TagName=
"struct"; FixitTagName =
"struct ";TagKind=tok::kw_struct;
break;
3092 TagName=
"__interface"; FixitTagName =
"__interface ";
3093 TagKind=tok::kw___interface;
break;
3095 TagName=
"class" ; FixitTagName =
"class " ;TagKind=tok::kw_class ;
break;
3103 Diag(
Loc, diag::err_use_of_tag_name_without_tag)
3104 << TokenName << TagName <<
getLangOpts().CPlusPlus
3110 Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
3111 << TokenName << TagName;
3115 if (TagKind == tok::kw_enum)
3116 ParseEnumSpecifier(
Loc, DS, TemplateInfo, AS,
3117 DeclSpecContext::DSC_normal);
3119 ParseClassSpecifier(TagKind,
Loc, DS, TemplateInfo, AS,
3121 DeclSpecContext::DSC_normal, Attrs);
3128 if (!isTypeSpecifier(DSC) && (!SS || DSC == DeclSpecContext::DSC_top_level ||
3129 DSC == DeclSpecContext::DSC_class)) {
3133 case tok::l_paren: {
3140 TentativeParsingAction PA(*
this);
3142 TPResult TPR = TryParseDeclarator(
false);
3145 if (TPR != TPResult::False) {
3153 if (DSC == DeclSpecContext::DSC_class ||
3154 (DSC == DeclSpecContext::DSC_top_level && SS)) {
3157 Diag(
Loc, diag::err_constructor_bad_name)
3178 AnnotateScopeToken(*SS,
false);
3200 const char *PrevSpec;
3221 if (IsTemplateName) {
3223 TemplateArgList Args;
3224 ParseTemplateIdAfterTemplateName(
true, LAngle, Args, RAngle);
3238Parser::DeclSpecContext
3242 return DeclSpecContext::DSC_class;
3244 return DeclSpecContext::DSC_top_level;
3246 return DeclSpecContext::DSC_template_param;
3248 return DeclSpecContext::DSC_template_arg;
3250 return DeclSpecContext::DSC_template_type_arg;
3253 return DeclSpecContext::DSC_trailing;
3256 return DeclSpecContext::DSC_alias_declaration;
3258 return DeclSpecContext::DSC_association;
3260 return DeclSpecContext::DSC_type_specifier;
3262 return DeclSpecContext::DSC_condition;
3264 return DeclSpecContext::DSC_conv_operator;
3266 return DeclSpecContext::DSC_new;
3281 return DeclSpecContext::DSC_normal;
3284 llvm_unreachable(
"Missing DeclaratorContext case");
3297 if (isTypeIdInParens()) {
3326 assert(Tok.
isOneOf(tok::kw_alignas, tok::kw__Alignas) &&
3327 "Not an alignment-specifier!");
3334 if (
T.expectAndConsume())
3341 ParseAlignArgument(PP.
getSpelling(KWTok),
T.getOpenLocation(),
3350 *EndLoc =
T.getCloseLocation();
3357 ArgExprs.push_back(ArgExpr.
get());
3358 Attrs.
addNew(KWName, KWLoc,
nullptr, KWLoc, ArgExprs.data(), 1, Kind,
3363void Parser::DistributeCLateParsedAttrs(
Decl *Dcl,
3364 LateParsedAttrList *LateAttrs) {
3369 for (
auto *LateAttr : *LateAttrs) {
3370 if (LateAttr->Decls.empty())
3371 LateAttr->addDecl(Dcl);
3384 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
3389 if (Tok.
is(tok::r_paren)) {
3397 using ExpressionKind =
3401 ExpressionKind::EK_AttrArgument);
3411 ArgExprs.push_back(ArgExpr.
get());
3421 ScopeName, ScopeLoc, ArgExprs.data(), ArgExprs.size(), Form);
3424ExprResult Parser::ParseExtIntegerArgument() {
3425 assert(Tok.
isOneOf(tok::kw__ExtInt, tok::kw__BitInt) &&
3426 "Not an extended int type");
3430 if (
T.expectAndConsume())
3439 if(
T.consumeClose())
3453 DeclSpecContext DSContext,
3454 LateParsedAttrList *LateAttrs) {
3457 bool EnteringContext = (DSContext == DeclSpecContext::DSC_class ||
3458 DSContext == DeclSpecContext::DSC_top_level);
3461 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype,
3462 tok::annot_template_id) &&
3468 bool HasScope = Tok.
is(tok::annot_cxxscope);
3474 bool MightBeDeclarator =
true;
3475 if (Tok.
isOneOf(tok::kw_typename, tok::annot_typename)) {
3477 MightBeDeclarator =
false;
3478 }
else if (AfterScope.
is(tok::annot_template_id)) {
3484 MightBeDeclarator =
false;
3485 }
else if (AfterScope.
is(tok::identifier)) {
3486 const Token &Next = HasScope ? GetLookAheadToken(2) :
NextToken();
3490 if (Next.isOneOf(tok::star, tok::amp, tok::ampamp, tok::identifier,
3491 tok::annot_cxxscope, tok::coloncolon)) {
3493 MightBeDeclarator =
false;
3494 }
else if (HasScope) {
3505 switch (Classification.
getKind()) {
3511 llvm_unreachable(
"typo correction is not possible here");
3518 MightBeDeclarator =
false;
3534 if (MightBeDeclarator)
3539 diag::err_expected_after)
3550 ParsedTemplateInfo NotATemplate;
3551 ParseDeclarationSpecifiers(DS, NotATemplate, AS, DSContext, LateAttrs);
3582void Parser::ParseDeclarationSpecifiers(
3584 DeclSpecContext DSContext, LateParsedAttrList *LateAttrs,
3596 if (DSContext == DeclSpecContext::DSC_conv_operator) {
3599 DSContext = DeclSpecContext::DSC_type_specifier;
3602 bool EnteringContext = (DSContext == DeclSpecContext::DSC_class ||
3603 DSContext == DeclSpecContext::DSC_top_level);
3604 bool AttrsLastTime =
false;
3610 bool isStorageClass =
false;
3611 const char *PrevSpec =
nullptr;
3612 unsigned DiagID = 0;
3633 auto handleOpenCLImageKW = [&] (StringRef Ext,
TypeSpecifierType ImageTypeSpec) {
3647 bool IsTemplateSpecOrInst =
3648 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
3649 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
3658 ProhibitAttributes(attrs);
3662 if (!PA.isCXX11Attribute() && !PA.isC23Attribute() &&
3663 !PA.isRegularKeywordAttribute())
3671 if (PA.getKind() == ParsedAttr::AT_VectorSize) {
3672 Diag(PA.getLoc(), diag::warn_attribute_ignored) << PA;
3679 if (PA.isTypeAttr() && PA.getKind() != ParsedAttr::AT_LifetimeBound &&
3680 PA.getKind() != ParsedAttr::AT_AnyX86NoCfCheck)
3682 Diag(PA.getLoc(), diag::err_attribute_not_type_attr)
3683 << PA << PA.isRegularKeywordAttribute();
3692 DS.
Finish(Actions, Policy);
3696 case tok::kw__Alignas:
3697 diagnoseUseOfC11Keyword(Tok);
3699 case tok::kw_alignas:
3705 if (Tok.
getKind() == tok::kw_alignas)
3706 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
3712 if (!isAllowedCXX11AttributeSpecifier())
3713 goto DoneWithDeclSpec;
3716 ProhibitAttributes(attrs);
3723 ParseCXX11Attributes(attrs);
3724 AttrsLastTime =
true;
3727 case tok::code_completion: {
3731 bool AllowNonIdentifiers
3737 bool AllowNestedNameSpecifiers
3738 = DSContext == DeclSpecContext::DSC_top_level ||
3743 getCurScope(), DS, AllowNonIdentifiers, AllowNestedNameSpecifiers);
3748 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
3749 CCC = DSContext == DeclSpecContext::DSC_class
3752 else if (DSContext == DeclSpecContext::DSC_class)
3756 else if (CurParsedObjCImpl)
3764 case tok::coloncolon:
3770 goto DoneWithDeclSpec;
3772 if (Tok.
is(tok::coloncolon))
3773 goto DoneWithDeclSpec;
3776 case tok::annot_cxxscope: {
3778 goto DoneWithDeclSpec;
3781 if (TemplateInfo.TemplateParams)
3791 ? takeTemplateIdAnnotation(Next)
3797 ConsumeAnnotationToken();
3811 if ((DSContext == DeclSpecContext::DSC_top_level ||
3812 DSContext == DeclSpecContext::DSC_class) &&
3815 isConstructorDeclarator(
false,
3822 goto DoneWithDeclSpec;
3826 ConsumeAnnotationToken();
3827 assert(Tok.
is(tok::annot_template_id) &&
3828 "ParseOptionalCXXScopeSpecifier not working");
3829 AnnotateTemplateIdTokenAsType(SS, AllowImplicitTypename);
3839 ConsumeAnnotationToken();
3843 if (Next.is(tok::annot_typename)) {
3845 ConsumeAnnotationToken();
3849 PrevSpec, DiagID,
T, Policy);
3853 ConsumeAnnotationToken();
3857 Next.is(tok::annot_template_id) &&
3861 ConsumeAnnotationToken();
3862 AnnotateTemplateIdTokenAsType(SS, AllowImplicitTypename);
3866 if (Next.isNot(tok::identifier))
3867 goto DoneWithDeclSpec;
3872 if ((DSContext == DeclSpecContext::DSC_top_level ||
3873 DSContext == DeclSpecContext::DSC_class) &&
3876 isConstructorDeclarator(
false,
3880 goto DoneWithDeclSpec;
3889 *Next.getIdentifierInfo(), Next.getLocation(),
getCurScope(), &SS,
3890 false,
false,
nullptr,
3893 isClassTemplateDeductionContext(DSContext), AllowImplicitTypename);
3895 if (IsTemplateSpecOrInst)
3903 if (TryAnnotateTypeConstraint())
3904 goto DoneWithDeclSpec;
3905 if (Tok.
isNot(tok::annot_cxxscope) ||
3909 ConsumeAnnotationToken();
3911 if (ParseImplicitInt(DS, &SS, TemplateInfo, AS, DSContext, Attrs)) {
3912 if (!Attrs.
empty()) {
3913 AttrsLastTime =
true;
3914 attrs.takeAllFrom(Attrs);
3918 goto DoneWithDeclSpec;
3922 ConsumeAnnotationToken();
3925 DiagID, TypeRep, Policy);
3935 case tok::annot_typename: {
3939 goto DoneWithDeclSpec;
3948 ConsumeAnnotationToken();
3953 case tok::kw___is_signed:
3964 TryKeywordIdentFallback(
true);
3967 goto DoneWithDeclSpec;
3970 case tok::kw___super:
3971 case tok::kw_decltype:
3972 case tok::identifier:
3978 goto DoneWithDeclSpec;
3984 if (!
getLangOpts().DeclSpecKeyword && Tok.
is(tok::identifier) &&
3986 Diag(
Loc, diag::err_ms_attributes_not_enabled);
3996 if (
T.consumeOpen()) {
3997 assert(
false &&
"Not a left paren?");
4016 if (IsTemplateSpecOrInst)
4020 if (IsTemplateSpecOrInst)
4023 goto DoneWithDeclSpec;
4026 if (!Tok.
is(tok::identifier))
4031 if (TryAltiVecToken(DS,
Loc, PrevSpec, DiagID,
isInvalid))
4037 goto DoneWithDeclSpec;
4039 if (DSContext == DeclSpecContext::DSC_objc_method_result &&
4040 isObjCInstancetype()) {
4044 DiagID, TypeRep, Policy);
4057 isConstructorDeclarator(
true,
4060 goto DoneWithDeclSpec;
4064 false,
false,
nullptr,
false,
false,
4065 isClassTemplateDeductionContext(DSContext));
4070 if (TryAnnotateTypeConstraint())
4071 goto DoneWithDeclSpec;
4072 if (Tok.
isNot(tok::identifier))
4075 if (ParseImplicitInt(DS,
nullptr, TemplateInfo, AS, DSContext, Attrs)) {
4076 if (!Attrs.
empty()) {
4077 AttrsLastTime =
true;
4078 attrs.takeAllFrom(Attrs);
4082 goto DoneWithDeclSpec;
4089 (DSContext == DeclSpecContext::DSC_class ||
4090 DSContext == DeclSpecContext::DSC_top_level) &&
4093 isConstructorDeclarator(
true,
4095 goto DoneWithDeclSpec;
4098 DiagID, TypeRep, Policy);
4110 TypeResult NewTypeRep = parseObjCTypeArgsAndProtocolQualifiers(
4125 case tok::annot_template_id: {
4137 TemplateId =
nullptr;
4145 tok::kw_volatile, tok::kw_restrict, tok::amp,
4147 Diag(
Loc, diag::err_placeholder_expected_auto_or_decltype_auto)
4151 TemplateId, Policy);
4155 goto DoneWithDeclSpec;
4158 TemplateId =
nullptr;
4160 ConsumeAnnotationToken();
4164 if (Tracker.consumeOpen()) {
4166 Diag(Tok, diag::err_expected) << tok::l_paren;
4170 Tracker.skipToEnd();
4171 Diag(Tok, diag::err_placeholder_expected_auto_or_decltype_auto)
4176 Tracker.consumeClose();
4184 DiagID, TemplateId, Policy);
4187 TemplateId, Policy);
4196 goto DoneWithDeclSpec;
4204 isConstructorDeclarator(
true,
4207 goto DoneWithDeclSpec;
4212 AnnotateTemplateIdTokenAsType(SS, AllowImplicitTypename);
4217 case tok::kw___attribute:
4218 case tok::kw___declspec:
4219 ParseAttributes(PAKM_GNU | PAKM_Declspec, DS.
getAttributes(), LateAttrs);
4223 case tok::kw___forceinline: {
4228 nullptr, 0, tok::kw___forceinline);
4232 case tok::kw___unaligned:
4237 case tok::kw___sptr:
4238 case tok::kw___uptr:
4239 case tok::kw___ptr64:
4240 case tok::kw___ptr32:
4242 case tok::kw___cdecl:
4243 case tok::kw___stdcall:
4244 case tok::kw___fastcall:
4245 case tok::kw___thiscall:
4246 case tok::kw___regcall:
4247 case tok::kw___vectorcall:
4251 case tok::kw___funcref:
4256 case tok::kw___pascal:
4261 case tok::kw___kernel:
4266 case tok::kw___noinline__:
4271 case tok::kw__Nonnull:
4272 case tok::kw__Nullable:
4273 case tok::kw__Nullable_result:
4274 case tok::kw__Null_unspecified:
4279 case tok::kw___kindof:
4281 nullptr, 0, tok::kw___kindof);
4286 case tok::kw_typedef:
4288 PrevSpec, DiagID, Policy);
4289 isStorageClass =
true;
4291 case tok::kw_extern:
4293 Diag(Tok, diag::ext_thread_before) <<
"extern";
4295 PrevSpec, DiagID, Policy);
4296 isStorageClass =
true;
4298 case tok::kw___private_extern__:
4300 Loc, PrevSpec, DiagID, Policy);
4301 isStorageClass =
true;
4303 case tok::kw_static:
4305 Diag(Tok, diag::ext_thread_before) <<
"static";
4307 PrevSpec, DiagID, Policy);
4308 isStorageClass =
true;
4312 if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
4314 PrevSpec, DiagID, Policy);
4316 Diag(Tok, diag::ext_auto_storage_class)
4323 PrevSpec, DiagID, Policy);
4324 isStorageClass =
true;
4326 case tok::kw___auto_type:
4327 Diag(Tok, diag::ext_auto_type);
4331 case tok::kw_register:
4333 PrevSpec, DiagID, Policy);
4334 isStorageClass =
true;
4336 case tok::kw_mutable:
4338 PrevSpec, DiagID, Policy);
4339 isStorageClass =
true;
4341 case tok::kw___thread:
4344 isStorageClass =
true;
4346 case tok::kw_thread_local:
4348 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
4357 Loc, PrevSpec, DiagID);
4358 isStorageClass =
true;
4360 case tok::kw__Thread_local:
4361 diagnoseUseOfC11Keyword(Tok);
4363 Loc, PrevSpec, DiagID);
4364 isStorageClass =
true;
4368 case tok::kw_inline:
4371 case tok::kw_virtual:
4375 !
getActions().getOpenCLOptions().isAvailableOption(
4377 DiagID = diag::err_openclcxx_virtual_function;
4384 case tok::kw_explicit: {
4388 ConsumedEnd = ExplicitLoc;
4390 if (Tok.
is(tok::l_paren)) {
4393 ? diag::warn_cxx17_compat_explicit_bool
4394 : diag::ext_explicit_bool);
4398 Tracker.consumeOpen();
4405 if (ExplicitExpr.isUsable()) {
4407 Tracker.consumeClose();
4411 Tracker.skipToEnd();
4417 ExplicitSpec, CloseParenLoc);
4420 case tok::kw__Noreturn:
4421 diagnoseUseOfC11Keyword(Tok);
4426 case tok::kw_friend:
4427 if (DSContext == DeclSpecContext::DSC_class) {
4434 DiagID = diag::err_friend_invalid_in_context;
4440 case tok::kw___module_private__:
4445 case tok::kw_constexpr:
4447 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
4451 case tok::kw_consteval:
4455 case tok::kw_constinit:
4471 PrevSpec, DiagID, Policy);
4473 case tok::kw___int64:
4475 PrevSpec, DiagID, Policy);
4477 case tok::kw_signed:
4481 case tok::kw_unsigned:
4485 case tok::kw__Complex:
4487 Diag(Tok, diag::ext_c99_feature) << Tok.
getName();
4491 case tok::kw__Imaginary:
4493 Diag(Tok, diag::ext_c99_feature) << Tok.
getName();
4509 case tok::kw__ExtInt:
4510 case tok::kw__BitInt: {
4511 DiagnoseBitIntUse(Tok);
4516 ConsumedEnd = PrevTokLocation;
4519 case tok::kw___int128:
4527 case tok::kw___bf16:
4535 case tok::kw_double:
4539 case tok::kw__Float16:
4543 case tok::kw__Accum:
4545 "This keyword is only used when fixed point types are enabled "
4546 "with `-ffixed-point`");
4550 case tok::kw__Fract:
4552 "This keyword is only used when fixed point types are enabled "
4553 "with `-ffixed-point`");
4559 "This keyword is only used when fixed point types are enabled "
4560 "with `-ffixed-point`");
4563 case tok::kw___float128:
4567 case tok::kw___ibm128:
4571 case tok::kw_wchar_t:
4575 case tok::kw_char8_t:
4579 case tok::kw_char16_t:
4583 case tok::kw_char32_t:
4589 Diag(Tok, diag::warn_c23_compat_keyword) << Tok.
getName();
4593 Diag(Tok, diag::ext_c99_feature) << Tok.
getName();
4595 if (Tok.
is(tok::kw_bool) &&
4599 DiagID = diag::err_bool_redeclaration;
4608 case tok::kw__Decimal32:
4612 case tok::kw__Decimal64:
4616 case tok::kw__Decimal128:
4620 case tok::kw___vector:
4623 case tok::kw___pixel:
4626 case tok::kw___bool:
4631 getLangOpts().getOpenCLCompatibleVersion() < 200) {
4636 goto DoneWithDeclSpec;
4638 DiagID = diag::err_opencl_unknown_type_specifier;
4645#define IMAGE_READ_WRITE_TYPE(Type, Id, Ext)
4646#define IMAGE_WRITE_TYPE(Type, Id, Ext)
4647#define IMAGE_READ_TYPE(ImgType, Id, Ext) \
4648 case tok::kw_##ImgType##_t: \
4649 if (!handleOpenCLImageKW(Ext, DeclSpec::TST_##ImgType##_t)) \
4650 goto DoneWithDeclSpec; \
4652#include "clang/Basic/OpenCLImageTypes.def"
4653 case tok::kw___unknown_anytype:
4655 PrevSpec, DiagID, Policy);
4660 case tok::kw_struct:
4661 case tok::kw___interface:
4662 case tok::kw_union: {
4670 ParseClassSpecifier(Kind,
Loc, DS, TemplateInfo, AS,
4671 EnteringContext, DSContext, Attributes);
4675 if (!Attributes.empty()) {
4676 AttrsLastTime =
true;
4677 attrs.takeAllFrom(Attributes);
4685 ParseEnumSpecifier(
Loc, DS, TemplateInfo, AS, DSContext);
4693 case tok::kw_volatile:
4697 case tok::kw_restrict:
4703 case tok::kw_typename:
4706 goto DoneWithDeclSpec;
4708 if (!Tok.
is(tok::kw_typename))
4713 case tok::kw_typeof:
4714 case tok::kw_typeof_unqual:
4715 ParseTypeofSpecifier(DS);
4718 case tok::annot_decltype:
4719 ParseDecltypeSpecifier(DS);
4722 case tok::annot_pack_indexing_type:
4723 ParsePackIndexingType(DS);
4726 case tok::annot_pragma_pack:
4730 case tok::annot_pragma_ms_pragma:
4731 HandlePragmaMSPragma();
4734 case tok::annot_pragma_ms_vtordisp:
4735 HandlePragmaMSVtorDisp();
4738 case tok::annot_pragma_ms_pointers_to_members:
4739 HandlePragmaMSPointersToMembers();
4742#define TRANSFORM_TYPE_TRAIT_DEF(_, Trait) case tok::kw___##Trait:
4743#include "clang/Basic/TransformTypeTraits.def"
4747 if (!MaybeParseTypeTransformTypeSpecifier(DS))
4748 goto ParseIdentifier;
4751 case tok::kw__Atomic:
4756 diagnoseUseOfC11Keyword(Tok);
4758 ParseAtomicSpecifier(DS);
4766 case tok::kw___generic:
4771 if (!Actions.
getLangOpts().OpenCLGenericAddressSpace) {
4772 DiagID = diag::err_opencl_unknown_type_specifier;
4778 case tok::kw_private:
4782 goto DoneWithDeclSpec;
4784 case tok::kw___private:
4785 case tok::kw___global:
4786 case tok::kw___local:
4787 case tok::kw___constant:
4789 case tok::kw___read_only:
4790 case tok::kw___write_only:
4791 case tok::kw___read_write:
4795 case tok::kw_groupshared:
4803#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
4804 case tok::kw_##Name: \
4805 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_##Name, Loc, PrevSpec, \
4808#include "clang/Basic/HLSLIntangibleTypes.def"
4815 goto DoneWithDeclSpec;
4820 if (
Type.isUsable()) {
4822 PrevSpec, DiagID,
Type.get(),
4824 Diag(StartLoc, DiagID) << PrevSpec;
4840 assert(PrevSpec &&
"Method did not return previous specifier!");
4843 if (DiagID == diag::ext_duplicate_declspec ||
4844 DiagID == diag::ext_warn_duplicate_declspec ||
4845 DiagID == diag::err_duplicate_declspec)
4849 else if (DiagID == diag::err_opencl_unknown_type_specifier) {
4853 Diag(
Loc, DiagID) << PrevSpec;
4856 if (DiagID != diag::err_bool_redeclaration && ConsumedEnd.
isInvalid())
4860 AttrsLastTime =
false;
4872 if (!RD || !RD->getName().empty() || RD->isAnonymousStructOrUnion())
4875 for (
auto *I : RD->decls()) {
4876 auto *VD = dyn_cast<ValueDecl>(I);
4884 for (
const auto &DD : CAT->dependent_decls()) {
4885 if (!RD->containsDecl(DD.getDecl())) {
4886 P.Diag(VD->getBeginLoc(), diag::err_count_attr_param_not_in_same_struct)
4887 << DD.getDecl() << CAT->getKind() << CAT->isArrayType();
4888 P.Diag(DD.getDecl()->getBeginLoc(),
4889 diag::note_flexible_array_counted_by_attr_field)
4917void Parser::ParseStructDeclaration(
4920 LateParsedAttrList *LateFieldAttrs) {
4922 if (Tok.
is(tok::kw___extension__)) {
4926 return ParseStructDeclaration(DS, FieldsCallback, LateFieldAttrs);
4931 MaybeParseCXX11Attributes(Attrs);
4934 ParseSpecifierQualifierList(DS);
4938 if (Tok.
is(tok::semi)) {
4943 ProhibitAttributes(Attrs);
4947 assert(!AnonRecord &&
"Did not expect anonymous struct or union here");
4953 bool FirstDeclarator =
true;
4957 DeclaratorInfo.D.setCommaLoc(CommaLoc);
4960 if (!FirstDeclarator) {
4963 DiagnoseAndSkipCXX11Attributes();
4964 MaybeParseGNUAttributes(DeclaratorInfo.D);
4965 DiagnoseAndSkipCXX11Attributes();
4970 if (Tok.
isNot(tok::colon)) {
4973 ParseDeclarator(DeclaratorInfo.D);
4975 DeclaratorInfo.D.SetIdentifier(
nullptr, Tok.
getLocation());
4987 DeclaratorInfo.BitfieldSize = Res.
get();
4991 MaybeParseGNUAttributes(DeclaratorInfo.D, LateFieldAttrs);
4994 Decl *
Field = FieldsCallback(DeclaratorInfo);
4996 DistributeCLateParsedAttrs(Field, LateFieldAttrs);
5003 FirstDeclarator =
false;
5009void Parser::ParseLexedCAttributeList(LateParsedAttrList &LAs,
bool EnterScope,
5011 assert(LAs.parseSoon() &&
5012 "Attribute list should be marked for immediate parsing.");
5013 for (
auto *LA : LAs) {
5014 ParseLexedCAttribute(*LA,
EnterScope, OutAttrs);
5025void Parser::ParseLexedCAttribute(LateParsedAttribute &LA,
bool EnterScope,
5034 LA.Toks.push_back(AttrEnd);
5038 LA.Toks.push_back(Tok);
5039 PP.EnterTokenStream(LA.Toks,
true,
5050 assert(LA.Decls.size() <= 1 &&
5051 "late field attribute expects to have at most one declaration.");
5054 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs,
nullptr,
nullptr,
5057 for (
auto *
D : LA.Decls)
5062 while (Tok.
isNot(tok::eof))
5087 "parsing struct/union body");
5091 if (
T.consumeOpen())
5099 LateParsedAttrList LateFieldAttrs(
true,
5103 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
5104 Tok.
isNot(tok::eof)) {
5108 if (Tok.
is(tok::semi)) {
5109 ConsumeExtraSemi(InsideStruct,
TagType);
5114 if (Tok.
isOneOf(tok::kw__Static_assert, tok::kw_static_assert)) {
5116 ParseStaticAssertDeclaration(DeclEnd);
5120 if (Tok.
is(tok::annot_pragma_pack)) {
5125 if (Tok.
is(tok::annot_pragma_align)) {
5126 HandlePragmaAlign();
5130 if (Tok.
isOneOf(tok::annot_pragma_openmp, tok::annot_attr_openmp)) {
5134 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
5138 if (Tok.
is(tok::annot_pragma_openacc)) {
5147 ConsumeAnnotationToken();
5151 if (!Tok.
is(tok::at)) {
5157 FD.D, FD.BitfieldSize);
5164 ParseStructDeclaration(DS, CFieldCallback, &LateFieldAttrs);
5168 Diag(Tok, diag::err_unexpected_at);
5173 ExpectAndConsume(tok::l_paren);
5174 if (!Tok.
is(tok::identifier)) {
5175 Diag(Tok, diag::err_expected) << tok::identifier;
5183 ExpectAndConsume(tok::r_paren);
5189 if (Tok.
is(tok::r_brace)) {
5190 ExpectAndConsume(tok::semi, diag::ext_expected_semi_decl_list);
5194 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
5205 MaybeParseGNUAttributes(attrs, &LateFieldAttrs);
5208 ParseLexedCAttributeList(LateFieldAttrs,
false);
5213 T.getOpenLocation(),
T.getCloseLocation(), attrs);
5249 const ParsedTemplateInfo &TemplateInfo,
5252 if (Tok.
is(tok::code_completion)) {
5262 MaybeParseAttributes(PAKM_GNU | PAKM_Declspec | PAKM_CXX11, attrs);
5265 bool IsScopedUsingClassTag =
false;
5270 : diag::ext_scoped_enum);
5271 IsScopedUsingClassTag = Tok.
is(tok::kw_class);
5276 ProhibitAttributes(attrs);
5279 MaybeParseAttributes(PAKM_GNU | PAKM_Declspec | PAKM_CXX11, attrs);
5288 bool shouldDelayDiagsInTag =
5289 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
5290 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
5294 AllowDefiningTypeSpec AllowEnumSpecifier =
5296 bool CanBeOpaqueEnumDeclaration =
5297 DS.
isEmpty() && isOpaqueEnumDeclarationContext(DSC);
5300 (AllowEnumSpecifier == AllowDefiningTypeSpec::Yes ||
5301 CanBeOpaqueEnumDeclaration);
5309 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
5314 if (Spec.
isSet() && Tok.
isNot(tok::identifier)) {
5315 Diag(Tok, diag::err_expected) << tok::identifier;
5317 if (Tok.
isNot(tok::l_brace)) {
5329 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::l_brace) &&
5330 Tok.
isNot(tok::colon)) {
5331 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
5342 if (Tok.
is(tok::identifier)) {
5347 if (!Name && ScopedEnumKWLoc.
isValid()) {
5350 Diag(Tok, diag::err_scoped_enum_missing_identifier);
5352 IsScopedUsingClassTag =
false;
5357 if (shouldDelayDiagsInTag)
5358 diagsFromTag.done();
5363 bool CanBeBitfield =
5367 if (Tok.
is(tok::colon)) {
5392 if (CanBeBitfield && !isEnumBase(CanBeOpaqueEnumDeclaration)) {
5397 }
else if (CanHaveEnumBase || !ColonIsSacred) {
5408 DeclSpecContext::DSC_type_specifier);
5413 BaseRange =
SourceRange(ColonLoc, DeclaratorInfo.getSourceRange().getEnd());
5417 Diag(ColonLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type)
5420 Diag(ColonLoc, diag::ext_cxx11_enum_fixed_underlying_type)
5423 Diag(ColonLoc, diag::ext_ms_c_enum_fixed_underlying_type)
5426 Diag(ColonLoc, diag::ext_clang_c_enum_fixed_underlying_type)
5443 if (AllowEnumSpecifier == AllowDefiningTypeSpec::No)
5445 else if (Tok.
is(tok::l_brace)) {
5454 IsScopedUsingClassTag =
false;
5460 }
else if (!isTypeSpecifier(DSC) &&
5461 (Tok.
is(tok::semi) ||
5463 !isValidAfterTypeSpecifier(CanBeBitfield)))) {
5468 if (Tok.
isNot(tok::semi)) {
5470 ExpectAndConsume(tok::semi, diag::err_expected_after,
"enum");
5478 bool IsElaboratedTypeSpecifier =
5484 diagsFromTag.redelay();
5488 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
5492 Diag(Tok, diag::err_enum_template);
5497 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
5500 Diag(StartLoc, diag::err_explicit_instantiation_enum);
5504 assert(TemplateInfo.TemplateParams &&
"no template parameters");
5506 TemplateInfo.TemplateParams->size());
5511 Diag(Tok, diag::err_enumerator_unnamed_no_def);
5527 if (IsElaboratedTypeSpecifier && !
getLangOpts().MicrosoftExt &&
5529 ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
5530 diag::err_keyword_not_allowed,
5533 Diag(BaseRange.
getBegin(), diag::ext_enum_base_in_type_specifier)
5534 << (AllowEnumSpecifier == AllowDefiningTypeSpec::Yes) << BaseRange;
5535 else if (ScopedEnumKWLoc.
isValid())
5536 Diag(ScopedEnumKWLoc, diag::ext_elaborated_enum_class)
5540 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
5550 bool IsDependent =
false;
5551 const char *PrevSpec =
nullptr;
5556 TParams, Owned, IsDependent, ScopedEnumKWLoc,
5557 IsScopedUsingClassTag,
5558 BaseType, DSC == DeclSpecContext::DSC_type_specifier,
5559 DSC == DeclSpecContext::DSC_template_param ||
5560 DSC == DeclSpecContext::DSC_template_type_arg,
5561 OffsetOfState, &SkipBody).
get();
5571 NameLoc.
isValid() ? NameLoc : StartLoc,
5572 PrevSpec, DiagID,
TagDecl, Owned,
5574 Diag(StartLoc, DiagID) << PrevSpec;
5583 Diag(Tok, diag::err_expected_type_name_after_typename);
5589 if (
Type.isInvalid()) {
5595 NameLoc.
isValid() ? NameLoc : StartLoc,
5596 PrevSpec, DiagID,
Type.get(),
5598 Diag(StartLoc, DiagID) << PrevSpec;
5617 ParseEnumBody(StartLoc,
D);
5626 NameLoc.
isValid() ? NameLoc : StartLoc,
5627 PrevSpec, DiagID,
TagDecl, Owned,
5629 Diag(StartLoc, DiagID) << PrevSpec;
5652 Diag(Tok, diag::err_empty_enum);
5657 Decl *LastEnumConstDecl =
nullptr;
5660 while (Tok.
isNot(tok::r_brace)) {
5663 if (Tok.
isNot(tok::identifier)) {
5675 MaybeParseGNUAttributes(attrs);
5676 if (isAllowedCXX11AttributeSpecifier()) {
5679 ? diag::warn_cxx14_compat_ns_enum_attribute
5680 : diag::ext_ns_enum_attribute)
5682 ParseCXX11Attributes(attrs);
5687 EnumAvailabilityDiags.emplace_back(*
this);
5700 EqualLoc, AssignedVal.
get());
5701 EnumAvailabilityDiags.back().done();
5703 EnumConstantDecls.push_back(EnumConstDecl);
5704 LastEnumConstDecl = EnumConstDecl;
5706 if (Tok.
is(tok::identifier)) {
5709 Diag(
Loc, diag::err_enumerator_list_missing_comma)
5732 if (Tok.
is(tok::r_brace) && CommaLoc.
isValid()) {
5735 diag::ext_enumerator_list_comma_cxx :
5736 diag::ext_enumerator_list_comma_c)
5739 Diag(CommaLoc, diag::warn_cxx98_compat_enumerator_list_comma)
5750 MaybeParseGNUAttributes(attrs);
5756 assert(EnumConstantDecls.size() == EnumAvailabilityDiags.size());
5757 for (
size_t i = 0, e = EnumConstantDecls.size(); i != e; ++i) {
5759 EnumAvailabilityDiags[i].redelay();
5760 PD.complete(EnumConstantDecls[i]);
5769 if (!isValidAfterTypeSpecifier(CanBeBitfield)) {
5770 ExpectAndConsume(tok::semi, diag::err_expected_after,
"enum");
5782bool Parser::isKnownToBeTypeSpecifier(
const Token &Tok)
const {
5784 default:
return false;
5788 case tok::kw___int64:
5789 case tok::kw___int128:
5790 case tok::kw_signed:
5791 case tok::kw_unsigned:
5792 case tok::kw__Complex:
5793 case tok::kw__Imaginary:
5796 case tok::kw_wchar_t:
5797 case tok::kw_char8_t:
5798 case tok::kw_char16_t:
5799 case tok::kw_char32_t:
5801 case tok::kw__ExtInt:
5802 case tok::kw__BitInt:
5803 case tok::kw___bf16:
5806 case tok::kw_double:
5807 case tok::kw__Accum:
5808 case tok::kw__Fract:
5809 case tok::kw__Float16:
5810 case tok::kw___float128:
5811 case tok::kw___ibm128:
5814 case tok::kw__Decimal32:
5815 case tok::kw__Decimal64:
5816 case tok::kw__Decimal128:
5817 case tok::kw___vector:
5818#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
5819#include "clang/Basic/OpenCLImageTypes.def"
5820#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
5821#include "clang/Basic/HLSLIntangibleTypes.def"
5825 case tok::kw_struct:
5826 case tok::kw___interface:
5832 case tok::annot_typename:
5839bool Parser::isTypeSpecifierQualifier() {
5841 default:
return false;
5843 case tok::identifier:
5844 if (TryAltiVecVectorToken())
5847 case tok::kw_typename:
5852 if (Tok.
is(tok::identifier))
5854 return isTypeSpecifierQualifier();
5856 case tok::coloncolon:
5863 return isTypeSpecifierQualifier();
5866 case tok::kw___attribute:
5868 case tok::kw_typeof:
5869 case tok::kw_typeof_unqual:
5874 case tok::kw___int64:
5875 case tok::kw___int128:
5876 case tok::kw_signed:
5877 case tok::kw_unsigned:
5878 case tok::kw__Complex:
5879 case tok::kw__Imaginary:
5882 case tok::kw_wchar_t:
5883 case tok::kw_char8_t:
5884 case tok::kw_char16_t:
5885 case tok::kw_char32_t:
5887 case tok::kw__ExtInt:
5888 case tok::kw__BitInt:
5890 case tok::kw___bf16:
5892 case tok::kw_double:
5893 case tok::kw__Accum:
5894 case tok::kw__Fract:
5895 case tok::kw__Float16:
5896 case tok::kw___float128:
5897 case tok::kw___ibm128:
5900 case tok::kw__Decimal32:
5901 case tok::kw__Decimal64:
5902 case tok::kw__Decimal128:
5903 case tok::kw___vector:
5904#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
5905#include "clang/Basic/OpenCLImageTypes.def"
5906#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
5907#include "clang/Basic/HLSLIntangibleTypes.def"
5911 case tok::kw_struct:
5912 case tok::kw___interface:
5919 case tok::kw_volatile:
5920 case tok::kw_restrict:
5924 case tok::kw___unknown_anytype:
5927 case tok::annot_typename:
5934 case tok::kw___cdecl:
5935 case tok::kw___stdcall:
5936 case tok::kw___fastcall:
5937 case tok::kw___thiscall:
5938 case tok::kw___regcall:
5939 case tok::kw___vectorcall:
5941 case tok::kw___ptr64:
5942 case tok::kw___ptr32:
5943 case tok::kw___pascal:
5944 case tok::kw___unaligned:
5946 case tok::kw__Nonnull:
5947 case tok::kw__Nullable:
5948 case tok::kw__Nullable_result:
5949 case tok::kw__Null_unspecified:
5951 case tok::kw___kindof:
5953 case tok::kw___private:
5954 case tok::kw___local:
5955 case tok::kw___global:
5956 case tok::kw___constant:
5957 case tok::kw___generic:
5958 case tok::kw___read_only:
5959 case tok::kw___read_write:
5960 case tok::kw___write_only:
5961 case tok::kw___funcref:
5964 case tok::kw_private:
5968 case tok::kw__Atomic:
5972 case tok::kw_groupshared:
5985 ParsedStmtContext SubStmtCtx = ParsedStmtContext();
5989 StmtResult R = ParseStatementOrDeclaration(Stmts, SubStmtCtx);
5995 if (Tok.
is(tok::annot_repl_input_end) &&
5997 ConsumeAnnotationToken();
6002 DeclsInGroup.push_back(TLSD);
6005 for (
Stmt *S : Stmts) {
6010 DeclsInGroup.push_back(
D);
6023bool Parser::isDeclarationSpecifier(
6025 bool DisambiguatingWithExpression) {
6027 default:
return false;
6034 case tok::identifier:
6038 if (TryAltiVecVectorToken())
6041 case tok::kw_decltype:
6042 case tok::kw_typename:
6047 if (TryAnnotateTypeConstraint())
6049 if (Tok.
is(tok::identifier))
6057 if (DisambiguatingWithExpression &&
6058 isStartOfObjCClassMessageMissingOpenBracket())
6061 return isDeclarationSpecifier(AllowImplicitTypename);
6063 case tok::coloncolon:
6077 case tok::kw_typedef:
6078 case tok::kw_extern:
6079 case tok::kw___private_extern__:
6080 case tok::kw_static:
6082 case tok::kw___auto_type:
6083 case tok::kw_register:
6084 case tok::kw___thread:
6085 case tok::kw_thread_local:
6086 case tok::kw__Thread_local:
6089 case tok::kw___module_private__:
6092 case tok::kw___unknown_anytype:
6097 case tok::kw___int64:
6098 case tok::kw___int128:
6099 case tok::kw_signed:
6100 case tok::kw_unsigned:
6101 case tok::kw__Complex:
6102 case tok::kw__Imaginary:
6105 case tok::kw_wchar_t:
6106 case tok::kw_char8_t:
6107 case tok::kw_char16_t:
6108 case tok::kw_char32_t:
6111 case tok::kw__ExtInt:
6112 case tok::kw__BitInt:
6114 case tok::kw___bf16:
6116 case tok::kw_double:
6117 case tok::kw__Accum:
6118 case tok::kw__Fract:
6119 case tok::kw__Float16:
6120 case tok::kw___float128:
6121 case tok::kw___ibm128:
6124 case tok::kw__Decimal32:
6125 case tok::kw__Decimal64:
6126 case tok::kw__Decimal128:
6127 case tok::kw___vector:
6131 case tok::kw_struct:
6133 case tok::kw___interface:
6139 case tok::kw_volatile:
6140 case tok::kw_restrict:
6144 case tok::kw_inline:
6145 case tok::kw_virtual:
6146 case tok::kw_explicit:
6147 case tok::kw__Noreturn:
6150 case tok::kw__Alignas:
6153 case tok::kw_friend:
6156 case tok::kw_static_assert:
6157 case tok::kw__Static_assert:
6160 case tok::kw_typeof:
6161 case tok::kw_typeof_unqual:
6164 case tok::kw___attribute:
6167 case tok::annot_decltype:
6168 case tok::annot_pack_indexing_type:
6169 case tok::kw_constexpr:
6172 case tok::kw_consteval:
6173 case tok::kw_constinit:
6176 case tok::kw__Atomic:
6179 case tok::kw_alignas:
6189 case tok::annot_typename:
6190 return !DisambiguatingWithExpression ||
6191 !isStartOfObjCClassMessageMissingOpenBracket();
6194 case tok::annot_template_id: {
6200 return isTypeConstraintAnnotation() &&
6204 case tok::annot_cxxscope: {
6213 if (
NextToken().is(tok::identifier) && TryAnnotateTypeConstraint())
6215 return isTypeConstraintAnnotation() &&
6216 GetLookAheadToken(2).isOneOf(tok::kw_auto, tok::kw_decltype);
6219 case tok::kw___declspec:
6220 case tok::kw___cdecl:
6221 case tok::kw___stdcall:
6222 case tok::kw___fastcall:
6223 case tok::kw___thiscall:
6224 case tok::kw___regcall:
6225 case tok::kw___vectorcall:
6227 case tok::kw___sptr:
6228 case tok::kw___uptr:
6229 case tok::kw___ptr64:
6230 case tok::kw___ptr32:
6231 case tok::kw___forceinline:
6232 case tok::kw___pascal:
6233 case tok::kw___unaligned:
6235 case tok::kw__Nonnull:
6236 case tok::kw__Nullable:
6237 case tok::kw__Nullable_result:
6238 case tok::kw__Null_unspecified:
6240 case tok::kw___kindof:
6242 case tok::kw___private:
6243 case tok::kw___local:
6244 case tok::kw___global:
6245 case tok::kw___constant:
6246 case tok::kw___generic:
6247 case tok::kw___read_only:
6248 case tok::kw___read_write:
6249 case tok::kw___write_only:
6250#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
6251#include "clang/Basic/OpenCLImageTypes.def"
6252#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
6253#include "clang/Basic/HLSLIntangibleTypes.def"
6255 case tok::kw___funcref:
6256 case tok::kw_groupshared:
6259 case tok::kw_private:
6264bool Parser::isConstructorDeclarator(
bool IsUnqualified,
bool DeductionGuide,
6266 const ParsedTemplateInfo *TemplateInfo) {
6267 RevertingTentativeParsingAction TPA(*
this);
6270 if (TemplateInfo && TemplateInfo->TemplateParams)
6273 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
6280 if (Tok.
is(tok::identifier)) {
6284 }
else if (Tok.
is(tok::annot_template_id)) {
6285 ConsumeAnnotationToken();
6292 SkipCXX11Attributes();
6295 if (Tok.
isNot(tok::l_paren)) {
6302 if (Tok.
is(tok::r_paren) ||
6303 (Tok.
is(tok::ellipsis) &&
NextToken().is(tok::r_paren))) {
6310 isCXX11AttributeSpecifier(
false,
6316 DeclaratorScopeObj DeclScopeObj(*
this, SS);
6318 DeclScopeObj.EnterDeclaratorScope();
6322 MaybeParseMicrosoftAttributes(Attrs);
6331 bool IsConstructor =
false;
6337 if (Tok.
is(tok::kw_this)) {
6339 return isDeclarationSpecifier(ITC);
6342 if (isDeclarationSpecifier(ITC))
6343 IsConstructor =
true;
6344 else if (Tok.
is(tok::identifier) ||
6345 (Tok.
is(tok::annot_cxxscope) &&
NextToken().is(tok::identifier))) {
6350 if (Tok.
is(tok::annot_cxxscope))
6351 ConsumeAnnotationToken();
6363 case tok::coloncolon:
6376 SkipCXX11Attributes();
6378 if (DeductionGuide) {
6380 IsConstructor = Tok.
is(tok::arrow);
6383 if (Tok.
is(tok::colon) || Tok.
is(tok::kw_try)) {
6387 IsConstructor =
true;
6389 if (Tok.
is(tok::semi) || Tok.
is(tok::l_brace)) {
6402 IsConstructor = IsUnqualified;
6407 IsConstructor =
true;
6411 return IsConstructor;
6426void Parser::ParseTypeQualifierListOpt(
6427 DeclSpec &DS,
unsigned AttrReqs,
bool AtomicAllowed,
6428 bool IdentifierRequired,
6430 if ((AttrReqs & AR_CXX11AttributesParsed) &&
6431 isAllowedCXX11AttributeSpecifier()) {
6433 ParseCXX11Attributes(Attrs);
6441 const char *PrevSpec =
nullptr;
6442 unsigned DiagID = 0;
6446 case tok::code_completion:
6449 (*CodeCompletionHandler)();
6458 case tok::kw_volatile:
6462 case tok::kw_restrict:
6466 case tok::kw__Atomic:
6468 goto DoneWithTypeQuals;
6469 diagnoseUseOfC11Keyword(Tok);
6475 case tok::kw_private:
6477 goto DoneWithTypeQuals;
6479 case tok::kw___private:
6480 case tok::kw___global:
6481 case tok::kw___local:
6482 case tok::kw___constant:
6483 case tok::kw___generic:
6484 case tok::kw___read_only:
6485 case tok::kw___write_only:
6486 case tok::kw___read_write:
6490 case tok::kw_groupshared:
6498 case tok::kw___unaligned:
6502 case tok::kw___uptr:
6507 if (TryKeywordIdentFallback(
false))
6511 case tok::kw___sptr:
6513 case tok::kw___ptr64:
6514 case tok::kw___ptr32:
6515 case tok::kw___cdecl:
6516 case tok::kw___stdcall:
6517 case tok::kw___fastcall:
6518 case tok::kw___thiscall:
6519 case tok::kw___regcall:
6520 case tok::kw___vectorcall:
6521 if (AttrReqs & AR_DeclspecAttributesParsed) {
6525 goto DoneWithTypeQuals;
6527 case tok::kw___funcref:
6530 goto DoneWithTypeQuals;
6532 case tok::kw___pascal:
6533 if (AttrReqs & AR_VendorAttributesParsed) {
6537 goto DoneWithTypeQuals;
6540 case tok::kw__Nonnull:
6541 case tok::kw__Nullable:
6542 case tok::kw__Nullable_result:
6543 case tok::kw__Null_unspecified:
6548 case tok::kw___kindof:
6550 nullptr, 0, tok::kw___kindof);
6554 case tok::kw___attribute:
6555 if (AttrReqs & AR_GNUAttributesParsedAndRejected)
6557 Diag(Tok, diag::err_attributes_not_allowed);
6561 if (AttrReqs & AR_GNUAttributesParsed ||
6562 AttrReqs & AR_GNUAttributesParsedAndRejected) {
6580 assert(PrevSpec &&
"Method did not return previous specifier!");
6581 Diag(Tok, DiagID) << PrevSpec;
6592 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
6598 if (Kind == tok::star || Kind == tok::caret)
6602 if (Kind == tok::kw_pipe && Lang.OpenCL &&
6603 Lang.getOpenCLCompatibleVersion() >= 200)
6606 if (!Lang.CPlusPlus)
6609 if (Kind == tok::amp)
6617 if (Kind == tok::ampamp)
6626 const unsigned NumTypes =
D.getNumTypeObjects();
6628 for (
unsigned Idx = 0; Idx != NumTypes; ++Idx)
6660void Parser::ParseDeclaratorInternal(
Declarator &
D,
6661 DirectDeclParseFunction DirectDeclParser) {
6669 (Tok.
is(tok::coloncolon) || Tok.
is(tok::kw_decltype) ||
6670 (Tok.
is(tok::identifier) &&
6672 Tok.
is(tok::annot_cxxscope))) {
6673 TentativeParsingAction TPA(*
this,
true);
6679 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
6689 Tok.
is(tok::star)) {
6693 checkCompoundToken(SS.
getEndLoc(), tok::coloncolon,
6694 CompoundToken::MemberPtr);
6698 D.SetRangeEnd(StarLoc);
6700 ParseTypeQualifierListOpt(DS);
6701 D.ExtendWithDeclSpec(DS);
6705 ParseDeclaratorInternal(D, DirectDeclParser);
6719 ParseOptionalCXXScopeSpecifier(SS,
nullptr,
6726 if (
D.mayHaveIdentifier())
6727 D.getCXXScopeSpec() = SS;
6729 AnnotateScopeToken(SS,
true);
6731 if (DirectDeclParser)
6732 (this->*DirectDeclParser)(
D);
6741 ParseTypeQualifierListOpt(DS);
6750 if (DirectDeclParser)
6751 (this->*DirectDeclParser)(
D);
6760 if (Kind == tok::star || Kind == tok::caret) {
6766 unsigned Reqs = AR_CXX11AttributesParsed | AR_DeclspecAttributesParsed |
6768 ? AR_GNUAttributesParsed
6769 : AR_GNUAttributesParsedAndRejected);
6770 ParseTypeQualifierListOpt(DS, Reqs,
true, !
D.mayOmitIdentifier());
6771 D.ExtendWithDeclSpec(DS);
6775 D.
getBeginLoc(), [&] { ParseDeclaratorInternal(D, DirectDeclParser); });
6776 if (Kind == tok::star)
6794 if (Kind == tok::ampamp)
6796 diag::warn_cxx98_compat_rvalue_reference :
6797 diag::ext_rvalue_reference);
6800 ParseTypeQualifierListOpt(DS);
6801 D.ExtendWithDeclSpec(DS);
6809 diag::err_invalid_reference_qualifier_application) <<
"const";
6812 diag::err_invalid_reference_qualifier_application) <<
"volatile";
6816 diag::err_invalid_reference_qualifier_application) <<
"_Atomic";
6821 D.
getBeginLoc(), [&] { ParseDeclaratorInternal(D, DirectDeclParser); });
6823 if (
D.getNumTypeObjects() > 0) {
6828 Diag(InnerChunk.
Loc, diag::err_illegal_decl_reference_to_reference)
6831 Diag(InnerChunk.
Loc, diag::err_illegal_decl_reference_to_reference)
6853 if (
D.getName().StartLocation.isInvalid() &&
6854 D.getName().EndLocation.isValid())
6855 return D.getName().EndLocation;
6906void Parser::ParseDirectDeclarator(
Declarator &
D) {
6907 DeclaratorScopeObj DeclScopeObj(*
this,
D.getCXXScopeSpec());
6911 if (Tok.
is(tok::l_square) && !
D.mayOmitIdentifier() &&
6912 D.getCXXScopeSpec().isEmpty())
6913 return ParseDecompositionDeclarator(
D);
6924 if (
D.getCXXScopeSpec().isEmpty()) {
6927 ParseOptionalCXXScopeSpecifier(
6928 D.getCXXScopeSpec(),
nullptr,
6929 false, EnteringContext);
6943 if (
D.getCXXScopeSpec().isValid()) {
6945 D.getCXXScopeSpec()))
6948 DeclScopeObj.EnterDeclaratorScope();
6953 D.setInvalidType(
true);
6955 goto PastIdentifier;
6966 if (Tok.
is(tok::ellipsis) &&
D.getCXXScopeSpec().isEmpty() &&
6970 NextToken().is(tok::r_paren) && !
D.hasGroupingParens() &&
6972 D.getDeclSpec().getTypeSpecType() !=
TST_auto)) {
6979 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc,
D);
6982 D.setEllipsisLoc(EllipsisLoc);
6989 if (Tok.
isOneOf(tok::identifier, tok::kw_operator, tok::annot_template_id,
6993 bool AllowConstructorName;
6994 bool AllowDeductionGuide;
6995 if (
D.getDeclSpec().hasTypeSpecifier()) {
6996 AllowConstructorName =
false;
6997 AllowDeductionGuide =
false;
6998 }
else if (
D.getCXXScopeSpec().isSet()) {
7001 AllowDeductionGuide =
false;
7008 bool HadScope =
D.getCXXScopeSpec().isValid();
7014 true, AllowConstructorName,
7015 AllowDeductionGuide, &TemplateKWLoc,
7019 D.getCXXScopeSpec().isInvalid()) {
7021 D.setInvalidType(
true);
7025 if (!HadScope &&
D.getCXXScopeSpec().isValid() &&
7027 D.getCXXScopeSpec()))
7028 DeclScopeObj.EnterDeclaratorScope();
7035 goto PastIdentifier;
7038 if (
D.getCXXScopeSpec().isNotEmpty()) {
7041 diag::err_expected_unqualified_id)
7044 goto PastIdentifier;
7046 }
else if (Tok.
is(tok::identifier) &&
D.mayHaveIdentifier()) {
7048 "There's a C++-specific check for tok::identifier above");
7053 goto PastIdentifier;
7054 }
else if (Tok.
is(tok::identifier) && !
D.mayHaveIdentifier()) {
7058 bool DiagnoseIdentifier =
false;
7059 if (
D.hasGroupingParens())
7062 DiagnoseIdentifier =
true;
7065 DiagnoseIdentifier =
7073 !isCXX11VirtSpecifier(Tok))
7075 tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try);
7076 if (DiagnoseIdentifier) {
7081 goto PastIdentifier;
7085 if (Tok.
is(tok::l_paren)) {
7089 if (
D.mayOmitIdentifier() &&
D.mayBeFollowedByCXXDirectInit()) {
7090 RevertingTentativeParsingAction PA(*
this);
7091 if (TryParseDeclarator(
true,
D.mayHaveIdentifier(),
true,
7092 D.getDeclSpec().getTypeSpecType() ==
TST_auto) ==
7095 goto PastIdentifier;
7102 ParseParenDeclarator(
D);
7107 if (
D.getCXXScopeSpec().isSet()) {
7110 if (!
D.isInvalidType() &&
7112 D.getCXXScopeSpec()))
7115 DeclScopeObj.EnterDeclaratorScope();
7117 }
else if (
D.mayOmitIdentifier()) {
7124 if (
D.hasEllipsis() &&
D.hasGroupingParens())
7126 diag::ext_abstract_pack_declarator_parens);
7128 if (Tok.
getKind() == tok::annot_pragma_parser_crash)
7130 if (Tok.
is(tok::l_square))
7131 return ParseMisplacedBracketDeclarator(
D);
7139 diag::err_expected_member_name_or_semi_objcxx_keyword)
7146 goto PastIdentifier;
7149 diag::err_expected_member_name_or_semi)
7153 if (Tok.
getKind() == tok::TokenKind::kw_while) {
7154 Diag(Tok, diag::err_while_loop_outside_of_a_function);
7156 if (Tok.
isOneOf(tok::period, tok::arrow))
7157 Diag(Tok, diag::err_invalid_operator_on_type) << Tok.
is(tok::arrow);
7165 diag::err_expected_unqualified_id)
7170 diag::err_expected_either)
7171 << tok::identifier << tok::l_paren;
7175 D.setInvalidType(
true);
7179 assert(
D.isPastIdentifier() &&
7180 "Haven't past the location of the identifier yet?");
7183 if (
D.hasName() && !
D.getNumTypeObjects())
7184 MaybeParseCXX11Attributes(
D);
7187 if (Tok.
is(tok::l_paren)) {
7188 bool IsFunctionDeclaration =
D.isFunctionDeclaratorAFunctionDeclaration();
7191 ParseScope PrototypeScope(
this,
7193 (IsFunctionDeclaration
7199 bool IsAmbiguous =
false;
7210 if (
D.getCXXScopeSpec().isSet())
7211 AllowImplicitTypename =
7219 TentativelyDeclaredIdentifiers.push_back(
D.getIdentifier());
7220 bool IsFunctionDecl =
7221 isCXXFunctionDeclarator(&IsAmbiguous, AllowImplicitTypename);
7222 TentativelyDeclaredIdentifiers.pop_back();
7223 if (!IsFunctionDecl)
7229 if (IsFunctionDeclaration)
7231 TemplateParameterDepth);
7232 ParseFunctionDeclarator(
D, attrs,
T, IsAmbiguous);
7233 if (IsFunctionDeclaration)
7235 PrototypeScope.Exit();
7236 }
else if (Tok.
is(tok::l_square)) {
7237 ParseBracketDeclarator(
D);
7245 if (!
T.consumeOpen())
7248 }
else if (Tok.
is(tok::kw_requires) &&
D.hasGroupingParens()) {
7256 Diag(Tok, diag::err_requires_clause_inside_parens);
7260 if (TrailingRequiresClause.
isUsable() &&
D.isFunctionDeclarator() &&
7261 !
D.hasTrailingRequiresClause())
7263 D.setTrailingRequiresClause(TrailingRequiresClause.
get());
7270void Parser::ParseDecompositionDeclarator(
Declarator &
D) {
7271 assert(Tok.
is(tok::l_square));
7273 TentativeParsingAction PA(*
this);
7277 if (isCXX11AttributeSpecifier())
7278 DiagnoseAndSkipCXX11Attributes();
7282 if (!(Tok.
is(tok::identifier) &&
7285 !(Tok.
is(tok::r_square) &&
7288 return ParseMisplacedBracketDeclarator(
D);
7292 while (Tok.
isNot(tok::r_square)) {
7294 if (Tok.
is(tok::comma))
7297 if (Tok.
is(tok::identifier)) {
7299 Diag(EndLoc, diag::err_expected)
7302 Diag(Tok, diag::err_expected_comma_or_rsquare);
7305 SkipUntil(tok::r_square, tok::comma, tok::identifier,
7307 if (Tok.
is(tok::comma))
7309 else if (Tok.
isNot(tok::identifier))
7314 if (isCXX11AttributeSpecifier())
7315 DiagnoseAndSkipCXX11Attributes();
7317 if (Tok.
isNot(tok::identifier)) {
7318 Diag(Tok, diag::err_expected) << tok::identifier;
7327 if (isCXX11AttributeSpecifier()) {
7329 ? diag::warn_cxx23_compat_decl_attrs_on_binding
7330 : diag::ext_decl_attrs_on_binding);
7331 MaybeParseCXX11Attributes(Attrs);
7337 if (Tok.
isNot(tok::r_square))
7351 return D.setDecompositionBindings(
T.getOpenLocation(),
Bindings,
7352 T.getCloseLocation());
7372 assert(!
D.isPastIdentifier() &&
"Should be called before passing identifier");
7385 bool RequiresArg =
false;
7386 if (Tok.
is(tok::kw___attribute)) {
7387 ParseGNUAttributes(attrs);
7395 ParseMicrosoftTypeAttributes(attrs);
7398 if (Tok.
is(tok::kw___pascal))
7399 ParseBorlandTypeAttributes(attrs);
7407 if (!
D.mayOmitIdentifier()) {
7411 }
else if (Tok.
is(tok::r_paren) ||
7414 isDeclarationSpecifier(
7416 isCXX11AttributeSpecifier()) {
7432 bool hadGroupingParens =
D.hasGroupingParens();
7433 D.setGroupingParens(
true);
7434 ParseDeclaratorInternal(
D, &Parser::ParseDirectDeclarator);
7439 std::move(attrs),
T.getCloseLocation());
7441 D.setGroupingParens(hadGroupingParens);
7445 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc,
D);
7458 ParseScope PrototypeScope(
this,
7460 (
D.isFunctionDeclaratorAFunctionDeclaration()
7462 ParseFunctionDeclarator(
D, attrs,
T,
false, RequiresArg);
7463 PrototypeScope.Exit();
7466void Parser::InitCXXThisScopeForDeclaratorIfRelevant(
7468 std::optional<Sema::CXXThisScopeRAII> &ThisScope) {
7476 bool IsCXX11MemberFunction =
7480 ? !
D.getDeclSpec().isFriendSpecified()
7482 D.getCXXScopeSpec().isValid() &&
7484 if (!IsCXX11MemberFunction)
7504 ThisScope.emplace(Actions, dyn_cast<CXXRecordDecl>(Actions.
CurContext), Q,
7505 IsCXX11MemberFunction);
7528void Parser::ParseFunctionDeclarator(
Declarator &
D,
7533 assert(
getCurScope()->isFunctionPrototypeScope() &&
7534 "Should call from a Function scope");
7536 assert(
D.isPastIdentifier() &&
"Should not call before identifier!");
7540 bool HasProto =
false;
7547 bool RefQualifierIsLValueRef =
true;
7565 StartLoc = LParenLoc;
7567 if (isFunctionDeclaratorIdentifierList()) {
7569 Diag(Tok, diag::err_argument_required_after_attribute);
7571 ParseFunctionDeclaratorIdentifierList(
D, ParamInfo);
7575 LocalEndLoc = RParenLoc;
7580 MaybeParseCXX11Attributes(FnAttrs);
7581 ProhibitAttributes(FnAttrs);
7583 if (Tok.
isNot(tok::r_paren))
7584 ParseParameterDeclarationClause(
D, FirstArgAttrs, ParamInfo, EllipsisLoc);
7585 else if (RequiresArg)
7586 Diag(Tok, diag::err_argument_required_after_attribute);
7597 LocalEndLoc = RParenLoc;
7606 ParseTypeQualifierListOpt(
7607 DS, AR_NoAttributesParsed,
7609 false, llvm::function_ref<
void()>([&]() {
7617 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc))
7618 EndLoc = RefQualifierLoc;
7620 std::optional<Sema::CXXThisScopeRAII> ThisScope;
7621 InitCXXThisScopeForDeclaratorIfRelevant(
D, DS, ThisScope);
7637 D.isFunctionDeclaratorAFunctionDeclaration();
7639 GetLookAheadToken(0).is(tok::kw_noexcept) &&
7640 GetLookAheadToken(1).is(tok::l_paren) &&
7641 GetLookAheadToken(2).is(tok::kw_noexcept) &&
7642 GetLookAheadToken(3).is(tok::l_paren) &&
7643 GetLookAheadToken(4).is(tok::identifier) &&
7644 GetLookAheadToken(4).getIdentifierInfo()->isStr(
"swap")) {
7655 ESpecType = tryParseExceptionSpecification(Delayed,
7658 DynamicExceptionRanges,
7660 ExceptionSpecTokens);
7662 EndLoc = ESpecRange.
getEnd();
7666 MaybeParseCXX11Attributes(FnAttrs);
7669 LocalEndLoc = EndLoc;
7671 Diag(Tok, diag::warn_cxx98_compat_trailing_return_type);
7672 if (
D.getDeclSpec().getTypeSpecType() ==
TST_auto)
7673 StartLoc =
D.getDeclSpec().getTypeSpecTypeLoc();
7676 TrailingReturnType =
7677 ParseTrailingReturnType(
Range,
D.mayBeFollowedByCXXDirectInit());
7682 MaybeParseCXX11Attributes(FnAttrs);
7694 if (!ND || isa<ParmVarDecl>(ND))
7696 DeclsInPrototype.push_back(ND);
7703 llvm::sort(DeclsInPrototype, [](
Decl *D1,
Decl *D2) {
7711 HasProto, IsAmbiguous, LParenLoc, ParamInfo.data(),
7712 ParamInfo.size(), EllipsisLoc, RParenLoc,
7713 RefQualifierIsLValueRef, RefQualifierLoc,
7715 ESpecType, ESpecRange, DynamicExceptions.data(),
7716 DynamicExceptionRanges.data(), DynamicExceptions.size(),
7717 NoexceptExpr.
isUsable() ? NoexceptExpr.
get() :
nullptr,
7718 ExceptionSpecTokens, DeclsInPrototype, StartLoc,
7719 LocalEndLoc,
D, TrailingReturnType, TrailingReturnTypeLoc,
7721 std::move(FnAttrs), EndLoc);
7726bool Parser::ParseRefQualifier(
bool &RefQualifierIsLValueRef,
7728 if (Tok.
isOneOf(tok::amp, tok::ampamp)) {
7730 diag::warn_cxx98_compat_ref_qualifier :
7731 diag::ext_ref_qualifier);
7733 RefQualifierIsLValueRef = Tok.
is(tok::amp);
7745bool Parser::isFunctionDeclaratorIdentifierList() {
7747 && Tok.
is(tok::identifier)
7748 && !TryAltiVecVectorToken()
7764 && (!Tok.
is(tok::eof) &&
7777void Parser::ParseFunctionDeclaratorIdentifierList(
7781 assert(!
getLangOpts().requiresStrictPrototypes() &&
7782 "Cannot parse an identifier list in C23 or C++");
7788 if (!
D.getIdentifier())
7789 Diag(Tok, diag::ext_ident_list_in_param);
7792 llvm::SmallSet<const IdentifierInfo*, 16> ParamsSoFar;
7796 if (Tok.
isNot(tok::identifier)) {
7797 Diag(Tok, diag::err_expected) << tok::identifier;
7808 Diag(Tok, diag::err_unexpected_typedef_ident) << ParmII;
7811 if (!ParamsSoFar.insert(ParmII).second) {
7812 Diag(Tok, diag::err_param_redefinition) << ParmII;
7858void Parser::ParseParameterDeclarationClause(
7867 if (
getCurScope()->getFunctionPrototypeDepth() - 1 >
7888 IsACXXFunctionDeclaration) {
7910 ArgDeclSpecAttrs.takeAllFrom(FirstArgAttrs);
7913 MaybeParseCXX11Attributes(ArgDeclAttrs);
7916 MaybeParseMicrosoftAttributes(ArgDeclSpecAttrs);
7937 Diag(ThisLoc, diag::err_requires_expr_explicit_object_parameter);
7940 ParsedTemplateInfo TemplateInfo;
7941 ParseDeclarationSpecifiers(DS, TemplateInfo,
AS_none,
7942 DeclSpecContext::DSC_normal,
7943 nullptr, AllowImplicitTypename);
7956 ParseDeclarator(ParmDeclarator);
7959 ParmDeclarator.SetRangeBegin(ThisLoc);
7962 MaybeParseGNUAttributes(ParmDeclarator);
7966 if (Tok.
is(tok::kw_requires)) {
7971 diag::err_requires_clause_on_declarator_not_declaring_a_function);
7982 std::unique_ptr<CachedTokens> DefArgToks;
7986 if (DS.
isEmpty() && ParmDeclarator.getIdentifier() ==
nullptr &&
7987 ParmDeclarator.getNumTypeObjects() == 0) {
7989 Diag(DSStart, diag::err_missing_param);
7996 if (Tok.
is(tok::ellipsis) &&
7998 (!ParmDeclarator.getEllipsisLoc().isValid() &&
8001 DiagnoseMisplacedEllipsisInDeclarator(
ConsumeToken(), ParmDeclarator);
8020 if (!ParmDeclarator.isInvalidType() && !ParmDeclarator.hasName() &&
8036 if (Tok.
is(tok::equal)) {
8047 ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument);
8063 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
8064 DefArgResult = ParseBraceInitializer();
8066 if (Tok.
is(tok::l_paren) &&
NextToken().is(tok::l_brace)) {
8067 Diag(Tok, diag::err_stmt_expr_in_default_arg) << 0;
8084 DefArgResult.
get());
8090 ParmDeclarator.getIdentifierLoc(),
8091 Param, std::move(DefArgToks)));
8098 Diag(EllipsisLoc, diag::err_missing_comma_before_ellipsis)
8100 }
else if (ParmDeclarator.getEllipsisLoc().isValid() ||
8105 Diag(EllipsisLoc, diag::warn_misplaced_ellipsis_vararg)
8106 << ParmEllipsis.
isValid() << ParmEllipsis;
8109 diag::note_misplaced_ellipsis_vararg_existing_ellipsis);
8111 Diag(ParmDeclarator.getIdentifierLoc(),
8112 diag::note_misplaced_ellipsis_vararg_add_ellipsis)
8115 << !ParmDeclarator.hasName();
8117 Diag(EllipsisLoc, diag::note_misplaced_ellipsis_vararg_add_comma)
8136void Parser::ParseBracketDeclarator(
Declarator &
D) {
8137 if (CheckProhibitedCXX11Attribute())
8145 if (Tok.
getKind() == tok::r_square) {
8148 MaybeParseCXX11Attributes(attrs);
8152 T.getOpenLocation(),
8153 T.getCloseLocation()),
8154 std::move(attrs),
T.getCloseLocation());
8156 }
else if (Tok.
getKind() == tok::numeric_constant &&
8157 GetLookAheadToken(1).is(tok::r_square)) {
8164 MaybeParseCXX11Attributes(attrs);
8168 T.getOpenLocation(),
8169 T.getCloseLocation()),
8170 std::move(attrs),
T.getCloseLocation());
8172 }
else if (Tok.
getKind() == tok::code_completion) {
8185 ParseTypeQualifierListOpt(DS, AR_CXX11AttributesParsed);
8193 bool isStar =
false;
8200 if (Tok.
is(tok::star) && GetLookAheadToken(1).is(tok::r_square)) {
8204 Diag(StaticLoc, diag::err_unspecified_vla_size_with_static);
8208 }
else if (Tok.
isNot(tok::r_square)) {
8226 Diag(StaticLoc, diag::err_unspecified_size_with_static);
8233 D.setInvalidType(
true);
8246 isStar, NumElements.
get(),
T.getOpenLocation(),
8247 T.getCloseLocation()),
8252void Parser::ParseMisplacedBracketDeclarator(
Declarator &
D) {
8253 assert(Tok.
is(tok::l_square) &&
"Missing opening bracket");
8254 assert(!
D.mayOmitIdentifier() &&
"Declarator cannot omit identifier");
8260 while (Tok.
is(tok::l_square)) {
8261 ParseBracketDeclarator(TempDeclarator);
8267 if (Tok.
is(tok::semi))
8268 D.getName().EndLocation = StartBracketLoc;
8273 ParseDeclaratorInternal(
D, &Parser::ParseDirectDeclarator);
8278 if (TempDeclarator.getNumTypeObjects() == 0)
8282 bool NeedParens =
false;
8283 if (
D.getNumTypeObjects() != 0) {
8284 switch (
D.getTypeObject(
D.getNumTypeObjects() - 1).
Kind) {
8307 for (
unsigned i = 0, e = TempDeclarator.getNumTypeObjects(); i < e; ++i) {
8309 D.AddTypeInfo(Chunk, TempDeclarator.getAttributePool(),
SourceLocation());
8314 if (!
D.getIdentifier() && !NeedParens)
8320 SourceRange BracketRange(StartBracketLoc, EndBracketLoc);
8324 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
8332 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
8352void Parser::ParseTypeofSpecifier(
DeclSpec &DS) {
8353 assert(Tok.
isOneOf(tok::kw_typeof, tok::kw_typeof_unqual) &&
8354 "Not a typeof specifier");
8356 bool IsUnqual = Tok.
is(tok::kw_typeof_unqual);
8363 bool HasParens = Tok.
is(tok::l_paren);
8373 ParseExprAfterUnaryExprOrTypeTrait(OpTok, isCastExpr, CastTy, CastRange));
8389 const char *PrevSpec =
nullptr;
8397 Diag(StartLoc, DiagID) << PrevSpec;
8414 const char *PrevSpec =
nullptr;
8422 Diag(StartLoc, DiagID) << PrevSpec;
8428void Parser::ParseAtomicSpecifier(
DeclSpec &DS) {
8429 assert(Tok.
is(tok::kw__Atomic) &&
NextToken().is(tok::l_paren) &&
8430 "Not an atomic specifier");
8434 if (
T.consumeOpen())
8438 if (
Result.isInvalid()) {
8446 if (
T.getCloseLocation().isInvalid())
8452 const char *PrevSpec =
nullptr;
8457 Diag(StartLoc, DiagID) << PrevSpec;
8462bool Parser::TryAltiVecVectorTokenOutOfLine() {
8464 switch (Next.getKind()) {
8465 default:
return false;
8468 case tok::kw_signed:
8469 case tok::kw_unsigned:
8474 case tok::kw_double:
8477 case tok::kw___bool:
8478 case tok::kw___pixel:
8479 Tok.
setKind(tok::kw___vector);
8481 case tok::identifier:
8482 if (Next.getIdentifierInfo() == Ident_pixel) {
8483 Tok.
setKind(tok::kw___vector);
8486 if (Next.getIdentifierInfo() == Ident_bool ||
8487 Next.getIdentifierInfo() == Ident_Bool) {
8488 Tok.
setKind(tok::kw___vector);
8496 const char *&PrevSpec,
unsigned &DiagID,
8501 switch (Next.getKind()) {
8504 case tok::kw_signed:
8505 case tok::kw_unsigned:
8510 case tok::kw_double:
8513 case tok::kw___bool:
8514 case tok::kw___pixel:
8517 case tok::identifier:
8518 if (Next.getIdentifierInfo() == Ident_pixel) {
8522 if (Next.getIdentifierInfo() == Ident_bool ||
8523 Next.getIdentifierInfo() == Ident_Bool) {
8544TypeResult Parser::ParseTypeFromString(StringRef TypeStr, StringRef Context,
8551 FileID FID = SourceMgr.createFileID(
8552 llvm::MemoryBuffer::getMemBufferCopy(TypeStr, Context),
SrcMgr::C_User,
8556 Lexer L(FID, SourceMgr.getBufferOrFake(FID), PP);
8557 L.setParsingPreprocessorDirective(
true);
8563 Tokens.push_back(Tok);
8564 }
while (Tok.
isNot(tok::eod));
8569 Token &EndToken = Tokens.back();
8576 Tokens.push_back(Tok);
8579 PP.EnterTokenStream(Tokens,
false,
8587 ParseScope LocalScope(
this, 0);
8600 while (Tok.
isNot(tok::eof))
8604 if (Tok.
is(tok::eof) && Tok.
getEofData() == TypeStr.data())
8609void Parser::DiagnoseBitIntUse(
const Token &Tok) {
8613 assert(Tok.
isOneOf(tok::kw__ExtInt, tok::kw__BitInt) &&
8614 "expected either an _ExtInt or _BitInt token!");
8617 if (Tok.
is(tok::kw__ExtInt)) {
8618 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)
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.
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)
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.
static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
enum clang::DeclaratorChunk::@222 Kind
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.
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