28 #include "llvm/ADT/Optional.h" 29 #include "llvm/ADT/SmallSet.h" 30 #include "llvm/ADT/SmallString.h" 31 #include "llvm/ADT/StringSwitch.h" 32 #include "llvm/Support/ScopedPrinter.h" 34 using namespace clang;
50 DeclSpecContext DSC = getDeclSpecContextFromDeclaratorContext(Context);
51 if (DSC == DeclSpecContext::DSC_normal)
52 DSC = DeclSpecContext::DSC_type_specifier;
58 ParseSpecifierQualifierList(DS, AS, DSC);
64 ParseDeclarator(DeclaratorInfo);
76 if (Name.size() >= 4 && Name.startswith(
"__") && Name.endswith(
"__"))
77 return Name.drop_front(2).drop_back(2);
84 #define CLANG_ATTR_LATE_PARSED_LIST 86 #include "clang/Parse/AttrParserStringSwitches.inc" 88 #undef CLANG_ATTR_LATE_PARSED_LIST 134 LateParsedAttrList *LateAttrs,
136 assert(Tok.
is(tok::kw___attribute) &&
"Not a GNU attribute list!");
138 while (Tok.
is(tok::kw___attribute)) {
140 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
145 if (ExpectAndConsume(tok::l_paren, diag::err_expected_lparen_after,
"(")) {
164 if (Tok.
isNot(tok::l_paren)) {
165 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
172 ParseGNUAttributeArgs(AttrName, AttrNameLoc, attrs, endLoc,
nullptr,
178 LateParsedAttribute *LA =
179 new LateParsedAttribute(
this, *AttrName, AttrNameLoc);
180 LateAttrs->push_back(LA);
184 if (!ClassStack.empty() && !LateAttrs->parseSoon())
185 getCurrentClass().LateParsedDeclarations.push_back(LA);
189 LA->Toks.push_back(Tok);
192 ConsumeAndStoreUntil(tok::r_paren, LA->Toks,
true);
197 LA->Toks.push_back(Eof);
200 if (ExpectAndConsume(tok::r_paren))
203 if (ExpectAndConsume(tok::r_paren))
212 #define CLANG_ATTR_IDENTIFIER_ARG_LIST 214 #include "clang/Parse/AttrParserStringSwitches.inc" 216 #undef CLANG_ATTR_IDENTIFIER_ARG_LIST 221 #define CLANG_ATTR_TYPE_ARG_LIST 223 #include "clang/Parse/AttrParserStringSwitches.inc" 225 #undef CLANG_ATTR_TYPE_ARG_LIST 231 #define CLANG_ATTR_ARG_CONTEXT_LIST 233 #include "clang/Parse/AttrParserStringSwitches.inc" 235 #undef CLANG_ATTR_ARG_CONTEXT_LIST 239 assert(Tok.
is(tok::identifier) &&
"expected an identifier");
258 if (Tok.
isNot(tok::r_paren))
270 ScopeName, ScopeLoc, T.
get(), Syntax);
273 ScopeName, ScopeLoc,
nullptr, 0, Syntax);
276 unsigned Parser::ParseAttributeArgsCommon(
284 if (Tok.
is(tok::identifier)) {
295 IsIdentifierArg = Next.
isOneOf(tok::r_paren, tok::comma);
299 ArgExprs.push_back(ParseIdentifierLoc());
302 if (!ArgExprs.empty() ? Tok.
is(tok::comma) : Tok.
isNot(tok::r_paren)) {
304 if (!ArgExprs.empty())
319 if (ArgExpr.isInvalid()) {
323 ArgExprs.push_back(ArgExpr.get());
329 if (!ExpectAndConsume(tok::r_paren)) {
332 ArgExprs.data(), ArgExprs.size(), Syntax);
338 return static_cast<unsigned>(ArgExprs.size());
352 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
357 if (AttrKind == AttributeList::AT_Availability) {
358 ParseAvailabilityAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
361 }
else if (AttrKind == AttributeList::AT_ExternalSourceSymbol) {
362 ParseExternalSourceSymbolAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
363 ScopeName, ScopeLoc, Syntax);
365 }
else if (AttrKind == AttributeList::AT_ObjCBridgeRelated) {
366 ParseObjCBridgeRelatedAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
367 ScopeName, ScopeLoc, Syntax);
369 }
else if (AttrKind == AttributeList::AT_TypeTagForDatatype) {
370 ParseTypeTagForDatatypeAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
371 ScopeName, ScopeLoc, Syntax);
374 ParseAttributeWithTypeArg(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
388 for (
unsigned i = 0; i != FTI.
NumParams; ++i) {
394 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
398 unsigned Parser::ParseClangAttributeArgs(
402 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
407 if (AttrKind == AttributeList::AT_ExternalSourceSymbol) {
408 ParseExternalSourceSymbolAttribute(*AttrName, AttrNameLoc, Attrs, EndLoc,
409 ScopeName, ScopeLoc, Syntax);
413 return ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs, EndLoc,
414 ScopeName, ScopeLoc, Syntax);
432 if (AttrName->
getName() ==
"property") {
447 bool HasInvalidAccessor =
false;
452 if (!Tok.
is(tok::identifier)) {
454 if (Tok.
is(tok::r_paren) && !HasInvalidAccessor &&
455 AccessorNames[AK_Put] ==
nullptr &&
456 AccessorNames[AK_Get] ==
nullptr) {
457 Diag(AttrNameLoc, diag::err_ms_property_no_getter_or_putter);
468 if (KindStr ==
"get") {
470 }
else if (KindStr ==
"put") {
474 }
else if (KindStr ==
"set") {
475 Diag(KindLoc, diag::err_ms_property_has_set_accessor)
482 Diag(KindLoc, diag::err_ms_property_missing_accessor_kind);
484 HasInvalidAccessor =
true;
485 goto next_property_accessor;
489 Diag(KindLoc, diag::err_ms_property_unknown_accessor);
490 HasInvalidAccessor =
true;
509 if (!Tok.
is(tok::identifier)) {
514 if (Kind == AK_Invalid) {
516 }
else if (AccessorNames[Kind] !=
nullptr) {
518 Diag(KindLoc, diag::err_ms_property_duplicate_accessor) << KindStr;
524 next_property_accessor:
530 if (Tok.
is(tok::r_paren))
533 Diag(Tok.
getLocation(), diag::err_ms_property_expected_comma_or_rparen);
538 if (!HasInvalidAccessor)
540 AccessorNames[AK_Get], AccessorNames[AK_Put],
543 return !HasInvalidAccessor;
547 ParseAttributeArgsCommon(AttrName, AttrNameLoc, Attrs,
nullptr,
nullptr,
554 Diag(OpenParenLoc, diag::err_attribute_requires_arguments) << AttrName;
568 assert(
getLangOpts().DeclSpecKeyword &&
"__declspec keyword is not enabled");
569 assert(Tok.
is(tok::kw___declspec) &&
"Not a declspec!");
571 while (Tok.
is(tok::kw___declspec)) {
580 while (Tok.
isNot(tok::r_paren)) {
587 bool IsString = Tok.
getKind() == tok::string_literal;
588 if (!IsString && Tok.
getKind() != tok::identifier &&
589 Tok.
getKind() != tok::kw_restrict) {
590 Diag(Tok, diag::err_ms_declspec_type);
599 bool Invalid =
false;
600 StringRef Str = PP.
getSpelling(Tok, StrBuffer, &Invalid);
606 AttrNameLoc = ConsumeStringToken();
612 bool AttrHandled =
false;
615 if (Tok.
is(tok::l_paren))
616 AttrHandled = ParseMicrosoftDeclSpecArgs(AttrName, AttrNameLoc, Attrs);
617 else if (AttrName->
getName() ==
"property")
623 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
636 case tok::kw___fastcall:
637 case tok::kw___stdcall:
638 case tok::kw___thiscall:
639 case tok::kw___regcall:
640 case tok::kw___cdecl:
641 case tok::kw___vectorcall:
642 case tok::kw___ptr64:
644 case tok::kw___ptr32:
646 case tok::kw___uptr: {
649 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
659 void Parser::DiagnoseAndSkipExtendedMicrosoftTypeAttributes() {
665 Diag(StartLoc, diag::warn_microsoft_qualifiers_ignored) << Range;
675 case tok::kw_volatile:
676 case tok::kw___fastcall:
677 case tok::kw___stdcall:
678 case tok::kw___thiscall:
679 case tok::kw___cdecl:
680 case tok::kw___vectorcall:
681 case tok::kw___ptr32:
682 case tok::kw___ptr64:
684 case tok::kw___unaligned:
697 while (Tok.
is(tok::kw___pascal)) {
700 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
707 while (Tok.
is(tok::kw___kernel)) {
710 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
718 Attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
726 case tok::kw__Nonnull:
727 case tok::kw__Nullable:
728 case tok::kw__Null_unspecified: {
732 Diag(AttrNameLoc, diag::ext_nullability)
734 attrs.
addNew(AttrName, AttrNameLoc,
nullptr, AttrNameLoc,
nullptr, 0,
745 return (Separator ==
'.' || Separator ==
'_');
757 if (!Tok.
is(tok::numeric_constant)) {
758 Diag(Tok, diag::err_expected_version);
770 const char *ThisTokBegin = &Buffer[0];
773 bool Invalid =
false;
774 unsigned ActualLength = PP.
getSpelling(Tok, ThisTokBegin, &Invalid);
779 unsigned AfterMajor = 0;
781 while (AfterMajor < ActualLength &&
isDigit(ThisTokBegin[AfterMajor])) {
782 Major = Major * 10 + ThisTokBegin[AfterMajor] -
'0';
786 if (AfterMajor == 0) {
787 Diag(Tok, diag::err_expected_version);
793 if (AfterMajor == ActualLength) {
798 Diag(Tok, diag::err_zero_version);
805 const char AfterMajorSeparator = ThisTokBegin[AfterMajor];
807 || (AfterMajor + 1 == ActualLength)) {
808 Diag(Tok, diag::err_expected_version);
815 unsigned AfterMinor = AfterMajor + 1;
817 while (AfterMinor < ActualLength &&
isDigit(ThisTokBegin[AfterMinor])) {
818 Minor = Minor * 10 + ThisTokBegin[AfterMinor] -
'0';
822 if (AfterMinor == ActualLength) {
826 if (Major == 0 && Minor == 0) {
827 Diag(Tok, diag::err_zero_version);
831 return VersionTuple(Major, Minor, (AfterMajorSeparator ==
'_'));
834 const char AfterMinorSeparator = ThisTokBegin[AfterMinor];
837 Diag(Tok, diag::err_expected_version);
844 if (AfterMajorSeparator != AfterMinorSeparator)
845 Diag(Tok, diag::warn_expected_consistent_version_separator);
848 unsigned AfterSubminor = AfterMinor + 1;
849 unsigned Subminor = 0;
850 while (AfterSubminor < ActualLength &&
isDigit(ThisTokBegin[AfterSubminor])) {
851 Subminor = Subminor * 10 + ThisTokBegin[AfterSubminor] -
'0';
855 if (AfterSubminor != ActualLength) {
856 Diag(Tok, diag::err_expected_version);
862 return VersionTuple(Major, Minor, Subminor, (AfterMajorSeparator ==
'_'));
890 void Parser::ParseAvailabilityAttribute(
IdentifierInfo &Availability,
897 enum { Introduced, Deprecated, Obsoleted, Unknown };
904 Diag(Tok, diag::err_expected) << tok::l_paren;
909 if (Tok.
isNot(tok::identifier)) {
910 Diag(Tok, diag::err_availability_expected_platform);
917 if (Ident->getName() ==
"macosx")
921 else if (Ident->getName() ==
"macosx_app_extension")
925 AvailabilityAttr::canonicalizePlatformName(Ident->getName()));
929 if (ExpectAndConsume(tok::comma)) {
936 if (!Ident_introduced) {
950 if (Tok.
isNot(tok::identifier)) {
951 Diag(Tok, diag::err_availability_expected_change);
958 if (Keyword == Ident_strict) {
960 Diag(KeywordLoc, diag::err_availability_redundant)
963 StrictLoc = KeywordLoc;
967 if (Keyword == Ident_unavailable) {
968 if (UnavailableLoc.
isValid()) {
969 Diag(KeywordLoc, diag::err_availability_redundant)
972 UnavailableLoc = KeywordLoc;
976 if (Tok.
isNot(tok::equal)) {
977 Diag(Tok, diag::err_expected_after) << Keyword << tok::equal;
982 if (Keyword == Ident_message || Keyword == Ident_replacement) {
983 if (Tok.
isNot(tok::string_literal)) {
984 Diag(Tok, diag::err_expected_string_literal)
989 if (Keyword == Ident_message)
990 MessageExpr = ParseStringLiteralExpression();
992 ReplacementExpr = ParseStringLiteralExpression();
995 cast_or_null<StringLiteral>(MessageExpr.
get())) {
996 if (MessageStringLiteral->getCharByteWidth() != 1) {
997 Diag(MessageStringLiteral->getSourceRange().getBegin(),
998 diag::err_expected_string_literal)
1004 if (Keyword == Ident_message)
1012 if ((Keyword == Ident_introduced || Keyword == Ident_deprecated) &&
1013 Tok.
is(tok::identifier)) {
1017 if (Keyword == Ident_introduced)
1018 UnavailableLoc = KeywordLoc;
1024 VersionTuple Version = ParseVersionTuple(VersionRange);
1026 if (Version.
empty()) {
1032 if (Keyword == Ident_introduced)
1034 else if (Keyword == Ident_deprecated)
1036 else if (Keyword == Ident_obsoleted)
1041 if (Index < Unknown) {
1042 if (!Changes[Index].KeywordLoc.
isInvalid()) {
1043 Diag(KeywordLoc, diag::err_availability_redundant)
1046 Changes[Index].VersionRange.
getEnd());
1050 Changes[Index].
Version = Version;
1053 Diag(KeywordLoc, diag::err_availability_unknown_change)
1054 << Keyword << VersionRange;
1068 if (UnavailableLoc.
isValid()) {
1069 bool Complained =
false;
1070 for (
unsigned Index = Introduced; Index != Unknown; ++Index) {
1071 if (Changes[Index].KeywordLoc.
isValid()) {
1073 Diag(UnavailableLoc, diag::warn_availability_and_unavailable)
1075 Changes[Index].VersionRange.getEnd());
1086 attrs.
addNew(&Availability,
1088 ScopeName, ScopeLoc,
1090 Changes[Introduced],
1091 Changes[Deprecated],
1093 UnavailableLoc, MessageExpr.
get(),
1110 void Parser::ParseExternalSourceSymbolAttribute(
1120 if (!Ident_language) {
1127 bool HasLanguage =
false;
1129 bool HasDefinedIn =
false;
1134 if (Tok.
isNot(tok::identifier)) {
1135 Diag(Tok, diag::err_external_source_symbol_expected_keyword);
1142 if (Keyword == Ident_generated_declaration) {
1143 if (GeneratedDeclaration) {
1144 Diag(Tok, diag::err_external_source_symbol_duplicate_clause) << Keyword;
1148 GeneratedDeclaration = ParseIdentifierLoc();
1152 if (Keyword != Ident_language && Keyword != Ident_defined_in) {
1153 Diag(Tok, diag::err_external_source_symbol_expected_keyword);
1159 if (ExpectAndConsume(tok::equal, diag::err_expected_after,
1165 bool HadLanguage = HasLanguage, HadDefinedIn = HasDefinedIn;
1166 if (Keyword == Ident_language)
1169 HasDefinedIn =
true;
1171 if (Tok.
isNot(tok::string_literal)) {
1172 Diag(Tok, diag::err_expected_string_literal)
1174 << (Keyword != Ident_language);
1178 if (Keyword == Ident_language) {
1180 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1182 ParseStringLiteralExpression();
1185 Language = ParseStringLiteralExpression();
1187 assert(Keyword == Ident_defined_in &&
"Invalid clause keyword!");
1189 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1191 ParseStringLiteralExpression();
1194 DefinedInExpr = ParseStringLiteralExpression();
1205 GeneratedDeclaration};
1207 ScopeName, ScopeLoc, Args, llvm::array_lengthof(Args), Syntax);
1221 void Parser::ParseObjCBridgeRelatedAttribute(
IdentifierInfo &ObjCBridgeRelated,
1231 Diag(Tok, diag::err_expected) << tok::l_paren;
1236 if (Tok.
isNot(tok::identifier)) {
1237 Diag(Tok, diag::err_objcbridge_related_expected_related_class);
1242 if (ExpectAndConsume(tok::comma)) {
1249 if (Tok.
is(tok::identifier)) {
1250 ClassMethod = ParseIdentifierLoc();
1252 Diag(Tok, diag::err_objcbridge_related_selector_name);
1258 if (Tok.
is(tok::colon))
1259 Diag(Tok, diag::err_objcbridge_related_selector_name);
1261 Diag(Tok, diag::err_expected) << tok::comma;
1268 if (Tok.
is(tok::identifier))
1269 InstanceMethod = ParseIdentifierLoc();
1270 else if (Tok.
isNot(tok::r_paren)) {
1271 Diag(Tok, diag::err_expected) << tok::r_paren;
1284 attrs.
addNew(&ObjCBridgeRelated,
1286 ScopeName, ScopeLoc,
1296 void Parser::LateParsedDeclaration::ParseLexedAttributes() {}
1298 void Parser::LateParsedClass::ParseLexedAttributes() {
1299 Self->ParseLexedAttributes(*Class);
1302 void Parser::LateParsedAttribute::ParseLexedAttributes() {
1303 Self->ParseLexedAttribute(*
this,
true,
false);
1308 void Parser::ParseLexedAttributes(ParsingClass &Class) {
1311 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
1314 if (HasTemplateScope)
1318 bool AlreadyHasClassScope = Class.TopLevelClass;
1320 ParseScope ClassScope(
this, ScopeFlags, !AlreadyHasClassScope);
1321 ParseScopeFlags ClassScopeFlags(
this, ScopeFlags, AlreadyHasClassScope);
1324 if (!AlreadyHasClassScope)
1326 Class.TagOrTemplate);
1327 if (!Class.LateParsedDeclarations.empty()) {
1328 for (
unsigned i = 0, ni = Class.LateParsedDeclarations.size(); i < ni; ++i){
1329 Class.LateParsedDeclarations[i]->ParseLexedAttributes();
1333 if (!AlreadyHasClassScope)
1335 Class.TagOrTemplate);
1339 void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
1341 assert(LAs.parseSoon() &&
1342 "Attribute list should be marked for immediate parsing.");
1343 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
1346 ParseLexedAttribute(*LAs[i],
EnterScope, OnDefinition);
1357 void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
1366 LA.Toks.push_back(AttrEnd);
1370 LA.Toks.push_back(Tok);
1371 PP.EnterTokenStream(LA.Toks,
true);
1378 if (LA.Decls.size() > 0) {
1379 Decl *D = LA.Decls[0];
1387 if (LA.Decls.size() == 1) {
1391 if (HasTemplateScope)
1402 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc,
1410 if (HasTemplateScope) {
1416 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc,
1421 Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();
1427 Diag(Tok, diag::warn_attribute_on_function_definition)
1430 for (
unsigned i = 0, ni = LA.Decls.size(); i < ni; ++i)
1442 void Parser::ParseTypeTagForDatatypeAttribute(
IdentifierInfo &AttrName,
1449 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
1454 if (Tok.
isNot(tok::identifier)) {
1455 Diag(Tok, diag::err_expected) << tok::identifier;
1461 if (ExpectAndConsume(tok::comma)) {
1473 bool LayoutCompatible =
false;
1474 bool MustBeNull =
false;
1476 if (Tok.
isNot(tok::identifier)) {
1477 Diag(Tok, diag::err_expected) << tok::identifier;
1482 if (Flag->
isStr(
"layout_compatible"))
1483 LayoutCompatible =
true;
1484 else if (Flag->
isStr(
"must_be_null"))
1487 Diag(Tok, diag::err_type_safety_unknown_flag) << Flag;
1494 if (!T.consumeClose()) {
1496 ArgumentKind, MatchingCType.
get(),
1497 LayoutCompatible, MustBeNull, Syntax);
1501 *EndLoc = T.getCloseLocation();
1512 bool Parser::DiagnoseProhibitedCXX11Attribute() {
1513 assert(Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square));
1515 switch (isCXX11AttributeSpecifier(
true)) {
1516 case CAK_NotAttributeSpecifier:
1520 case CAK_InvalidAttributeSpecifier:
1524 case CAK_AttributeSpecifier:
1529 assert(Tok.
is(tok::r_square) &&
"isCXX11AttributeSpecifier lied");
1531 Diag(BeginLoc, diag::err_attributes_not_allowed)
1535 llvm_unreachable(
"All cases handled above.");
1542 void Parser::DiagnoseMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
1544 assert((Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square)) ||
1545 Tok.
is(tok::kw_alignas));
1549 ParseCXX11Attributes(Attrs);
1552 Diag(Loc, diag::err_attributes_not_allowed)
1557 void Parser::DiagnoseProhibitedAttributes(ParsedAttributesWithRange &attrs,
1559 if (CorrectLocation.
isValid()) {
1561 Diag(CorrectLocation, diag::err_attributes_misplaced)
1565 Diag(attrs.Range.getBegin(), diag::err_attributes_not_allowed) << attrs.Range;
1568 void Parser::ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
1571 if (!
Attr->isCXX11Attribute() && !
Attr->isC2xAttribute())
1574 Diag(
Attr->getLoc(), diag::warn_unknown_attribute_ignored)
1591 void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
1605 if ((AL->
getKind() == AttributeList::AT_Aligned &&
1614 TypeAttrTail->
setNext(
nullptr);
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);
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();
2021 Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(
2022 D, ParsedTemplateInfo(), FRI);
2023 if (LateParsedAttrs.size() > 0)
2024 ParseLexedAttributeList(LateParsedAttrs, FirstDecl,
true,
false);
2027 DeclsInGroup.push_back(FirstDecl);
2035 if (Tok.
isAtStartOfLine() && ExpectSemi && !MightBeDeclarator(Context)) {
2039 Diag(CommaLoc, diag::err_expected_semi_declaration)
2056 MaybeParseGNUAttributes(D);
2060 DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2064 Decl *ThisDecl = ParseDeclarationAfterDeclarator(D);
2067 DeclsInGroup.push_back(ThisDecl);
2076 ? diag::err_invalid_token_after_toplevel_declarator
2077 : diag::err_expected_semi_declaration)) {
2081 if (!isDeclarationSpecifier()) {
2092 bool Parser::ParseAsmAttributesAfterDeclarator(
Declarator &D) {
2094 if (Tok.
is(tok::kw_asm)) {
2106 MaybeParseGNUAttributes(D);
2132 Decl *Parser::ParseDeclarationAfterDeclarator(
2133 Declarator &D,
const ParsedTemplateInfo &TemplateInfo) {
2134 if (ParseAsmAttributesAfterDeclarator(D))
2137 return ParseDeclarationAfterDeclaratorAndAttributes(D, TemplateInfo);
2140 Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
2141 Declarator &D,
const ParsedTemplateInfo &TemplateInfo, ForRangeInit *FRI) {
2143 struct InitializerScopeRAII {
2149 :
P(P), D(D), ThisDecl(ThisDecl) {
2159 ~InitializerScopeRAII() { pop(); }
2174 Decl *ThisDecl =
nullptr;
2175 switch (TemplateInfo.Kind) {
2176 case ParsedTemplateInfo::NonTemplate:
2177 ThisDecl = Actions.ActOnDeclarator(
getCurScope(), D);
2180 case ParsedTemplateInfo::Template:
2181 case ParsedTemplateInfo::ExplicitSpecialization: {
2182 ThisDecl = Actions.ActOnTemplateDeclarator(
getCurScope(),
2183 *TemplateInfo.TemplateParams,
2185 if (
VarTemplateDecl *VT = dyn_cast_or_null<VarTemplateDecl>(ThisDecl))
2188 ThisDecl = VT->getTemplatedDecl();
2191 case ParsedTemplateInfo::ExplicitInstantiation: {
2192 if (Tok.
is(tok::semi)) {
2193 DeclResult ThisRes = Actions.ActOnExplicitInstantiation(
2194 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc, D);
2199 ThisDecl = ThisRes.
get();
2207 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2209 ThisDecl = Actions.ActOnDeclarator(
getCurScope(), D);
2212 PP.getLocForEndOfToken(TemplateInfo.TemplateLoc);
2214 diag::err_explicit_instantiation_with_definition)
2220 FakedParamLists.push_back(Actions.ActOnTemplateParameterList(
2222 LAngleLoc,
nullptr));
2225 Actions.ActOnTemplateDeclarator(
getCurScope(), FakedParamLists, D);
2234 if (isTokenEqualOrEqualTypo()) {
2237 if (Tok.
is(tok::kw_delete)) {
2243 }
else if (Tok.
is(tok::kw_default)) {
2250 InitializerScopeRAII InitScope(*
this, D, ThisDecl);
2252 if (Tok.
is(tok::code_completion)) {
2253 Actions.CodeCompleteInitializer(
getCurScope(), ThisDecl);
2254 Actions.FinalizeDeclaration(ThisDecl);
2264 Diag(EqualLoc, diag::err_single_decl_assign_in_for_range)
2268 FRI->ColonLoc = EqualLoc;
2270 FRI->RangeExpr = Init;
2277 StopTokens.push_back(tok::comma);
2280 StopTokens.push_back(tok::r_paren);
2282 Actions.ActOnInitializerError(ThisDecl);
2284 Actions.AddInitializerToDecl(ThisDecl, Init.
get(),
2287 }
else if (Tok.
is(tok::l_paren)) {
2295 InitializerScopeRAII InitScope(*
this, D, ThisDecl);
2297 llvm::function_ref<void()> ExprListCompleter;
2298 auto ThisVarDecl = dyn_cast_or_null<VarDecl>(ThisDecl);
2299 auto ConstructorCompleter = [&, ThisVarDecl] {
2300 Actions.CodeCompleteConstructor(
2301 getCurScope(), ThisVarDecl->getType()->getCanonicalTypeInternal(),
2310 ExprListCompleter = ConstructorCompleter;
2313 if (ParseExpressionList(Exprs, CommaLocs, ExprListCompleter)) {
2314 Actions.ActOnInitializerError(ThisDecl);
2320 assert(!Exprs.empty() && Exprs.size()-1 == CommaLocs.size() &&
2321 "Unexpected number of commas!");
2328 Actions.AddInitializerToDecl(ThisDecl, Initializer.
get(),
2331 }
else if (
getLangOpts().CPlusPlus11 && Tok.
is(tok::l_brace) &&
2334 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2336 InitializerScopeRAII InitScope(*
this, D, ThisDecl);
2343 Actions.ActOnInitializerError(ThisDecl);
2345 Actions.AddInitializerToDecl(ThisDecl, Init.
get(),
true);
2348 Actions.ActOnUninitializedDecl(ThisDecl);
2351 Actions.FinalizeDeclaration(ThisDecl);
2363 DeclSpecContext DSC) {
2367 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS, DSC);
2372 Diag(Tok, diag::err_expected_type);
2375 Diag(Tok, diag::err_typename_requires_specqual);
2386 diag::err_typename_invalid_storageclass);
2427 return T.
isOneOf(tok::l_square, tok::l_paren, tok::r_paren, tok::semi,
2428 tok::comma, tok::equal, tok::kw_asm, tok::l_brace,
2442 const ParsedTemplateInfo &TemplateInfo,
2444 ParsedAttributesWithRange &Attrs) {
2445 assert(Tok.
is(tok::identifier) &&
"should have identifier");
2467 if (!isTypeSpecifier(DSC) && !
getLangOpts().CPlusPlus &&
2480 AnnotateScopeToken(*SS,
false);
2489 if (
ParsedType T = Actions.ActOnMSVCUnknownTypeName(
2490 *Tok.getIdentifierInfo(), Tok.getLocation(),
2491 DSC == DeclSpecContext::DSC_template_type_arg)) {
2492 const char *PrevSpec;
2495 Actions.getASTContext().getPrintingPolicy());
2508 if (SS ==
nullptr) {
2509 const char *TagName =
nullptr, *FixitTagName =
nullptr;
2512 switch (Actions.isTagName(*Tok.getIdentifierInfo(),
getCurScope())) {
2515 TagName=
"enum" ; FixitTagName =
"enum " ; TagKind=tok::kw_enum ;
break;
2517 TagName=
"union" ; FixitTagName =
"union " ;TagKind=tok::kw_union ;
break;
2519 TagName=
"struct"; FixitTagName =
"struct ";TagKind=tok::kw_struct;
break;
2521 TagName=
"__interface"; FixitTagName =
"__interface ";
2522 TagKind=tok::kw___interface;
break;
2524 TagName=
"class" ; FixitTagName =
"class " ;TagKind=tok::kw_class ;
break;
2532 Diag(Loc, diag::err_use_of_tag_name_without_tag)
2533 << TokenName << TagName <<
getLangOpts().CPlusPlus
2536 if (Actions.LookupParsedName(R,
getCurScope(), SS)) {
2539 Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
2540 << TokenName << TagName;
2544 if (TagKind == tok::kw_enum)
2545 ParseEnumSpecifier(Loc, DS, TemplateInfo, AS,
2546 DeclSpecContext::DSC_normal);
2548 ParseClassSpecifier(TagKind, Loc, DS, TemplateInfo, AS,
2550 DeclSpecContext::DSC_normal, Attrs);
2557 if (!isTypeSpecifier(DSC) && (!SS || DSC == DeclSpecContext::DSC_top_level ||
2558 DSC == DeclSpecContext::DSC_class)) {
2562 case tok::l_paren: {
2569 TentativeParsingAction PA(*
this);
2571 TPResult TPR = TryParseDeclarator(
false);
2574 if (TPR != TPResult::False) {
2582 if (DSC == DeclSpecContext::DSC_class ||
2583 (DSC == DeclSpecContext::DSC_top_level && SS)) {
2585 if (Actions.isCurrentClassNameTypo(II, SS)) {
2586 Diag(Loc, diag::err_constructor_bad_name)
2587 << Tok.getIdentifierInfo() << II
2589 Tok.setIdentifierInfo(II);
2604 AnnotateScopeToken(*SS,
false);
2620 Actions.DiagnoseUnknownTypeName(II, Loc,
getCurScope(), SS, T,
2626 const char *PrevSpec;
2629 Actions.getASTContext().getPrintingPolicy());
2634 }
else if (II != Tok.getIdentifierInfo()) {
2647 if (IsTemplateName) {
2649 TemplateArgList Args;
2650 ParseTemplateIdAfterTemplateName(
true, LAngle, Args, RAngle);
2664 Parser::DeclSpecContext
2667 return DeclSpecContext::DSC_class;
2669 return DeclSpecContext::DSC_top_level;
2671 return DeclSpecContext::DSC_template_param;
2673 return DeclSpecContext::DSC_template_type_arg;
2675 return DeclSpecContext::DSC_trailing;
2678 return DeclSpecContext::DSC_alias_declaration;
2679 return DeclSpecContext::DSC_normal;
2694 if (isTypeIdInParens()) {
2698 ER = Actions.ActOnUnaryExprOrTypeTraitExpr(TypeLoc,
UETT_AlignOf,
true,
2719 assert(Tok.
isOneOf(tok::kw_alignas, tok::kw__Alignas) &&
2720 "Not an alignment-specifier!");
2741 ArgExprs.push_back(ArgExpr.
get());
2742 Attrs.
addNew(KWName, KWLoc,
nullptr, KWLoc, ArgExprs.data(), 1,
2755 DeclSpecContext DSContext,
2756 LateParsedAttrList *LateAttrs) {
2759 bool EnteringContext = (DSContext == DeclSpecContext::DSC_class ||
2760 DSContext == DeclSpecContext::DSC_top_level);
2763 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype,
2764 tok::annot_template_id) &&
2770 bool HasScope = Tok.
is(tok::annot_cxxscope);
2776 bool MightBeDeclarator =
true;
2777 if (Tok.
isOneOf(tok::kw_typename, tok::annot_typename)) {
2779 MightBeDeclarator =
false;
2780 }
else if (AfterScope.
is(tok::annot_template_id)) {
2786 MightBeDeclarator =
false;
2787 }
else if (AfterScope.
is(tok::identifier)) {
2788 const Token &Next = HasScope ? GetLookAheadToken(2) :
NextToken();
2792 if (Next.
isOneOf(tok::star, tok::amp, tok::ampamp, tok::identifier,
2793 tok::annot_cxxscope, tok::coloncolon)) {
2795 MightBeDeclarator =
false;
2796 }
else if (HasScope) {
2801 Actions.RestoreNestedNameSpecifierAnnotation(
2802 Tok.getAnnotationValue(), Tok.getAnnotationRange(), SS);
2807 switch (Classification.
getKind()) {
2814 llvm_unreachable(
"typo correction and nested name specifiers not " 2820 MightBeDeclarator =
false;
2833 if (MightBeDeclarator)
2836 const PrintingPolicy &PPol = Actions.getASTContext().getPrintingPolicy();
2838 diag::err_expected_after)
2849 ParsedTemplateInfo NotATemplate;
2850 ParseDeclarationSpecifiers(DS, NotATemplate, AS, DSContext, LateAttrs);
2881 void Parser::ParseDeclarationSpecifiers(
DeclSpec &DS,
2882 const ParsedTemplateInfo &TemplateInfo,
2884 DeclSpecContext DSContext,
2885 LateParsedAttrList *LateAttrs) {
2894 bool EnteringContext = (DSContext == DeclSpecContext::DSC_class ||
2895 DSContext == DeclSpecContext::DSC_top_level);
2896 bool AttrsLastTime =
false;
2897 ParsedAttributesWithRange attrs(AttrFactory);
2902 bool isStorageClass =
false;
2903 const char *PrevSpec =
nullptr;
2904 unsigned DiagID = 0;
2916 Tok.setKind(tok::identifier);
2920 switch (Tok.getKind()) {
2924 ProhibitAttributes(attrs);
2929 ProhibitCXX11Attributes(attrs, diag::err_attribute_not_type_attr);
2936 DS.
Finish(Actions, Policy);
2940 case tok::kw_alignas:
2941 if (!standardAttributesAllowed() || !isCXX11AttributeSpecifier())
2942 goto DoneWithDeclSpec;
2944 ProhibitAttributes(attrs);
2951 ParseCXX11Attributes(attrs);
2952 AttrsLastTime =
true;
2955 case tok::code_completion: {
2958 bool AllowNonIdentifiers
2964 bool AllowNestedNameSpecifiers
2965 = DSContext == DeclSpecContext::DSC_top_level ||
2969 AllowNonIdentifiers,
2970 AllowNestedNameSpecifiers);
2971 return cutOffParsing();
2976 else if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
2979 else if (DSContext == DeclSpecContext::DSC_class)
2981 else if (CurParsedObjCImpl)
2984 Actions.CodeCompleteOrdinaryName(
getCurScope(), CCC);
2985 return cutOffParsing();
2988 case tok::coloncolon:
2993 goto DoneWithDeclSpec;
2995 if (Tok.
is(tok::coloncolon))
2996 goto DoneWithDeclSpec;
2999 case tok::annot_cxxscope: {
3001 goto DoneWithDeclSpec;
3004 Actions.RestoreNestedNameSpecifierAnnotation(Tok.getAnnotationValue(),
3005 Tok.getAnnotationRange(),
3010 if (Next.
is(tok::annot_template_id) &&
3023 if ((DSContext == DeclSpecContext::DSC_top_level ||
3024 DSContext == DeclSpecContext::DSC_class) &&
3027 isConstructorDeclarator(
false)) {
3032 goto DoneWithDeclSpec;
3036 ConsumeAnnotationToken();
3037 assert(Tok.
is(tok::annot_template_id) &&
3038 "ParseOptionalCXXScopeSpecifier not working");
3039 AnnotateTemplateIdTokenAsType();
3043 if (Next.
is(tok::annot_typename)) {
3045 ConsumeAnnotationToken();
3046 if (Tok.getAnnotationValue()) {
3049 Tok.getAnnotationEndLoc(),
3050 PrevSpec, DiagID,
T, Policy);
3057 ConsumeAnnotationToken();
3060 if (Next.
isNot(tok::identifier))
3061 goto DoneWithDeclSpec;
3066 if ((DSContext == DeclSpecContext::DSC_top_level ||
3067 DSContext == DeclSpecContext::DSC_class) &&
3070 isConstructorDeclarator(
false))
3071 goto DoneWithDeclSpec;
3078 isClassTemplateDeductionContext(DSContext));
3086 ConsumeAnnotationToken();
3087 ParsedAttributesWithRange Attrs(AttrFactory);
3088 if (ParseImplicitInt(DS, &SS, TemplateInfo, AS, DSContext, Attrs)) {
3089 if (!Attrs.empty()) {
3090 AttrsLastTime =
true;
3091 attrs.takeAllFrom(Attrs);
3095 goto DoneWithDeclSpec;
3099 ConsumeAnnotationToken();
3102 DiagID, TypeRep, Policy);
3112 case tok::annot_typename: {
3116 goto DoneWithDeclSpec;
3118 if (Tok.getAnnotationValue()) {
3129 ConsumeAnnotationToken();
3134 case tok::kw___is_signed:
3145 TryKeywordIdentFallback(
true);
3148 goto DoneWithDeclSpec;
3151 case tok::kw___super:
3152 case tok::kw_decltype:
3153 case tok::identifier: {
3158 goto DoneWithDeclSpec;
3164 if (!
getLangOpts().DeclSpecKeyword && Tok.
is(tok::identifier) &&
3165 Tok.getIdentifierInfo()->getName().equals(
"__declspec")) {
3166 Diag(Loc, diag::err_ms_attributes_not_enabled);
3177 assert(
false &&
"Not a left paren?");
3190 goto DoneWithDeclSpec;
3192 if (!Tok.
is(tok::identifier))
3197 if (TryAltiVecToken(DS, Loc, PrevSpec, DiagID, isInvalid))
3203 goto DoneWithDeclSpec;
3205 if (DSContext == DeclSpecContext::DSC_objc_method_result &&
3206 isObjCInstancetype()) {
3207 ParsedType TypeRep = Actions.ActOnObjCInstanceType(Loc);
3210 DiagID, TypeRep, Policy);
3220 *Tok.getIdentifierInfo(), Tok.getLocation(),
getCurScope(),
nullptr,
3221 false,
false,
nullptr,
false,
false,
3222 isClassTemplateDeductionContext(DSContext));
3227 ParsedAttributesWithRange Attrs(AttrFactory);
3228 if (ParseImplicitInt(DS,
nullptr, TemplateInfo, AS, DSContext, Attrs)) {
3229 if (!Attrs.empty()) {
3230 AttrsLastTime =
true;
3231 attrs.takeAllFrom(Attrs);
3235 goto DoneWithDeclSpec;
3241 Actions.isCurrentClassName(*Tok.getIdentifierInfo(),
getCurScope()) &&
3242 isConstructorDeclarator(
true))
3243 goto DoneWithDeclSpec;
3248 (DSContext == DeclSpecContext::DSC_class ||
3249 DSContext == DeclSpecContext::DSC_top_level) &&
3250 Actions.isDeductionGuideName(
getCurScope(), *Tok.getIdentifierInfo(),
3251 Tok.getLocation()) &&
3252 isConstructorDeclarator(
true,
3254 goto DoneWithDeclSpec;
3257 DiagID, TypeRep, Policy);
3269 TypeResult NewTypeRep = parseObjCTypeArgsAndProtocolQualifiers(
3284 case tok::annot_template_id: {
3289 goto DoneWithDeclSpec;
3297 isConstructorDeclarator(TemplateId->
SS.
isEmpty()))
3298 goto DoneWithDeclSpec;
3302 AnnotateTemplateIdTokenAsType();
3307 case tok::kw___attribute:
3312 case tok::kw___declspec:
3317 case tok::kw___forceinline: {
3326 case tok::kw___unaligned:
3331 case tok::kw___sptr:
3332 case tok::kw___uptr:
3333 case tok::kw___ptr64:
3334 case tok::kw___ptr32:
3336 case tok::kw___cdecl:
3337 case tok::kw___stdcall:
3338 case tok::kw___fastcall:
3339 case tok::kw___thiscall:
3340 case tok::kw___regcall:
3341 case tok::kw___vectorcall:
3346 case tok::kw___pascal:
3351 case tok::kw___kernel:
3356 case tok::kw__Nonnull:
3357 case tok::kw__Nullable:
3358 case tok::kw__Null_unspecified:
3363 case tok::kw___kindof:
3370 case tok::kw_typedef:
3372 PrevSpec, DiagID, Policy);
3373 isStorageClass =
true;
3375 case tok::kw_extern:
3377 Diag(Tok, diag::ext_thread_before) <<
"extern";
3379 PrevSpec, DiagID, Policy);
3380 isStorageClass =
true;
3382 case tok::kw___private_extern__:
3384 Loc, PrevSpec, DiagID, Policy);
3385 isStorageClass =
true;
3387 case tok::kw_static:
3389 Diag(Tok, diag::ext_thread_before) <<
"static";
3391 PrevSpec, DiagID, Policy);
3392 isStorageClass =
true;
3396 if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
3398 PrevSpec, DiagID, Policy);
3400 Diag(Tok, diag::ext_auto_storage_class)
3407 PrevSpec, DiagID, Policy);
3408 isStorageClass =
true;
3410 case tok::kw___auto_type:
3411 Diag(Tok, diag::ext_auto_type);
3415 case tok::kw_register:
3417 PrevSpec, DiagID, Policy);
3418 isStorageClass =
true;
3420 case tok::kw_mutable:
3422 PrevSpec, DiagID, Policy);
3423 isStorageClass =
true;
3425 case tok::kw___thread:
3428 isStorageClass =
true;
3430 case tok::kw_thread_local:
3434 case tok::kw__Thread_local:
3436 Loc, PrevSpec, DiagID);
3437 isStorageClass =
true;
3441 case tok::kw_inline:
3444 case tok::kw_virtual:
3447 case tok::kw_explicit:
3450 case tok::kw__Noreturn:
3452 Diag(Loc, diag::ext_c11_noreturn);
3457 case tok::kw__Alignas:
3459 Diag(Tok, diag::ext_c11_alignment) << Tok.getName();
3464 case tok::kw_friend:
3465 if (DSContext == DeclSpecContext::DSC_class)
3469 DiagID = diag::err_friend_invalid_in_context;
3475 case tok::kw___module_private__:
3480 case tok::kw_constexpr:
3497 case tok::kw___int64:
3501 case tok::kw_signed:
3505 case tok::kw_unsigned:
3509 case tok::kw__Complex:
3513 case tok::kw__Imaginary:
3529 case tok::kw___int128:
3541 case tok::kw_double:
3545 case tok::kw__Float16:
3549 case tok::kw___float128:
3553 case tok::kw_wchar_t:
3557 case tok::kw_char16_t:
3561 case tok::kw_char32_t:
3567 if (Tok.
is(tok::kw_bool) &&
3571 DiagID = diag::err_bool_redeclaration;
3573 Tok.setKind(tok::identifier);
3580 case tok::kw__Decimal32:
3584 case tok::kw__Decimal64:
3588 case tok::kw__Decimal128:
3592 case tok::kw___vector:
3595 case tok::kw___pixel:
3598 case tok::kw___bool:
3605 Tok.getIdentifierInfo()->revertTokenIDToIdentifier();
3606 goto DoneWithDeclSpec;
3608 isInvalid = DS.
SetTypePipe(
true, Loc, PrevSpec, DiagID, Policy);
3610 #define GENERIC_IMAGE_TYPE(ImgType, Id) \ 3611 case tok::kw_##ImgType##_t: \ 3612 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, \ 3615 #include "clang/Basic/OpenCLImageTypes.def" 3616 case tok::kw___unknown_anytype:
3618 PrevSpec, DiagID, Policy);
3623 case tok::kw_struct:
3624 case tok::kw___interface:
3625 case tok::kw_union: {
3632 ParsedAttributesWithRange Attributes(AttrFactory);
3633 ParseClassSpecifier(Kind, Loc, DS, TemplateInfo, AS,
3634 EnteringContext, DSContext, Attributes);
3638 if (!Attributes.empty()) {
3639 AttrsLastTime =
true;
3640 attrs.takeAllFrom(Attributes);
3648 ParseEnumSpecifier(Loc, DS, TemplateInfo, AS, DSContext);
3656 case tok::kw_volatile:
3660 case tok::kw_restrict:
3666 case tok::kw_typename:
3669 goto DoneWithDeclSpec;
3671 if (!Tok.
is(tok::kw_typename))
3676 case tok::kw_typeof:
3677 ParseTypeofSpecifier(DS);
3680 case tok::annot_decltype:
3681 ParseDecltypeSpecifier(DS);
3684 case tok::annot_pragma_pack:
3688 case tok::annot_pragma_ms_pragma:
3689 HandlePragmaMSPragma();
3692 case tok::annot_pragma_ms_vtordisp:
3693 HandlePragmaMSVtorDisp();
3696 case tok::annot_pragma_ms_pointers_to_members:
3697 HandlePragmaMSPointersToMembers();
3700 case tok::kw___underlying_type:
3701 ParseUnderlyingTypeSpecifier(DS);
3704 case tok::kw__Atomic:
3710 ParseAtomicSpecifier(DS);
3718 case tok::kw___generic:
3721 if (Actions.getLangOpts().OpenCLVersion < 200) {
3722 DiagID = diag::err_opencl_unknown_type_specifier;
3723 PrevSpec = Tok.getIdentifierInfo()->getNameStart();
3728 case tok::kw___private:
3729 case tok::kw___global:
3730 case tok::kw___local:
3731 case tok::kw___constant:
3732 case tok::kw___read_only:
3733 case tok::kw___write_only:
3734 case tok::kw___read_write:
3743 goto DoneWithDeclSpec;
3750 PrevSpec, DiagID, Type.
get(),
3751 Actions.getASTContext().getPrintingPolicy()))
3752 Diag(StartLoc, DiagID) << PrevSpec;
3765 assert(PrevSpec &&
"Method did not return previous specifier!");
3768 if (DiagID == diag::ext_duplicate_declspec)
3771 else if (DiagID == diag::err_opencl_unknown_type_specifier) {
3772 const int OpenCLVer =
getLangOpts().OpenCLVersion;
3773 std::string VerSpec = llvm::to_string(OpenCLVer / 100) +
3775 llvm::to_string((OpenCLVer % 100) / 10);
3776 Diag(Tok, DiagID) << VerSpec << PrevSpec << isStorageClass;
3778 Diag(Tok, DiagID) << PrevSpec;
3782 if (DiagID != diag::err_bool_redeclaration)
3785 AttrsLastTime =
false;
3807 void Parser::ParseStructDeclaration(
3811 if (Tok.
is(tok::kw___extension__)) {
3815 return ParseStructDeclaration(DS, FieldsCallback);
3819 ParsedAttributesWithRange Attrs(AttrFactory);
3820 MaybeParseCXX11Attributes(Attrs);
3824 ParseSpecifierQualifierList(DS);
3828 if (Tok.
is(tok::semi)) {
3832 assert(!AnonRecord &&
"Did not expect anonymous struct or union here");
3838 bool FirstDeclarator =
true;
3845 if (!FirstDeclarator)
3846 MaybeParseGNUAttributes(DeclaratorInfo.
D);
3850 if (Tok.
isNot(tok::colon)) {
3853 ParseDeclarator(DeclaratorInfo.
D);
3866 MaybeParseGNUAttributes(DeclaratorInfo.
D);
3869 FieldsCallback(DeclaratorInfo);
3876 FirstDeclarator =
false;
3893 "parsing struct/union body");
3901 Actions.ActOnTagStartDefinition(
getCurScope(), TagDecl);
3906 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3911 if (Tok.
is(tok::semi)) {
3912 ConsumeExtraSemi(InsideStruct,
TagType);
3917 if (Tok.
is(tok::kw__Static_assert)) {
3919 ParseStaticAssertDeclaration(DeclEnd);
3923 if (Tok.
is(tok::annot_pragma_pack)) {
3928 if (Tok.
is(tok::annot_pragma_align)) {
3929 HandlePragmaAlign();
3933 if (Tok.
is(tok::annot_pragma_openmp)) {
3936 ParsedAttributesWithRange Attrs(AttrFactory);
3937 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
3941 if (!Tok.
is(tok::at)) {
3947 FD.D, FD.BitfieldSize);
3948 FieldDecls.push_back(Field);
3954 ParseStructDeclaration(DS, CFieldCallback);
3958 Diag(Tok, diag::err_unexpected_at);
3963 ExpectAndConsume(tok::l_paren);
3964 if (!Tok.
is(tok::identifier)) {
3965 Diag(Tok, diag::err_expected) << tok::identifier;
3970 Actions.ActOnDefs(
getCurScope(), TagDecl, Tok.getLocation(),
3971 Tok.getIdentifierInfo(), Fields);
3972 FieldDecls.insert(FieldDecls.end(), Fields.begin(), Fields.end());
3974 ExpectAndConsume(tok::r_paren);
3980 if (Tok.
is(tok::r_brace)) {
3981 ExpectAndConsume(tok::semi, diag::ext_expected_semi_decl_list);
3985 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
3996 MaybeParseGNUAttributes(attrs);
3999 RecordLoc, TagDecl, FieldDecls,
4037 const ParsedTemplateInfo &TemplateInfo,
4040 if (Tok.
is(tok::code_completion)) {
4043 return cutOffParsing();
4047 ParsedAttributesWithRange attrs(AttrFactory);
4048 MaybeParseGNUAttributes(attrs);
4049 MaybeParseCXX11Attributes(attrs);
4050 MaybeParseMicrosoftDeclSpecs(attrs);
4053 bool IsScopedUsingClassTag =
false;
4056 if (Tok.
isOneOf(tok::kw_class, tok::kw_struct)) {
4058 : diag::ext_scoped_enum);
4059 IsScopedUsingClassTag = Tok.
is(tok::kw_class);
4064 ProhibitAttributes(attrs);
4067 MaybeParseGNUAttributes(attrs);
4068 MaybeParseCXX11Attributes(attrs);
4069 MaybeParseMicrosoftDeclSpecs(attrs);
4078 bool shouldDelayDiagsInTag =
4079 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
4080 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
4084 bool AllowDeclaration = DSC != DeclSpecContext::DSC_trailing;
4086 bool AllowFixedUnderlyingType = AllowDeclaration &&
4097 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
4101 if (Spec.
isSet() && Tok.
isNot(tok::identifier)) {
4102 Diag(Tok, diag::err_expected) << tok::identifier;
4103 if (Tok.
isNot(tok::l_brace)) {
4115 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::l_brace) &&
4116 !(AllowFixedUnderlyingType && Tok.
is(tok::colon))) {
4117 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
4127 if (Tok.
is(tok::identifier)) {
4128 Name = Tok.getIdentifierInfo();
4132 if (!Name && ScopedEnumKWLoc.
isValid()) {
4135 Diag(Tok, diag::err_scoped_enum_missing_identifier);
4137 IsScopedUsingClassTag =
false;
4142 if (shouldDelayDiagsInTag)
4143 diagsFromTag.
done();
4149 if (AllowFixedUnderlyingType && Tok.
is(tok::colon)) {
4150 bool PossibleBitfield =
false;
4151 if (CanBeBitfield) {
4164 if (TPR == TPResult::True)
4165 PossibleBitfield =
true;
4170 else if (TPR == TPResult::False &&
4171 GetLookAheadToken(2).
getKind() == tok::semi) {
4178 TentativeParsingAction TPA(*
this);
4190 isCXXDeclarationSpecifier(TPResult::True) != TPResult::True) ||
4193 PossibleBitfield =
true;
4205 if (!PossibleBitfield) {
4210 Diag(StartLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type);
4213 Diag(StartLoc, diag::ext_cxx11_enum_fixed_underlying_type) << Range;
4215 Diag(StartLoc, diag::ext_c_enum_fixed_underlying_type) << Range;
4231 if (!AllowDeclaration) {
4233 }
else if (Tok.
is(tok::l_brace)) {
4235 Diag(Tok.getLocation(), diag::err_friend_decl_defines_type)
4243 }
else if (!isTypeSpecifier(DSC) &&
4244 (Tok.
is(tok::semi) ||
4245 (Tok.isAtStartOfLine() &&
4246 !isValidAfterTypeSpecifier(CanBeBitfield)))) {
4248 if (Tok.
isNot(tok::semi)) {
4250 ExpectAndConsume(tok::semi, diag::err_expected_after,
"enum");
4252 Tok.setKind(tok::semi);
4265 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
4269 Diag(Tok, diag::err_enum_template);
4274 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
4277 Diag(StartLoc, diag::err_explicit_instantiation_enum);
4281 assert(TemplateInfo.TemplateParams &&
"no template parameters");
4283 TemplateInfo.TemplateParams->size());
4287 ProhibitAttributes(attrs);
4290 Diag(Tok, diag::err_enumerator_unnamed_no_def);
4297 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
4302 SkipBody = Actions.shouldSkipAnonEnumBody(
getCurScope(),
4307 bool IsDependent =
false;
4308 const char *PrevSpec =
nullptr;
4310 Decl *TagDecl = Actions.ActOnTag(
4313 IsDependent, ScopedEnumKWLoc, IsScopedUsingClassTag, BaseType,
4314 DSC == DeclSpecContext::DSC_type_specifier,
4315 DSC == DeclSpecContext::DSC_template_param ||
4316 DSC == DeclSpecContext::DSC_template_type_arg,
4327 NameLoc.
isValid() ? NameLoc : StartLoc,
4328 PrevSpec, DiagID, TagDecl, Owned,
4330 Diag(StartLoc, DiagID) << PrevSpec;
4339 Diag(Tok, diag::err_expected_type_name_after_typename);
4351 NameLoc.
isValid() ? NameLoc : StartLoc,
4352 PrevSpec, DiagID, Type.
get(),
4353 Actions.getASTContext().getPrintingPolicy()))
4354 Diag(StartLoc, DiagID) << PrevSpec;
4373 ParseEnumBody(StartLoc, D);
4375 !Actions.ActOnDuplicateDefinition(DS, TagDecl, SkipBody)) {
4382 NameLoc.
isValid() ? NameLoc : StartLoc,
4383 PrevSpec, DiagID, TagDecl, Owned,
4385 Diag(StartLoc, DiagID) << PrevSpec;
4401 Actions.ActOnTagStartDefinition(
getCurScope(), EnumDecl);
4408 Diag(Tok, diag::err_empty_enum);
4413 Decl *LastEnumConstDecl =
nullptr;
4416 while (Tok.
isNot(tok::r_brace)) {
4419 if (Tok.
isNot(tok::identifier)) {
4420 Diag(Tok.getLocation(), diag::err_expected) << tok::identifier;
4430 ParsedAttributesWithRange attrs(AttrFactory);
4431 MaybeParseGNUAttributes(attrs);
4432 ProhibitAttributes(attrs);
4433 if (standardAttributesAllowed() && isCXX11AttributeSpecifier()) {
4436 ? diag::warn_cxx14_compat_ns_enum_attribute
4437 : diag::ext_ns_enum_attribute)
4439 ParseCXX11Attributes(attrs);
4444 EnumAvailabilityDiags.emplace_back(*
this);
4453 Decl *EnumConstDecl = Actions.ActOnEnumConstant(
4454 getCurScope(), EnumDecl, LastEnumConstDecl, IdentLoc, Ident,
4455 attrs.getList(), EqualLoc, AssignedVal.
get());
4456 EnumAvailabilityDiags.back().done();
4458 EnumConstantDecls.push_back(EnumConstDecl);
4459 LastEnumConstDecl = EnumConstDecl;
4461 if (Tok.
is(tok::identifier)) {
4464 Diag(Loc, diag::err_enumerator_list_missing_comma)
4474 Diag(Tok.getLocation(), diag::err_expected_either) << tok::r_brace
4477 Diag(Tok.getLocation(), diag::err_expected_end_of_enumerator);
4487 if (Tok.
is(tok::r_brace) && CommaLoc.
isValid()) {
4490 diag::ext_enumerator_list_comma_cxx :
4491 diag::ext_enumerator_list_comma_c)
4494 Diag(CommaLoc, diag::warn_cxx98_compat_enumerator_list_comma)
4505 MaybeParseGNUAttributes(attrs);
4507 Actions.ActOnEnumBody(StartLoc, T.
getRange(),
4508 EnumDecl, EnumConstantDecls,
4513 assert(EnumConstantDecls.size() == EnumAvailabilityDiags.size());
4514 for (
size_t i = 0, e = EnumConstantDecls.size(); i != e; ++i) {
4516 EnumAvailabilityDiags[i].redelay();
4526 if (!isValidAfterTypeSpecifier(CanBeBitfield)) {
4527 ExpectAndConsume(tok::semi, diag::err_expected_after,
"enum");
4532 Tok.setKind(tok::semi);
4539 bool Parser::isKnownToBeTypeSpecifier(
const Token &Tok)
const {
4541 default:
return false;
4545 case tok::kw___int64:
4546 case tok::kw___int128:
4547 case tok::kw_signed:
4548 case tok::kw_unsigned:
4549 case tok::kw__Complex:
4550 case tok::kw__Imaginary:
4553 case tok::kw_wchar_t:
4554 case tok::kw_char16_t:
4555 case tok::kw_char32_t:
4559 case tok::kw_double:
4560 case tok::kw__Float16:
4561 case tok::kw___float128:
4564 case tok::kw__Decimal32:
4565 case tok::kw__Decimal64:
4566 case tok::kw__Decimal128:
4567 case tok::kw___vector:
4568 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: 4569 #include "clang/Basic/OpenCLImageTypes.def" 4573 case tok::kw_struct:
4574 case tok::kw___interface:
4580 case tok::annot_typename:
4587 bool Parser::isTypeSpecifierQualifier() {
4589 default:
return false;
4591 case tok::identifier:
4592 if (TryAltiVecVectorToken())
4595 case tok::kw_typename:
4600 if (Tok.
is(tok::identifier))
4602 return isTypeSpecifierQualifier();
4604 case tok::coloncolon:
4611 return isTypeSpecifierQualifier();
4614 case tok::kw___attribute:
4616 case tok::kw_typeof:
4621 case tok::kw___int64:
4622 case tok::kw___int128:
4623 case tok::kw_signed:
4624 case tok::kw_unsigned:
4625 case tok::kw__Complex:
4626 case tok::kw__Imaginary:
4629 case tok::kw_wchar_t:
4630 case tok::kw_char16_t:
4631 case tok::kw_char32_t:
4635 case tok::kw_double:
4636 case tok::kw__Float16:
4637 case tok::kw___float128:
4640 case tok::kw__Decimal32:
4641 case tok::kw__Decimal64:
4642 case tok::kw__Decimal128:
4643 case tok::kw___vector:
4644 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: 4645 #include "clang/Basic/OpenCLImageTypes.def" 4649 case tok::kw_struct:
4650 case tok::kw___interface:
4657 case tok::kw_volatile:
4658 case tok::kw_restrict:
4661 case tok::kw___unknown_anytype:
4664 case tok::annot_typename:
4671 case tok::kw___cdecl:
4672 case tok::kw___stdcall:
4673 case tok::kw___fastcall:
4674 case tok::kw___thiscall:
4675 case tok::kw___regcall:
4676 case tok::kw___vectorcall:
4678 case tok::kw___ptr64:
4679 case tok::kw___ptr32:
4680 case tok::kw___pascal:
4681 case tok::kw___unaligned:
4683 case tok::kw__Nonnull:
4684 case tok::kw__Nullable:
4685 case tok::kw__Null_unspecified:
4687 case tok::kw___kindof:
4689 case tok::kw___private:
4690 case tok::kw___local:
4691 case tok::kw___global:
4692 case tok::kw___constant:
4693 case tok::kw___generic:
4694 case tok::kw___read_only:
4695 case tok::kw___read_write:
4696 case tok::kw___write_only:
4701 case tok::kw__Atomic:
4711 bool Parser::isDeclarationSpecifier(
bool DisambiguatingWithExpression) {
4713 default:
return false;
4718 case tok::identifier:
4722 if (TryAltiVecVectorToken())
4725 case tok::kw_decltype:
4726 case tok::kw_typename:
4731 if (Tok.
is(tok::identifier))
4739 if (DisambiguatingWithExpression &&
4740 isStartOfObjCClassMessageMissingOpenBracket())
4743 return isDeclarationSpecifier();
4745 case tok::coloncolon:
4754 return isDeclarationSpecifier();
4757 case tok::kw_typedef:
4758 case tok::kw_extern:
4759 case tok::kw___private_extern__:
4760 case tok::kw_static:
4762 case tok::kw___auto_type:
4763 case tok::kw_register:
4764 case tok::kw___thread:
4765 case tok::kw_thread_local:
4766 case tok::kw__Thread_local:
4769 case tok::kw___module_private__:
4772 case tok::kw___unknown_anytype:
4777 case tok::kw___int64:
4778 case tok::kw___int128:
4779 case tok::kw_signed:
4780 case tok::kw_unsigned:
4781 case tok::kw__Complex:
4782 case tok::kw__Imaginary:
4785 case tok::kw_wchar_t:
4786 case tok::kw_char16_t:
4787 case tok::kw_char32_t:
4792 case tok::kw_double:
4793 case tok::kw__Float16:
4794 case tok::kw___float128:
4797 case tok::kw__Decimal32:
4798 case tok::kw__Decimal64:
4799 case tok::kw__Decimal128:
4800 case tok::kw___vector:
4804 case tok::kw_struct:
4806 case tok::kw___interface:
4812 case tok::kw_volatile:
4813 case tok::kw_restrict:
4816 case tok::kw_inline:
4817 case tok::kw_virtual:
4818 case tok::kw_explicit:
4819 case tok::kw__Noreturn:
4822 case tok::kw__Alignas:
4825 case tok::kw_friend:
4828 case tok::kw__Static_assert:
4831 case tok::kw_typeof:
4834 case tok::kw___attribute:
4837 case tok::annot_decltype:
4838 case tok::kw_constexpr:
4841 case tok::kw__Atomic:
4849 case tok::annot_typename:
4850 return !DisambiguatingWithExpression ||
4851 !isStartOfObjCClassMessageMissingOpenBracket();
4853 case tok::kw___declspec:
4854 case tok::kw___cdecl:
4855 case tok::kw___stdcall:
4856 case tok::kw___fastcall:
4857 case tok::kw___thiscall:
4858 case tok::kw___regcall:
4859 case tok::kw___vectorcall:
4861 case tok::kw___sptr:
4862 case tok::kw___uptr:
4863 case tok::kw___ptr64:
4864 case tok::kw___ptr32:
4865 case tok::kw___forceinline:
4866 case tok::kw___pascal:
4867 case tok::kw___unaligned:
4869 case tok::kw__Nonnull:
4870 case tok::kw__Nullable:
4871 case tok::kw__Null_unspecified:
4873 case tok::kw___kindof:
4875 case tok::kw___private:
4876 case tok::kw___local:
4877 case tok::kw___global:
4878 case tok::kw___constant:
4879 case tok::kw___generic:
4880 case tok::kw___read_only:
4881 case tok::kw___read_write:
4882 case tok::kw___write_only:
4883 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t: 4884 #include "clang/Basic/OpenCLImageTypes.def" 4890 bool Parser::isConstructorDeclarator(
bool IsUnqualified,
bool DeductionGuide) {
4891 TentativeParsingAction TPA(*
this);
4895 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
4902 if (Tok.
is(tok::identifier)) {
4906 }
else if (Tok.
is(tok::annot_template_id)) {
4907 ConsumeAnnotationToken();
4915 SkipCXX11Attributes();
4918 if (Tok.
isNot(tok::l_paren)) {
4926 if (Tok.
is(tok::r_paren) ||
4935 isCXX11AttributeSpecifier(
false,
4942 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4944 DeclScopeObj.EnterDeclaratorScope();
4948 MaybeParseMicrosoftAttributes(Attrs);
4953 bool IsConstructor =
false;
4954 if (isDeclarationSpecifier())
4955 IsConstructor =
true;
4956 else if (Tok.
is(tok::identifier) ||
4957 (Tok.
is(tok::annot_cxxscope) &&
NextToken().
is(tok::identifier))) {
4962 if (Tok.
is(tok::annot_cxxscope))
4963 ConsumeAnnotationToken();
4975 case tok::coloncolon:
4988 SkipCXX11Attributes();
4990 if (DeductionGuide) {
4992 IsConstructor = Tok.
is(tok::arrow);
4995 if (Tok.
is(tok::colon) || Tok.
is(tok::kw_try)) {
4999 IsConstructor =
true;
5001 if (Tok.
is(tok::semi) || Tok.
is(tok::l_brace)) {
5014 IsConstructor = IsUnqualified;
5019 IsConstructor =
true;
5025 return IsConstructor;
5040 void Parser::ParseTypeQualifierListOpt(
5041 DeclSpec &DS,
unsigned AttrReqs,
bool AtomicAllowed,
5042 bool IdentifierRequired,
5044 if (standardAttributesAllowed() && (AttrReqs & AR_CXX11AttributesParsed) &&
5045 isCXX11AttributeSpecifier()) {
5046 ParsedAttributesWithRange attrs(AttrFactory);
5047 ParseCXX11Attributes(attrs);
5055 const char *PrevSpec =
nullptr;
5056 unsigned DiagID = 0;
5060 case tok::code_completion:
5062 (*CodeCompletionHandler)();
5064 Actions.CodeCompleteTypeQualifiers(DS);
5065 return cutOffParsing();
5071 case tok::kw_volatile:
5075 case tok::kw_restrict:
5079 case tok::kw__Atomic:
5081 goto DoneWithTypeQuals;
5087 case tok::kw___private:
5088 case tok::kw___global:
5089 case tok::kw___local:
5090 case tok::kw___constant:
5091 case tok::kw___generic:
5092 case tok::kw___read_only:
5093 case tok::kw___write_only:
5094 case tok::kw___read_write:
5098 case tok::kw___unaligned:
5102 case tok::kw___uptr:
5107 if (TryKeywordIdentFallback(
false))
5111 case tok::kw___sptr:
5113 case tok::kw___ptr64:
5114 case tok::kw___ptr32:
5115 case tok::kw___cdecl:
5116 case tok::kw___stdcall:
5117 case tok::kw___fastcall:
5118 case tok::kw___thiscall:
5119 case tok::kw___regcall:
5120 case tok::kw___vectorcall:
5121 if (AttrReqs & AR_DeclspecAttributesParsed) {
5125 goto DoneWithTypeQuals;
5126 case tok::kw___pascal:
5127 if (AttrReqs & AR_VendorAttributesParsed) {
5131 goto DoneWithTypeQuals;
5134 case tok::kw__Nonnull:
5135 case tok::kw__Nullable:
5136 case tok::kw__Null_unspecified:
5141 case tok::kw___kindof:
5147 case tok::kw___attribute:
5148 if (AttrReqs & AR_GNUAttributesParsedAndRejected)
5150 Diag(Tok, diag::err_attributes_not_allowed);
5154 if (AttrReqs & AR_GNUAttributesParsed ||
5155 AttrReqs & AR_GNUAttributesParsedAndRejected) {
5165 DS.
Finish(Actions, Actions.getASTContext().getPrintingPolicy());
5173 assert(PrevSpec &&
"Method did not return previous specifier!");
5174 Diag(Tok, DiagID) << PrevSpec;
5182 void Parser::ParseDeclarator(
Declarator &D) {
5185 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
5190 if (Kind == tok::star || Kind == tok::caret)
5193 if ((Kind == tok::kw_pipe) && Lang.OpenCL && (Lang.OpenCLVersion >= 200))
5196 if (!Lang.CPlusPlus)
5199 if (Kind == tok::amp)
5207 if (Kind == tok::ampamp)
5208 return Lang.CPlusPlus11 ||
5219 for (
unsigned Idx = 0; Idx != NumTypes; ++Idx)
5251 void Parser::ParseDeclaratorInternal(
Declarator &D,
5252 DirectDeclParseFunction DirectDeclParser) {
5253 if (Diags.hasAllExtensionsSilenced())
5260 (Tok.
is(tok::coloncolon) || Tok.
is(tok::kw_decltype) ||
5261 (Tok.
is(tok::identifier) &&
5263 Tok.
is(tok::annot_cxxscope))) {
5264 bool EnteringContext =
5268 ParseOptionalCXXScopeSpecifier(SS,
nullptr, EnteringContext);
5271 if (Tok.
isNot(tok::star)) {
5276 AnnotateScopeToken(SS,
true);
5278 if (DirectDeclParser)
5279 (this->*DirectDeclParser)(D);
5286 ParseTypeQualifierListOpt(DS);
5290 ParseDeclaratorInternal(D, DirectDeclParser);
5306 ParseTypeQualifierListOpt(DS);
5315 if (DirectDeclParser)
5316 (this->*DirectDeclParser)(D);
5325 if (Kind == tok::star || Kind == tok::caret) {
5331 unsigned Reqs = AR_CXX11AttributesParsed | AR_DeclspecAttributesParsed |
5333 ? AR_GNUAttributesParsed
5334 : AR_GNUAttributesParsedAndRejected);
5339 ParseDeclaratorInternal(D, DirectDeclParser);
5340 if (Kind == tok::star)
5362 if (Kind == tok::ampamp)
5364 diag::warn_cxx98_compat_rvalue_reference :
5365 diag::ext_rvalue_reference);
5368 ParseTypeQualifierListOpt(DS);
5377 diag::err_invalid_reference_qualifier_application) <<
"const";
5380 diag::err_invalid_reference_qualifier_application) <<
"volatile";
5384 diag::err_invalid_reference_qualifier_application) <<
"_Atomic";
5388 ParseDeclaratorInternal(D, DirectDeclParser);
5395 Diag(InnerChunk.
Loc, diag::err_illegal_decl_reference_to_reference)
5398 Diag(InnerChunk.
Loc, diag::err_illegal_decl_reference_to_reference)
5474 void Parser::ParseDirectDeclarator(
Declarator &D) {
5481 return ParseDecompositionDeclarator(D);
5493 bool EnteringContext =
5501 if (Actions.ShouldEnterDeclaratorScope(
getCurScope(),
5505 DeclScopeObj.EnterDeclaratorScope();
5512 goto PastIdentifier;
5529 !Actions.containsUnexpandedParameterPacks(D) &&
5537 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, D);
5547 if (Tok.
isOneOf(tok::identifier, tok::kw_operator, tok::annot_template_id,
5551 bool AllowConstructorName;
5552 bool AllowDeductionGuide;
5554 AllowConstructorName =
false;
5555 AllowDeductionGuide =
false;
5557 AllowConstructorName =
5560 AllowDeductionGuide =
false;
5562 AllowConstructorName =
5564 AllowDeductionGuide =
5573 true, AllowConstructorName,
5574 AllowDeductionGuide,
nullptr, TemplateKWLoc,
5587 DeclScopeObj.EnterDeclaratorScope();
5594 goto PastIdentifier;
5600 diag::err_expected_unqualified_id)
5603 goto PastIdentifier;
5607 "There's a C++-specific check for tok::identifier above");
5612 goto PastIdentifier;
5617 bool DiagnoseIdentifier =
false;
5621 DiagnoseIdentifier =
true;
5624 DiagnoseIdentifier =
5631 !isCXX11VirtSpecifier(Tok))
5633 tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try);
5634 if (DiagnoseIdentifier) {
5639 goto PastIdentifier;
5643 if (Tok.
is(tok::l_paren)) {
5647 ParseParenDeclarator(D);
5660 DeclScopeObj.EnterDeclaratorScope();
5671 diag::ext_abstract_pack_declarator_parens);
5673 if (Tok.
getKind() == tok::annot_pragma_parser_crash)
5675 if (Tok.
is(tok::l_square))
5676 return ParseMisplacedBracketDeclarator(D);
5684 diag::err_expected_member_name_or_semi_objcxx_keyword)
5691 goto PastIdentifier;
5694 diag::err_expected_member_name_or_semi)
5698 if (Tok.
isOneOf(tok::period, tok::arrow))
5699 Diag(Tok, diag::err_invalid_operator_on_type) << Tok.
is(tok::arrow);
5703 Diag(PP.getLocForEndOfToken(Loc), diag::err_expected_unqualified_id)
5707 diag::err_expected_unqualified_id)
5712 diag::err_expected_either)
5713 << tok::identifier << tok::l_paren;
5721 "Haven't past the location of the identifier yet?");
5725 MaybeParseCXX11Attributes(D);
5728 if (Tok.
is(tok::l_paren)) {
5731 ParseScope PrototypeScope(
this,
5739 bool IsAmbiguous =
false;
5743 TentativelyDeclaredIdentifiers.push_back(D.
getIdentifier());
5744 bool IsFunctionDecl = isCXXFunctionDeclarator(&IsAmbiguous);
5745 TentativelyDeclaredIdentifiers.pop_back();
5746 if (!IsFunctionDecl)
5752 ParseFunctionDeclarator(D, attrs, T, IsAmbiguous);
5753 PrototypeScope.Exit();
5754 }
else if (Tok.
is(tok::l_square)) {
5755 ParseBracketDeclarator(D);
5762 void Parser::ParseDecompositionDeclarator(
Declarator &D) {
5763 assert(Tok.
is(tok::l_square));
5769 if (!(
NextToken().is(tok::identifier) &&
5770 GetLookAheadToken(2).isOneOf(tok::comma, tok::r_square)) &&
5772 GetLookAheadToken(2).isOneOf(tok::equal, tok::l_brace)))
5773 return ParseMisplacedBracketDeclarator(D);
5779 while (Tok.
isNot(tok::r_square)) {
5780 if (!Bindings.empty()) {
5781 if (Tok.
is(tok::comma))
5784 if (Tok.
is(tok::identifier)) {
5786 Diag(EndLoc, diag::err_expected)
5789 Diag(Tok, diag::err_expected_comma_or_rsquare);
5792 SkipUntil(tok::r_square, tok::comma, tok::identifier,
5794 if (Tok.
is(tok::comma))
5796 else if (Tok.
isNot(tok::identifier))
5801 if (Tok.
isNot(tok::identifier)) {
5802 Diag(Tok, diag::err_expected) << tok::identifier;
5810 if (Tok.
isNot(tok::r_square))
5816 if (Bindings.empty())
5839 void Parser::ParseParenDeclarator(
Declarator &D) {
5843 assert(!D.
isPastIdentifier() &&
"Should be called before passing identifier");
5856 bool RequiresArg =
false;
5857 if (Tok.
is(tok::kw___attribute)) {
5858 ParseGNUAttributes(attrs);
5866 ParseMicrosoftTypeAttributes(attrs);
5869 if (Tok.
is(tok::kw___pascal))
5870 ParseBorlandTypeAttributes(attrs);
5882 }
else if (Tok.
is(tok::r_paren) ||
5885 isDeclarationSpecifier() ||
5886 isCXX11AttributeSpecifier()) {
5904 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
5915 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, D);
5928 ParseScope PrototypeScope(
this,
5932 ParseFunctionDeclarator(D, attrs, T,
false, RequiresArg);
5933 PrototypeScope.Exit();
5955 void Parser::ParseFunctionDeclarator(
Declarator &D,
5960 assert(
getCurScope()->isFunctionPrototypeScope() &&
5961 "Should call from a Function scope");
5967 bool HasProto =
false;
5974 bool RefQualifierIsLValueRef =
true;
5985 ParsedAttributesWithRange FnAttrs(AttrFactory);
5994 StartLoc = LParenLoc;
5996 if (isFunctionDeclaratorIdentifierList()) {
5998 Diag(Tok, diag::err_argument_required_after_attribute);
6000 ParseFunctionDeclaratorIdentifierList(D, ParamInfo);
6004 LocalEndLoc = RParenLoc;
6009 MaybeParseCXX11Attributes(FnAttrs);
6010 ProhibitAttributes(FnAttrs);
6012 if (Tok.
isNot(tok::r_paren))
6013 ParseParameterDeclarationClause(D, FirstArgAttrs, ParamInfo,
6015 else if (RequiresArg)
6016 Diag(Tok, diag::err_argument_required_after_attribute);
6018 HasProto = ParamInfo.size() ||
getLangOpts().CPlusPlus
6024 LocalEndLoc = RParenLoc;
6033 ParseTypeQualifierListOpt(DS, AR_NoAttributesParsed,
6036 llvm::function_ref<
void()>([&]() {
6037 Actions.CodeCompleteFunctionQualifiers(DS, D);
6047 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc))
6048 EndLoc = RefQualifierLoc;
6057 bool IsCXX11MemberFunction =
6064 Actions.CurContext->isRecord());
6066 dyn_cast<CXXRecordDecl>(Actions.CurContext),
6071 IsCXX11MemberFunction);
6076 if (Delayed && Actions.isLibstdcxxEagerExceptionSpecHack(D) &&
6077 GetLookAheadToken(0).is(tok::kw_noexcept) &&
6078 GetLookAheadToken(1).is(tok::l_paren) &&
6079 GetLookAheadToken(2).is(tok::kw_noexcept) &&
6080 GetLookAheadToken(3).is(tok::l_paren) &&
6081 GetLookAheadToken(4).is(tok::identifier) &&
6082 GetLookAheadToken(4).getIdentifierInfo()->isStr(
"swap")) {
6093 ESpecType = tryParseExceptionSpecification(Delayed,
6096 DynamicExceptionRanges,
6098 ExceptionSpecTokens);
6100 EndLoc = ESpecRange.
getEnd();
6104 MaybeParseCXX11Attributes(FnAttrs);
6107 LocalEndLoc = EndLoc;
6109 Diag(Tok, diag::warn_cxx98_compat_trailing_return_type);
6114 TrailingReturnType = ParseTrailingReturnType(Range);
6117 }
else if (standardAttributesAllowed()) {
6118 MaybeParseCXX11Attributes(FnAttrs);
6131 if (!ND || isa<ParmVarDecl>(ND))
6133 DeclsInPrototype.push_back(ND);
6141 ParamInfo.data(), ParamInfo.size(),
6142 EllipsisLoc, RParenLoc,
6144 RefQualifierIsLValueRef,
6145 RefQualifierLoc, ConstQualifierLoc,
6146 VolatileQualifierLoc,
6147 RestrictQualifierLoc,
6149 ESpecType, ESpecRange,
6150 DynamicExceptions.data(),
6151 DynamicExceptionRanges.data(),
6152 DynamicExceptions.size(),
6154 NoexceptExpr.
get() :
nullptr,
6155 ExceptionSpecTokens,
6157 StartLoc, LocalEndLoc, D,
6158 TrailingReturnType),
6164 bool Parser::ParseRefQualifier(
bool &RefQualifierIsLValueRef,
6166 if (Tok.
isOneOf(tok::amp, tok::ampamp)) {
6168 diag::warn_cxx98_compat_ref_qualifier :
6169 diag::ext_ref_qualifier);
6171 RefQualifierIsLValueRef = Tok.
is(tok::amp);
6183 bool Parser::isFunctionDeclaratorIdentifierList() {
6185 && Tok.
is(tok::identifier)
6186 && !TryAltiVecVectorToken()
6215 void Parser::ParseFunctionDeclaratorIdentifierList(
6223 Diag(Tok, diag::ext_ident_list_in_param);
6226 llvm::SmallSet<const IdentifierInfo*, 16> ParamsSoFar;
6230 if (Tok.
isNot(tok::identifier)) {
6231 Diag(Tok, diag::err_expected) << tok::identifier;
6242 Diag(Tok, diag::err_unexpected_typedef_ident) << ParmII;
6245 if (!ParamsSoFar.insert(ParmII).second) {
6246 Diag(Tok, diag::err_param_redefinition) << ParmII;
6291 void Parser::ParseParameterDeclarationClause(
6321 ParseDeclarationSpecifiers(DS);
6331 ParseDeclarator(ParmDeclarator);
6334 MaybeParseGNUAttributes(ParmDeclarator);
6341 std::unique_ptr<CachedTokens> DefArgToks;
6345 if (DS.
isEmpty() && ParmDeclarator.getIdentifier() ==
nullptr &&
6346 ParmDeclarator.getNumTypeObjects() == 0) {
6348 Diag(DSStart, diag::err_missing_param);
6355 if (Tok.
is(tok::ellipsis) &&
6357 (!ParmDeclarator.getEllipsisLoc().isValid() &&
6358 !Actions.isUnexpandedParameterPackPermitted())) &&
6359 Actions.containsUnexpandedParameterPacks(ParmDeclarator))
6360 DiagnoseMisplacedEllipsisInDeclarator(
ConsumeToken(), ParmDeclarator);
6364 Decl *Param = Actions.ActOnParamDeclarator(
getCurScope(), ParmDeclarator);
6369 if (Tok.
is(tok::equal)) {
6380 if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
6382 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
6384 Actions.ActOnParamUnparsedDefaultArgument(Param, EqualLoc,
6400 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
6401 DefArgResult = ParseBraceInitializer();
6404 DefArgResult = Actions.CorrectDelayedTyposInExpr(DefArgResult);
6406 Actions.ActOnParamDefaultArgumentError(Param, EqualLoc);
6410 Actions.ActOnParamDefaultArgument(Param, EqualLoc,
6411 DefArgResult.
get());
6417 ParmDeclarator.getIdentifierLoc(),
6418 Param, std::move(DefArgToks)));
6425 Diag(EllipsisLoc, diag::err_missing_comma_before_ellipsis)
6427 }
else if (ParmDeclarator.getEllipsisLoc().isValid() ||
6428 Actions.containsUnexpandedParameterPacks(ParmDeclarator)) {
6432 Diag(EllipsisLoc, diag::warn_misplaced_ellipsis_vararg)
6433 << ParmEllipsis.
isValid() << ParmEllipsis;
6436 diag::note_misplaced_ellipsis_vararg_existing_ellipsis);
6438 Diag(ParmDeclarator.getIdentifierLoc(),
6439 diag::note_misplaced_ellipsis_vararg_add_ellipsis)
6442 << !ParmDeclarator.hasName();
6444 Diag(EllipsisLoc, diag::note_misplaced_ellipsis_vararg_add_comma)
6463 void Parser::ParseBracketDeclarator(
Declarator &D) {
6464 if (CheckProhibitedCXX11Attribute())
6472 if (Tok.
getKind() == tok::r_square) {
6475 MaybeParseCXX11Attributes(attrs);
6483 }
else if (Tok.
getKind() == tok::numeric_constant &&
6484 GetLookAheadToken(1).is(tok::r_square)) {
6491 MaybeParseCXX11Attributes(attrs);
6500 }
else if (Tok.
getKind() == tok::code_completion) {
6501 Actions.CodeCompleteBracketDeclarator(
getCurScope());
6502 return cutOffParsing();
6512 ParseTypeQualifierListOpt(DS, AR_CXX11AttributesParsed);
6520 bool isStar =
false;
6527 if (Tok.
is(tok::star) && GetLookAheadToken(1).is(tok::r_square)) {
6531 Diag(StaticLoc, diag::err_unspecified_vla_size_with_static);
6535 }
else if (Tok.
isNot(tok::r_square)) {
6553 Diag(StaticLoc, diag::err_unspecified_size_with_static);
6580 void Parser::ParseMisplacedBracketDeclarator(
Declarator &D) {
6581 assert(Tok.
is(tok::l_square) &&
"Missing opening bracket");
6587 while (Tok.
is(tok::l_square)) {
6588 ParseBracketDeclarator(TempDeclarator);
6594 if (Tok.
is(tok::semi))
6600 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
6605 if (TempDeclarator.getNumTypeObjects() == 0)
6609 bool NeedParens =
false;
6635 for (
unsigned i = 0, e = TempDeclarator.getNumTypeObjects(); i < e; ++i) {
6650 SourceRange BracketRange(StartBracketLoc, EndBracketLoc);
6654 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
6662 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
6675 void Parser::ParseTypeofSpecifier(
DeclSpec &DS) {
6676 assert(Tok.
is(tok::kw_typeof) &&
"Not a typeof specifier");
6680 const bool hasParens = Tok.
is(tok::l_paren);
6689 ExprResult Operand = Actions.CorrectDelayedTyposInExpr(
6690 ParseExprAfterUnaryExprOrTypeTrait(OpTok, isCastExpr, CastTy, CastRange));
6706 const char *PrevSpec =
nullptr;
6711 Actions.getASTContext().getPrintingPolicy()))
6712 Diag(StartLoc, DiagID) << PrevSpec;
6723 Operand = Actions.HandleExprEvaluationContextForTypeof(Operand.
get());
6729 const char *PrevSpec =
nullptr;
6733 DiagID, Operand.
get(),
6734 Actions.getASTContext().getPrintingPolicy()))
6735 Diag(StartLoc, DiagID) << PrevSpec;
6741 void Parser::ParseAtomicSpecifier(
DeclSpec &DS) {
6742 assert(Tok.
is(tok::kw__Atomic) &&
NextToken().
is(tok::l_paren) &&
6743 "Not an atomic specifier");
6765 const char *PrevSpec =
nullptr;
6768 DiagID, Result.
get(),
6769 Actions.getASTContext().getPrintingPolicy()))
6770 Diag(StartLoc, DiagID) << PrevSpec;
6775 bool Parser::TryAltiVecVectorTokenOutOfLine() {
6778 default:
return false;
6781 case tok::kw_signed:
6782 case tok::kw_unsigned:
6787 case tok::kw_double:
6789 case tok::kw___bool:
6790 case tok::kw___pixel:
6791 Tok.
setKind(tok::kw___vector);
6793 case tok::identifier:
6795 Tok.
setKind(tok::kw___vector);
6799 Tok.
setKind(tok::kw___vector);
6807 const char *&PrevSpec,
unsigned &DiagID,
6809 const PrintingPolicy &Policy = Actions.getASTContext().getPrintingPolicy();
6815 case tok::kw_signed:
6816 case tok::kw_unsigned:
6821 case tok::kw_double:
6823 case tok::kw___bool:
6824 case tok::kw___pixel:
6827 case tok::identifier:
void ClearFunctionSpecs()
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
Defines the clang::ASTContext interface.
static bool isAttributeLateParsed(const IdentifierInfo &II)
isAttributeLateParsed - Return true if the attribute has arguments that require late parsing...
AttributeList * addNewPropertyAttr(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierInfo *getterId, IdentifierInfo *setterId, AttributeList::Syntax syntaxUsed)
Add microsoft __delspec(property) attribute.
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.
Represents a version number in the form major[.minor[.subminor[.build]]].
SourceLocation getEndOfPreviousToken()
AttributeList * getNext() const
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
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
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
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.
ParmVarDecl - Represents a parameter to a function.
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
AttributeList * getList() const
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
RecordDecl - 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)
__ptr16, alignas(...), etc.
One of these records is kept for each identifier that is lexed.
void set(AttributeList *newList)
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.
llvm::PointerUnion< Expr *, IdentifierLoc * > ArgsUnion
A union of the various pointer types that can be passed to an AttributeList as an argument...
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
SourceLocation getTypeSpecTypeLoc() const
static const TST TST_class
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
AttributeList * addNewTypeAttr(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ParsedType typeArg, AttributeList::Syntax syntaxUsed)
Add an attribute with a single type argument.
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.
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 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
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.
void addAttributes(AttributeList *AL)
Concatenates two attribute lists.
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
enum clang::DeclaratorChunk::@198 Kind
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.
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)
AvailabilityChange Changes[NumAvailabilitySlots]
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.
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 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
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...
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
const FunctionProtoType * T
void addAllAtEnd(AttributeList *newList)
bool isKnownToGCC() const
void SkipMalformedDecl()
SkipMalformedDecl - Read tokens until we get to some likely good stopping point for skipping past a s...
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.
bool isCXX11Attribute() const
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
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.
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero)...
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...
TagDecl - 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
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)
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.
Decl * getRepAsDecl() const
static const TST TST_typeofType
bool isDeclspecAttribute() const
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)
bool isMicrosoftAttribute() const
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
EnumDecl - Represents an enum.
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.
Syntax
The style used to specify an attribute.
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
void setNext(AttributeList *N)
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.
CXXScopeSpec & getTypeSpecScope()
AttributeList * addNew(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, AttributeList::Syntax syntax, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
This is a scope that can contain a declaration.
unsigned getMaxArgs() const
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 ...
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 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
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)
NamedDecl - This represents a decl with a name.
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...
attr::Kind getKind() const
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)
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].
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
SourceLocation getLocation() const
void startToken()
Reset all flags to cleared.
AttributeList * addNewTypeTagForDatatype(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierLoc *argumentKind, ParsedType matchingCType, bool layoutCompatible, bool mustBeNull, AttributeList::Syntax syntax)
Add type_tag_for_datatype attribute.
Decl * ActOnDeclarator(Scope *S, Declarator &D)
AttributeList - Represents a syntactic attribute.
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