28 #include "llvm/ADT/Optional.h" 29 #include "llvm/ADT/SmallSet.h" 30 #include "llvm/ADT/SmallString.h" 31 #include "llvm/ADT/StringSwitch.h" 33 using namespace clang;
49 DeclSpecContext DSC = getDeclSpecContextFromDeclaratorContext(Context);
50 if (DSC == DeclSpecContext::DSC_normal)
51 DSC = DeclSpecContext::DSC_type_specifier;
57 ParseSpecifierQualifierList(DS, AS, DSC);
63 ParseDeclarator(DeclaratorInfo);
75 if (Name.size() >= 4 && Name.startswith(
"__") && Name.endswith(
"__"))
76 return Name.drop_front(2).drop_back(2);
83 #define CLANG_ATTR_LATE_PARSED_LIST 85 #include "clang/Parse/AttrParserStringSwitches.inc" 87 #undef CLANG_ATTR_LATE_PARSED_LIST 133 LateParsedAttrList *LateAttrs,
135 assert(Tok.
is(tok::kw___attribute) &&
"Not a GNU attribute list!");
137 while (Tok.
is(tok::kw___attribute)) {
139 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
144 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
"(")) {
163 if (Tok.
isNot(tok::l_paren)) {
164 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
171 ParseGNUAttributeArgs(AttrName, AttrNameLoc, attrs, endLoc,
nullptr,
177 LateParsedAttribute *LA =
178 new LateParsedAttribute(
this, *AttrName, AttrNameLoc);
179 LateAttrs->push_back(LA);
183 if (!ClassStack.empty() && !LateAttrs->parseSoon())
184 getCurrentClass().LateParsedDeclarations.push_back(LA);
188 LA->Toks.push_back(Tok);
191 ConsumeAndStoreUntil(tok::r_paren, LA->Toks,
true);
196 LA->Toks.push_back(Eof);
199 if (ExpectAndConsume(tok::r_paren))
202 if (ExpectAndConsume(tok::r_paren))
211 #define CLANG_ATTR_IDENTIFIER_ARG_LIST 213 #include "clang/Parse/AttrParserStringSwitches.inc" 215 #undef CLANG_ATTR_IDENTIFIER_ARG_LIST 220 #define CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST 222 #include "clang/Parse/AttrParserStringSwitches.inc" 224 #undef CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST 229 #define CLANG_ATTR_TYPE_ARG_LIST 231 #include "clang/Parse/AttrParserStringSwitches.inc" 233 #undef CLANG_ATTR_TYPE_ARG_LIST 239 #define CLANG_ATTR_ARG_CONTEXT_LIST 241 #include "clang/Parse/AttrParserStringSwitches.inc" 243 #undef CLANG_ATTR_ARG_CONTEXT_LIST 247 assert(Tok.
is(tok::identifier) &&
"expected an identifier");
266 if (Tok.
isNot(tok::r_paren))
278 ScopeName, ScopeLoc, T.
get(), Syntax);
281 ScopeName, ScopeLoc,
nullptr, 0, Syntax);
284 unsigned Parser::ParseAttributeArgsCommon(
292 if (Tok.
is(tok::identifier)) {
304 IsIdentifierArg = Next.
isOneOf(tok::r_paren, tok::comma);
308 ArgExprs.push_back(ParseIdentifierLoc());
311 if (!ArgExprs.empty() ? Tok.
is(tok::comma) : Tok.
isNot(tok::r_paren)) {
313 if (!ArgExprs.empty())
319 if (Tok.
is(tok::identifier) &&
321 ArgExprs.push_back(ParseIdentifierLoc());
335 ArgExprs.push_back(ArgExpr.
get());
342 if (!ExpectAndConsume(tok::r_paren)) {
345 ArgExprs.data(), ArgExprs.size(), Syntax);
351 return static_cast<unsigned>(ArgExprs.size());
365 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
370 if (AttrKind == ParsedAttr::AT_Availability) {
371 ParseAvailabilityAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
374 }
else if (AttrKind == ParsedAttr::AT_ExternalSourceSymbol) {
375 ParseExternalSourceSymbolAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
376 ScopeName, ScopeLoc, Syntax);
378 }
else if (AttrKind == ParsedAttr::AT_ObjCBridgeRelated) {
379 ParseObjCBridgeRelatedAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
380 ScopeName, ScopeLoc, Syntax);
382 }
else if (AttrKind == ParsedAttr::AT_TypeTagForDatatype) {
383 ParseTypeTagForDatatypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
384 ScopeName, ScopeLoc, Syntax);
387 ParseAttributeWithTypeArg(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
401 for (
unsigned i = 0; i != FTI.
NumParams; ++i) {
407 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
411 unsigned Parser::ParseClangAttributeArgs(
415 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
422 return ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
423 ScopeName, ScopeLoc, Syntax);
424 case ParsedAttr::AT_ExternalSourceSymbol:
425 ParseExternalSourceSymbolAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
426 ScopeName, ScopeLoc, Syntax);
428 case ParsedAttr::AT_Availability:
429 ParseAvailabilityAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
432 case ParsedAttr::AT_ObjCBridgeRelated:
433 ParseObjCBridgeRelatedAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
434 ScopeName, ScopeLoc, Syntax);
436 case ParsedAttr::AT_TypeTagForDatatype:
437 ParseTypeTagForDatatypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
438 ScopeName, ScopeLoc, Syntax);
441 return !Attrs.
empty() ? Attrs.
begin()->getNumArgs() : 0;
459 if (AttrName->
getName() ==
"property") {
474 bool HasInvalidAccessor =
false;
479 if (!Tok.
is(tok::identifier)) {
481 if (Tok.
is(tok::r_paren) && !HasInvalidAccessor &&
482 AccessorNames[AK_Put] ==
nullptr &&
483 AccessorNames[AK_Get] ==
nullptr) {
484 Diag(AttrNameLoc, diag::err_ms_property_no_getter_or_putter);
495 if (KindStr ==
"get") {
497 }
else if (KindStr ==
"put") {
501 }
else if (KindStr ==
"set") {
502 Diag(KindLoc, diag::err_ms_property_has_set_accessor)
509 Diag(KindLoc, diag::err_ms_property_missing_accessor_kind);
511 HasInvalidAccessor =
true;
512 goto next_property_accessor;
516 Diag(KindLoc, diag::err_ms_property_unknown_accessor);
517 HasInvalidAccessor =
true;
536 if (!Tok.
is(tok::identifier)) {
541 if (Kind == AK_Invalid) {
543 }
else if (AccessorNames[Kind] !=
nullptr) {
545 Diag(KindLoc, diag::err_ms_property_duplicate_accessor) << KindStr;
551 next_property_accessor:
557 if (Tok.
is(tok::r_paren))
560 Diag(Tok.
getLocation(), diag::err_ms_property_expected_comma_or_rparen);
565 if (!HasInvalidAccessor)
567 AccessorNames[AK_Get], AccessorNames[AK_Put],
570 return !HasInvalidAccessor;
574 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs,
nullptr,
nullptr,
579 if (!Attrs.
empty() && Attrs.
begin()->getMaxArgs() && !NumArgs) {
580 Diag(OpenParenLoc, diag::err_attribute_requires_arguments) << AttrName;
594 assert(
getLangOpts().DeclSpecKeyword &&
"__declspec keyword is not enabled");
595 assert(Tok.
is(tok::kw___declspec) &&
"Not a declspec!");
597 while (Tok.
is(tok::kw___declspec)) {
606 while (Tok.
isNot(tok::r_paren)) {
613 bool IsString = Tok.
getKind() == tok::string_literal;
614 if (!IsString && Tok.
getKind() != tok::identifier &&
615 Tok.
getKind() != tok::kw_restrict) {
616 Diag(Tok, diag::err_ms_declspec_type);
625 bool Invalid =
false;
626 StringRef Str = PP.
getSpelling(Tok, StrBuffer, &Invalid);
632 AttrNameLoc = ConsumeStringToken();
638 bool AttrHandled =
false;
641 if (Tok.
is(tok::l_paren))
642 AttrHandled = ParseMicrosoftDeclSpecArgs(AttrName, AttrNameLoc, Attrs);
643 else if (AttrName->
getName() ==
"property")
649 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
662 case tok::kw___fastcall:
663 case tok::kw___stdcall:
664 case tok::kw___thiscall:
665 case tok::kw___regcall:
666 case tok::kw___cdecl:
667 case tok::kw___vectorcall:
668 case tok::kw___ptr64:
670 case tok::kw___ptr32:
672 case tok::kw___uptr: {
675 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
685 void Parser::DiagnoseAndSkipExtendedMicrosoftTypeAttributes() {
691 Diag(StartLoc, diag::warn_microsoft_qualifiers_ignored) << Range;
701 case tok::kw_volatile:
702 case tok::kw___fastcall:
703 case tok::kw___stdcall:
704 case tok::kw___thiscall:
705 case tok::kw___cdecl:
706 case tok::kw___vectorcall:
707 case tok::kw___ptr32:
708 case tok::kw___ptr64:
710 case tok::kw___unaligned:
723 while (Tok.
is(tok::kw___pascal)) {
726 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
733 while (Tok.
is(tok::kw___kernel)) {
736 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
744 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
752 case tok::kw__Nonnull:
753 case tok::kw__Nullable:
754 case tok::kw__Null_unspecified: {
758 Diag(AttrNameLoc, diag::ext_nullability)
760 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
771 return (Separator ==
'.' || Separator ==
'_');
782 VersionTuple Parser::ParseVersionTuple(
SourceRange &Range) {
785 if (!Tok.
is(tok::numeric_constant)) {
786 Diag(Tok, diag::err_expected_version);
789 return VersionTuple();
798 const char *ThisTokBegin = &Buffer[0];
801 bool Invalid =
false;
802 unsigned ActualLength = PP.
getSpelling(Tok, ThisTokBegin, &Invalid);
804 return VersionTuple();
807 unsigned AfterMajor = 0;
809 while (AfterMajor < ActualLength &&
isDigit(ThisTokBegin[AfterMajor])) {
810 Major = Major * 10 + ThisTokBegin[AfterMajor] -
'0';
814 if (AfterMajor == 0) {
815 Diag(Tok, diag::err_expected_version);
818 return VersionTuple();
821 if (AfterMajor == ActualLength) {
826 Diag(Tok, diag::err_zero_version);
827 return VersionTuple();
830 return VersionTuple(Major);
833 const char AfterMajorSeparator = ThisTokBegin[AfterMajor];
835 || (AfterMajor + 1 == ActualLength)) {
836 Diag(Tok, diag::err_expected_version);
839 return VersionTuple();
843 unsigned AfterMinor = AfterMajor + 1;
845 while (AfterMinor < ActualLength &&
isDigit(ThisTokBegin[AfterMinor])) {
846 Minor = Minor * 10 + ThisTokBegin[AfterMinor] -
'0';
850 if (AfterMinor == ActualLength) {
854 if (Major == 0 && Minor == 0) {
855 Diag(Tok, diag::err_zero_version);
856 return VersionTuple();
859 return VersionTuple(Major, Minor);
862 const char AfterMinorSeparator = ThisTokBegin[AfterMinor];
865 Diag(Tok, diag::err_expected_version);
868 return VersionTuple();
872 if (AfterMajorSeparator != AfterMinorSeparator)
873 Diag(Tok, diag::warn_expected_consistent_version_separator);
876 unsigned AfterSubminor = AfterMinor + 1;
877 unsigned Subminor = 0;
878 while (AfterSubminor < ActualLength &&
isDigit(ThisTokBegin[AfterSubminor])) {
879 Subminor = Subminor * 10 + ThisTokBegin[AfterSubminor] -
'0';
883 if (AfterSubminor != ActualLength) {
884 Diag(Tok, diag::err_expected_version);
887 return VersionTuple();
890 return VersionTuple(Major, Minor, Subminor);
918 void Parser::ParseAvailabilityAttribute(
IdentifierInfo &Availability,
925 enum { Introduced, Deprecated, Obsoleted, Unknown };
932 Diag(Tok, diag::err_expected) << tok::l_paren;
937 if (Tok.
isNot(tok::identifier)) {
938 Diag(Tok, diag::err_availability_expected_platform);
945 if (Ident->getName() ==
"macosx")
949 else if (Ident->getName() ==
"macosx_app_extension")
953 AvailabilityAttr::canonicalizePlatformName(Ident->getName()));
957 if (ExpectAndConsume(tok::comma)) {
964 if (!Ident_introduced) {
978 if (Tok.
isNot(tok::identifier)) {
979 Diag(Tok, diag::err_availability_expected_change);
986 if (Keyword == Ident_strict) {
988 Diag(KeywordLoc, diag::err_availability_redundant)
991 StrictLoc = KeywordLoc;
995 if (Keyword == Ident_unavailable) {
996 if (UnavailableLoc.
isValid()) {
997 Diag(KeywordLoc, diag::err_availability_redundant)
1000 UnavailableLoc = KeywordLoc;
1004 if (Tok.
isNot(tok::equal)) {
1005 Diag(Tok, diag::err_expected_after) << Keyword << tok::equal;
1010 if (Keyword == Ident_message || Keyword == Ident_replacement) {
1011 if (Tok.
isNot(tok::string_literal)) {
1012 Diag(Tok, diag::err_expected_string_literal)
1017 if (Keyword == Ident_message)
1018 MessageExpr = ParseStringLiteralExpression();
1020 ReplacementExpr = ParseStringLiteralExpression();
1023 cast_or_null<StringLiteral>(MessageExpr.
get())) {
1024 if (MessageStringLiteral->getCharByteWidth() != 1) {
1025 Diag(MessageStringLiteral->getSourceRange().getBegin(),
1026 diag::err_expected_string_literal)
1032 if (Keyword == Ident_message)
1040 if ((Keyword == Ident_introduced || Keyword == Ident_deprecated) &&
1041 Tok.
is(tok::identifier)) {
1045 if (Keyword == Ident_introduced)
1046 UnavailableLoc = KeywordLoc;
1052 VersionTuple Version = ParseVersionTuple(VersionRange);
1054 if (Version.empty()) {
1060 if (Keyword == Ident_introduced)
1062 else if (Keyword == Ident_deprecated)
1064 else if (Keyword == Ident_obsoleted)
1069 if (Index < Unknown) {
1070 if (!Changes[Index].KeywordLoc.
isInvalid()) {
1071 Diag(KeywordLoc, diag::err_availability_redundant)
1074 Changes[Index].VersionRange.
getEnd());
1078 Changes[Index].
Version = Version;
1081 Diag(KeywordLoc, diag::err_availability_unknown_change)
1082 << Keyword << VersionRange;
1096 if (UnavailableLoc.
isValid()) {
1097 bool Complained =
false;
1098 for (
unsigned Index = Introduced; Index != Unknown; ++Index) {
1099 if (Changes[Index].KeywordLoc.
isValid()) {
1101 Diag(UnavailableLoc, diag::warn_availability_and_unavailable)
1103 Changes[Index].VersionRange.getEnd());
1114 attrs.
addNew(&Availability,
1116 ScopeName, ScopeLoc,
1118 Changes[Introduced],
1119 Changes[Deprecated],
1121 UnavailableLoc, MessageExpr.
get(),
1138 void Parser::ParseExternalSourceSymbolAttribute(
1148 if (!Ident_language) {
1155 bool HasLanguage =
false;
1157 bool HasDefinedIn =
false;
1162 if (Tok.
isNot(tok::identifier)) {
1163 Diag(Tok, diag::err_external_source_symbol_expected_keyword);
1170 if (Keyword == Ident_generated_declaration) {
1171 if (GeneratedDeclaration) {
1172 Diag(Tok, diag::err_external_source_symbol_duplicate_clause) << Keyword;
1176 GeneratedDeclaration = ParseIdentifierLoc();
1180 if (Keyword != Ident_language && Keyword != Ident_defined_in) {
1181 Diag(Tok, diag::err_external_source_symbol_expected_keyword);
1187 if (ExpectAndConsume(tok::equal, diag::err_expected_after,
1193 bool HadLanguage = HasLanguage, HadDefinedIn = HasDefinedIn;
1194 if (Keyword == Ident_language)
1197 HasDefinedIn =
true;
1199 if (Tok.
isNot(tok::string_literal)) {
1200 Diag(Tok, diag::err_expected_string_literal)
1202 << (Keyword != Ident_language);
1206 if (Keyword == Ident_language) {
1208 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1210 ParseStringLiteralExpression();
1213 Language = ParseStringLiteralExpression();
1215 assert(Keyword == Ident_defined_in &&
"Invalid clause keyword!");
1217 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1219 ParseStringLiteralExpression();
1222 DefinedInExpr = ParseStringLiteralExpression();
1233 GeneratedDeclaration};
1235 ScopeName, ScopeLoc, Args, llvm::array_lengthof(Args), Syntax);
1249 void Parser::ParseObjCBridgeRelatedAttribute(
IdentifierInfo &ObjCBridgeRelated,
1259 Diag(Tok, diag::err_expected) << tok::l_paren;
1264 if (Tok.
isNot(tok::identifier)) {
1265 Diag(Tok, diag::err_objcbridge_related_expected_related_class);
1270 if (ExpectAndConsume(tok::comma)) {
1279 if (Tok.
is(tok::identifier)) {
1280 ClassMethod = ParseIdentifierLoc();
1282 Diag(Tok, diag::err_objcbridge_related_selector_name);
1288 if (Tok.
is(tok::colon))
1289 Diag(Tok, diag::err_objcbridge_related_selector_name);
1291 Diag(Tok, diag::err_expected) << tok::comma;
1299 if (Tok.
is(tok::identifier))
1300 InstanceMethod = ParseIdentifierLoc();
1301 else if (Tok.
isNot(tok::r_paren)) {
1302 Diag(Tok, diag::err_expected) << tok::r_paren;
1315 attrs.
addNew(&ObjCBridgeRelated,
1317 ScopeName, ScopeLoc,
1327 void Parser::LateParsedDeclaration::ParseLexedAttributes() {}
1329 void Parser::LateParsedClass::ParseLexedAttributes() {
1330 Self->ParseLexedAttributes(*Class);
1333 void Parser::LateParsedAttribute::ParseLexedAttributes() {
1334 Self->ParseLexedAttribute(*
this,
true,
false);
1339 void Parser::ParseLexedAttributes(ParsingClass &Class) {
1342 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
1345 if (HasTemplateScope)
1349 bool AlreadyHasClassScope = Class.TopLevelClass;
1351 ParseScope ClassScope(
this, ScopeFlags, !AlreadyHasClassScope);
1352 ParseScopeFlags ClassScopeFlags(
this, ScopeFlags, AlreadyHasClassScope);
1355 if (!AlreadyHasClassScope)
1357 Class.TagOrTemplate);
1358 if (!Class.LateParsedDeclarations.empty()) {
1359 for (
unsigned i = 0, ni = Class.LateParsedDeclarations.size(); i < ni; ++i){
1360 Class.LateParsedDeclarations[i]->ParseLexedAttributes();
1364 if (!AlreadyHasClassScope)
1366 Class.TagOrTemplate);
1370 void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
1372 assert(LAs.parseSoon() &&
1373 "Attribute list should be marked for immediate parsing.");
1374 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
1377 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition);
1388 void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
1397 LA.Toks.push_back(AttrEnd);
1401 LA.Toks.push_back(Tok);
1402 PP.EnterTokenStream(LA.Toks,
true);
1409 if (LA.Decls.size() > 0) {
1410 Decl *D = LA.Decls[0];
1418 if (LA.Decls.size() == 1) {
1422 if (HasTemplateScope)
1433 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc,
1441 if (HasTemplateScope) {
1447 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc,
1452 Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();
1455 if (OnDefinition && !Attrs.
empty() && !Attrs.
begin()->isCXX11Attribute() &&
1456 Attrs.
begin()->isKnownToGCC())
1457 Diag(Tok, diag::warn_attribute_on_function_definition)
1460 for (
unsigned i = 0, ni = LA.Decls.size(); i < ni; ++i)
1472 void Parser::ParseTypeTagForDatatypeAttribute(
IdentifierInfo &AttrName,
1479 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
1484 if (Tok.
isNot(tok::identifier)) {
1485 Diag(Tok, diag::err_expected) << tok::identifier;
1491 if (ExpectAndConsume(tok::comma)) {
1503 bool LayoutCompatible =
false;
1504 bool MustBeNull =
false;
1506 if (Tok.
isNot(tok::identifier)) {
1507 Diag(Tok, diag::err_expected) << tok::identifier;
1512 if (Flag->
isStr(
"layout_compatible"))
1513 LayoutCompatible =
true;
1514 else if (Flag->
isStr(
"must_be_null"))
1517 Diag(Tok, diag::err_type_safety_unknown_flag) << Flag;
1524 if (!T.consumeClose()) {
1526 ArgumentKind, MatchingCType.
get(),
1527 LayoutCompatible, MustBeNull, Syntax);
1531 *EndLoc = T.getCloseLocation();
1542 bool Parser::DiagnoseProhibitedCXX11Attribute() {
1543 assert(Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square));
1545 switch (isCXX11AttributeSpecifier(
true)) {
1546 case CAK_NotAttributeSpecifier:
1550 case CAK_InvalidAttributeSpecifier:
1554 case CAK_AttributeSpecifier:
1559 assert(Tok.
is(tok::r_square) &&
"isCXX11AttributeSpecifier lied");
1561 Diag(BeginLoc, diag::err_attributes_not_allowed)
1565 llvm_unreachable(
"All cases handled above.");
1572 void Parser::DiagnoseMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
1574 assert((Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square)) ||
1575 Tok.
is(tok::kw_alignas));
1579 ParseCXX11Attributes(Attrs);
1582 Diag(Loc, diag::err_attributes_not_allowed)
1587 void Parser::DiagnoseProhibitedAttributes(
1589 if (CorrectLocation.
isValid()) {
1591 Diag(CorrectLocation, diag::err_attributes_misplaced)
1595 Diag(Range.
getBegin(), diag::err_attributes_not_allowed) << Range;
1598 void Parser::ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
1601 if (!AL.isCXX11Attribute() && !AL.isC2xAttribute())
1604 Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) << AL.getName();
1606 Diag(AL.getLoc(), DiagID) << AL.getName();
1619 void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
1628 if ((AL.getKind() == ParsedAttr::AT_Aligned &&
1629 AL.isDeclspecAttribute()) ||
1630 AL.isMicrosoftAttribute())
1631 ToBeMoved.push_back(&AL);
1658 ParsedAttributesWithRange &attrs) {
1664 Decl *SingleDecl =
nullptr;
1666 case tok::kw_template:
1667 case tok::kw_export:
1668 ProhibitAttributes(attrs);
1669 SingleDecl = ParseDeclarationStartingWithTemplate(Context, DeclEnd, attrs);
1671 case tok::kw_inline:
1674 ProhibitAttributes(attrs);
1676 return ParseNamespace(Context, DeclEnd, InlineLoc);
1678 return ParseSimpleDeclaration(Context, DeclEnd, attrs,
1680 case tok::kw_namespace:
1681 ProhibitAttributes(attrs);
1682 return ParseNamespace(Context, DeclEnd);
1684 return ParseUsingDirectiveOrDeclaration(Context, ParsedTemplateInfo(),
1686 case tok::kw_static_assert:
1687 case tok::kw__Static_assert:
1688 ProhibitAttributes(attrs);
1689 SingleDecl = ParseStaticAssertDeclaration(DeclEnd);
1692 return ParseSimpleDeclaration(Context, DeclEnd, attrs,
true);
1719 ParsedAttributesWithRange &Attrs,
1720 bool RequireSemi, ForRangeInit *FRI) {
1724 DeclSpecContext DSContext = getDeclSpecContextFromDeclaratorContext(Context);
1725 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(),
AS_none, DSContext);
1730 DiagnoseMissingSemiAfterTagDefinition(DS,
AS_none, DSContext))
1735 if (Tok.
is(tok::semi)) {
1736 ProhibitAttributes(Attrs);
1744 Decl* decls[] = {AnonRecord, TheDecl};
1751 return ParseDeclGroup(DS, Context, &DeclEnd, FRI);
1758 case tok::annot_cxxscope:
1759 case tok::annot_template_id:
1761 case tok::code_completion:
1762 case tok::coloncolon:
1764 case tok::kw___attribute:
1765 case tok::kw_operator:
1782 case tok::identifier:
1784 case tok::code_completion:
1785 case tok::coloncolon:
1788 case tok::equalequal:
1789 case tok::kw_alignas:
1791 case tok::kw___attribute:
1810 case tok::identifier:
1833 if (Tok.
isOneOf(tok::comma, tok::l_brace, tok::kw_try)) {
1857 case tok::kw_inline:
1862 (!ParsingInObjCContainer || CurParsedObjCImpl))
1866 case tok::kw_namespace:
1871 (!ParsingInObjCContainer || CurParsedObjCImpl))
1878 ParsingInObjCContainer)
1890 case tok::annot_module_begin:
1891 case tok::annot_module_end:
1892 case tok::annot_module_include:
1909 ForRangeInit *FRI) {
1923 LateParsedAttrList LateParsedAttrs(
true);
1925 MaybeParseGNUAttributes(D, &LateParsedAttrs);
1930 if (Tok.
is(tok::kw__Noreturn)) {
1932 const char *PrevSpec;
1938 MaybeParseGNUAttributes(D, &LateParsedAttrs);
1939 Fixit &= Tok.
isOneOf(tok::semi, tok::l_brace, tok::kw_try);
1941 Diag(Loc, diag::err_c11_noreturn_misplaced)
1953 !isDeclarationAfterDeclarator()) {
1959 if (isStartOfFunctionDefinition(D)) {
1961 Diag(Tok, diag::err_function_declared_typedef);
1968 ParseFunctionDefinition(D, ParsedTemplateInfo(), &LateParsedAttrs);
1972 if (isDeclarationSpecifier()) {
1980 Diag(Tok, diag::err_expected_fn_body);
1985 if (Tok.
is(tok::l_brace)) {
1986 Diag(Tok, diag::err_function_definition_not_allowed);
1993 if (ParseAsmAttributesAfterDeclarator(D))
2002 if (FRI && (Tok.
is(tok::colon) || isTokIdentifier_in())) {
2003 bool IsForRangeLoop =
false;
2005 IsForRangeLoop =
true;
2006 if (Tok.
is(tok::l_brace))
2007 FRI->RangeExpr = ParseBraceInitializer();
2013 if (IsForRangeLoop) {
2017 if (
auto *VD = dyn_cast_or_null<VarDecl>(ThisDecl))
2018 VD->setObjCForDecl(
true);
2026 Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(
2027 D, ParsedTemplateInfo(), FRI);
2028 if (LateParsedAttrs.size() > 0)
2029 ParseLexedAttributeList(LateParsedAttrs, FirstDecl,
true,
false);
2032 DeclsInGroup.push_back(FirstDecl);
2040 if (Tok.
isAtStartOfLine() && ExpectSemi && !MightBeDeclarator(Context)) {
2044 Diag(CommaLoc, diag::err_expected_semi_declaration)
2061 MaybeParseGNUAttributes(D);
2065 DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2069 Decl *ThisDecl = ParseDeclarationAfterDeclarator(D);
2072 DeclsInGroup.push_back(ThisDecl);
2081 ? diag::err_invalid_token_after_toplevel_declarator
2082 : diag::err_expected_semi_declaration)) {
2086 if (!isDeclarationSpecifier()) {
2097 bool Parser::ParseAsmAttributesAfterDeclarator(
Declarator &D) {
2099 if (Tok.
is(tok::kw_asm)) {
2111 MaybeParseGNUAttributes(D);
2137 Decl *Parser::ParseDeclarationAfterDeclarator(
2138 Declarator &D,
const ParsedTemplateInfo &TemplateInfo) {
2139 if (ParseAsmAttributesAfterDeclarator(D))
2142 return ParseDeclarationAfterDeclaratorAndAttributes(D, TemplateInfo);
2145 Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
2146 Declarator &D,
const ParsedTemplateInfo &TemplateInfo, ForRangeInit *FRI) {
2148 struct InitializerScopeRAII {
2154 :
P(P), D(D), ThisDecl(ThisDecl) {
2164 ~InitializerScopeRAII() { pop(); }
2179 Decl *ThisDecl =
nullptr;
2180 switch (TemplateInfo.Kind) {
2181 case ParsedTemplateInfo::NonTemplate:
2182 ThisDecl = Actions.ActOnDeclarator(
getCurScope(), D);
2185 case ParsedTemplateInfo::Template:
2186 case ParsedTemplateInfo::ExplicitSpecialization: {
2187 ThisDecl = Actions.ActOnTemplateDeclarator(
getCurScope(),
2188 *TemplateInfo.TemplateParams,
2190 if (
VarTemplateDecl *VT = dyn_cast_or_null<VarTemplateDecl>(ThisDecl))
2193 ThisDecl = VT->getTemplatedDecl();
2196 case ParsedTemplateInfo::ExplicitInstantiation: {
2197 if (Tok.
is(tok::semi)) {
2198 DeclResult ThisRes = Actions.ActOnExplicitInstantiation(
2199 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc, D);
2204 ThisDecl = ThisRes.
get();
2212 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2214 ThisDecl = Actions.ActOnDeclarator(
getCurScope(), D);
2217 PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
2219 diag::err_explicit_instantiation_with_definition)
2225 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
2227 LAngleLoc,
nullptr));
2230 Actions.ActOnTemplateDeclarator(
getCurScope(), FakedParamLists, D);
2239 if (isTokenEqualOrEqualTypo()) {
2242 if (Tok.
is(tok::kw_delete)) {
2248 }
else if (Tok.
is(tok::kw_default)) {
2255 InitializerScopeRAII InitScope(*
this, D, ThisDecl);
2257 if (Tok.
is(tok::code_completion)) {
2258 Actions.CodeCompleteInitializer(
getCurScope(), ThisDecl);
2259 Actions.FinalizeDeclaration(ThisDecl);
2269 Diag(EqualLoc, diag::err_single_decl_assign_in_for_range)
2273 FRI->ColonLoc = EqualLoc;
2275 FRI->RangeExpr = Init;
2282 StopTokens.push_back(tok::comma);
2285 StopTokens.push_back(tok::r_paren);
2287 Actions.ActOnInitializerError(ThisDecl);
2289 Actions.AddInitializerToDecl(ThisDecl, Init.
get(),
2292 }
else if (Tok.
is(tok::l_paren)) {
2300 InitializerScopeRAII InitScope(*
this, D, ThisDecl);
2302 llvm::function_ref<void()> ExprListCompleter;
2303 auto ThisVarDecl = dyn_cast_or_null<VarDecl>(ThisDecl);
2304 auto ConstructorCompleter = [&, ThisVarDecl] {
2305 Actions.CodeCompleteConstructor(
2306 getCurScope(), ThisVarDecl->getType()->getCanonicalTypeInternal(),
2315 ExprListCompleter = ConstructorCompleter;
2318 if (ParseExpressionList(Exprs, CommaLocs, ExprListCompleter)) {
2319 Actions.ActOnInitializerError(ThisDecl);
2325 assert(!Exprs.empty() && Exprs.size()-1 == CommaLocs.size() &&
2326 "Unexpected number of commas!");
2333 Actions.AddInitializerToDecl(ThisDecl, Initializer.
get(),
2336 }
else if (
getLangOpts().CPlusPlus11 && Tok.
is(tok::l_brace) &&
2339 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2341 InitializerScopeRAII InitScope(*
this, D, ThisDecl);
2348 Actions.ActOnInitializerError(ThisDecl);
2350 Actions.AddInitializerToDecl(ThisDecl, Init.
get(),
true);
2353 Actions.ActOnUninitializedDecl(ThisDecl);
2356 Actions.FinalizeDeclaration(ThisDecl);
2368 DeclSpecContext DSC) {
2372 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS, DSC);
2377 Diag(Tok, diag::err_expected_type);
2380 Diag(Tok, diag::err_typename_requires_specqual);
2391 diag::err_typename_invalid_storageclass);
2432 return T.
isOneOf(tok::l_square, tok::l_paren, tok::r_paren, tok::semi,
2433 tok::comma, tok::equal, tok::kw_asm, tok::l_brace,
2447 const ParsedTemplateInfo &TemplateInfo,
2449 ParsedAttributesWithRange &Attrs) {
2450 assert(Tok.
is(tok::identifier) &&
"should have identifier");
2472 if (!isTypeSpecifier(DSC) && !
getLangOpts().CPlusPlus &&
2485 AnnotateScopeToken(*SS,
false);
2494 if (
ParsedType T = Actions.ActOnMSVCUnknownTypeName(
2495 *Tok.getIdentifierInfo(), Tok.getLocation(),
2496 DSC == DeclSpecContext::DSC_template_type_arg)) {
2497 const char *PrevSpec;
2500 Actions.getASTContext().getPrintingPolicy());
2513 if (SS ==
nullptr) {
2514 const char *TagName =
nullptr, *FixitTagName =
nullptr;
2517 switch (Actions.isTagName(*Tok.getIdentifierInfo(),
getCurScope())) {
2520 TagName=
"enum" ; FixitTagName =
"enum " ; TagKind=tok::kw_enum ;
break;
2522 TagName=
"union" ; FixitTagName =
"union " ;TagKind=tok::kw_union ;
break;
2524 TagName=
"struct"; FixitTagName =
"struct ";TagKind=tok::kw_struct;
break;
2526 TagName=
"__interface"; FixitTagName =
"__interface ";
2527 TagKind=tok::kw___interface;
break;
2529 TagName=
"class" ; FixitTagName =
"class " ;TagKind=tok::kw_class ;
break;
2537 Diag(Loc, diag::err_use_of_tag_name_without_tag)
2538 << TokenName << TagName <<
getLangOpts().CPlusPlus
2541 if (Actions.LookupParsedName(R,
getCurScope(), SS)) {
2544 Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
2545 << TokenName << TagName;
2549 if (TagKind == tok::kw_enum)
2550 ParseEnumSpecifier(Loc, DS, TemplateInfo, AS,
2551 DeclSpecContext::DSC_normal);
2553 ParseClassSpecifier(TagKind, Loc, DS, TemplateInfo, AS,
2555 DeclSpecContext::DSC_normal, Attrs);
2562 if (!isTypeSpecifier(DSC) && (!SS || DSC == DeclSpecContext::DSC_top_level ||
2563 DSC == DeclSpecContext::DSC_class)) {
2567 case tok::l_paren: {
2574 TentativeParsingAction PA(*
this);
2576 TPResult TPR = TryParseDeclarator(
false);
2579 if (TPR != TPResult::False) {
2587 if (DSC == DeclSpecContext::DSC_class ||
2588 (DSC == DeclSpecContext::DSC_top_level && SS)) {
2590 if (Actions.isCurrentClassNameTypo(II, SS)) {
2591 Diag(Loc, diag::err_constructor_bad_name)
2592 << Tok.getIdentifierInfo() << II
2594 Tok.setIdentifierInfo(II);
2609 AnnotateScopeToken(*SS,
false);
2625 Actions.DiagnoseUnknownTypeName(II, Loc,
getCurScope(), SS, T,
2631 const char *PrevSpec;
2634 Actions.getASTContext().getPrintingPolicy());
2639 }
else if (II != Tok.getIdentifierInfo()) {
2652 if (IsTemplateName) {
2654 TemplateArgList Args;
2655 ParseTemplateIdAfterTemplateName(
true, LAngle, Args, RAngle);
2669 Parser::DeclSpecContext
2672 return DeclSpecContext::DSC_class;
2674 return DeclSpecContext::DSC_top_level;
2676 return DeclSpecContext::DSC_template_param;
2679 return DeclSpecContext::DSC_template_type_arg;
2682 return DeclSpecContext::DSC_trailing;
2685 return DeclSpecContext::DSC_alias_declaration;
2686 return DeclSpecContext::DSC_normal;
2701 if (isTypeIdInParens()) {
2705 ER = Actions.ActOnUnaryExprOrTypeTraitExpr(TypeLoc,
UETT_AlignOf,
true,
2726 assert(Tok.
isOneOf(tok::kw_alignas, tok::kw__Alignas) &&
2727 "Not an alignment-specifier!");
2748 ArgExprs.push_back(ArgExpr.
get());
2749 Attrs.
addNew(KWName, KWLoc,
nullptr, KWLoc, ArgExprs.data(), 1,
2762 DeclSpecContext DSContext,
2763 LateParsedAttrList *LateAttrs) {
2766 bool EnteringContext = (DSContext == DeclSpecContext::DSC_class ||
2767 DSContext == DeclSpecContext::DSC_top_level);
2770 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype,
2771 tok::annot_template_id) &&
2777 bool HasScope = Tok.
is(tok::annot_cxxscope);
2783 bool MightBeDeclarator =
true;
2784 if (Tok.
isOneOf(tok::kw_typename, tok::annot_typename)) {
2786 MightBeDeclarator =
false;
2787 }
else if (AfterScope.
is(tok::annot_template_id)) {
2793 MightBeDeclarator =
false;
2794 }
else if (AfterScope.
is(tok::identifier)) {
2795 const Token &Next = HasScope ? GetLookAheadToken(2) :
NextToken();
2799 if (Next.
isOneOf(tok::star, tok::amp, tok::ampamp, tok::identifier,
2800 tok::annot_cxxscope, tok::coloncolon)) {
2802 MightBeDeclarator =
false;
2803 }
else if (HasScope) {
2808 Actions.RestoreNestedNameSpecifierAnnotation(
2809 Tok.getAnnotationValue(), Tok.getAnnotationRange(), SS);
2814 switch (Classification.
getKind()) {
2821 llvm_unreachable(
"typo correction and nested name specifiers not " 2827 MightBeDeclarator =
false;
2840 if (MightBeDeclarator)
2843 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
2845 diag::err_expected_after)
2856 ParsedTemplateInfo NotATemplate;
2857 ParseDeclarationSpecifiers(DS, NotATemplate, AS, DSContext, LateAttrs);
2864 const char *&PrevSpec,
unsigned &DiagID,
2866 assert(!LangOpts.FixedPoint);
2867 DiagID = diag::err_fixed_point_not_enabled;
2899 void Parser::ParseDeclarationSpecifiers(
DeclSpec &DS,
2900 const ParsedTemplateInfo &TemplateInfo,
2902 DeclSpecContext DSContext,
2903 LateParsedAttrList *LateAttrs) {
2912 bool EnteringContext = (DSContext == DeclSpecContext::DSC_class ||
2913 DSContext == DeclSpecContext::DSC_top_level);
2914 bool AttrsLastTime =
false;
2915 ParsedAttributesWithRange attrs(AttrFactory);
2920 bool isStorageClass =
false;
2921 const char *PrevSpec =
nullptr;
2922 unsigned DiagID = 0;
2934 Tok.setKind(tok::identifier);
2938 switch (Tok.getKind()) {
2942 ProhibitAttributes(attrs);
2947 ProhibitCXX11Attributes(attrs, diag::err_attribute_not_type_attr);
2954 DS.
Finish(Actions, Policy);
2958 case tok::kw_alignas:
2959 if (!standardAttributesAllowed() || !isCXX11AttributeSpecifier())
2960 goto DoneWithDeclSpec;
2962 ProhibitAttributes(attrs);
2969 ParseCXX11Attributes(attrs);
2970 AttrsLastTime =
true;
2973 case tok::code_completion: {
2976 bool AllowNonIdentifiers
2982 bool AllowNestedNameSpecifiers
2983 = DSContext == DeclSpecContext::DSC_top_level ||
2987 AllowNonIdentifiers,
2988 AllowNestedNameSpecifiers);
2989 return cutOffParsing();
2994 else if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
2997 else if (DSContext == DeclSpecContext::DSC_class)
2999 else if (CurParsedObjCImpl)
3002 Actions.CodeCompleteOrdinaryName(
getCurScope(), CCC);
3003 return cutOffParsing();
3006 case tok::coloncolon:
3011 goto DoneWithDeclSpec;
3013 if (Tok.
is(tok::coloncolon))
3014 goto DoneWithDeclSpec;
3017 case tok::annot_cxxscope: {
3019 goto DoneWithDeclSpec;
3022 Actions.RestoreNestedNameSpecifierAnnotation(Tok.getAnnotationValue(),
3023 Tok.getAnnotationRange(),
3028 if (Next.
is(tok::annot_template_id) &&
3041 if ((DSContext == DeclSpecContext::DSC_top_level ||
3042 DSContext == DeclSpecContext::DSC_class) &&
3045 isConstructorDeclarator(
false)) {
3050 goto DoneWithDeclSpec;
3054 ConsumeAnnotationToken();
3055 assert(Tok.
is(tok::annot_template_id) &&
3056 "ParseOptionalCXXScopeSpecifier not working");
3057 AnnotateTemplateIdTokenAsType();
3061 if (Next.
is(tok::annot_typename)) {
3063 ConsumeAnnotationToken();
3064 if (Tok.getAnnotationValue()) {
3067 Tok.getAnnotationEndLoc(),
3068 PrevSpec, DiagID, T, Policy);
3075 ConsumeAnnotationToken();
3078 if (Next.
isNot(tok::identifier))
3079 goto DoneWithDeclSpec;
3084 if ((DSContext == DeclSpecContext::DSC_top_level ||
3085 DSContext == DeclSpecContext::DSC_class) &&
3088 isConstructorDeclarator(
false))
3089 goto DoneWithDeclSpec;
3096 isClassTemplateDeductionContext(DSContext));
3104 ConsumeAnnotationToken();
3105 ParsedAttributesWithRange Attrs(AttrFactory);
3106 if (ParseImplicitInt(DS, &SS, TemplateInfo, AS, DSContext, Attrs)) {
3107 if (!Attrs.empty()) {
3108 AttrsLastTime =
true;
3109 attrs.takeAllFrom(Attrs);
3113 goto DoneWithDeclSpec;
3117 ConsumeAnnotationToken();
3120 DiagID, TypeRep, Policy);
3130 case tok::annot_typename: {
3134 goto DoneWithDeclSpec;
3136 if (Tok.getAnnotationValue()) {
3147 ConsumeAnnotationToken();
3152 case tok::kw___is_signed:
3163 TryKeywordIdentFallback(
true);
3166 goto DoneWithDeclSpec;
3169 case tok::kw___super:
3170 case tok::kw_decltype:
3171 case tok::identifier: {
3176 goto DoneWithDeclSpec;
3182 if (!
getLangOpts().DeclSpecKeyword && Tok.
is(tok::identifier) &&
3183 Tok.getIdentifierInfo()->getName().equals(
"__declspec")) {
3184 Diag(Loc, diag::err_ms_attributes_not_enabled);
3195 assert(
false &&
"Not a left paren?");
3208 goto DoneWithDeclSpec;
3210 if (!Tok.
is(tok::identifier))
3215 if (TryAltiVecToken(DS, Loc, PrevSpec, DiagID, isInvalid))
3221 goto DoneWithDeclSpec;
3223 if (DSContext == DeclSpecContext::DSC_objc_method_result &&
3224 isObjCInstancetype()) {
3225 ParsedType TypeRep = Actions.ActOnObjCInstanceType(Loc);
3228 DiagID, TypeRep, Policy);
3240 Actions.isCurrentClassName(*Tok.getIdentifierInfo(),
getCurScope()) &&
3241 isConstructorDeclarator(
true))
3242 goto DoneWithDeclSpec;
3245 *Tok.getIdentifierInfo(), Tok.getLocation(),
getCurScope(),
nullptr,
3246 false,
false,
nullptr,
false,
false,
3247 isClassTemplateDeductionContext(DSContext));
3252 ParsedAttributesWithRange Attrs(AttrFactory);
3253 if (ParseImplicitInt(DS,
nullptr, TemplateInfo, AS, DSContext, Attrs)) {
3254 if (!Attrs.empty()) {
3255 AttrsLastTime =
true;
3256 attrs.takeAllFrom(Attrs);
3260 goto DoneWithDeclSpec;
3266 (DSContext == DeclSpecContext::DSC_class ||
3267 DSContext == DeclSpecContext::DSC_top_level) &&
3268 Actions.isDeductionGuideName(
getCurScope(), *Tok.getIdentifierInfo(),
3269 Tok.getLocation()) &&
3270 isConstructorDeclarator(
true,
3272 goto DoneWithDeclSpec;
3275 DiagID, TypeRep, Policy);
3287 TypeResult NewTypeRep = parseObjCTypeArgsAndProtocolQualifiers(
3302 case tok::annot_template_id: {
3307 goto DoneWithDeclSpec;
3315 isConstructorDeclarator(TemplateId->
SS.
isEmpty()))
3316 goto DoneWithDeclSpec;
3320 AnnotateTemplateIdTokenAsType();
3325 case tok::kw___attribute:
3330 case tok::kw___declspec:
3335 case tok::kw___forceinline: {
3344 case tok::kw___unaligned:
3349 case tok::kw___sptr:
3350 case tok::kw___uptr:
3351 case tok::kw___ptr64:
3352 case tok::kw___ptr32:
3354 case tok::kw___cdecl:
3355 case tok::kw___stdcall:
3356 case tok::kw___fastcall:
3357 case tok::kw___thiscall:
3358 case tok::kw___regcall:
3359 case tok::kw___vectorcall:
3364 case tok::kw___pascal:
3369 case tok::kw___kernel:
3374 case tok::kw__Nonnull:
3375 case tok::kw__Nullable:
3376 case tok::kw__Null_unspecified:
3381 case tok::kw___kindof:
3388 case tok::kw_typedef:
3390 PrevSpec, DiagID, Policy);
3391 isStorageClass =
true;
3393 case tok::kw_extern:
3395 Diag(Tok, diag::ext_thread_before) <<
"extern";
3397 PrevSpec, DiagID, Policy);
3398 isStorageClass =
true;
3400 case tok::kw___private_extern__:
3402 Loc, PrevSpec, DiagID, Policy);
3403 isStorageClass =
true;
3405 case tok::kw_static:
3407 Diag(Tok, diag::ext_thread_before) <<
"static";
3409 PrevSpec, DiagID, Policy);
3410 isStorageClass =
true;
3414 if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
3416 PrevSpec, DiagID, Policy);
3418 Diag(Tok, diag::ext_auto_storage_class)
3425 PrevSpec, DiagID, Policy);
3426 isStorageClass =
true;
3428 case tok::kw___auto_type:
3429 Diag(Tok, diag::ext_auto_type);
3433 case tok::kw_register:
3435 PrevSpec, DiagID, Policy);
3436 isStorageClass =
true;
3438 case tok::kw_mutable:
3440 PrevSpec, DiagID, Policy);
3441 isStorageClass =
true;
3443 case tok::kw___thread:
3446 isStorageClass =
true;
3448 case tok::kw_thread_local:
3451 isStorageClass =
true;
3453 case tok::kw__Thread_local:
3455 Loc, PrevSpec, DiagID);
3456 isStorageClass =
true;
3460 case tok::kw_inline:
3463 case tok::kw_virtual:
3466 DiagID = diag::err_openclcxx_virtual_function;
3467 PrevSpec = Tok.getIdentifierInfo()->getNameStart();
3474 case tok::kw_explicit:
3477 case tok::kw__Noreturn:
3479 Diag(Loc, diag::ext_c11_noreturn);
3484 case tok::kw__Alignas:
3486 Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
3491 case tok::kw_friend:
3492 if (DSContext == DeclSpecContext::DSC_class)
3496 DiagID = diag::err_friend_invalid_in_context;
3502 case tok::kw___module_private__:
3507 case tok::kw_constexpr:
3524 case tok::kw___int64:
3528 case tok::kw_signed:
3532 case tok::kw_unsigned:
3536 case tok::kw__Complex:
3540 case tok::kw__Imaginary:
3556 case tok::kw___int128:
3568 case tok::kw_double:
3572 case tok::kw__Float16:
3576 case tok::kw__Accum:
3584 case tok::kw__Fract:
3599 case tok::kw___float128:
3603 case tok::kw_wchar_t:
3607 case tok::kw_char8_t:
3611 case tok::kw_char16_t:
3615 case tok::kw_char32_t:
3621 if (Tok.
is(tok::kw_bool) &&
3625 DiagID = diag::err_bool_redeclaration;
3627 Tok.setKind(tok::identifier);
3634 case tok::kw__Decimal32:
3638 case tok::kw__Decimal64:
3642 case tok::kw__Decimal128:
3646 case tok::kw___vector:
3649 case tok::kw___pixel:
3652 case tok::kw___bool:
3659 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
3660 goto DoneWithDeclSpec;
3662 isInvalid = DS.
SetTypePipe(
true, Loc, PrevSpec, DiagID, Policy);
3664 #define GENERIC_IMAGE_TYPE(ImgType, Id) \ 3665 case tok::kw_##ImgType##_t: \ 3666 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, \ 3669 #include "clang/Basic/OpenCLImageTypes.def" 3670 case tok::kw___unknown_anytype:
3672 PrevSpec, DiagID, Policy);
3677 case tok::kw_struct:
3678 case tok::kw___interface:
3679 case tok::kw_union: {
3686 ParsedAttributesWithRange Attributes(AttrFactory);
3687 ParseClassSpecifier(Kind, Loc, DS, TemplateInfo, AS,
3688 EnteringContext, DSContext, Attributes);
3692 if (!Attributes.empty()) {
3693 AttrsLastTime =
true;
3694 attrs.takeAllFrom(Attributes);
3702 ParseEnumSpecifier(Loc, DS, TemplateInfo, AS, DSContext);
3710 case tok::kw_volatile:
3714 case tok::kw_restrict:
3720 case tok::kw_typename:
3723 goto DoneWithDeclSpec;
3725 if (!Tok.
is(tok::kw_typename))
3730 case tok::kw_typeof:
3731 ParseTypeofSpecifier(DS);
3734 case tok::annot_decltype:
3735 ParseDecltypeSpecifier(DS);
3738 case tok::annot_pragma_pack:
3742 case tok::annot_pragma_ms_pragma:
3743 HandlePragmaMSPragma();
3746 case tok::annot_pragma_ms_vtordisp:
3747 HandlePragmaMSVtorDisp();
3750 case tok::annot_pragma_ms_pointers_to_members:
3751 HandlePragmaMSPointersToMembers();
3754 case tok::kw___underlying_type:
3755 ParseUnderlyingTypeSpecifier(DS);
3758 case tok::kw__Atomic:
3764 ParseAtomicSpecifier(DS);
3772 case tok::kw___read_only:
3773 case tok::kw___write_only:
3774 case tok::kw___read_write:
3776 if (Actions.getLangOpts().OpenCLCPlusPlus) {
3777 DiagID = diag::err_openclcxx_reserved;
3778 PrevSpec = Tok.getIdentifierInfo()->getNameStart();
3785 case tok::kw___generic:
3788 if (Actions.getLangOpts().OpenCLVersion < 200 &&
3789 !Actions.getLangOpts().OpenCLCPlusPlus) {
3790 DiagID = diag::err_opencl_unknown_type_specifier;
3791 PrevSpec = Tok.getIdentifierInfo()->getNameStart();
3796 case tok::kw___private:
3797 case tok::kw___global:
3798 case tok::kw___local:
3799 case tok::kw___constant:
3808 goto DoneWithDeclSpec;
3815 PrevSpec, DiagID, Type.
get(),
3816 Actions.getASTContext().getPrintingPolicy()))
3817 Diag(StartLoc, DiagID) << PrevSpec;
3830 assert(PrevSpec &&
"Method did not return previous specifier!");
3833 if (DiagID == diag::ext_duplicate_declspec)
3836 else if (DiagID == diag::err_opencl_unknown_type_specifier) {
3839 << PrevSpec << isStorageClass;
3841 Diag(Tok, DiagID) << PrevSpec;
3845 if (DiagID != diag::err_bool_redeclaration)
3849 AttrsLastTime =
false;
3871 void Parser::ParseStructDeclaration(
3875 if (Tok.
is(tok::kw___extension__)) {
3879 return ParseStructDeclaration(DS, FieldsCallback);
3883 ParsedAttributesWithRange Attrs(AttrFactory);
3884 MaybeParseCXX11Attributes(Attrs);
3888 ParseSpecifierQualifierList(DS);
3892 if (Tok.
is(tok::semi)) {
3896 assert(!AnonRecord &&
"Did not expect anonymous struct or union here");
3902 bool FirstDeclarator =
true;
3909 if (!FirstDeclarator)
3910 MaybeParseGNUAttributes(DeclaratorInfo.
D);
3914 if (Tok.
isNot(tok::colon)) {
3917 ParseDeclarator(DeclaratorInfo.
D);
3930 MaybeParseGNUAttributes(DeclaratorInfo.
D);
3933 FieldsCallback(DeclaratorInfo);
3940 FirstDeclarator =
false;
3957 "parsing struct/union body");
3965 Actions.ActOnTagStartDefinition(
getCurScope(), TagDecl);
3970 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3975 if (Tok.
is(tok::semi)) {
3976 ConsumeExtraSemi(InsideStruct,
TagType);
3981 if (Tok.
is(tok::kw__Static_assert)) {
3983 ParseStaticAssertDeclaration(DeclEnd);
3987 if (Tok.
is(tok::annot_pragma_pack)) {
3992 if (Tok.
is(tok::annot_pragma_align)) {
3993 HandlePragmaAlign();
3997 if (Tok.
is(tok::annot_pragma_openmp)) {
4000 ParsedAttributesWithRange Attrs(AttrFactory);
4001 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
4005 if (!Tok.
is(tok::at)) {
4011 FD.D, FD.BitfieldSize);
4012 FieldDecls.push_back(Field);
4018 ParseStructDeclaration(DS, CFieldCallback);
4022 Diag(Tok, diag::err_unexpected_at);
4027 ExpectAndConsume(tok::l_paren);
4028 if (!Tok.
is(tok::identifier)) {
4029 Diag(Tok, diag::err_expected) << tok::identifier;
4034 Actions.ActOnDefs(
getCurScope(), TagDecl, Tok.getLocation(),
4035 Tok.getIdentifierInfo(), Fields);
4036 FieldDecls.insert(FieldDecls.end(), Fields.begin(), Fields.end());
4038 ExpectAndConsume(tok::r_paren);
4044 if (Tok.
is(tok::r_brace)) {
4045 ExpectAndConsume(tok::semi, diag::ext_expected_semi_decl_list);
4049 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
4060 MaybeParseGNUAttributes(attrs);
4062 Actions.ActOnFields(
getCurScope(), RecordLoc, TagDecl, FieldDecls,
4099 const ParsedTemplateInfo &TemplateInfo,
4102 if (Tok.
is(tok::code_completion)) {
4105 return cutOffParsing();
4109 ParsedAttributesWithRange attrs(AttrFactory);
4110 MaybeParseGNUAttributes(attrs);
4111 MaybeParseCXX11Attributes(attrs);
4112 MaybeParseMicrosoftDeclSpecs(attrs);
4115 bool IsScopedUsingClassTag =
false;
4118 if (Tok.
isOneOf(tok::kw_class, tok::kw_struct)) {
4120 : diag::ext_scoped_enum);
4121 IsScopedUsingClassTag = Tok.
is(tok::kw_class);
4126 ProhibitAttributes(attrs);
4129 MaybeParseGNUAttributes(attrs);
4130 MaybeParseCXX11Attributes(attrs);
4131 MaybeParseMicrosoftDeclSpecs(attrs);
4140 bool shouldDelayDiagsInTag =
4141 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
4142 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
4146 bool AllowDeclaration = DSC != DeclSpecContext::DSC_trailing;
4148 bool AllowFixedUnderlyingType = AllowDeclaration &&
4159 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
4163 if (Spec.
isSet() && Tok.
isNot(tok::identifier)) {
4164 Diag(Tok, diag::err_expected) << tok::identifier;
4165 if (Tok.
isNot(tok::l_brace)) {
4177 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::l_brace) &&
4178 !(AllowFixedUnderlyingType && Tok.
is(tok::colon))) {
4179 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
4189 if (Tok.
is(tok::identifier)) {
4190 Name = Tok.getIdentifierInfo();
4194 if (!Name && ScopedEnumKWLoc.
isValid()) {
4197 Diag(Tok, diag::err_scoped_enum_missing_identifier);
4199 IsScopedUsingClassTag =
false;
4204 if (shouldDelayDiagsInTag)
4205 diagsFromTag.
done();
4211 if (AllowFixedUnderlyingType && Tok.
is(tok::colon)) {
4212 bool PossibleBitfield =
false;
4213 if (CanBeBitfield) {
4226 if (TPR == TPResult::True)
4227 PossibleBitfield =
true;
4232 else if (TPR == TPResult::False &&
4233 GetLookAheadToken(2).
getKind() == tok::semi) {
4240 TentativeParsingAction TPA(*
this);
4252 isCXXDeclarationSpecifier(TPResult::True) != TPResult::True) ||
4255 PossibleBitfield =
true;
4267 if (!PossibleBitfield) {
4272 Diag(StartLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type);
4275 Diag(StartLoc, diag::ext_cxx11_enum_fixed_underlying_type) << Range;
4277 Diag(StartLoc, diag::ext_c_enum_fixed_underlying_type) << Range;
4293 if (!AllowDeclaration) {
4295 }
else if (Tok.
is(tok::l_brace)) {
4297 Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
4305 }
else if (!isTypeSpecifier(DSC) &&
4306 (Tok.
is(tok::semi) ||
4307 (Tok.isAtStartOfLine() &&
4308 !isValidAfterTypeSpecifier(CanBeBitfield)))) {
4310 if (Tok.
isNot(tok::semi)) {
4312 ExpectAndConsume(tok::semi, diag::err_expected_after,
"enum");
4314 Tok.setKind(tok::semi);
4327 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
4331 Diag(Tok, diag::err_enum_template);
4336 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
4339 Diag(StartLoc, diag::err_explicit_instantiation_enum);
4343 assert(TemplateInfo.TemplateParams &&
"no template parameters");
4345 TemplateInfo.TemplateParams->size());
4349 ProhibitAttributes(attrs);
4352 Diag(Tok, diag::err_enumerator_unnamed_no_def);
4359 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
4364 SkipBody = Actions.shouldSkipAnonEnumBody(
getCurScope(),
4369 bool IsDependent =
false;
4370 const char *PrevSpec =
nullptr;
4372 Decl *TagDecl = Actions.ActOnTag(
4375 ScopedEnumKWLoc, IsScopedUsingClassTag, BaseType,
4376 DSC == DeclSpecContext::DSC_type_specifier,
4377 DSC == DeclSpecContext::DSC_template_param ||
4378 DSC == DeclSpecContext::DSC_template_type_arg,
4389 NameLoc.
isValid() ? NameLoc : StartLoc,
4390 PrevSpec, DiagID, TagDecl, Owned,
4392 Diag(StartLoc, DiagID) << PrevSpec;
4401 Diag(Tok, diag::err_expected_type_name_after_typename);
4413 NameLoc.
isValid() ? NameLoc : StartLoc,
4414 PrevSpec, DiagID, Type.
get(),
4415 Actions.getASTContext().getPrintingPolicy()))
4416 Diag(StartLoc, DiagID) << PrevSpec;
4435 ParseEnumBody(StartLoc, D);
4437 !Actions.ActOnDuplicateDefinition(DS, TagDecl, SkipBody)) {
4444 NameLoc.
isValid() ? NameLoc : StartLoc,
4445 PrevSpec, DiagID, TagDecl, Owned,
4447 Diag(StartLoc, DiagID) << PrevSpec;
4463 Actions.ActOnTagStartDefinition(
getCurScope(), EnumDecl);
4470 Diag(Tok, diag::err_empty_enum);
4475 Decl *LastEnumConstDecl =
nullptr;
4478 while (Tok.
isNot(tok::r_brace)) {
4481 if (Tok.
isNot(tok::identifier)) {
4482 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4492 ParsedAttributesWithRange attrs(AttrFactory);
4493 MaybeParseGNUAttributes(attrs);
4494 ProhibitAttributes(attrs);
4495 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
4498 ? diag::warn_cxx14_compat_ns_enum_attribute
4499 : diag::ext_ns_enum_attribute)
4501 ParseCXX11Attributes(attrs);
4506 EnumAvailabilityDiags.emplace_back(*
this);
4515 Decl *EnumConstDecl = Actions.ActOnEnumConstant(
4516 getCurScope(), EnumDecl, LastEnumConstDecl, IdentLoc, Ident, attrs,
4517 EqualLoc, AssignedVal.
get());
4518 EnumAvailabilityDiags.back().done();
4520 EnumConstantDecls.push_back(EnumConstDecl);
4521 LastEnumConstDecl = EnumConstDecl;
4523 if (Tok.
is(tok::identifier)) {
4526 Diag(Loc, diag::err_enumerator_list_missing_comma)
4536 Diag(Tok.getLocation(), diag::err_expected_either) << tok::r_brace
4539 Diag(Tok.getLocation(), diag::err_expected_end_of_enumerator);
4549 if (Tok.
is(tok::r_brace) && CommaLoc.
isValid()) {
4552 diag::ext_enumerator_list_comma_cxx :
4553 diag::ext_enumerator_list_comma_c)
4556 Diag(CommaLoc, diag::warn_cxx98_compat_enumerator_list_comma)
4567 MaybeParseGNUAttributes(attrs);
4569 Actions.ActOnEnumBody(StartLoc, T.
getRange(), EnumDecl, EnumConstantDecls,
4573 assert(EnumConstantDecls.size() == EnumAvailabilityDiags.size());
4574 for (
size_t i = 0, e = EnumConstantDecls.size(); i != e; ++i) {
4576 EnumAvailabilityDiags[i].redelay();
4586 if (!isValidAfterTypeSpecifier(CanBeBitfield)) {
4587 ExpectAndConsume(tok::semi, diag::err_expected_after,
"enum");
4592 Tok.setKind(tok::semi);
4599 bool Parser::isKnownToBeTypeSpecifier(
const Token &Tok)
const {
4601 default:
return false;
4605 case tok::kw___int64:
4606 case tok::kw___int128:
4607 case tok::kw_signed:
4608 case tok::kw_unsigned:
4609 case tok::kw__Complex:
4610 case tok::kw__Imaginary:
4613 case tok::kw_wchar_t:
4614 case tok::kw_char8_t:
4615 case tok::kw_char16_t:
4616 case tok::kw_char32_t:
4620 case tok::kw_double:
4621 case tok::kw__Accum:
4622 case tok::kw__Fract:
4623 case tok::kw__Float16:
4624 case tok::kw___float128:
4627 case tok::kw__Decimal32:
4628 case tok::kw__Decimal64:
4629 case tok::kw__Decimal128:
4630 case tok::kw___vector:
4631 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: 4632 #include "clang/Basic/OpenCLImageTypes.def" 4636 case tok::kw_struct:
4637 case tok::kw___interface:
4643 case tok::annot_typename:
4650 bool Parser::isTypeSpecifierQualifier() {
4652 default:
return false;
4654 case tok::identifier:
4655 if (TryAltiVecVectorToken())
4658 case tok::kw_typename:
4663 if (Tok.
is(tok::identifier))
4665 return isTypeSpecifierQualifier();
4667 case tok::coloncolon:
4674 return isTypeSpecifierQualifier();
4677 case tok::kw___attribute:
4679 case tok::kw_typeof:
4684 case tok::kw___int64:
4685 case tok::kw___int128:
4686 case tok::kw_signed:
4687 case tok::kw_unsigned:
4688 case tok::kw__Complex:
4689 case tok::kw__Imaginary:
4692 case tok::kw_wchar_t:
4693 case tok::kw_char8_t:
4694 case tok::kw_char16_t:
4695 case tok::kw_char32_t:
4699 case tok::kw_double:
4700 case tok::kw__Accum:
4701 case tok::kw__Fract:
4702 case tok::kw__Float16:
4703 case tok::kw___float128:
4706 case tok::kw__Decimal32:
4707 case tok::kw__Decimal64:
4708 case tok::kw__Decimal128:
4709 case tok::kw___vector:
4710 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: 4711 #include "clang/Basic/OpenCLImageTypes.def" 4715 case tok::kw_struct:
4716 case tok::kw___interface:
4723 case tok::kw_volatile:
4724 case tok::kw_restrict:
4728 case tok::kw___unknown_anytype:
4731 case tok::annot_typename:
4738 case tok::kw___cdecl:
4739 case tok::kw___stdcall:
4740 case tok::kw___fastcall:
4741 case tok::kw___thiscall:
4742 case tok::kw___regcall:
4743 case tok::kw___vectorcall:
4745 case tok::kw___ptr64:
4746 case tok::kw___ptr32:
4747 case tok::kw___pascal:
4748 case tok::kw___unaligned:
4750 case tok::kw__Nonnull:
4751 case tok::kw__Nullable:
4752 case tok::kw__Null_unspecified:
4754 case tok::kw___kindof:
4756 case tok::kw___private:
4757 case tok::kw___local:
4758 case tok::kw___global:
4759 case tok::kw___constant:
4760 case tok::kw___generic:
4761 case tok::kw___read_only:
4762 case tok::kw___read_write:
4763 case tok::kw___write_only:
4768 case tok::kw__Atomic:
4778 bool Parser::isDeclarationSpecifier(
bool DisambiguatingWithExpression) {
4780 default:
return false;
4785 case tok::identifier:
4789 if (TryAltiVecVectorToken())
4792 case tok::kw_decltype:
4793 case tok::kw_typename:
4798 if (Tok.
is(tok::identifier))
4806 if (DisambiguatingWithExpression &&
4807 isStartOfObjCClassMessageMissingOpenBracket())
4810 return isDeclarationSpecifier();
4812 case tok::coloncolon:
4821 return isDeclarationSpecifier();
4824 case tok::kw_typedef:
4825 case tok::kw_extern:
4826 case tok::kw___private_extern__:
4827 case tok::kw_static:
4829 case tok::kw___auto_type:
4830 case tok::kw_register:
4831 case tok::kw___thread:
4832 case tok::kw_thread_local:
4833 case tok::kw__Thread_local:
4836 case tok::kw___module_private__:
4839 case tok::kw___unknown_anytype:
4844 case tok::kw___int64:
4845 case tok::kw___int128:
4846 case tok::kw_signed:
4847 case tok::kw_unsigned:
4848 case tok::kw__Complex:
4849 case tok::kw__Imaginary:
4852 case tok::kw_wchar_t:
4853 case tok::kw_char8_t:
4854 case tok::kw_char16_t:
4855 case tok::kw_char32_t:
4860 case tok::kw_double:
4861 case tok::kw__Accum:
4862 case tok::kw__Fract:
4863 case tok::kw__Float16:
4864 case tok::kw___float128:
4867 case tok::kw__Decimal32:
4868 case tok::kw__Decimal64:
4869 case tok::kw__Decimal128:
4870 case tok::kw___vector:
4874 case tok::kw_struct:
4876 case tok::kw___interface:
4882 case tok::kw_volatile:
4883 case tok::kw_restrict:
4887 case tok::kw_inline:
4888 case tok::kw_virtual:
4889 case tok::kw_explicit:
4890 case tok::kw__Noreturn:
4893 case tok::kw__Alignas:
4896 case tok::kw_friend:
4899 case tok::kw__Static_assert:
4902 case tok::kw_typeof:
4905 case tok::kw___attribute:
4908 case tok::annot_decltype:
4909 case tok::kw_constexpr:
4912 case tok::kw__Atomic:
4920 case tok::annot_typename:
4921 return !DisambiguatingWithExpression ||
4922 !isStartOfObjCClassMessageMissingOpenBracket();
4924 case tok::kw___declspec:
4925 case tok::kw___cdecl:
4926 case tok::kw___stdcall:
4927 case tok::kw___fastcall:
4928 case tok::kw___thiscall:
4929 case tok::kw___regcall:
4930 case tok::kw___vectorcall:
4932 case tok::kw___sptr:
4933 case tok::kw___uptr:
4934 case tok::kw___ptr64:
4935 case tok::kw___ptr32:
4936 case tok::kw___forceinline:
4937 case tok::kw___pascal:
4938 case tok::kw___unaligned:
4940 case tok::kw__Nonnull:
4941 case tok::kw__Nullable:
4942 case tok::kw__Null_unspecified:
4944 case tok::kw___kindof:
4946 case tok::kw___private:
4947 case tok::kw___local:
4948 case tok::kw___global:
4949 case tok::kw___constant:
4950 case tok::kw___generic:
4951 case tok::kw___read_only:
4952 case tok::kw___read_write:
4953 case tok::kw___write_only:
4954 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: 4955 #include "clang/Basic/OpenCLImageTypes.def" 4961 bool Parser::isConstructorDeclarator(
bool IsUnqualified,
bool DeductionGuide) {
4962 TentativeParsingAction TPA(*
this);
4966 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
4973 if (Tok.
is(tok::identifier)) {
4977 }
else if (Tok.
is(tok::annot_template_id)) {
4978 ConsumeAnnotationToken();
4986 SkipCXX11Attributes();
4989 if (Tok.
isNot(tok::l_paren)) {
4997 if (Tok.
is(tok::r_paren) ||
5006 isCXX11AttributeSpecifier(
false,
5013 DeclaratorScopeObj DeclScopeObj(*
this, SS);
5015 DeclScopeObj.EnterDeclaratorScope();
5019 MaybeParseMicrosoftAttributes(Attrs);
5024 bool IsConstructor =
false;
5025 if (isDeclarationSpecifier())
5026 IsConstructor =
true;
5027 else if (Tok.
is(tok::identifier) ||
5028 (Tok.
is(tok::annot_cxxscope) &&
NextToken().
is(tok::identifier))) {
5033 if (Tok.
is(tok::annot_cxxscope))
5034 ConsumeAnnotationToken();
5046 case tok::coloncolon:
5059 SkipCXX11Attributes();
5061 if (DeductionGuide) {
5063 IsConstructor = Tok.
is(tok::arrow);
5066 if (Tok.
is(tok::colon) || Tok.
is(tok::kw_try)) {
5070 IsConstructor =
true;
5072 if (Tok.
is(tok::semi) || Tok.
is(tok::l_brace)) {
5085 IsConstructor = IsUnqualified;
5090 IsConstructor =
true;
5096 return IsConstructor;
5111 void Parser::ParseTypeQualifierListOpt(
5112 DeclSpec &DS,
unsigned AttrReqs,
bool AtomicAllowed,
5113 bool IdentifierRequired,
5115 if (standardAttributesAllowed() && (AttrReqs & AR_CXX11AttributesParsed) &&
5116 isCXX11AttributeSpecifier()) {
5117 ParsedAttributesWithRange attrs(AttrFactory);
5118 ParseCXX11Attributes(attrs);
5126 const char *PrevSpec =
nullptr;
5127 unsigned DiagID = 0;
5131 case tok::code_completion:
5133 (*CodeCompletionHandler)();
5135 Actions.CodeCompleteTypeQualifiers(DS);
5136 return cutOffParsing();
5142 case tok::kw_volatile:
5146 case tok::kw_restrict:
5150 case tok::kw__Atomic:
5152 goto DoneWithTypeQuals;
5158 case tok::kw___private:
5159 case tok::kw___global:
5160 case tok::kw___local:
5161 case tok::kw___constant:
5162 case tok::kw___generic:
5163 case tok::kw___read_only:
5164 case tok::kw___write_only:
5165 case tok::kw___read_write:
5169 case tok::kw___unaligned:
5173 case tok::kw___uptr:
5178 if (TryKeywordIdentFallback(
false))
5182 case tok::kw___sptr:
5184 case tok::kw___ptr64:
5185 case tok::kw___ptr32:
5186 case tok::kw___cdecl:
5187 case tok::kw___stdcall:
5188 case tok::kw___fastcall:
5189 case tok::kw___thiscall:
5190 case tok::kw___regcall:
5191 case tok::kw___vectorcall:
5192 if (AttrReqs & AR_DeclspecAttributesParsed) {
5196 goto DoneWithTypeQuals;
5197 case tok::kw___pascal:
5198 if (AttrReqs & AR_VendorAttributesParsed) {
5202 goto DoneWithTypeQuals;
5205 case tok::kw__Nonnull:
5206 case tok::kw__Nullable:
5207 case tok::kw__Null_unspecified:
5212 case tok::kw___kindof:
5218 case tok::kw___attribute:
5219 if (AttrReqs & AR_GNUAttributesParsedAndRejected)
5221 Diag(Tok, diag::err_attributes_not_allowed);
5225 if (AttrReqs & AR_GNUAttributesParsed ||
5226 AttrReqs & AR_GNUAttributesParsedAndRejected) {
5236 DS.
Finish(Actions, Actions.getASTContext().getPrintingPolicy());
5244 assert(PrevSpec &&
"Method did not return previous specifier!");
5245 Diag(Tok, DiagID) << PrevSpec;
5253 void Parser::ParseDeclarator(
Declarator &D) {
5256 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
5261 if (Kind == tok::star || Kind == tok::caret)
5264 if ((Kind == tok::kw_pipe) && Lang.OpenCL && (Lang.OpenCLVersion >= 200))
5267 if (!Lang.CPlusPlus)
5270 if (Kind == tok::amp)
5278 if (Kind == tok::ampamp)
5279 return Lang.CPlusPlus11 ||
5290 for (
unsigned Idx = 0; Idx != NumTypes; ++Idx)
5322 void Parser::ParseDeclaratorInternal(
Declarator &D,
5323 DirectDeclParseFunction DirectDeclParser) {
5324 if (Diags.hasAllExtensionsSilenced())
5331 (Tok.
is(tok::coloncolon) || Tok.
is(tok::kw_decltype) ||
5332 (Tok.
is(tok::identifier) &&
5334 Tok.
is(tok::annot_cxxscope))) {
5335 bool EnteringContext =
5339 ParseOptionalCXXScopeSpecifier(SS,
nullptr, EnteringContext);
5342 if (Tok.
isNot(tok::star)) {
5347 AnnotateScopeToken(SS,
true);
5349 if (DirectDeclParser)
5350 (this->*DirectDeclParser)(D);
5357 ParseTypeQualifierListOpt(DS);
5361 ParseDeclaratorInternal(D, DirectDeclParser);
5377 ParseTypeQualifierListOpt(DS);
5386 if (DirectDeclParser)
5387 (this->*DirectDeclParser)(D);
5396 if (Kind == tok::star || Kind == tok::caret) {
5402 unsigned Reqs = AR_CXX11AttributesParsed | AR_DeclspecAttributesParsed |
5404 ? AR_GNUAttributesParsed
5405 : AR_GNUAttributesParsedAndRejected);
5410 ParseDeclaratorInternal(D, DirectDeclParser);
5411 if (Kind == tok::star)
5429 if (Kind == tok::ampamp)
5431 diag::warn_cxx98_compat_rvalue_reference :
5432 diag::ext_rvalue_reference);
5435 ParseTypeQualifierListOpt(DS);
5444 diag::err_invalid_reference_qualifier_application) <<
"const";
5447 diag::err_invalid_reference_qualifier_application) <<
"volatile";
5451 diag::err_invalid_reference_qualifier_application) <<
"_Atomic";
5455 ParseDeclaratorInternal(D, DirectDeclParser);
5462 Diag(InnerChunk.
Loc, diag::err_illegal_decl_reference_to_reference)
5465 Diag(InnerChunk.
Loc, diag::err_illegal_decl_reference_to_reference)
5540 void Parser::ParseDirectDeclarator(
Declarator &D) {
5547 return ParseDecompositionDeclarator(D);
5559 bool EnteringContext =
5567 if (Actions.ShouldEnterDeclaratorScope(
getCurScope(),
5571 DeclScopeObj.EnterDeclaratorScope();
5578 goto PastIdentifier;
5595 !Actions.containsUnexpandedParameterPacks(D) &&
5603 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, D);
5613 if (Tok.
isOneOf(tok::identifier, tok::kw_operator, tok::annot_template_id,
5617 bool AllowConstructorName;
5618 bool AllowDeductionGuide;
5620 AllowConstructorName =
false;
5621 AllowDeductionGuide =
false;
5623 AllowConstructorName =
5626 AllowDeductionGuide =
false;
5628 AllowConstructorName =
5630 AllowDeductionGuide =
5638 true, AllowConstructorName,
5639 AllowDeductionGuide,
nullptr,
nullptr,
5652 DeclScopeObj.EnterDeclaratorScope();
5659 goto PastIdentifier;
5665 diag::err_expected_unqualified_id)
5668 goto PastIdentifier;
5672 "There's a C++-specific check for tok::identifier above");
5677 goto PastIdentifier;
5682 bool DiagnoseIdentifier =
false;
5686 DiagnoseIdentifier =
true;
5689 DiagnoseIdentifier =
5697 !isCXX11VirtSpecifier(Tok))
5699 tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try);
5700 if (DiagnoseIdentifier) {
5705 goto PastIdentifier;
5709 if (Tok.
is(tok::l_paren)) {
5714 RevertingTentativeParsingAction PA(*
this);
5718 goto PastIdentifier;
5725 ParseParenDeclarator(D);
5738 DeclScopeObj.EnterDeclaratorScope();
5749 diag::ext_abstract_pack_declarator_parens);
5751 if (Tok.
getKind() == tok::annot_pragma_parser_crash)
5753 if (Tok.
is(tok::l_square))
5754 return ParseMisplacedBracketDeclarator(D);
5762 diag::err_expected_member_name_or_semi_objcxx_keyword)
5769 goto PastIdentifier;
5772 diag::err_expected_member_name_or_semi)
5776 if (Tok.
isOneOf(tok::period, tok::arrow))
5777 Diag(Tok, diag::err_invalid_operator_on_type) << Tok.
is(tok::arrow);
5781 Diag(PP.getLocForEndOfToken(Loc), diag::err_expected_unqualified_id)
5785 diag::err_expected_unqualified_id)
5790 diag::err_expected_either)
5791 << tok::identifier << tok::l_paren;
5799 "Haven't past the location of the identifier yet?");
5803 MaybeParseCXX11Attributes(D);
5806 if (Tok.
is(tok::l_paren)) {
5809 ParseScope PrototypeScope(
this,
5817 bool IsAmbiguous =
false;
5821 TentativelyDeclaredIdentifiers.push_back(D.
getIdentifier());
5822 bool IsFunctionDecl = isCXXFunctionDeclarator(&IsAmbiguous);
5823 TentativelyDeclaredIdentifiers.pop_back();
5824 if (!IsFunctionDecl)
5830 ParseFunctionDeclarator(D, attrs, T, IsAmbiguous);
5831 PrototypeScope.Exit();
5832 }
else if (Tok.
is(tok::l_square)) {
5833 ParseBracketDeclarator(D);
5840 void Parser::ParseDecompositionDeclarator(
Declarator &D) {
5841 assert(Tok.
is(tok::l_square));
5847 if (!(
NextToken().is(tok::identifier) &&
5848 GetLookAheadToken(2).isOneOf(tok::comma, tok::r_square)) &&
5850 GetLookAheadToken(2).isOneOf(tok::equal, tok::l_brace)))
5851 return ParseMisplacedBracketDeclarator(D);
5857 while (Tok.
isNot(tok::r_square)) {
5858 if (!Bindings.empty()) {
5859 if (Tok.
is(tok::comma))
5862 if (Tok.
is(tok::identifier)) {
5864 Diag(EndLoc, diag::err_expected)
5867 Diag(Tok, diag::err_expected_comma_or_rsquare);
5870 SkipUntil(tok::r_square, tok::comma, tok::identifier,
5872 if (Tok.
is(tok::comma))
5874 else if (Tok.
isNot(tok::identifier))
5879 if (Tok.
isNot(tok::identifier)) {
5880 Diag(Tok, diag::err_expected) << tok::identifier;
5888 if (Tok.
isNot(tok::r_square))
5894 if (Bindings.empty())
5917 void Parser::ParseParenDeclarator(
Declarator &D) {
5921 assert(!D.
isPastIdentifier() &&
"Should be called before passing identifier");
5934 bool RequiresArg =
false;
5935 if (Tok.
is(tok::kw___attribute)) {
5936 ParseGNUAttributes(attrs);
5944 ParseMicrosoftTypeAttributes(attrs);
5947 if (Tok.
is(tok::kw___pascal))
5948 ParseBorlandTypeAttributes(attrs);
5960 }
else if (Tok.
is(tok::r_paren) ||
5963 isDeclarationSpecifier() ||
5964 isCXX11AttributeSpecifier()) {
5982 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
5993 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, D);
6006 ParseScope PrototypeScope(
this,
6010 ParseFunctionDeclarator(D, attrs, T,
false, RequiresArg);
6011 PrototypeScope.Exit();
6033 void Parser::ParseFunctionDeclarator(
Declarator &D,
6038 assert(
getCurScope()->isFunctionPrototypeScope() &&
6039 "Should call from a Function scope");
6045 bool HasProto =
false;
6052 bool RefQualifierIsLValueRef =
true;
6063 ParsedAttributesWithRange FnAttrs(AttrFactory);
6072 StartLoc = LParenLoc;
6074 if (isFunctionDeclaratorIdentifierList()) {
6076 Diag(Tok, diag::err_argument_required_after_attribute);
6078 ParseFunctionDeclaratorIdentifierList(D, ParamInfo);
6082 LocalEndLoc = RParenLoc;
6087 MaybeParseCXX11Attributes(FnAttrs);
6088 ProhibitAttributes(FnAttrs);
6090 if (Tok.
isNot(tok::r_paren))
6091 ParseParameterDeclarationClause(D, FirstArgAttrs, ParamInfo,
6093 else if (RequiresArg)
6094 Diag(Tok, diag::err_argument_required_after_attribute);
6096 HasProto = ParamInfo.size() ||
getLangOpts().CPlusPlus
6102 LocalEndLoc = RParenLoc;
6111 ParseTypeQualifierListOpt(DS, AR_NoAttributesParsed,
6114 llvm::function_ref<
void()>([&]() {
6115 Actions.CodeCompleteFunctionQualifiers(DS, D);
6125 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc))
6126 EndLoc = RefQualifierLoc;
6135 bool IsCXX11MemberFunction =
6142 Actions.CurContext->isRecord());
6144 dyn_cast<CXXRecordDecl>(Actions.CurContext),
6149 IsCXX11MemberFunction);
6154 if (Delayed && Actions.isLibstdcxxEagerExceptionSpecHack(D) &&
6155 GetLookAheadToken(0).is(tok::kw_noexcept) &&
6156 GetLookAheadToken(1).is(tok::l_paren) &&
6157 GetLookAheadToken(2).is(tok::kw_noexcept) &&
6158 GetLookAheadToken(3).is(tok::l_paren) &&
6159 GetLookAheadToken(4).is(tok::identifier) &&
6160 GetLookAheadToken(4).getIdentifierInfo()->isStr(
"swap")) {
6171 ESpecType = tryParseExceptionSpecification(Delayed,
6174 DynamicExceptionRanges,
6176 ExceptionSpecTokens);
6178 EndLoc = ESpecRange.
getEnd();
6182 MaybeParseCXX11Attributes(FnAttrs);
6185 LocalEndLoc = EndLoc;
6187 Diag(Tok, diag::warn_cxx98_compat_trailing_return_type);
6192 TrailingReturnType =
6196 }
else if (standardAttributesAllowed()) {
6197 MaybeParseCXX11Attributes(FnAttrs);
6210 if (!ND || isa<ParmVarDecl>(ND))
6212 DeclsInPrototype.push_back(ND);
6218 HasProto, IsAmbiguous, LParenLoc, ParamInfo.data(),
6219 ParamInfo.size(), EllipsisLoc, RParenLoc,
6221 RefQualifierLoc, ConstQualifierLoc, VolatileQualifierLoc,
6222 RestrictQualifierLoc,
6224 DynamicExceptions.data(), DynamicExceptionRanges.data(),
6225 DynamicExceptions.size(),
6226 NoexceptExpr.
isUsable() ? NoexceptExpr.
get() :
nullptr,
6227 ExceptionSpecTokens, DeclsInPrototype, StartLoc,
6228 LocalEndLoc, D, TrailingReturnType),
6229 std::move(FnAttrs), EndLoc);
6234 bool Parser::ParseRefQualifier(
bool &RefQualifierIsLValueRef,
6236 if (Tok.
isOneOf(tok::amp, tok::ampamp)) {
6238 diag::warn_cxx98_compat_ref_qualifier :
6239 diag::ext_ref_qualifier);
6241 RefQualifierIsLValueRef = Tok.
is(tok::amp);
6253 bool Parser::isFunctionDeclaratorIdentifierList() {
6255 && Tok.
is(tok::identifier)
6256 && !TryAltiVecVectorToken()
6285 void Parser::ParseFunctionDeclaratorIdentifierList(
6293 Diag(Tok, diag::ext_ident_list_in_param);
6296 llvm::SmallSet<const IdentifierInfo*, 16> ParamsSoFar;
6300 if (Tok.
isNot(tok::identifier)) {
6301 Diag(Tok, diag::err_expected) << tok::identifier;
6312 Diag(Tok, diag::err_unexpected_typedef_ident) << ParmII;
6315 if (!ParamsSoFar.insert(ParmII).second) {
6316 Diag(Tok, diag::err_param_redefinition) << ParmII;
6361 void Parser::ParseParameterDeclarationClause(
6391 ParseDeclarationSpecifiers(DS);
6401 ParseDeclarator(ParmDeclarator);
6404 MaybeParseGNUAttributes(ParmDeclarator);
6411 std::unique_ptr<CachedTokens> DefArgToks;
6415 if (DS.
isEmpty() && ParmDeclarator.getIdentifier() ==
nullptr &&
6416 ParmDeclarator.getNumTypeObjects() == 0) {
6418 Diag(DSStart, diag::err_missing_param);
6425 if (Tok.
is(tok::ellipsis) &&
6427 (!ParmDeclarator.getEllipsisLoc().isValid() &&
6428 !Actions.isUnexpandedParameterPackPermitted())) &&
6429 Actions.containsUnexpandedParameterPacks(ParmDeclarator))
6430 DiagnoseMisplacedEllipsisInDeclarator(
ConsumeToken(), ParmDeclarator);
6434 Decl *Param = Actions.ActOnParamDeclarator(
getCurScope(), ParmDeclarator);
6439 if (Tok.
is(tok::equal)) {
6450 if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
6452 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
6454 Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
6470 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
6471 DefArgResult = ParseBraceInitializer();
6474 DefArgResult = Actions.CorrectDelayedTyposInExpr(DefArgResult);
6476 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
6480 Actions.ActOnParamDefaultArgument(Param, EqualLoc,
6481 DefArgResult.
get());
6487 ParmDeclarator.getIdentifierLoc(),
6488 Param, std::move(DefArgToks)));
6495 Diag(EllipsisLoc, diag::err_missing_comma_before_ellipsis)
6497 }
else if (ParmDeclarator.getEllipsisLoc().isValid() ||
6498 Actions.containsUnexpandedParameterPacks(ParmDeclarator)) {
6502 Diag(EllipsisLoc, diag::warn_misplaced_ellipsis_vararg)
6503 << ParmEllipsis.
isValid() << ParmEllipsis;
6506 diag::note_misplaced_ellipsis_vararg_existing_ellipsis);
6508 Diag(ParmDeclarator.getIdentifierLoc(),
6509 diag::note_misplaced_ellipsis_vararg_add_ellipsis)
6512 << !ParmDeclarator.hasName();
6514 Diag(EllipsisLoc, diag::note_misplaced_ellipsis_vararg_add_comma)
6533 void Parser::ParseBracketDeclarator(
Declarator &D) {
6534 if (CheckProhibitedCXX11Attribute())
6542 if (Tok.
getKind() == tok::r_square) {
6545 MaybeParseCXX11Attributes(attrs);
6553 }
else if (Tok.
getKind() == tok::numeric_constant &&
6554 GetLookAheadToken(1).is(tok::r_square)) {
6561 MaybeParseCXX11Attributes(attrs);
6569 }
else if (Tok.
getKind() == tok::code_completion) {
6570 Actions.CodeCompleteBracketDeclarator(
getCurScope());
6571 return cutOffParsing();
6581 ParseTypeQualifierListOpt(DS, AR_CXX11AttributesParsed);
6589 bool isStar =
false;
6596 if (Tok.
is(tok::star) && GetLookAheadToken(1).is(tok::r_square)) {
6600 Diag(StaticLoc, diag::err_unspecified_vla_size_with_static);
6604 }
else if (Tok.
isNot(tok::r_square)) {
6622 Diag(StaticLoc, diag::err_unspecified_size_with_static);
6648 void Parser::ParseMisplacedBracketDeclarator(
Declarator &D) {
6649 assert(Tok.
is(tok::l_square) &&
"Missing opening bracket");
6655 while (Tok.
is(tok::l_square)) {
6656 ParseBracketDeclarator(TempDeclarator);
6662 if (Tok.
is(tok::semi))
6668 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
6673 if (TempDeclarator.getNumTypeObjects() == 0)
6677 bool NeedParens =
false;
6702 for (
unsigned i = 0, e = TempDeclarator.getNumTypeObjects(); i < e; ++i) {
6715 SourceRange BracketRange(StartBracketLoc, EndBracketLoc);
6719 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
6727 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
6740 void Parser::ParseTypeofSpecifier(
DeclSpec &DS) {
6741 assert(Tok.
is(tok::kw_typeof) &&
"Not a typeof specifier");
6745 const bool hasParens = Tok.
is(tok::l_paren);
6754 ExprResult Operand = Actions.CorrectDelayedTyposInExpr(
6755 ParseExprAfterUnaryExprOrTypeTrait(OpTok, isCastExpr, CastTy, CastRange));
6771 const char *PrevSpec =
nullptr;
6776 Actions.getASTContext().getPrintingPolicy()))
6777 Diag(StartLoc, DiagID) << PrevSpec;
6788 Operand = Actions.HandleExprEvaluationContextForTypeof(Operand.
get());
6794 const char *PrevSpec =
nullptr;
6798 DiagID, Operand.
get(),
6799 Actions.getASTContext().getPrintingPolicy()))
6800 Diag(StartLoc, DiagID) << PrevSpec;
6806 void Parser::ParseAtomicSpecifier(
DeclSpec &DS) {
6807 assert(Tok.
is(tok::kw__Atomic) &&
NextToken().
is(tok::l_paren) &&
6808 "Not an atomic specifier");
6830 const char *PrevSpec =
nullptr;
6833 DiagID, Result.
get(),
6834 Actions.getASTContext().getPrintingPolicy()))
6835 Diag(StartLoc, DiagID) << PrevSpec;
6840 bool Parser::TryAltiVecVectorTokenOutOfLine() {
6843 default:
return false;
6846 case tok::kw_signed:
6847 case tok::kw_unsigned:
6852 case tok::kw_double:
6854 case tok::kw___bool:
6855 case tok::kw___pixel:
6856 Tok.
setKind(tok::kw___vector);
6858 case tok::identifier:
6860 Tok.
setKind(tok::kw___vector);
6864 Tok.
setKind(tok::kw___vector);
6872 const char *&PrevSpec,
unsigned &DiagID,
6874 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
6880 case tok::kw_signed:
6881 case tok::kw_unsigned:
6886 case tok::kw_double:
6888 case tok::kw___bool:
6889 case tok::kw___pixel:
6892 case tok::identifier:
void ClearFunctionSpecs()
Defines the clang::ASTContext interface.
static bool isAttributeLateParsed(const IdentifierInfo &II)
isAttributeLateParsed - Return true if the attribute has arguments that require late parsing...
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
no exception specification
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
This is a scope that corresponds to the parameters within a function prototype.
SourceLocation getEndOfPreviousToken()
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
static const TSS TSS_unsigned
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
Code completion occurs within a class, struct, or union.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
static const TST TST_wchar
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an ParsedAttr as an argument.
static bool attributeHasVariadicIdentifierArg(const IdentifierInfo &II)
Determine whether the given attribute has a variadic identifier argument.
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)) {...
bool isEmpty() const
No scope specifier.
static const TST TST_typeofExpr
static const TST TST_char16
Decl - This represents one declaration (or definition), e.g.
RAII object used to inform the actions that we're currently parsing a declaration.
bool SetConstexprSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Is the identifier known as a __declspec-style attribute?
A RAII object used to temporarily suppress access-like checking.
Defines the C++ template declaration subclasses.
The base class of the type hierarchy.
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
SourceLocation getCloseLocation() const
This indicates that the scope corresponds to a function, which means that labels are set here...
One instance of this struct is used for each type in a declarator that is parsed. ...
Declaration of a variable template.
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location...
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
TemplateNameKind Kind
The kind of template that Template refers to.
void ActOnExitFunctionContext()
Wrapper for void* pointer.
Parser - This implements a parser for the C family of languages.
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
TSCS getThreadStorageClassSpec() const
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
SourceLocation getLocEnd() const LLVM_READONLY
static IdentifierLoc * create(ASTContext &Ctx, SourceLocation Loc, IdentifierInfo *Ident)
SourceLocation getEndLoc() const
NameClassificationKind getKind() const
RAII object that enters a new expression evaluation context.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
Information about one declarator, including the parsed type information and the identifier.
bool setFunctionSpecExplicit(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
void setTypeofParensRange(SourceRange range)
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
static const TST TST_interface
RAII object used to temporarily allow the C++ 'this' expression to be used, with the given qualifiers...
static const TST TST_char
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
Describes how types, statements, expressions, and declarations should be printed. ...
Code completion occurs within an Objective-C implementation or category implementation.
RAII object that makes sure paren/bracket/brace count is correct after declaration/statement parsing...
friend class ObjCDeclContextSwitch
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
Represents a parameter to a function.
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
tok::TokenKind getKind() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
bool mayOmitIdentifier() const
mayOmitIdentifier - Return true if the identifier is either optional or not allowed.
Information about a template-id annotation token.
Base wrapper for a particular "section" of type source info.
SourceLocation getFriendSpecLoc() const
Represents a struct/union/class.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
bool TryConsumeToken(tok::TokenKind Expected)
One of these records is kept for each identifier that is lexed.
static const TST TST_decimal32
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
static bool attributeHasIdentifierArg(const IdentifierInfo &II)
Determine whether the given attribute has an identifier argument.
static const TST TST_char8
SourceLocation getTypeSpecTypeLoc() const
static const TST TST_class
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
static const TST TST_double
Code completion occurs following one or more template headers within a class.
bool setFunctionSpecVirtual(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
The iterator over UnresolvedSets.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Token - This structure provides full information about a lexed token.
static const TST TST_enum
void setKind(tok::TokenKind K)
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ...
SourceLocation getLocStart() const LLVM_READONLY
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
bool hasTagDefinition() const
void ClearStorageClassSpecs()
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc, SourceLocation UnalignedQualLoc)
Return a DeclaratorChunk for a pointer.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
void * getAsOpaquePtr() const
static const TST TST_accum
bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool isInvalidType() const
Code completion occurs at top-level or namespace context.
The controlling scope in a if/switch/while/for statement.
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
This is a scope that corresponds to a block/closure object.
bool isFunctionDeclaratorAFunctionDeclaration() const
Return true if a function declarator at this position would be a function declaration.
static ParsedType getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
Represents the results of name lookup.
void setExtension(bool Val=true)
This scope corresponds to an enum.
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 ...
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
static StringRef normalizeAttrName(StringRef Name)
Normalizes an attribute name by dropping prefixed and suffixed __.
void SetRangeBegin(SourceLocation Loc)
SetRangeBegin - Set the start of the source range to Loc, unless it's invalid.
Code completion occurs following one or more template headers.
bool isTypeSpecPipe() const
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl *> Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
SourceRange getRange() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const clang::PrintingPolicy & getPrintingPolicy() const
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool hasAttributes() const
Scope - A scope is a transient data structure that is used while parsing the program.
Represents information about a change in availability for an entity, which is part of the encoding of...
Represents a C++ nested-name-specifier or a global scope specifier.
enum clang::DeclaratorChunk::@196 Kind
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type...
SourceLocation getConstSpecLoc() const
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
bool isCPlusPlusKeyword(const LangOptions &LangOpts) const
Return true if this token is a C++ keyword in the specified language.
void addAtEnd(ParsedAttr *newAttr)
static bool VersionNumberSeparator(const char Separator)
SourceRange getSourceRange() const LLVM_READONLY
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
VersionTuple getOpenCLVersionTuple() const
Return the OpenCL C or C++ version as a VersionTuple.
VersionTuple Version
The version number at which the change occurred.
IdentifierInfo * getIdentifier() const
static const TST TST_float
Code completion occurs within a sequence of declaration specifiers within a function, method, or block.
void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an initializer for the declaratio...
unsigned getFlags() const
getFlags - Return the flags for this scope.
Provides definitions for the various language-specific address spaces.
static const TSW TSW_long
SourceLocation getUnalignedSpecLoc() const
ParsedAttr * addNewTypeTagForDatatype(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierLoc *argumentKind, ParsedType matchingCType, bool layoutCompatible, bool mustBeNull, ParsedAttr::Syntax syntax)
Add type_tag_for_datatype attribute.
void ClearConstexprSpec()
bool mayBeFollowedByCXXDirectInit() const
mayBeFollowedByCXXDirectInit - Return true if the declarator can be followed by a C++ direct initiali...
A class for parsing a declarator.
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear...
void SetRangeStart(SourceLocation Loc)
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
TST getTypeSpecType() const
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
ParsedAttr * addNewPropertyAttr(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierInfo *getterId, IdentifierInfo *setterId, ParsedAttr::Syntax syntaxUsed)
Add microsoft __delspec(property) attribute.
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS, RecordDecl *&AnonRecord)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e...
void setDecompositionBindings(SourceLocation LSquareLoc, ArrayRef< DecompositionDeclarator::Binding > Bindings, SourceLocation RSquareLoc)
Set the decomposition bindings for this declarator.
Represents a character-granular source range.
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, 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())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
bool isExplicitSpecified() const
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
bool ParseUnqualifiedId(CXXScopeSpec &SS, bool EnteringContext, bool AllowDestructorName, bool AllowConstructorName, bool AllowDeductionGuide, ParsedType ObjectType, SourceLocation *TemplateKWLoc, UnqualifiedId &Result)
Parse a C++ unqualified-id (or a C identifier), which describes the name of an entity.
static DeclaratorChunk getPipe(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
TypeResult ActOnTypeName(Scope *S, Declarator &D)
bool isTypeAltiVecVector() const
void setEofData(const void *D)
static bool isPipeDeclerator(const Declarator &D)
SourceLocation getVolatileSpecLoc() const
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
void setAsmLabel(Expr *E)
DeclContext * getDeclContext()
bool isConstexprSpecified() const
static const TST TST_decimal64
This is a compound statement scope.
SourceLocation getStorageClassSpecLoc() const
UnqualifiedIdKind getKind() const
Determine what kind of name we have.
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
void UpdateTypeRep(ParsedType Rep)
SourceLocation KeywordLoc
The location of the keyword indicating the kind of change.
A class for parsing a field declarator.
bool isValid() const
Determine whether this availability change is valid.
SourceLocation Loc
Loc - The place where this type was defined.
static SourceLocation getMissingDeclaratorIdLoc(Declarator &D, SourceLocation Loc)
void setEllipsisLoc(SourceLocation EL)
SourceLocation getEnd() const
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceLocation getOpenLocation() const
static const TST TST_half
bool isFriendSpecified() const
Wraps an identifier and optional source location for the identifier.
void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl)
ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an initializer for the declaration ...
The result type of a method or function.
SourceRange VersionRange
The source range covering the version number.
static const TSW TSW_short
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
bool isFirstDeclarator() const
const LangOptions & getLangOpts() const
bool SetTypeSpecWidth(TSW 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 ...
This is a scope that corresponds to the parameters within a function prototype for a function declara...
bool hasGroupingParens() const
static const TST TST_char32
static const TST TST_fract
A class for parsing a DeclSpec.
bool isTemplateDecl() const
returns true if this declaration is a template
static DeclaratorChunk getParen(SourceLocation LParenLoc, SourceLocation RParenLoc)
Return a DeclaratorChunk for a paren.
Stop skipping at semicolon.
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
SCS getStorageClassSpec() const
static const TST TST_float16
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
Encodes a location in the source.
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
bool isTypeSpecOwned() const
static const TST TST_auto_type
bool TryAnnotateTypeOrScopeToken()
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
static void SetupFixedPointError(const LangOptions &LangOpts, const char *&PrevSpec, unsigned &DiagID, bool &isInvalid)
Syntax
The style used to specify an attribute.
Represents the declaration of a struct/union/class/enum.
void ExitScope()
ExitScope - Pop a scope off the scope stack.
This is a scope that corresponds to the Objective-C @catch statement.
ASTContext & getASTContext() const LLVM_READONLY
static const TST TST_union
IdentifierInfo * getIdentifierInfo() const
ParsedAttr - Represents a syntactic attribute.
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 TSS TSS_signed
ExtensionRAIIObject - This saves the state of extension warnings when constructed and disables them...
void setGroupingParens(bool flag)
ParsedAttr * addNew(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, ParsedAttr::Syntax syntax, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
void EnterScope(unsigned ScopeFlags)
EnterScope - Start a new scope.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
const void * getEofData() const
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang, DeclaratorContext TheContext)
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
void remove(ParsedAttr *ToBeRemoved)
Decl * getRepAsDecl() const
static const TST TST_typeofType
Scope * getCurScope() const
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang)
bool SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
SourceLocation getInlineSpecLoc() const
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
SourceLocation getModulePrivateSpecLoc() const
StringRef getName() const
Return the actual identifier string.
The scope of a struct/union/class definition.
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isNot(tok::TokenKind K) const
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
TSW getTypeSpecWidth() const
ParserCompletionContext
Describes the context in which code completion occurs.
bool setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static bool isInvalid(LocType Loc, bool *Invalid)
Dataflow Directional Tag Classes.
bool isValid() const
Return true if this is a valid SourceLocation object.
bool expectAndConsume(unsigned DiagID=diag::err_expected, const char *Msg="", tok::TokenKind SkipToTok=tok::unknown)
static const TST TST_auto
static const TST TST_void
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
static const TST TST_int128
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
SourceLocation getPipeLoc() const
This is a scope that corresponds to the template parameters of a C++ template.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
SourceLocation getLocEnd() const LLVM_READONLY
The name refers to a template whose specialization produces a type.
static const TST TST_unspecified
unsigned getLength() const
bool isValid() const
A scope specifier is present, and it refers to a real scope.
LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
const TargetInfo & getTargetInfo() const
static const TST TST_decimal128
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void takeAttributesFrom(ParsedAttributes &attrs)
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
static const TSCS TSCS___thread
SourceLocation getVirtualSpecLoc() const
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_typename
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
void ActOnCXXForRangeDecl(Decl *D)
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.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
CXXScopeSpec & getTypeSpecScope()
This is a scope that can contain a declaration.
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
SourceLocation getIdentifierLoc() const
bool isSet() const
Deprecated.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
ParsedAttr * addNewTypeAttr(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ParsedType typeArg, ParsedAttr::Syntax syntaxUsed)
Add an attribute with a single type argument.
void setInvalidType(bool Val=true)
ExprResult ParseConstantExpression(TypeCastState isTypeCast=NotTypeCast)
static DeclaratorChunk getBlockPointer(unsigned TypeQuals, SourceLocation Loc)
Return a DeclaratorChunk for a block.
static bool attributeParsedArgsUnevaluated(const IdentifierInfo &II)
Determine whether the given attribute requires parsing its arguments in an unevaluated context or not...
Captures information about "declaration specifiers".
SourceLocation getRestrictSpecLoc() const
static bool isValidAfterIdentifierInDeclarator(const Token &T)
isValidAfterIdentifierInDeclaratorAfterDeclSpec - Return true if the specified token is valid after t...
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl *> Group)
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
static const TSCS TSCS_thread_local
SourceLocation getEllipsisLoc() const
bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool mayHaveIdentifier() const
mayHaveIdentifier - Return true if the identifier is either optional or required. ...
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
static const TST TST_float128
AvailabilityChange Changes[NumAvailabilitySlots]
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
static const TST TST_bool
bool isVirtualSpecified() const
Decl * getObjCDeclContext() const
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
A template-id, e.g., f<int>.
void Finish(Sema &S, const PrintingPolicy &Policy)
Finish - This does final analysis of the declspec, issuing diagnostics for things like "_Imaginary" (...
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
bool isInlineSpecified() const
void ExtendWithDeclSpec(const DeclSpec &DS)
ExtendWithDeclSpec - Extend the declarator source range to include the given declspec, unless its location is invalid.
SourceLocation getAtomicSpecLoc() const
static const TSW TSW_longlong
static Decl::Kind getKind(const Decl *D)
SourceLocation getExplicitSpecLoc() const
SourceLocation getConstexprSpecLoc() const
static bool attributeIsTypeArgAttr(const IdentifierInfo &II)
Determine whether the given attribute parses a type argument.
static const TST TST_atomic
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
static const TST TST_struct
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed...
DeclaratorContext getContext() const
void setLocation(SourceLocation L)
A trivial tuple used to represent a source range.
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
This represents a decl that may have a name.
__ptr16, alignas(...), etc.
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
static const TSCS TSCS__Thread_local
Callback handler that receives notifications when performing code completion within the preprocessor...
void * getAnnotationValue() const
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
SourceLocation getLocEnd() const LLVM_READONLY
void SetRangeEnd(SourceLocation Loc)
void addAttributes(ParsedAttributesView &AL)
Concatenates two attribute lists.
SourceLocation getBegin() const
ParsedAttributes - A collection of parsed attributes.
void setCommaLoc(SourceLocation CL)
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
void startToken()
Reset all flags to cleared.
Decl * ActOnDeclarator(Scope *S, Declarator &D)
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
static DeclaratorChunk getMemberPointer(const CXXScopeSpec &SS, unsigned TypeQuals, SourceLocation Loc)
bool setFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
Stop skipping at specified token, but don't skip the token itself.
unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template)
SourceLocation getEndLoc() const