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 == DSC_normal)
52 DSC = 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");
255 Parens.consumeOpen();
258 if (Tok.
isNot(tok::r_paren))
261 if (Parens.consumeClose())
269 SourceRange(AttrNameLoc, Parens.getCloseLocation()),
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") {
438 T.expectAndConsume(diag::err_expected_lparen_after,
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)) {
574 if (T.expectAndConsume(diag::err_expected_lparen_after,
"__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);
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,
628 *End = T.getCloseLocation();
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 };
903 if (T.consumeOpen()) {
904 Diag(Tok, diag::err_expected) << tok::l_paren;
909 if (Tok.
isNot(tok::identifier)) {
910 Diag(Tok, diag::err_availability_expected_platform);
924 if (ExpectAndConsume(tok::comma)) {
931 if (!Ident_introduced) {
945 if (Tok.
isNot(tok::identifier)) {
946 Diag(Tok, diag::err_availability_expected_change);
953 if (Keyword == Ident_strict) {
955 Diag(KeywordLoc, diag::err_availability_redundant)
958 StrictLoc = KeywordLoc;
962 if (Keyword == Ident_unavailable) {
963 if (UnavailableLoc.
isValid()) {
964 Diag(KeywordLoc, diag::err_availability_redundant)
967 UnavailableLoc = KeywordLoc;
971 if (Tok.
isNot(tok::equal)) {
972 Diag(Tok, diag::err_expected_after) << Keyword << tok::equal;
977 if (Keyword == Ident_message || Keyword == Ident_replacement) {
978 if (Tok.
isNot(tok::string_literal)) {
979 Diag(Tok, diag::err_expected_string_literal)
984 if (Keyword == Ident_message)
985 MessageExpr = ParseStringLiteralExpression();
987 ReplacementExpr = ParseStringLiteralExpression();
990 cast_or_null<StringLiteral>(MessageExpr.
get())) {
991 if (MessageStringLiteral->getCharByteWidth() != 1) {
992 Diag(MessageStringLiteral->getSourceRange().getBegin(),
993 diag::err_expected_string_literal)
999 if (Keyword == Ident_message)
1007 if ((Keyword == Ident_introduced || Keyword == Ident_deprecated) &&
1008 Tok.
is(tok::identifier)) {
1012 if (Keyword == Ident_introduced)
1013 UnavailableLoc = KeywordLoc;
1019 VersionTuple Version = ParseVersionTuple(VersionRange);
1021 if (Version.
empty()) {
1027 if (Keyword == Ident_introduced)
1029 else if (Keyword == Ident_deprecated)
1031 else if (Keyword == Ident_obsoleted)
1036 if (Index < Unknown) {
1037 if (!Changes[Index].KeywordLoc.
isInvalid()) {
1038 Diag(KeywordLoc, diag::err_availability_redundant)
1041 Changes[Index].VersionRange.
getEnd());
1045 Changes[Index].
Version = Version;
1048 Diag(KeywordLoc, diag::err_availability_unknown_change)
1049 << Keyword << VersionRange;
1055 if (T.consumeClose())
1059 *endLoc = T.getCloseLocation();
1063 if (UnavailableLoc.
isValid()) {
1064 bool Complained =
false;
1065 for (
unsigned Index = Introduced; Index !=
Unknown; ++Index) {
1066 if (Changes[Index].KeywordLoc.
isValid()) {
1068 Diag(UnavailableLoc, diag::warn_availability_and_unavailable)
1070 Changes[Index].VersionRange.
getEnd());
1081 attrs.
addNew(&Availability,
1082 SourceRange(AvailabilityLoc, T.getCloseLocation()),
1083 ScopeName, ScopeLoc,
1085 Changes[Introduced],
1086 Changes[Deprecated],
1088 UnavailableLoc, MessageExpr.
get(),
1105 void Parser::ParseExternalSourceSymbolAttribute(
1111 if (T.expectAndConsume())
1115 if (!Ident_language) {
1122 bool HasLanguage =
false;
1124 bool HasDefinedIn =
false;
1129 if (Tok.
isNot(tok::identifier)) {
1130 Diag(Tok, diag::err_external_source_symbol_expected_keyword);
1137 if (Keyword == Ident_generated_declaration) {
1138 if (GeneratedDeclaration) {
1139 Diag(Tok, diag::err_external_source_symbol_duplicate_clause) << Keyword;
1143 GeneratedDeclaration = ParseIdentifierLoc();
1147 if (Keyword != Ident_language && Keyword != Ident_defined_in) {
1148 Diag(Tok, diag::err_external_source_symbol_expected_keyword);
1154 if (ExpectAndConsume(tok::equal, diag::err_expected_after,
1160 bool HadLanguage = HasLanguage, HadDefinedIn = HasDefinedIn;
1161 if (Keyword == Ident_language)
1164 HasDefinedIn =
true;
1166 if (Tok.
isNot(tok::string_literal)) {
1167 Diag(Tok, diag::err_expected_string_literal)
1169 << (Keyword != Ident_language);
1173 if (Keyword == Ident_language) {
1175 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1177 ParseStringLiteralExpression();
1180 Language = ParseStringLiteralExpression();
1182 assert(Keyword == Ident_defined_in &&
"Invalid clause keyword!");
1184 Diag(KeywordLoc, diag::err_external_source_symbol_duplicate_clause)
1186 ParseStringLiteralExpression();
1189 DefinedInExpr = ParseStringLiteralExpression();
1194 if (T.consumeClose())
1197 *EndLoc = T.getCloseLocation();
1200 GeneratedDeclaration};
1202 ScopeName, ScopeLoc, Args, llvm::array_lengthof(Args), Syntax);
1216 void Parser::ParseObjCBridgeRelatedAttribute(
IdentifierInfo &ObjCBridgeRelated,
1225 if (T.consumeOpen()) {
1226 Diag(Tok, diag::err_expected) << tok::l_paren;
1231 if (Tok.
isNot(tok::identifier)) {
1232 Diag(Tok, diag::err_objcbridge_related_expected_related_class);
1237 if (ExpectAndConsume(tok::comma)) {
1244 if (Tok.
is(tok::identifier)) {
1245 ClassMethod = ParseIdentifierLoc();
1247 Diag(Tok, diag::err_objcbridge_related_selector_name);
1253 if (Tok.
is(tok::colon))
1254 Diag(Tok, diag::err_objcbridge_related_selector_name);
1256 Diag(Tok, diag::err_expected) << tok::comma;
1263 if (Tok.
is(tok::identifier))
1264 InstanceMethod = ParseIdentifierLoc();
1265 else if (Tok.
isNot(tok::r_paren)) {
1266 Diag(Tok, diag::err_expected) << tok::r_paren;
1272 if (T.consumeClose())
1276 *endLoc = T.getCloseLocation();
1279 attrs.
addNew(&ObjCBridgeRelated,
1280 SourceRange(ObjCBridgeRelatedLoc, T.getCloseLocation()),
1281 ScopeName, ScopeLoc,
1291 void Parser::LateParsedDeclaration::ParseLexedAttributes() {}
1293 void Parser::LateParsedClass::ParseLexedAttributes() {
1294 Self->ParseLexedAttributes(*Class);
1297 void Parser::LateParsedAttribute::ParseLexedAttributes() {
1298 Self->ParseLexedAttribute(*
this,
true,
false);
1303 void Parser::ParseLexedAttributes(ParsingClass &Class) {
1306 bool HasTemplateScope = !Class.TopLevelClass && Class.TemplateScope;
1309 if (HasTemplateScope)
1313 bool AlreadyHasClassScope = Class.TopLevelClass;
1315 ParseScope ClassScope(
this, ScopeFlags, !AlreadyHasClassScope);
1316 ParseScopeFlags ClassScopeFlags(
this, ScopeFlags, AlreadyHasClassScope);
1319 if (!AlreadyHasClassScope)
1321 Class.TagOrTemplate);
1322 if (!Class.LateParsedDeclarations.empty()) {
1323 for (
unsigned i = 0, ni = Class.LateParsedDeclarations.size(); i < ni; ++i){
1324 Class.LateParsedDeclarations[i]->ParseLexedAttributes();
1328 if (!AlreadyHasClassScope)
1330 Class.TagOrTemplate);
1334 void Parser::ParseLexedAttributeList(LateParsedAttrList &LAs,
Decl *D,
1335 bool EnterScope,
bool OnDefinition) {
1336 assert(LAs.parseSoon() &&
1337 "Attribute list should be marked for immediate parsing.");
1338 for (
unsigned i = 0, ni = LAs.size(); i < ni; ++i) {
1341 ParseLexedAttribute(*LAs[i], EnterScope, OnDefinition);
1352 void Parser::ParseLexedAttribute(LateParsedAttribute &LA,
1353 bool EnterScope,
bool OnDefinition) {
1361 LA.Toks.push_back(AttrEnd);
1365 LA.Toks.push_back(Tok);
1366 PP.EnterTokenStream(LA.Toks,
true);
1368 ConsumeAnyToken(
true);
1373 if (LA.Decls.size() > 0) {
1374 Decl *D = LA.Decls[0];
1382 if (LA.Decls.size() == 1) {
1386 if (HasTemplateScope)
1395 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc,
1403 if (HasTemplateScope) {
1409 ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc,
1414 Diag(Tok, diag::warn_attribute_no_decl) << LA.AttrName.getName();
1420 Diag(Tok, diag::warn_attribute_on_function_definition)
1423 for (
unsigned i = 0, ni = LA.Decls.size(); i < ni; ++i)
1435 void Parser::ParseTypeTagForDatatypeAttribute(
IdentifierInfo &AttrName,
1442 assert(Tok.
is(tok::l_paren) &&
"Attribute arg list not starting with '('");
1447 if (Tok.
isNot(tok::identifier)) {
1448 Diag(Tok, diag::err_expected) << tok::identifier;
1454 if (ExpectAndConsume(tok::comma)) {
1466 bool LayoutCompatible =
false;
1467 bool MustBeNull =
false;
1469 if (Tok.
isNot(tok::identifier)) {
1470 Diag(Tok, diag::err_expected) << tok::identifier;
1475 if (Flag->
isStr(
"layout_compatible"))
1476 LayoutCompatible =
true;
1477 else if (Flag->
isStr(
"must_be_null"))
1480 Diag(Tok, diag::err_type_safety_unknown_flag) << Flag;
1487 if (!T.consumeClose()) {
1489 ArgumentKind, MatchingCType.
get(),
1490 LayoutCompatible, MustBeNull, Syntax);
1494 *EndLoc = T.getCloseLocation();
1505 bool Parser::DiagnoseProhibitedCXX11Attribute() {
1506 assert(Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square));
1508 switch (isCXX11AttributeSpecifier(
true)) {
1509 case CAK_NotAttributeSpecifier:
1513 case CAK_InvalidAttributeSpecifier:
1517 case CAK_AttributeSpecifier:
1522 assert(Tok.
is(tok::r_square) &&
"isCXX11AttributeSpecifier lied");
1524 Diag(BeginLoc, diag::err_attributes_not_allowed)
1528 llvm_unreachable(
"All cases handled above.");
1535 void Parser::DiagnoseMisplacedCXX11Attribute(ParsedAttributesWithRange &Attrs,
1537 assert((Tok.
is(tok::l_square) &&
NextToken().
is(tok::l_square)) ||
1538 Tok.
is(tok::kw_alignas));
1542 ParseCXX11Attributes(Attrs);
1545 Diag(Loc, diag::err_attributes_not_allowed)
1550 void Parser::DiagnoseProhibitedAttributes(ParsedAttributesWithRange &attrs) {
1551 Diag(attrs.Range.getBegin(), diag::err_attributes_not_allowed)
1555 void Parser::ProhibitCXX11Attributes(ParsedAttributesWithRange &Attrs,
1561 Diag(Attr->
getLoc(), diag::warn_unknown_attribute_ignored)
1578 void Parser::stripTypeAttributesOffDeclSpec(ParsedAttributesWithRange &Attrs,
1592 if ((AL->
getKind() == AttributeList::AT_Aligned &&
1601 TypeAttrTail->
setNext(
nullptr);
1624 Attrs.addAllAtEnd(TypeAttrHead);
1645 ParsedAttributesWithRange &attrs) {
1651 Decl *SingleDecl =
nullptr;
1653 case tok::kw_template:
1654 case tok::kw_export:
1655 ProhibitAttributes(attrs);
1656 SingleDecl = ParseDeclarationStartingWithTemplate(Context, DeclEnd);
1658 case tok::kw_inline:
1661 ProhibitAttributes(attrs);
1663 return ParseNamespace(Context, DeclEnd, InlineLoc);
1665 return ParseSimpleDeclaration(Context, DeclEnd, attrs,
1667 case tok::kw_namespace:
1668 ProhibitAttributes(attrs);
1669 return ParseNamespace(Context, DeclEnd);
1671 return ParseUsingDirectiveOrDeclaration(Context, ParsedTemplateInfo(),
1673 case tok::kw_static_assert:
1674 case tok::kw__Static_assert:
1675 ProhibitAttributes(attrs);
1676 SingleDecl = ParseStaticAssertDeclaration(DeclEnd);
1679 return ParseSimpleDeclaration(Context, DeclEnd, attrs,
true);
1704 Parser::ParseSimpleDeclaration(
unsigned Context,
1706 ParsedAttributesWithRange &Attrs,
1707 bool RequireSemi, ForRangeInit *FRI) {
1711 DeclSpecContext DSContext = getDeclSpecContextFromDeclaratorContext(Context);
1712 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(),
AS_none, DSContext);
1717 DiagnoseMissingSemiAfterTagDefinition(DS,
AS_none, DSContext))
1722 if (Tok.
is(tok::semi)) {
1723 ProhibitAttributes(Attrs);
1729 DS.complete(TheDecl);
1731 Decl* decls[] = {AnonRecord, TheDecl};
1738 return ParseDeclGroup(DS, Context, &DeclEnd, FRI);
1743 bool Parser::MightBeDeclarator(
unsigned Context) {
1745 case tok::annot_cxxscope:
1746 case tok::annot_template_id:
1748 case tok::code_completion:
1749 case tok::coloncolon:
1751 case tok::kw___attribute:
1752 case tok::kw_operator:
1768 case tok::identifier:
1770 case tok::code_completion:
1771 case tok::coloncolon:
1774 case tok::equalequal:
1775 case tok::kw_alignas:
1777 case tok::kw___attribute:
1795 case tok::identifier:
1818 if (Tok.
isOneOf(tok::comma, tok::l_brace, tok::kw_try)) {
1842 case tok::kw_inline:
1847 (!ParsingInObjCContainer || CurParsedObjCImpl))
1851 case tok::kw_namespace:
1856 (!ParsingInObjCContainer || CurParsedObjCImpl))
1863 ParsingInObjCContainer)
1875 case tok::annot_module_begin:
1876 case tok::annot_module_end:
1877 case tok::annot_module_include:
1894 ForRangeInit *FRI) {
1900 if (!D.hasName() && !D.mayOmitIdentifier()) {
1908 LateParsedAttrList LateParsedAttrs(
true);
1909 if (D.isFunctionDeclarator()) {
1910 MaybeParseGNUAttributes(D, &LateParsedAttrs);
1915 if (Tok.
is(tok::kw__Noreturn)) {
1917 const char *PrevSpec;
1923 MaybeParseGNUAttributes(D, &LateParsedAttrs);
1924 Fixit &= Tok.
isOneOf(tok::semi, tok::l_brace, tok::kw_try);
1926 Diag(Loc, diag::err_c11_noreturn_misplaced)
1928 << (Fixit ?
FixItHint::CreateInsertion(D.getLocStart(),
"_Noreturn ")
1934 if (D.isFunctionDeclarator() &&
1938 !isDeclarationAfterDeclarator()) {
1944 if (isStartOfFunctionDefinition(D)) {
1946 Diag(Tok, diag::err_function_declared_typedef);
1953 ParseFunctionDefinition(D, ParsedTemplateInfo(), &LateParsedAttrs);
1957 if (isDeclarationSpecifier()) {
1965 Diag(Tok, diag::err_expected_fn_body);
1970 if (Tok.
is(tok::l_brace)) {
1971 Diag(Tok, diag::err_function_definition_not_allowed);
1978 if (ParseAsmAttributesAfterDeclarator(D))
1987 if (FRI && (Tok.
is(tok::colon) || isTokIdentifier_in())) {
1988 bool IsForRangeLoop =
false;
1990 IsForRangeLoop =
true;
1991 if (Tok.
is(tok::l_brace))
1992 FRI->RangeExpr = ParseBraceInitializer();
2001 D.complete(ThisDecl);
2006 Decl *FirstDecl = ParseDeclarationAfterDeclaratorAndAttributes(
2007 D, ParsedTemplateInfo(), FRI);
2008 if (LateParsedAttrs.size() > 0)
2009 ParseLexedAttributeList(LateParsedAttrs, FirstDecl,
true,
false);
2010 D.complete(FirstDecl);
2012 DeclsInGroup.push_back(FirstDecl);
2020 if (Tok.
isAtStartOfLine() && ExpectSemi && !MightBeDeclarator(Context)) {
2024 Diag(CommaLoc, diag::err_expected_semi_declaration)
2032 D.setCommaLoc(CommaLoc);
2041 MaybeParseGNUAttributes(D);
2045 DiagnoseAndSkipExtendedMicrosoftTypeAttributes();
2048 if (!D.isInvalidType()) {
2049 Decl *ThisDecl = ParseDeclarationAfterDeclarator(D);
2050 D.complete(ThisDecl);
2052 DeclsInGroup.push_back(ThisDecl);
2061 ? diag::err_invalid_token_after_toplevel_declarator
2062 : diag::err_expected_semi_declaration)) {
2066 if (!isDeclarationSpecifier()) {
2077 bool Parser::ParseAsmAttributesAfterDeclarator(
Declarator &D) {
2079 if (Tok.
is(tok::kw_asm)) {
2082 if (AsmLabel.isInvalid()) {
2091 MaybeParseGNUAttributes(D);
2117 Decl *Parser::ParseDeclarationAfterDeclarator(
2118 Declarator &D,
const ParsedTemplateInfo &TemplateInfo) {
2119 if (ParseAsmAttributesAfterDeclarator(D))
2122 return ParseDeclarationAfterDeclaratorAndAttributes(D, TemplateInfo);
2125 Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
2126 Declarator &D,
const ParsedTemplateInfo &TemplateInfo, ForRangeInit *FRI) {
2128 Decl *ThisDecl =
nullptr;
2129 switch (TemplateInfo.Kind) {
2130 case ParsedTemplateInfo::NonTemplate:
2134 case ParsedTemplateInfo::Template:
2135 case ParsedTemplateInfo::ExplicitSpecialization: {
2137 *TemplateInfo.TemplateParams,
2139 if (
VarTemplateDecl *VT = dyn_cast_or_null<VarTemplateDecl>(ThisDecl))
2142 ThisDecl = VT->getTemplatedDecl();
2145 case ParsedTemplateInfo::ExplicitInstantiation: {
2146 if (Tok.
is(tok::semi)) {
2148 getCurScope(), TemplateInfo.ExternLoc, TemplateInfo.TemplateLoc, D);
2153 ThisDecl = ThisRes.
get();
2161 Diag(Tok, diag::err_template_defn_explicit_instantiation)
2168 diag::err_explicit_instantiation_with_definition)
2176 LAngleLoc,
nullptr));
2188 if (isTokenEqualOrEqualTypo()) {
2191 if (Tok.
is(tok::kw_delete)) {
2197 }
else if (Tok.
is(tok::kw_default)) {
2209 if (Tok.
is(tok::code_completion)) {
2221 Diag(EqualLoc, diag::err_single_decl_assign_in_for_range)
2225 FRI->ColonLoc = EqualLoc;
2227 FRI->RangeExpr = Init;
2235 if (Init.isInvalid()) {
2237 StopTokens.push_back(tok::comma);
2240 StopTokens.push_back(tok::r_paren);
2247 }
else if (Tok.
is(tok::l_paren)) {
2253 CommaLocsTy CommaLocs;
2260 if (ParseExpressionList(Exprs, CommaLocs, [&] {
2262 cast<VarDecl>(ThisDecl)->getType()->getCanonicalTypeInternal(),
2276 assert(!Exprs.empty() && Exprs.size()-1 == CommaLocs.size() &&
2277 "Unexpected number of commas!");
2285 T.getCloseLocation(),
2290 }
else if (
getLangOpts().CPlusPlus11 && Tok.
is(tok::l_brace) &&
2293 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
2307 if (Init.isInvalid()) {
2328 DeclSpecContext DSC) {
2332 ParseDeclarationSpecifiers(DS, ParsedTemplateInfo(), AS, DSC);
2337 Diag(Tok, diag::err_expected_type);
2340 Diag(Tok, diag::err_typename_requires_specqual);
2351 diag::err_typename_invalid_storageclass);
2392 return T.
isOneOf(tok::l_square, tok::l_paren, tok::r_paren, tok::semi,
2393 tok::comma, tok::equal, tok::kw_asm, tok::l_brace,
2407 const ParsedTemplateInfo &TemplateInfo,
2409 ParsedAttributesWithRange &Attrs) {
2410 assert(Tok.
is(tok::identifier) &&
"should have identifier");
2432 if (!isTypeSpecifier(DSC) && !
getLangOpts().CPlusPlus &&
2445 AnnotateScopeToken(*SS,
false);
2456 DSC == DSC_template_type_arg)) {
2457 const char *PrevSpec;
2473 if (SS ==
nullptr) {
2474 const char *TagName =
nullptr, *FixitTagName =
nullptr;
2480 TagName=
"enum" ; FixitTagName =
"enum " ; TagKind=tok::kw_enum ;
break;
2482 TagName=
"union" ; FixitTagName =
"union " ;TagKind=tok::kw_union ;
break;
2484 TagName=
"struct"; FixitTagName =
"struct ";TagKind=tok::kw_struct;
break;
2486 TagName=
"__interface"; FixitTagName =
"__interface ";
2487 TagKind=tok::kw___interface;
break;
2489 TagName=
"class" ; FixitTagName =
"class " ;TagKind=tok::kw_class ;
break;
2497 Diag(Loc, diag::err_use_of_tag_name_without_tag)
2498 << TokenName << TagName <<
getLangOpts().CPlusPlus
2504 Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
2505 << TokenName << TagName;
2509 if (TagKind == tok::kw_enum)
2510 ParseEnumSpecifier(Loc, DS, TemplateInfo, AS, DSC_normal);
2512 ParseClassSpecifier(TagKind, Loc, DS, TemplateInfo, AS,
2513 false, DSC_normal, Attrs);
2520 if (!isTypeSpecifier(DSC) &&
2521 (!SS || DSC == DSC_top_level || DSC == DSC_class)) {
2525 case tok::l_paren: {
2532 TentativeParsingAction PA(*
this);
2534 TPResult TPR = TryParseDeclarator(
false);
2545 if (DSC == DSC_class || (DSC == DSC_top_level && SS)) {
2548 Diag(Loc, diag::err_constructor_bad_name)
2566 AnnotateScopeToken(*SS,
false);
2588 const char *PrevSpec;
2609 if (IsTemplateName) {
2611 TemplateArgList Args;
2612 ParseTemplateIdAfterTemplateName(
true, LAngle, Args, RAngle);
2626 Parser::DeclSpecContext
2627 Parser::getDeclSpecContextFromDeclaratorContext(
unsigned Context) {
2631 return DSC_top_level;
2633 return DSC_template_param;
2635 return DSC_template_type_arg;
2637 return DSC_trailing;
2640 return DSC_alias_declaration;
2656 if (isTypeIdInParens()) {
2681 assert(Tok.
isOneOf(tok::kw_alignas, tok::kw__Alignas) &&
2682 "Not an alignment-specifier!");
2688 if (T.expectAndConsume())
2692 ExprResult ArgExpr = ParseAlignArgument(T.getOpenLocation(), EllipsisLoc);
2700 *EndLoc = T.getCloseLocation();
2703 ArgExprs.push_back(ArgExpr.
get());
2704 Attrs.
addNew(KWName, KWLoc,
nullptr, KWLoc, ArgExprs.data(), 1,
2717 DeclSpecContext DSContext,
2718 LateParsedAttrList *LateAttrs) {
2721 bool EnteringContext = (DSContext == DSC_class || DSContext == DSC_top_level);
2724 Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_decltype,
2725 tok::annot_template_id) &&
2731 bool HasScope = Tok.
is(tok::annot_cxxscope);
2737 bool MightBeDeclarator =
true;
2738 if (Tok.
isOneOf(tok::kw_typename, tok::annot_typename)) {
2740 MightBeDeclarator =
false;
2741 }
else if (AfterScope.
is(tok::annot_template_id)) {
2747 MightBeDeclarator =
false;
2748 }
else if (AfterScope.
is(tok::identifier)) {
2749 const Token &Next = HasScope ? GetLookAheadToken(2) : NextToken();
2753 if (Next.
isOneOf(tok::star, tok::amp, tok::ampamp, tok::identifier,
2754 tok::annot_cxxscope, tok::coloncolon)) {
2756 MightBeDeclarator =
false;
2757 }
else if (HasScope) {
2768 switch (Classification.
getKind()) {
2775 llvm_unreachable(
"typo correction and nested name specifiers not "
2781 MightBeDeclarator =
false;
2794 if (MightBeDeclarator)
2799 diag::err_expected_after)
2810 ParsedTemplateInfo NotATemplate;
2811 ParseDeclarationSpecifiers(DS, NotATemplate, AS, DSContext, LateAttrs);
2842 void Parser::ParseDeclarationSpecifiers(
DeclSpec &DS,
2843 const ParsedTemplateInfo &TemplateInfo,
2845 DeclSpecContext DSContext,
2846 LateParsedAttrList *LateAttrs) {
2855 bool EnteringContext = (DSContext == DSC_class || DSContext == DSC_top_level);
2856 bool AttrsLastTime =
false;
2857 ParsedAttributesWithRange attrs(AttrFactory);
2862 bool isStorageClass =
false;
2863 const char *PrevSpec =
nullptr;
2864 unsigned DiagID = 0;
2884 ProhibitAttributes(attrs);
2889 ProhibitCXX11Attributes(attrs, diag::err_attribute_not_type_attr);
2896 DS.
Finish(Actions, Policy);
2900 case tok::kw_alignas:
2902 goto DoneWithDeclSpec;
2904 ProhibitAttributes(attrs);
2911 ParseCXX11Attributes(attrs);
2912 AttrsLastTime =
true;
2915 case tok::code_completion: {
2918 bool AllowNonIdentifiers
2924 bool AllowNestedNameSpecifiers
2925 = DSContext == DSC_top_level ||
2929 AllowNonIdentifiers,
2930 AllowNestedNameSpecifiers);
2931 return cutOffParsing();
2936 else if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
2939 else if (DSContext == DSC_class)
2941 else if (CurParsedObjCImpl)
2945 return cutOffParsing();
2948 case tok::coloncolon:
2953 goto DoneWithDeclSpec;
2955 if (Tok.
is(tok::coloncolon))
2956 goto DoneWithDeclSpec;
2959 case tok::annot_cxxscope: {
2961 goto DoneWithDeclSpec;
2970 if (Next.
is(tok::annot_template_id) &&
2983 if ((DSContext == DSC_top_level || DSContext == DSC_class) &&
2986 isConstructorDeclarator(
false)) {
2991 goto DoneWithDeclSpec;
2995 ConsumeAnnotationToken();
2996 assert(Tok.
is(tok::annot_template_id) &&
2997 "ParseOptionalCXXScopeSpecifier not working");
2998 AnnotateTemplateIdTokenAsType();
3002 if (Next.
is(tok::annot_typename)) {
3004 ConsumeAnnotationToken();
3009 PrevSpec, DiagID, T, Policy);
3016 ConsumeAnnotationToken();
3019 if (Next.
isNot(tok::identifier))
3020 goto DoneWithDeclSpec;
3025 if ((DSContext == DSC_top_level || DSContext == DSC_class) &&
3028 isConstructorDeclarator(
false))
3029 goto DoneWithDeclSpec;
3036 isClassTemplateDeductionContext(DSContext));
3044 ConsumeAnnotationToken();
3045 ParsedAttributesWithRange Attrs(AttrFactory);
3046 if (ParseImplicitInt(DS, &SS, TemplateInfo, AS, DSContext, Attrs)) {
3047 if (!Attrs.
empty()) {
3048 AttrsLastTime =
true;
3049 attrs.takeAllFrom(Attrs);
3053 goto DoneWithDeclSpec;
3057 ConsumeAnnotationToken();
3060 DiagID, TypeRep, Policy);
3070 case tok::annot_typename: {
3074 goto DoneWithDeclSpec;
3087 ConsumeAnnotationToken();
3092 case tok::kw___is_signed:
3103 TryKeywordIdentFallback(
true);
3106 goto DoneWithDeclSpec;
3109 case tok::kw___super:
3110 case tok::kw_decltype:
3111 case tok::identifier: {
3116 goto DoneWithDeclSpec;
3122 if (!
getLangOpts().DeclSpecKeyword && Tok.
is(tok::identifier) &&
3124 Diag(Loc, diag::err_ms_attributes_not_enabled);
3134 if (T.consumeOpen()) {
3135 assert(
false &&
"Not a left paren?");
3148 goto DoneWithDeclSpec;
3150 if (!Tok.
is(tok::identifier))
3155 if (TryAltiVecToken(DS, Loc, PrevSpec, DiagID, isInvalid))
3161 goto DoneWithDeclSpec;
3163 if (DSContext == DSC_objc_method_result && isObjCInstancetype()) {
3167 DiagID, TypeRep, Policy);
3178 false,
false,
nullptr,
false,
false,
3179 isClassTemplateDeductionContext(DSContext));
3184 ParsedAttributesWithRange Attrs(AttrFactory);
3185 if (ParseImplicitInt(DS,
nullptr, TemplateInfo, AS, DSContext, Attrs)) {
3186 if (!Attrs.
empty()) {
3187 AttrsLastTime =
true;
3188 attrs.takeAllFrom(Attrs);
3192 goto DoneWithDeclSpec;
3199 isConstructorDeclarator(
true))
3200 goto DoneWithDeclSpec;
3205 (DSContext == DSC_class || DSContext == DSC_top_level) &&
3208 isConstructorDeclarator(
true,
3210 goto DoneWithDeclSpec;
3213 DiagID, TypeRep, Policy);
3225 TypeResult NewTypeRep = parseObjCTypeArgsAndProtocolQualifiers(
3240 case tok::annot_template_id: {
3245 goto DoneWithDeclSpec;
3253 isConstructorDeclarator(TemplateId->
SS.
isEmpty()))
3254 goto DoneWithDeclSpec;
3258 AnnotateTemplateIdTokenAsType();
3263 case tok::kw___attribute:
3268 case tok::kw___declspec:
3273 case tok::kw___forceinline: {
3282 case tok::kw___unaligned:
3287 case tok::kw___sptr:
3288 case tok::kw___uptr:
3289 case tok::kw___ptr64:
3290 case tok::kw___ptr32:
3292 case tok::kw___cdecl:
3293 case tok::kw___stdcall:
3294 case tok::kw___fastcall:
3295 case tok::kw___thiscall:
3296 case tok::kw___regcall:
3297 case tok::kw___vectorcall:
3302 case tok::kw___pascal:
3307 case tok::kw___kernel:
3312 case tok::kw__Nonnull:
3313 case tok::kw__Nullable:
3314 case tok::kw__Null_unspecified:
3319 case tok::kw___kindof:
3326 case tok::kw_typedef:
3328 PrevSpec, DiagID, Policy);
3329 isStorageClass =
true;
3331 case tok::kw_extern:
3333 Diag(Tok, diag::ext_thread_before) <<
"extern";
3335 PrevSpec, DiagID, Policy);
3336 isStorageClass =
true;
3338 case tok::kw___private_extern__:
3340 Loc, PrevSpec, DiagID, Policy);
3341 isStorageClass =
true;
3343 case tok::kw_static:
3345 Diag(Tok, diag::ext_thread_before) <<
"static";
3347 PrevSpec, DiagID, Policy);
3348 isStorageClass =
true;
3352 if (isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
3354 PrevSpec, DiagID, Policy);
3356 Diag(Tok, diag::ext_auto_storage_class)
3363 PrevSpec, DiagID, Policy);
3364 isStorageClass =
true;
3366 case tok::kw___auto_type:
3367 Diag(Tok, diag::ext_auto_type);
3371 case tok::kw_register:
3373 PrevSpec, DiagID, Policy);
3374 isStorageClass =
true;
3376 case tok::kw_mutable:
3378 PrevSpec, DiagID, Policy);
3379 isStorageClass =
true;
3381 case tok::kw___thread:
3384 isStorageClass =
true;
3386 case tok::kw_thread_local:
3390 case tok::kw__Thread_local:
3392 Loc, PrevSpec, DiagID);
3393 isStorageClass =
true;
3397 case tok::kw_inline:
3400 case tok::kw_virtual:
3403 case tok::kw_explicit:
3406 case tok::kw__Noreturn:
3408 Diag(Loc, diag::ext_c11_noreturn);
3413 case tok::kw__Alignas:
3415 Diag(Tok, diag::ext_c11_alignment) << Tok.
getName();
3420 case tok::kw_friend:
3421 if (DSContext == DSC_class)
3425 DiagID = diag::err_friend_invalid_in_context;
3431 case tok::kw___module_private__:
3436 case tok::kw_constexpr:
3441 case tok::kw_concept:
3458 case tok::kw___int64:
3462 case tok::kw_signed:
3466 case tok::kw_unsigned:
3470 case tok::kw__Complex:
3474 case tok::kw__Imaginary:
3490 case tok::kw___int128:
3502 case tok::kw_double:
3506 case tok::kw___float128:
3510 case tok::kw_wchar_t:
3514 case tok::kw_char16_t:
3518 case tok::kw_char32_t:
3524 if (Tok.
is(tok::kw_bool) &&
3528 DiagID = diag::err_bool_redeclaration;
3537 case tok::kw__Decimal32:
3541 case tok::kw__Decimal64:
3545 case tok::kw__Decimal128:
3549 case tok::kw___vector:
3552 case tok::kw___pixel:
3555 case tok::kw___bool:
3563 goto DoneWithDeclSpec;
3565 isInvalid = DS.
SetTypePipe(
true, Loc, PrevSpec, DiagID, Policy);
3567 #define GENERIC_IMAGE_TYPE(ImgType, Id) \
3568 case tok::kw_##ImgType##_t: \
3569 isInvalid = DS.SetTypeSpecType(DeclSpec::TST_##ImgType##_t, Loc, PrevSpec, \
3572 #include "clang/Basic/OpenCLImageTypes.def"
3573 case tok::kw___unknown_anytype:
3575 PrevSpec, DiagID, Policy);
3580 case tok::kw_struct:
3581 case tok::kw___interface:
3582 case tok::kw_union: {
3589 ParsedAttributesWithRange Attributes(AttrFactory);
3590 ParseClassSpecifier(Kind, Loc, DS, TemplateInfo, AS,
3591 EnteringContext, DSContext, Attributes);
3595 if (!Attributes.empty()) {
3596 AttrsLastTime =
true;
3597 attrs.takeAllFrom(Attributes);
3605 ParseEnumSpecifier(Loc, DS, TemplateInfo, AS, DSContext);
3613 case tok::kw_volatile:
3617 case tok::kw_restrict:
3623 case tok::kw_typename:
3626 goto DoneWithDeclSpec;
3628 if (!Tok.
is(tok::kw_typename))
3633 case tok::kw_typeof:
3634 ParseTypeofSpecifier(DS);
3637 case tok::annot_decltype:
3638 ParseDecltypeSpecifier(DS);
3641 case tok::annot_pragma_pack:
3645 case tok::annot_pragma_ms_pragma:
3646 HandlePragmaMSPragma();
3649 case tok::annot_pragma_ms_vtordisp:
3650 HandlePragmaMSVtorDisp();
3653 case tok::annot_pragma_ms_pointers_to_members:
3654 HandlePragmaMSPointersToMembers();
3657 case tok::kw___underlying_type:
3658 ParseUnderlyingTypeSpecifier(DS);
3661 case tok::kw__Atomic:
3667 ParseAtomicSpecifier(DS);
3675 case tok::kw___generic:
3679 DiagID = diag::err_opencl_unknown_type_specifier;
3685 case tok::kw___private:
3686 case tok::kw___global:
3687 case tok::kw___local:
3688 case tok::kw___constant:
3689 case tok::kw___read_only:
3690 case tok::kw___write_only:
3691 case tok::kw___read_write:
3700 goto DoneWithDeclSpec;
3707 PrevSpec, DiagID, Type.
get(),
3709 Diag(StartLoc, DiagID) << PrevSpec;
3722 assert(PrevSpec &&
"Method did not return previous specifier!");
3725 if (DiagID == diag::ext_duplicate_declspec)
3728 else if (DiagID == diag::err_opencl_unknown_type_specifier) {
3729 const int OpenCLVer =
getLangOpts().OpenCLVersion;
3730 std::string VerSpec = llvm::to_string(OpenCLVer / 100) +
3732 llvm::to_string((OpenCLVer % 100) / 10);
3733 Diag(Tok, DiagID) << VerSpec << PrevSpec << isStorageClass;
3735 Diag(Tok, DiagID) << PrevSpec;
3739 if (DiagID != diag::err_bool_redeclaration)
3742 AttrsLastTime =
false;
3763 void Parser::ParseStructDeclaration(
3767 if (Tok.
is(tok::kw___extension__)) {
3771 return ParseStructDeclaration(DS, FieldsCallback);
3775 ParseSpecifierQualifierList(DS);
3779 if (Tok.
is(tok::semi)) {
3783 assert(!AnonRecord &&
"Did not expect anonymous struct or union here");
3789 bool FirstDeclarator =
true;
3793 DeclaratorInfo.D.setCommaLoc(CommaLoc);
3796 if (!FirstDeclarator)
3797 MaybeParseGNUAttributes(DeclaratorInfo.D);
3801 if (Tok.
isNot(tok::colon)) {
3804 ParseDeclarator(DeclaratorInfo.D);
3806 DeclaratorInfo.D.SetIdentifier(
nullptr, Tok.
getLocation());
3810 if (Res.isInvalid())
3813 DeclaratorInfo.BitfieldSize = Res.get();
3817 MaybeParseGNUAttributes(DeclaratorInfo.D);
3820 FieldsCallback(DeclaratorInfo);
3827 FirstDeclarator =
false;
3844 "parsing struct/union body");
3848 if (T.consumeOpen())
3857 while (!tryParseMisplacedModuleImport() && Tok.
isNot(tok::r_brace) &&
3862 if (Tok.
is(tok::semi)) {
3863 ConsumeExtraSemi(InsideStruct, TagType);
3868 if (Tok.
is(tok::kw__Static_assert)) {
3870 ParseStaticAssertDeclaration(DeclEnd);
3874 if (Tok.
is(tok::annot_pragma_pack)) {
3879 if (Tok.
is(tok::annot_pragma_align)) {
3880 HandlePragmaAlign();
3884 if (Tok.
is(tok::annot_pragma_openmp)) {
3887 ParsedAttributesWithRange Attrs(AttrFactory);
3888 (void)ParseOpenMPDeclarativeDirectiveWithExtDecl(AS, Attrs);
3892 if (!Tok.
is(tok::at)) {
3898 FD.D, FD.BitfieldSize);
3899 FieldDecls.push_back(Field);
3905 ParseStructDeclaration(DS, CFieldCallback);
3909 Diag(Tok, diag::err_unexpected_at);
3914 ExpectAndConsume(tok::l_paren);
3915 if (!Tok.
is(tok::identifier)) {
3916 Diag(Tok, diag::err_expected) << tok::identifier;
3923 FieldDecls.insert(FieldDecls.end(), Fields.begin(), Fields.end());
3925 ExpectAndConsume(tok::r_paren);
3931 if (Tok.
is(tok::r_brace)) {
3932 ExpectAndConsume(tok::semi, diag::ext_expected_semi_decl_list);
3936 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
3947 MaybeParseGNUAttributes(attrs);
3950 RecordLoc, TagDecl, FieldDecls,
3951 T.getOpenLocation(), T.getCloseLocation(),
3988 const ParsedTemplateInfo &TemplateInfo,
3991 if (Tok.
is(tok::code_completion)) {
3994 return cutOffParsing();
3998 ParsedAttributesWithRange attrs(AttrFactory);
3999 MaybeParseGNUAttributes(attrs);
4000 MaybeParseCXX11Attributes(attrs);
4001 MaybeParseMicrosoftDeclSpecs(attrs);
4004 bool IsScopedUsingClassTag =
false;
4007 if (Tok.
isOneOf(tok::kw_class, tok::kw_struct)) {
4009 : diag::ext_scoped_enum);
4010 IsScopedUsingClassTag = Tok.
is(tok::kw_class);
4015 ProhibitAttributes(attrs);
4018 MaybeParseGNUAttributes(attrs);
4019 MaybeParseCXX11Attributes(attrs);
4020 MaybeParseMicrosoftDeclSpecs(attrs);
4029 bool shouldDelayDiagsInTag =
4030 (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation ||
4031 TemplateInfo.Kind == ParsedTemplateInfo::ExplicitSpecialization);
4035 bool AllowDeclaration = DSC != DSC_trailing;
4037 bool AllowFixedUnderlyingType = AllowDeclaration &&
4048 if (ParseOptionalCXXScopeSpecifier(Spec,
nullptr,
4052 if (Spec.
isSet() && Tok.
isNot(tok::identifier)) {
4053 Diag(Tok, diag::err_expected) << tok::identifier;
4054 if (Tok.
isNot(tok::l_brace)) {
4066 if (Tok.
isNot(tok::identifier) && Tok.
isNot(tok::l_brace) &&
4067 !(AllowFixedUnderlyingType && Tok.
is(tok::colon))) {
4068 Diag(Tok, diag::err_expected_either) << tok::identifier << tok::l_brace;
4078 if (Tok.
is(tok::identifier)) {
4083 if (!Name && ScopedEnumKWLoc.
isValid()) {
4086 Diag(Tok, diag::err_scoped_enum_missing_identifier);
4088 IsScopedUsingClassTag =
false;
4093 if (shouldDelayDiagsInTag)
4094 diagsFromTag.done();
4100 if (AllowFixedUnderlyingType && Tok.
is(tok::colon)) {
4101 bool PossibleBitfield =
false;
4102 if (CanBeBitfield) {
4116 PossibleBitfield =
true;
4122 GetLookAheadToken(2).
getKind() == tok::semi) {
4129 TentativeParsingAction TPA(*
this);
4144 PossibleBitfield =
true;
4156 if (!PossibleBitfield) {
4161 Diag(StartLoc, diag::warn_cxx98_compat_enum_fixed_underlying_type);
4164 Diag(StartLoc, diag::ext_cxx11_enum_fixed_underlying_type) << Range;
4166 Diag(StartLoc, diag::ext_c_enum_fixed_underlying_type) << Range;
4182 if (!AllowDeclaration) {
4184 }
else if (Tok.
is(tok::l_brace)) {
4194 }
else if (!isTypeSpecifier(DSC) &&
4195 (Tok.
is(tok::semi) ||
4197 !isValidAfterTypeSpecifier(CanBeBitfield)))) {
4199 if (Tok.
isNot(tok::semi)) {
4201 ExpectAndConsume(tok::semi, diag::err_expected_after,
"enum");
4212 diagsFromTag.redelay();
4216 if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate &&
4220 Diag(Tok, diag::err_enum_template);
4225 if (TemplateInfo.Kind == ParsedTemplateInfo::ExplicitInstantiation) {
4228 Diag(StartLoc, diag::err_explicit_instantiation_enum);
4232 assert(TemplateInfo.TemplateParams &&
"no template parameters");
4234 TemplateInfo.TemplateParams->size());
4238 ProhibitAttributes(attrs);
4241 Diag(Tok, diag::err_enumerator_unnamed_no_def);
4248 stripTypeAttributesOffDeclSpec(attrs, DS, TUK);
4258 bool IsDependent =
false;
4259 const char *PrevSpec =
nullptr;
4262 StartLoc, SS, Name, NameLoc, attrs.getList(),
4264 Owned, IsDependent, ScopedEnumKWLoc,
4265 IsScopedUsingClassTag, BaseType,
4266 DSC == DSC_type_specifier,
4267 DSC == DSC_template_param ||
4268 DSC == DSC_template_type_arg, &SkipBody);
4278 NameLoc.
isValid() ? NameLoc : StartLoc,
4279 PrevSpec, DiagID, TagDecl, Owned,
4281 Diag(StartLoc, DiagID) << PrevSpec;
4290 Diag(Tok, diag::err_expected_type_name_after_typename);
4302 NameLoc.
isValid() ? NameLoc : StartLoc,
4303 PrevSpec, DiagID, Type.
get(),
4305 Diag(StartLoc, DiagID) << PrevSpec;
4324 ParseEnumBody(StartLoc, D);
4333 NameLoc.
isValid() ? NameLoc : StartLoc,
4334 PrevSpec, DiagID, TagDecl, Owned,
4336 Diag(StartLoc, DiagID) << PrevSpec;
4359 Diag(Tok, diag::err_empty_enum);
4364 Decl *LastEnumConstDecl =
nullptr;
4367 while (Tok.
isNot(tok::r_brace)) {
4370 if (Tok.
isNot(tok::identifier)) {
4381 ParsedAttributesWithRange attrs(AttrFactory);
4382 MaybeParseGNUAttributes(attrs);
4383 ProhibitAttributes(attrs);
4388 ParseCXX11Attributes(attrs);
4393 EnumAvailabilityDiags.emplace_back(*
this);
4403 getCurScope(), EnumDecl, LastEnumConstDecl, IdentLoc, Ident,
4404 attrs.getList(), EqualLoc, AssignedVal.
get());
4405 EnumAvailabilityDiags.back().done();
4407 EnumConstantDecls.push_back(EnumConstDecl);
4408 LastEnumConstDecl = EnumConstDecl;
4410 if (Tok.
is(tok::identifier)) {
4413 Diag(Loc, diag::err_enumerator_list_missing_comma)
4436 if (Tok.
is(tok::r_brace) && CommaLoc.
isValid()) {
4439 diag::ext_enumerator_list_comma_cxx :
4440 diag::ext_enumerator_list_comma_c)
4443 Diag(CommaLoc, diag::warn_cxx98_compat_enumerator_list_comma)
4454 MaybeParseGNUAttributes(attrs);
4457 EnumDecl, EnumConstantDecls,
4462 assert(EnumConstantDecls.size() == EnumAvailabilityDiags.size());
4463 for (
size_t i = 0, e = EnumConstantDecls.size(); i != e; ++i) {
4465 EnumAvailabilityDiags[i].redelay();
4466 PD.complete(EnumConstantDecls[i]);
4475 if (!isValidAfterTypeSpecifier(CanBeBitfield)) {
4476 ExpectAndConsume(tok::semi, diag::err_expected_after,
"enum");
4488 bool Parser::isKnownToBeTypeSpecifier(
const Token &Tok)
const {
4490 default:
return false;
4494 case tok::kw___int64:
4495 case tok::kw___int128:
4496 case tok::kw_signed:
4497 case tok::kw_unsigned:
4498 case tok::kw__Complex:
4499 case tok::kw__Imaginary:
4502 case tok::kw_wchar_t:
4503 case tok::kw_char16_t:
4504 case tok::kw_char32_t:
4508 case tok::kw_double:
4509 case tok::kw___float128:
4512 case tok::kw__Decimal32:
4513 case tok::kw__Decimal64:
4514 case tok::kw__Decimal128:
4515 case tok::kw___vector:
4516 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
4517 #include "clang/Basic/OpenCLImageTypes.def"
4521 case tok::kw_struct:
4522 case tok::kw___interface:
4528 case tok::annot_typename:
4535 bool Parser::isTypeSpecifierQualifier() {
4537 default:
return false;
4539 case tok::identifier:
4540 if (TryAltiVecVectorToken())
4543 case tok::kw_typename:
4548 if (Tok.
is(tok::identifier))
4550 return isTypeSpecifierQualifier();
4552 case tok::coloncolon:
4559 return isTypeSpecifierQualifier();
4562 case tok::kw___attribute:
4564 case tok::kw_typeof:
4569 case tok::kw___int64:
4570 case tok::kw___int128:
4571 case tok::kw_signed:
4572 case tok::kw_unsigned:
4573 case tok::kw__Complex:
4574 case tok::kw__Imaginary:
4577 case tok::kw_wchar_t:
4578 case tok::kw_char16_t:
4579 case tok::kw_char32_t:
4583 case tok::kw_double:
4584 case tok::kw___float128:
4587 case tok::kw__Decimal32:
4588 case tok::kw__Decimal64:
4589 case tok::kw__Decimal128:
4590 case tok::kw___vector:
4591 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
4592 #include "clang/Basic/OpenCLImageTypes.def"
4596 case tok::kw_struct:
4597 case tok::kw___interface:
4604 case tok::kw_volatile:
4605 case tok::kw_restrict:
4608 case tok::kw___unknown_anytype:
4611 case tok::annot_typename:
4618 case tok::kw___cdecl:
4619 case tok::kw___stdcall:
4620 case tok::kw___fastcall:
4621 case tok::kw___thiscall:
4622 case tok::kw___regcall:
4623 case tok::kw___vectorcall:
4625 case tok::kw___ptr64:
4626 case tok::kw___ptr32:
4627 case tok::kw___pascal:
4628 case tok::kw___unaligned:
4630 case tok::kw__Nonnull:
4631 case tok::kw__Nullable:
4632 case tok::kw__Null_unspecified:
4634 case tok::kw___kindof:
4636 case tok::kw___private:
4637 case tok::kw___local:
4638 case tok::kw___global:
4639 case tok::kw___constant:
4640 case tok::kw___generic:
4641 case tok::kw___read_only:
4642 case tok::kw___read_write:
4643 case tok::kw___write_only:
4648 case tok::kw__Atomic:
4658 bool Parser::isDeclarationSpecifier(
bool DisambiguatingWithExpression) {
4660 default:
return false;
4665 case tok::identifier:
4669 if (TryAltiVecVectorToken())
4672 case tok::kw_decltype:
4673 case tok::kw_typename:
4678 if (Tok.
is(tok::identifier))
4686 if (DisambiguatingWithExpression &&
4687 isStartOfObjCClassMessageMissingOpenBracket())
4690 return isDeclarationSpecifier();
4692 case tok::coloncolon:
4701 return isDeclarationSpecifier();
4704 case tok::kw_typedef:
4705 case tok::kw_extern:
4706 case tok::kw___private_extern__:
4707 case tok::kw_static:
4709 case tok::kw___auto_type:
4710 case tok::kw_register:
4711 case tok::kw___thread:
4712 case tok::kw_thread_local:
4713 case tok::kw__Thread_local:
4716 case tok::kw___module_private__:
4719 case tok::kw___unknown_anytype:
4724 case tok::kw___int64:
4725 case tok::kw___int128:
4726 case tok::kw_signed:
4727 case tok::kw_unsigned:
4728 case tok::kw__Complex:
4729 case tok::kw__Imaginary:
4732 case tok::kw_wchar_t:
4733 case tok::kw_char16_t:
4734 case tok::kw_char32_t:
4739 case tok::kw_double:
4740 case tok::kw___float128:
4743 case tok::kw__Decimal32:
4744 case tok::kw__Decimal64:
4745 case tok::kw__Decimal128:
4746 case tok::kw___vector:
4750 case tok::kw_struct:
4752 case tok::kw___interface:
4758 case tok::kw_volatile:
4759 case tok::kw_restrict:
4762 case tok::kw_inline:
4763 case tok::kw_virtual:
4764 case tok::kw_explicit:
4765 case tok::kw__Noreturn:
4768 case tok::kw__Alignas:
4771 case tok::kw_friend:
4774 case tok::kw__Static_assert:
4777 case tok::kw_typeof:
4780 case tok::kw___attribute:
4783 case tok::annot_decltype:
4784 case tok::kw_constexpr:
4787 case tok::kw_concept:
4790 case tok::kw__Atomic:
4798 case tok::annot_typename:
4799 return !DisambiguatingWithExpression ||
4800 !isStartOfObjCClassMessageMissingOpenBracket();
4802 case tok::kw___declspec:
4803 case tok::kw___cdecl:
4804 case tok::kw___stdcall:
4805 case tok::kw___fastcall:
4806 case tok::kw___thiscall:
4807 case tok::kw___regcall:
4808 case tok::kw___vectorcall:
4810 case tok::kw___sptr:
4811 case tok::kw___uptr:
4812 case tok::kw___ptr64:
4813 case tok::kw___ptr32:
4814 case tok::kw___forceinline:
4815 case tok::kw___pascal:
4816 case tok::kw___unaligned:
4818 case tok::kw__Nonnull:
4819 case tok::kw__Nullable:
4820 case tok::kw__Null_unspecified:
4822 case tok::kw___kindof:
4824 case tok::kw___private:
4825 case tok::kw___local:
4826 case tok::kw___global:
4827 case tok::kw___constant:
4828 case tok::kw___generic:
4829 case tok::kw___read_only:
4830 case tok::kw___read_write:
4831 case tok::kw___write_only:
4832 #define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
4833 #include "clang/Basic/OpenCLImageTypes.def"
4839 bool Parser::isConstructorDeclarator(
bool IsUnqualified,
bool DeductionGuide) {
4840 TentativeParsingAction TPA(*
this);
4844 if (ParseOptionalCXXScopeSpecifier(SS,
nullptr,
4851 if (Tok.
is(tok::identifier)) {
4855 }
else if (Tok.
is(tok::annot_template_id)) {
4856 ConsumeAnnotationToken();
4864 SkipCXX11Attributes();
4867 if (Tok.
isNot(tok::l_paren)) {
4875 if (Tok.
is(tok::r_paren) ||
4884 isCXX11AttributeSpecifier(
false,
4891 DeclaratorScopeObj DeclScopeObj(*
this, SS);
4893 DeclScopeObj.EnterDeclaratorScope();
4897 MaybeParseMicrosoftAttributes(Attrs);
4902 bool IsConstructor =
false;
4903 if (isDeclarationSpecifier())
4904 IsConstructor =
true;
4905 else if (Tok.
is(tok::identifier) ||
4906 (Tok.
is(tok::annot_cxxscope) &&
NextToken().
is(tok::identifier))) {
4911 if (Tok.
is(tok::annot_cxxscope))
4912 ConsumeAnnotationToken();
4924 case tok::coloncolon:
4937 SkipCXX11Attributes();
4939 if (DeductionGuide) {
4941 IsConstructor = Tok.
is(tok::arrow);
4944 if (Tok.
is(tok::colon) || Tok.
is(tok::kw_try)) {
4948 IsConstructor =
true;
4950 if (Tok.
is(tok::semi) || Tok.
is(tok::l_brace)) {
4963 IsConstructor = IsUnqualified;
4968 IsConstructor =
true;
4974 return IsConstructor;
4989 void Parser::ParseTypeQualifierListOpt(
4990 DeclSpec &DS,
unsigned AttrReqs,
bool AtomicAllowed,
4991 bool IdentifierRequired,
4994 isCXX11AttributeSpecifier()) {
4995 ParsedAttributesWithRange attrs(AttrFactory);
4996 ParseCXX11Attributes(attrs);
5003 bool isInvalid =
false;
5004 const char *PrevSpec =
nullptr;
5005 unsigned DiagID = 0;
5009 case tok::code_completion:
5011 (*CodeCompletionHandler)();
5014 return cutOffParsing();
5020 case tok::kw_volatile:
5024 case tok::kw_restrict:
5028 case tok::kw__Atomic:
5030 goto DoneWithTypeQuals;
5036 case tok::kw___private:
5037 case tok::kw___global:
5038 case tok::kw___local:
5039 case tok::kw___constant:
5040 case tok::kw___generic:
5041 case tok::kw___read_only:
5042 case tok::kw___write_only:
5043 case tok::kw___read_write:
5047 case tok::kw___unaligned:
5051 case tok::kw___uptr:
5056 if (TryKeywordIdentFallback(
false))
5060 case tok::kw___sptr:
5062 case tok::kw___ptr64:
5063 case tok::kw___ptr32:
5064 case tok::kw___cdecl:
5065 case tok::kw___stdcall:
5066 case tok::kw___fastcall:
5067 case tok::kw___thiscall:
5068 case tok::kw___regcall:
5069 case tok::kw___vectorcall:
5070 if (AttrReqs & AR_DeclspecAttributesParsed) {
5074 goto DoneWithTypeQuals;
5075 case tok::kw___pascal:
5076 if (AttrReqs & AR_VendorAttributesParsed) {
5080 goto DoneWithTypeQuals;
5083 case tok::kw__Nonnull:
5084 case tok::kw__Nullable:
5085 case tok::kw__Null_unspecified:
5090 case tok::kw___kindof:
5096 case tok::kw___attribute:
5097 if (AttrReqs & AR_GNUAttributesParsedAndRejected)
5099 Diag(Tok, diag::err_attributes_not_allowed);
5103 if (AttrReqs & AR_GNUAttributesParsed ||
5104 AttrReqs & AR_GNUAttributesParsedAndRejected) {
5122 assert(PrevSpec &&
"Method did not return previous specifier!");
5123 Diag(Tok, DiagID) << PrevSpec;
5131 void Parser::ParseDeclarator(
Declarator &D) {
5134 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
5138 unsigned TheContext) {
5139 if (Kind == tok::star || Kind == tok::caret)
5142 if ((Kind == tok::kw_pipe) && Lang.OpenCL && (Lang.OpenCLVersion >= 200))
5145 if (!Lang.CPlusPlus)
5148 if (Kind == tok::amp)
5156 if (Kind == tok::ampamp)
5167 for (
unsigned Idx = 0; Idx != NumTypes; ++Idx)
5199 void Parser::ParseDeclaratorInternal(
Declarator &D,
5200 DirectDeclParseFunction DirectDeclParser) {
5208 (Tok.
is(tok::coloncolon) || Tok.
is(tok::kw_decltype) ||
5209 (Tok.
is(tok::identifier) &&
5211 Tok.
is(tok::annot_cxxscope))) {
5215 ParseOptionalCXXScopeSpecifier(SS,
nullptr, EnteringContext);
5218 if (Tok.
isNot(tok::star)) {
5223 AnnotateScopeToken(SS,
true);
5225 if (DirectDeclParser)
5226 (this->*DirectDeclParser)(D);
5233 ParseTypeQualifierListOpt(DS);
5237 ParseDeclaratorInternal(D, DirectDeclParser);
5253 ParseTypeQualifierListOpt(DS);
5262 if (DirectDeclParser)
5263 (this->*DirectDeclParser)(D);
5272 if (Kind == tok::star || Kind == tok::caret) {
5278 unsigned Reqs = AR_CXX11AttributesParsed | AR_DeclspecAttributesParsed |
5280 ? AR_GNUAttributesParsed
5281 : AR_GNUAttributesParsedAndRejected);
5286 ParseDeclaratorInternal(D, DirectDeclParser);
5287 if (Kind == tok::star)
5309 if (Kind == tok::ampamp)
5311 diag::warn_cxx98_compat_rvalue_reference :
5312 diag::ext_rvalue_reference);
5315 ParseTypeQualifierListOpt(DS);
5324 diag::err_invalid_reference_qualifier_application) <<
"const";
5327 diag::err_invalid_reference_qualifier_application) <<
"volatile";
5331 diag::err_invalid_reference_qualifier_application) <<
"_Atomic";
5335 ParseDeclaratorInternal(D, DirectDeclParser);
5342 Diag(InnerChunk.
Loc, diag::err_illegal_decl_reference_to_reference)
5345 Diag(InnerChunk.
Loc, diag::err_illegal_decl_reference_to_reference)
5421 void Parser::ParseDirectDeclarator(
Declarator &D) {
5428 return ParseDecompositionDeclarator(D);
5451 DeclScopeObj.EnterDeclaratorScope();
5458 goto PastIdentifier;
5483 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, D);
5493 if (Tok.
isOneOf(tok::identifier, tok::kw_operator, tok::annot_template_id,
5497 bool AllowConstructorName;
5498 bool AllowDeductionGuide;
5500 AllowConstructorName =
false;
5501 AllowDeductionGuide =
false;
5503 AllowConstructorName =
5506 AllowDeductionGuide =
false;
5509 AllowDeductionGuide =
5518 true, AllowConstructorName,
5519 AllowDeductionGuide,
nullptr, TemplateKWLoc,
5532 DeclScopeObj.EnterDeclaratorScope();
5539 goto PastIdentifier;
5545 diag::err_expected_unqualified_id)
5548 goto PastIdentifier;
5552 "There's a C++-specific check for tok::identifier above");
5557 goto PastIdentifier;
5562 bool DiagnoseIdentifier =
false;
5566 DiagnoseIdentifier =
true;
5569 DiagnoseIdentifier =
5576 !isCXX11VirtSpecifier(Tok))
5578 tok::comma, tok::semi, tok::equal, tok::l_brace, tok::kw_try);
5579 if (DiagnoseIdentifier) {
5584 goto PastIdentifier;
5588 if (Tok.
is(tok::l_paren)) {
5592 ParseParenDeclarator(D);
5605 DeclScopeObj.EnterDeclaratorScope();
5616 diag::ext_abstract_pack_declarator_parens);
5618 if (Tok.
getKind() == tok::annot_pragma_parser_crash)
5620 if (Tok.
is(tok::l_square))
5621 return ParseMisplacedBracketDeclarator(D);
5629 diag::err_expected_member_name_or_semi_objcxx_keyword)
5636 goto PastIdentifier;
5639 diag::err_expected_member_name_or_semi)
5643 if (Tok.
isOneOf(tok::period, tok::arrow))
5644 Diag(Tok, diag::err_invalid_operator_on_type) << Tok.
is(tok::arrow);
5652 diag::err_expected_unqualified_id)
5657 diag::err_expected_either)
5658 << tok::identifier << tok::l_paren;
5666 "Haven't past the location of the identifier yet?");
5670 MaybeParseCXX11Attributes(D);
5673 if (Tok.
is(tok::l_paren)) {
5676 ParseScope PrototypeScope(
this,
5684 bool IsAmbiguous =
false;
5688 TentativelyDeclaredIdentifiers.push_back(D.
getIdentifier());
5689 bool IsFunctionDecl = isCXXFunctionDeclarator(&IsAmbiguous);
5690 TentativelyDeclaredIdentifiers.pop_back();
5691 if (!IsFunctionDecl)
5697 ParseFunctionDeclarator(D, attrs, T, IsAmbiguous);
5698 PrototypeScope.Exit();
5699 }
else if (Tok.
is(tok::l_square)) {
5700 ParseBracketDeclarator(D);
5707 void Parser::ParseDecompositionDeclarator(
Declarator &D) {
5708 assert(Tok.
is(tok::l_square));
5714 if (!(
NextToken().is(tok::identifier) &&
5715 GetLookAheadToken(2).isOneOf(tok::comma, tok::r_square)) &&
5717 GetLookAheadToken(2).isOneOf(tok::equal, tok::l_brace)))
5718 return ParseMisplacedBracketDeclarator(D);
5724 while (Tok.
isNot(tok::r_square)) {
5725 if (!Bindings.empty()) {
5726 if (Tok.
is(tok::comma))
5729 if (Tok.
is(tok::identifier)) {
5731 Diag(EndLoc, diag::err_expected)
5734 Diag(Tok, diag::err_expected_comma_or_rsquare);
5737 SkipUntil(tok::r_square, tok::comma, tok::identifier,
5739 if (Tok.
is(tok::comma))
5741 else if (Tok.
isNot(tok::identifier))
5746 if (Tok.
isNot(tok::identifier)) {
5747 Diag(Tok, diag::err_expected) << tok::identifier;
5755 if (Tok.
isNot(tok::r_square))
5761 if (Bindings.empty())
5768 T.getCloseLocation());
5784 void Parser::ParseParenDeclarator(
Declarator &D) {
5788 assert(!D.
isPastIdentifier() &&
"Should be called before passing identifier");
5801 bool RequiresArg =
false;
5802 if (Tok.
is(tok::kw___attribute)) {
5803 ParseGNUAttributes(attrs);
5811 ParseMicrosoftTypeAttributes(attrs);
5814 if (Tok.
is(tok::kw___pascal))
5815 ParseBorlandTypeAttributes(attrs);
5827 }
else if (Tok.
is(tok::r_paren) ||
5830 isDeclarationSpecifier() ||
5831 isCXX11AttributeSpecifier()) {
5849 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
5853 T.getCloseLocation()),
5854 attrs, T.getCloseLocation());
5860 DiagnoseMisplacedEllipsisInDeclarator(EllipsisLoc, D);
5873 ParseScope PrototypeScope(
this,
5877 ParseFunctionDeclarator(D, attrs, T,
false, RequiresArg);
5878 PrototypeScope.Exit();
5900 void Parser::ParseFunctionDeclarator(
Declarator &D,
5905 assert(
getCurScope()->isFunctionPrototypeScope() &&
5906 "Should call from a Function scope");
5912 bool HasProto =
false;
5919 bool RefQualifierIsLValueRef =
true;
5939 StartLoc = LParenLoc;
5941 if (isFunctionDeclaratorIdentifierList()) {
5943 Diag(Tok, diag::err_argument_required_after_attribute);
5945 ParseFunctionDeclaratorIdentifierList(D, ParamInfo);
5949 LocalEndLoc = RParenLoc;
5952 if (Tok.
isNot(tok::r_paren))
5953 ParseParameterDeclarationClause(D, FirstArgAttrs, ParamInfo,
5955 else if (RequiresArg)
5956 Diag(Tok, diag::err_argument_required_after_attribute);
5958 HasProto = ParamInfo.size() ||
getLangOpts().CPlusPlus;
5963 LocalEndLoc = RParenLoc;
5972 ParseTypeQualifierListOpt(DS, AR_NoAttributesParsed,
5975 llvm::function_ref<
void()>([&]() {
5986 if (ParseRefQualifier(RefQualifierIsLValueRef, RefQualifierLoc))
5987 EndLoc = RefQualifierLoc;
5996 bool IsCXX11MemberFunction =
6010 IsCXX11MemberFunction);
6016 GetLookAheadToken(0).is(tok::kw_noexcept) &&
6017 GetLookAheadToken(1).is(tok::l_paren) &&
6018 GetLookAheadToken(2).is(tok::kw_noexcept) &&
6019 GetLookAheadToken(3).is(tok::l_paren) &&
6020 GetLookAheadToken(4).is(tok::identifier) &&
6021 GetLookAheadToken(4).getIdentifierInfo()->isStr(
"swap")) {
6032 ESpecType = tryParseExceptionSpecification(Delayed,
6035 DynamicExceptionRanges,
6037 ExceptionSpecTokens);
6039 EndLoc = ESpecRange.
getEnd();
6043 MaybeParseCXX11Attributes(FnAttrs);
6046 LocalEndLoc = EndLoc;
6048 Diag(Tok, diag::warn_cxx98_compat_trailing_return_type);
6053 TrailingReturnType = ParseTrailingReturnType(Range);
6068 if (!ND || isa<ParmVarDecl>(ND))
6070 DeclsInPrototype.push_back(ND);
6078 ParamInfo.data(), ParamInfo.size(),
6079 EllipsisLoc, RParenLoc,
6081 RefQualifierIsLValueRef,
6082 RefQualifierLoc, ConstQualifierLoc,
6083 VolatileQualifierLoc,
6084 RestrictQualifierLoc,
6086 ESpecType, ESpecRange,
6087 DynamicExceptions.data(),
6088 DynamicExceptionRanges.data(),
6089 DynamicExceptions.size(),
6091 NoexceptExpr.
get() :
nullptr,
6092 ExceptionSpecTokens,
6094 StartLoc, LocalEndLoc, D,
6095 TrailingReturnType),
6101 bool Parser::ParseRefQualifier(
bool &RefQualifierIsLValueRef,
6103 if (Tok.
isOneOf(tok::amp, tok::ampamp)) {
6105 diag::warn_cxx98_compat_ref_qualifier :
6106 diag::ext_ref_qualifier);
6108 RefQualifierIsLValueRef = Tok.
is(tok::amp);
6120 bool Parser::isFunctionDeclaratorIdentifierList() {
6122 && Tok.
is(tok::identifier)
6123 && !TryAltiVecVectorToken()
6152 void Parser::ParseFunctionDeclaratorIdentifierList(
6160 Diag(Tok, diag::ext_ident_list_in_param);
6163 llvm::SmallSet<const IdentifierInfo*, 16> ParamsSoFar;
6167 if (Tok.
isNot(tok::identifier)) {
6168 Diag(Tok, diag::err_expected) << tok::identifier;
6179 Diag(Tok, diag::err_unexpected_typedef_ident) << ParmII;
6182 if (!ParamsSoFar.insert(ParmII).second) {
6183 Diag(Tok, diag::err_param_redefinition) << ParmII;
6228 void Parser::ParseParameterDeclarationClause(
6258 ParseDeclarationSpecifiers(DS);
6268 ParseDeclarator(ParmDeclarator);
6271 MaybeParseGNUAttributes(ParmDeclarator);
6278 std::unique_ptr<CachedTokens> DefArgToks;
6282 if (DS.
isEmpty() && ParmDeclarator.getIdentifier() ==
nullptr &&
6283 ParmDeclarator.getNumTypeObjects() == 0) {
6285 Diag(DSStart, diag::err_missing_param);
6292 if (Tok.
is(tok::ellipsis) &&
6294 (!ParmDeclarator.getEllipsisLoc().isValid() &&
6297 DiagnoseMisplacedEllipsisInDeclarator(
ConsumeToken(), ParmDeclarator);
6306 if (Tok.
is(tok::equal)) {
6317 if (!ConsumeAndStoreInitializer(*DefArgToks, CIK_DefaultArgument)) {
6337 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
6338 DefArgResult = ParseBraceInitializer();
6348 DefArgResult.
get());
6354 ParmDeclarator.getIdentifierLoc(),
6355 Param, std::move(DefArgToks)));
6362 Diag(EllipsisLoc, diag::err_missing_comma_before_ellipsis)
6364 }
else if (ParmDeclarator.getEllipsisLoc().isValid() ||
6369 Diag(EllipsisLoc, diag::warn_misplaced_ellipsis_vararg)
6370 << ParmEllipsis.
isValid() << ParmEllipsis;
6373 diag::note_misplaced_ellipsis_vararg_existing_ellipsis);
6375 Diag(ParmDeclarator.getIdentifierLoc(),
6376 diag::note_misplaced_ellipsis_vararg_add_ellipsis)
6379 << !ParmDeclarator.hasName();
6381 Diag(EllipsisLoc, diag::note_misplaced_ellipsis_vararg_add_comma)
6400 void Parser::ParseBracketDeclarator(
Declarator &D) {
6401 if (CheckProhibitedCXX11Attribute())
6409 if (Tok.
getKind() == tok::r_square) {
6412 MaybeParseCXX11Attributes(attrs);
6416 T.getOpenLocation(),
6417 T.getCloseLocation()),
6418 attrs, T.getCloseLocation());
6420 }
else if (Tok.
getKind() == tok::numeric_constant &&
6421 GetLookAheadToken(1).is(tok::r_square)) {
6428 MaybeParseCXX11Attributes(attrs);
6433 T.getOpenLocation(),
6434 T.getCloseLocation()),
6435 attrs, T.getCloseLocation());
6437 }
else if (Tok.
getKind() == tok::code_completion) {
6439 return cutOffParsing();
6449 ParseTypeQualifierListOpt(DS, AR_CXX11AttributesParsed);
6457 bool isStar =
false;
6464 if (Tok.
is(tok::star) && GetLookAheadToken(1).is(tok::r_square)) {
6468 Diag(StaticLoc, diag::err_unspecified_vla_size_with_static);
6472 }
else if (Tok.
isNot(tok::r_square)) {
6490 Diag(StaticLoc, diag::err_unspecified_size_with_static);
6511 T.getOpenLocation(),
6512 T.getCloseLocation()),
6517 void Parser::ParseMisplacedBracketDeclarator(
Declarator &D) {
6518 assert(Tok.
is(tok::l_square) &&
"Missing opening bracket");
6524 while (Tok.
is(tok::l_square)) {
6525 ParseBracketDeclarator(TempDeclarator);
6531 if (Tok.
is(tok::semi))
6537 ParseDeclaratorInternal(D, &Parser::ParseDirectDeclarator);
6542 if (TempDeclarator.getNumTypeObjects() == 0)
6546 bool NeedParens =
false;
6572 for (
unsigned i = 0, e = TempDeclarator.getNumTypeObjects(); i < e; ++i) {
6587 SourceRange BracketRange(StartBracketLoc, EndBracketLoc);
6591 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
6599 Diag(EndLoc, diag::err_brackets_go_after_unqualified_id)
6612 void Parser::ParseTypeofSpecifier(
DeclSpec &DS) {
6613 assert(Tok.
is(tok::kw_typeof) &&
"Not a typeof specifier");
6617 const bool hasParens = Tok.
is(tok::l_paren);
6627 ParseExprAfterUnaryExprOrTypeTrait(OpTok, isCastExpr, CastTy, CastRange));
6643 const char *PrevSpec =
nullptr;
6649 Diag(StartLoc, DiagID) << PrevSpec;
6666 const char *PrevSpec =
nullptr;
6670 DiagID, Operand.
get(),
6672 Diag(StartLoc, DiagID) << PrevSpec;
6678 void Parser::ParseAtomicSpecifier(
DeclSpec &DS) {
6679 assert(Tok.
is(tok::kw__Atomic) &&
NextToken().
is(tok::l_paren) &&
6680 "Not an atomic specifier");
6684 if (T.consumeOpen())
6696 if (T.getCloseLocation().isInvalid())
6702 const char *PrevSpec =
nullptr;
6705 DiagID, Result.
get(),
6707 Diag(StartLoc, DiagID) << PrevSpec;
6712 bool Parser::TryAltiVecVectorTokenOutOfLine() {
6715 default:
return false;
6718 case tok::kw_signed:
6719 case tok::kw_unsigned:
6724 case tok::kw_double:
6726 case tok::kw___bool:
6727 case tok::kw___pixel:
6728 Tok.
setKind(tok::kw___vector);
6730 case tok::identifier:
6732 Tok.
setKind(tok::kw___vector);
6736 Tok.
setKind(tok::kw___vector);
6744 const char *&PrevSpec,
unsigned &DiagID,
6752 case tok::kw_signed:
6753 case tok::kw_unsigned:
6758 case tok::kw_double:
6760 case tok::kw___bool:
6761 case tok::kw___pixel:
6764 case tok::identifier:
void ClearFunctionSpecs()
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
unsigned getFlags() const
getFlags - Return the flags for this scope.
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getCloseLocation() const
Defines the clang::ASTContext interface.
static bool isAttributeLateParsed(const IdentifierInfo &II)
isAttributeLateParsed - Return true if the attribute has arguments that require late parsing...
SourceLocation getEnd() const
AttributeList * addNewPropertyAttr(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, IdentifierInfo *getterId, IdentifierInfo *setterId, AttributeList::Syntax syntaxUsed)
Add microsoft __delspec(property) attribute.
IdKind getKind() const
Determine what kind of name we have.
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
TypeResult ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK, const CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation TagLoc, SourceLocation NameLoc)
static LLVM_READONLY bool isDigit(unsigned char c)
Return true if this character is an ASCII digit: [0-9].
no exception specification
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
SourceLocation getRestrictSpecLoc() const
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 getConstSpecLoc() const
SourceLocation getEndOfPreviousToken()
SourceLocation getExplicitSpecLoc() const
TSW getTypeSpecWidth() const
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
static const TSS TSS_unsigned
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
Code completion occurs within a class, struct, or union.
TheContext getContext() const
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
const LangOptions & getLangOpts() const
static const TST TST_wchar
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
Decl * getRepAsDecl() const
const LangOptions & getLangOpts() const
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
static const TST TST_typeofExpr
static const TST TST_char16
static bool isPtrOperatorToken(tok::TokenKind Kind, const LangOptions &Lang, unsigned TheContext)
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.
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
SCS getStorageClassSpec() const
const char * getName() const
The base class of the type hierarchy.
bool TryAnnotateCXXScopeToken(bool EnteringContext=false)
TryAnnotateScopeToken - Like TryAnnotateTypeOrScopeToken but only annotates C++ scope specifiers and ...
This indicates that the scope corresponds to a function, which means that labels are set here...
std::unique_ptr< llvm::MemoryBuffer > Buffer
One instance of this struct is used for each type in a declarator that is parsed. ...
Declaration of a variable template.
static FixItHint CreateInsertionFromRange(SourceLocation InsertionLoc, CharSourceRange FromRange, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code from FromRange at a specific location...
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getInlineSpecLoc() const
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.
bool SetTypeAltiVecBool(bool isAltiVecBool, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
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)
void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers, bool AllowNestedNameSpecifiers)
Decl * getObjCDeclContext() const
RAII object that enters a new expression evaluation context.
void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record)
void EnterToken(const Token &Tok)
Enters a token in the token stream to be lexed next.
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)
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
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...
Decl * ActOnParamDeclarator(Scope *S, Declarator &D)
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
friend class ObjCDeclContextSwitch
ParmVarDecl - Represents a parameter to a function.
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed...
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 ...
bool isEmpty() const
No scope specifier.
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 ...
Information about a template-id annotation token.
void ActOnUninitializedDecl(Decl *dcl)
Base wrapper for a particular "section" of type source info.
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
void CodeCompleteConstructor(Scope *S, QualType Type, SourceLocation Loc, ArrayRef< Expr * > Args)
RecordDecl - Represents a struct/union/class.
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool TryConsumeToken(tok::TokenKind Expected)
__ptr16, alignas(...), etc.
One of these records is kept for each identifier that is lexed.
void set(AttributeList *newList)
static const TST TST_decimal32
AttributeList * getList() const
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...
bool isTypeSpecPipe() const
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e...
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
static const TST TST_class
bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS)
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
void ActOnEnumBody(SourceLocation EnumLoc, SourceRange BraceRange, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, AttributeList *Attr)
bool isMicrosoftAttribute() const
AttributeList * addNewTypeAttr(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ParsedType typeArg, AttributeList::Syntax syntaxUsed)
Add an attribute with a single type argument.
bool isEmpty() const
isEmpty - Return true if this declaration specifier is completely empty: no tokens were parsed in the...
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.
ParsedType ActOnObjCInstanceType(SourceLocation Loc)
The parser has parsed the context-sensitive type 'instancetype' in an Objective-C message declaration...
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.
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
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 getTypeSpecTypeLoc() const
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, AttributeList *Attrs, SourceLocation EqualLoc, Expr *Val)
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
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...
bool mayBeFollowedByCXXDirectInit() const
mayBeFollowedByCXXDirectInit - Return true if the declarator can be followed by a C++ direct initiali...
bool SetTypeAltiVecPixel(bool isAltiVecPixel, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
Code completion occurs at top-level or namespace context.
The controlling scope in a if/switch/while/for statement.
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
const TargetInfo & getTargetInfo() const
void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, IdentifierInfo *ClassName, SmallVectorImpl< Decl * > &Decls)
Called whenever @defs(ClassName) is encountered in the source.
This is a scope that corresponds to a block/closure object.
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.
bool hasGroupingParens() const
void setExtension(bool Val=true)
This scope corresponds to an enum.
Decl * ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, bool IsTemplateParamOrArg, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'.
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
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.
bool ActOnDuplicateDefinition(DeclSpec &DS, Decl *Prev, SkipBodyInfo &SkipBody)
Perform ODR-like check for C/ObjC when merging tag types from modules.
Code completion occurs following one or more template headers.
void CodeCompleteBracketDeclarator(Scope *S)
void ActOnInitializerError(Decl *Dcl)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
bool setFunctionSpecForceInline(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
bool isCurrentClassNameTypo(IdentifierInfo *&II, const CXXScopeSpec *SS)
Determine whether the identifier II is a typo for the name of the class type currently being defined...
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
bool hasAllExtensionsSilenced()
bool SetFriendSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
SourceLocation getEndLoc() const
Represents information about a change in availability for an entity, which is part of the encoding of...
Represents a C++ nested-name-specifier or a global scope specifier.
enum clang::DeclaratorChunk::@196 Kind
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool setFunctionSpecNoreturn(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
AvailabilityChange Changes[NumAvailabilitySlots]
tok::TokenKind getKind() const
Decl * ActOnTemplateDeclarator(Scope *S, MultiTemplateParamsArg TemplateParameterLists, Declarator &D)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D, const VirtSpecifiers *VS=nullptr)
bool isFunctionDeclaratorAFunctionDeclaration() const
Return true if a function declarator at this position would be a function declaration.
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
static bool VersionNumberSeparator(const char Separator)
SourceRange getSourceRange() const LLVM_READONLY
void setInvalid(bool b=true) const
detail::InMemoryDirectory::const_iterator I
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
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.
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
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...
Provides definitions for the various language-specific address spaces.
void * getAnnotationValue() const
static const TSW TSW_long
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
TemplateParameterList * ActOnTemplateParameterList(unsigned Depth, SourceLocation ExportLoc, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< Decl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
ActOnTemplateParameterList - Builds a TemplateParameterList, optionally constrained by RequiresClause...
TST getTypeSpecType() const
void ClearConstexprSpec()
const void * getEofData() const
SourceLocation getModulePrivateSpecLoc() const
A class for parsing a declarator.
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S)
isTagName() - This method is called for error recovery purposes only to determine if the specified na...
void SetRangeStart(SourceLocation Loc)
NameClassificationKind getKind() const
SourceLocation getFriendSpecLoc() const
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
TypeResult ParseTypeName(SourceRange *Range=nullptr, Declarator::TheContext Context=Declarator::TypeNameContext, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
bool isCXXInstanceMember() const
Determine whether the given declaration is an instance member of a C++ class.
bool mayOmitIdentifier() const
mayOmitIdentifier - Return true if the identifier is either optional or not allowed.
void ActOnReenterCXXMethodParameter(Scope *S, ParmVarDecl *Param)
This is used to implement the constant expression evaluation part of the attribute enable_if extensio...
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
SourceRange getAnnotationRange() const
SourceRange of the group of tokens that this annotation token represents.
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
bool containsUnexpandedParameterPacks(Declarator &D)
Determine whether the given declarator contains any unexpanded parameter packs.
StringRef getName() const
Return the actual identifier string.
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.
SourceLocation getAtomicSpecLoc() const
bool isTemplateDecl() const
returns true if this declaration is a template
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)
void setEofData(const void *D)
static bool isPipeDeclerator(const Declarator &D)
void setAsmLabel(Expr *E)
SourceLocation getVolatileSpecLoc() const
DeclContext * getDeclContext()
static const TST TST_decimal64
bool isPastIdentifier() const
isPastIdentifier - Return true if we have parsed beyond the point where the name would appear...
Decl * ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth)
ActOnField - Each field of a C struct/union is passed into this in order to create a FieldDecl object...
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.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
bool isConstexprSpecified() const
A class for parsing a field declarator.
bool isNot(tok::TokenKind K) const
bool hasTypeSpecifier() const
Return true if any type-specifier has been found.
SourceLocation Loc
Loc - The place where this type was defined.
static SourceLocation getMissingDeclaratorIdLoc(Declarator &D, SourceLocation Loc)
void setEllipsisLoc(SourceLocation EL)
bool SetTypeSpecSign(TSS S, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_half
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.
SourceLocation getStorageClassSpecLoc() const
SourceRange VersionRange
The source range covering the version number.
SourceLocation getAnnotationEndLoc() const
static const TSW TSW_short
bool isVirtualSpecified() const
void CodeCompleteInitializer(Scope *S, Decl *D)
const clang::PrintingPolicy & getPrintingPolicy() const
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
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 ...
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr)
Perform name lookup on the given name, classifying it based on the results of name lookup and the fol...
This is a scope that corresponds to the parameters within a function prototype for a function declara...
void CodeCompleteTypeQualifiers(DeclSpec &DS)
static const TST TST_char32
A class for parsing a DeclSpec.
static DeclaratorChunk getParen(SourceLocation LParenLoc, SourceLocation RParenLoc)
Return a DeclaratorChunk for a paren.
bool SetConceptSpec(SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
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.
Encodes a location in the source.
void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record)
static const TST TST_auto_type
bool TryAnnotateTypeOrScopeToken()
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceRange BraceRange)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
SourceLocation getEndLoc() const
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
void FinalizeDeclaration(Decl *D)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getPipeLoc() const
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.
bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name, SourceLocation NameLoc, ParsedTemplateTy *Template=nullptr)
Determine whether a particular identifier might be the name in a C++1z deduction-guide declaration...
ASTContext & getASTContext() const
static const TST TST_union
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 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...
Scope * getCurScope() const
static const TSS TSS_signed
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
void setIdentifierInfo(IdentifierInfo *II)
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.
bool isInvalid() const
An error occurred during parsing of the scope specifier.
SourceLocation getConstexprSpecLoc() const
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
SourceLocation getVirtualSpecLoc() const
SourceLocation getUnalignedSpecLoc() const
static const TST TST_typeofType
SourceLocation getBegin() const
bool isLibstdcxxEagerExceptionSpecHack(const Declarator &D)
Determine if we're in a case where we need to (incorrectly) eagerly parse an exception specification ...
bool hasAttributes() const
bool SetTypeQual(TQ T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const LangOptions &Lang)
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 SetTypeAltiVecVector(bool isAltiVecVector, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
static DeclaratorChunk getArray(unsigned TypeQuals, bool isStatic, bool isStar, Expr *NumElts, SourceLocation LBLoc, SourceLocation RBLoc)
Return a DeclaratorChunk for an array.
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, AttributeList *AttrList)
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
SourceLocation getOpenLocation() const
The scope of a struct/union/class definition.
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
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)
TSCS getThreadStorageClassSpec() const
static const TST TST_auto
bool isFriendSpecified() const
static const TST TST_void
bool empty() const
Determine whether this version information is empty (e.g., all version components are zero)...
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
static const TST TST_int128
void CodeCompleteTag(Scope *S, unsigned TagSpec)
void ActOnParamDefaultArgument(Decl *param, SourceLocation EqualLoc, Expr *defarg)
ActOnParamDefaultArgument - Check whether the default argument provided for a function parameter is w...
bool hasTagDefinition() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
This is a scope that corresponds to the template parameters of a C++ template.
SourceLocation getLocEnd() const LLVM_READONLY
EnumDecl - Represents an enum.
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
The name refers to a template whose specialization produces a type.
static const TST TST_unspecified
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
bool isFirstDeclarator() const
Syntax
The style used to specify an attribute.
bool isCurrentClassName(const IdentifierInfo &II, Scope *S, const CXXScopeSpec *SS=nullptr)
isCurrentClassName - Determine whether the identifier II is the name of the class type currently bein...
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)
ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
IdentifierInfo * getName() const
static const TST TST_decimal128
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
void takeAttributesFrom(ParsedAttributes &attrs)
bool isCPlusPlusKeyword(const LangOptions &LangOpts) const
Return true if this token is a C++ keyword in the specified language.
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
static const TSCS TSCS___thread
void RestoreNestedNameSpecifierAnnotation(void *Annotation, SourceRange AnnotationRange, CXXScopeSpec &SS)
Given an annotation pointer for a nested-name-specifier, restore the nested-name-specifier structure...
bool mayHaveIdentifier() const
mayHaveIdentifier - Return true if the identifier is either optional or required. ...
bool isKnownToGCC() const
void setNext(AttributeList *N)
unsigned getMaxArgs() const
bool SetStorageClassSpecThread(TSCS TSC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
static const TST TST_typename
void * getAsOpaquePtr() const
void SetRangeEnd(SourceLocation Loc)
SetRangeEnd - Set the end of the source range to Loc, unless it's invalid.
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
DeclResult ActOnExplicitInstantiation(Scope *S, SourceLocation ExternLoc, SourceLocation TemplateLoc, unsigned TagSpec, SourceLocation KWLoc, const CXXScopeSpec &SS, TemplateTy Template, SourceLocation TemplateNameLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, AttributeList *Attr)
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)
SourceLocation getLoc() const
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
bool isInlineSpecified() const
A template-id, e.g., f<int>.
SmallVector< TemplateParameterList *, 4 > TemplateParameterLists
CXXScopeSpec & getTypeSpecScope()
AttributeList * addNew(IdentifierInfo *attrName, SourceRange attrRange, IdentifierInfo *scopeName, SourceLocation scopeLoc, ArgsUnion *args, unsigned numArgs, AttributeList::Syntax syntax, SourceLocation ellipsisLoc=SourceLocation())
Add attribute with expression arguments.
bool isUnexpandedParameterPackPermitted()
Determine whether an unexpanded parameter pack might be permitted in this location.
This is a scope that can contain a declaration.
IdentifierInfo * getIdentifier() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
bool isCXX11Attribute() const
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)
void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc)
ActOnParamDefaultArgumentError - Parsing or semantic analysis of the default argument for the paramet...
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".
bool isExplicitSpecified() const
SourceLocation getIdentifierLoc() const
static bool isValidAfterIdentifierInDeclarator(const Token &T)
isValidAfterIdentifierInDeclaratorAfterDeclSpec - Return true if the specified token is valid after t...
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
static const TSCS TSCS_thread_local
void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc)
ActOnParamUnparsedDefaultArgument - We've seen a default argument for a function parameter, but we can't parse it yet because we're inside a class definition.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult{return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
static const TST TST_float128
static const TST TST_bool
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
bool isTypeSpecOwned() const
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.
void ExtendWithDeclSpec(const DeclSpec &DS)
ExtendWithDeclSpec - Extend the declarator source range to include the given declspec, unless its location is invalid.
static const TSW TSW_longlong
static Decl::Kind getKind(const Decl *D)
bool isTypeAltiVecVector() const
unsigned getParsedSpecifiers() const
Return a bitmask of which flavors of specifiers this DeclSpec includes.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
bool isSet() const
Deprecated.
unsigned getLength() const
static bool attributeIsTypeArgAttr(const IdentifierInfo &II)
Determine whether the given attribute parses a type argument.
static const TST TST_atomic
bool isDeclspecAttribute() const
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...
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
void setLocation(SourceLocation L)
AttributeList * getNext() const
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
bool SetTypeSpecComplex(TSC C, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID)
NamedDecl - This represents a decl with a name.
bool isInvalidType() const
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
static const TSCS TSCS__Thread_local
ParsedType ActOnMSVCUnknownTypeName(const IdentifierInfo &II, SourceLocation NameLoc, bool IsTemplateTypeArg)
Attempt to behave like MSVC in situations where lookup of an unqualified type name has failed in a de...
Callback handler that receives notifications when performing code completion within the preprocessor...
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
SourceLocation getLocEnd() const LLVM_READONLY
void SetRangeEnd(SourceLocation Loc)
ParsedAttributes - A collection of parsed attributes.
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
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.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Decl * ActOnDeclarator(Scope *S, Declarator &D)
AttributeList - Represents a syntactic attribute.
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.
SourceLocation getEllipsisLoc() const
unsigned ActOnReenterTemplateScope(Scope *S, Decl *Template)
IdentifierInfo * getIdentifierInfo() const