23#include "llvm/ADT/SmallVector.h"
24#include "llvm/ADT/StringExtras.h"
31 if (Tok.
is(tok::kw___attribute)) {
32 if (Kind == tok::objc_interface || Kind == tok::objc_protocol)
33 Diag(Tok, diag::err_objc_postfix_attribute_hint)
34 << (
Kind == tok::objc_protocol);
36 Diag(Tok, diag::err_objc_postfix_attribute);
37 ParseGNUAttributes(attrs);
56 if (Tok.
is(tok::code_completion)) {
63 case tok::objc_interface:
64 case tok::objc_protocol:
65 case tok::objc_implementation:
68 for (
const auto &
Attr : DeclAttrs) {
74 Decl *SingleDecl =
nullptr;
77 return ParseObjCAtClassDeclaration(AtLoc);
78 case tok::objc_interface:
79 SingleDecl = ParseObjCAtInterfaceDeclaration(AtLoc, DeclAttrs);
81 case tok::objc_protocol:
82 return ParseObjCAtProtocolDeclaration(AtLoc, DeclAttrs);
83 case tok::objc_implementation:
84 return ParseObjCAtImplementationDeclaration(AtLoc, DeclAttrs);
86 return ParseObjCAtEndDeclaration(AtLoc);
87 case tok::objc_compatibility_alias:
88 SingleDecl = ParseObjCAtAliasDeclaration(AtLoc);
90 case tok::objc_synthesize:
91 SingleDecl = ParseObjCPropertySynthesize(AtLoc);
93 case tok::objc_dynamic:
94 SingleDecl = ParseObjCPropertyDynamic(AtLoc);
96 case tok::objc_import:
99 SingleDecl = ParseModuleImport(AtLoc, IS);
102 Diag(AtLoc, diag::err_atimport);
106 Diag(AtLoc, diag::err_unexpected_at);
108 SingleDecl =
nullptr;
122 : Actions(Actions), S(S), Params(nullptr) {}
155 MaybeSkipAttributes(tok::objc_class);
156 if (Tok.
is(tok::code_completion)) {
161 if (expectIdentifier()) {
171 if (Tok.
is(tok::less))
172 TypeParams = parseObjCTypeParamList();
173 ClassTypeParams.push_back(TypeParams);
179 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"@class"))
195 if (CurParsedObjCImpl) {
196 CurParsedObjCImpl->finish(AtLoc);
200 Diag(AtLoc, diag::err_objc_missing_end)
238 "ParseObjCAtInterfaceDeclaration(): Expected @interface");
239 CheckNestedObjCContexts(AtLoc);
243 if (Tok.
is(tok::code_completion)) {
249 MaybeSkipAttributes(tok::objc_interface);
251 if (expectIdentifier())
264 ObjCTypeParamListScope typeParamScope(Actions,
getCurScope());
265 if (Tok.
is(tok::less))
266 typeParameterList = parseObjCTypeParamListOrProtocolRefs(
267 typeParamScope, LAngleLoc, ProtocolIdents, EndProtoLoc);
269 if (Tok.
is(tok::l_paren) &&
270 !isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
277 if (Tok.
is(tok::code_completion)) {
284 if (Tok.
is(tok::identifier)) {
289 Diag(Tok, diag::err_expected)
295 if (T.getCloseLocation().isInvalid())
299 assert(LAngleLoc.
isInvalid() &&
"Cannot have already parsed protocols");
302 if (Tok.
is(tok::less) &&
303 ParseObjCProtocolReferences(ProtocolRefs, ProtocolLocs,
true,
true,
304 LAngleLoc, EndProtoLoc,
309 AtLoc, nameId, nameLoc, typeParameterList, categoryId, categoryLoc,
310 ProtocolRefs.data(), ProtocolRefs.size(), ProtocolLocs.data(),
313 if (Tok.
is(tok::l_brace))
314 ParseObjCClassInstanceVariables(CategoryType, tok::objc_private, AtLoc);
316 ParseObjCInterfaceDeclList(tok::objc_not_keyword, CategoryType);
328 if (Tok.
is(tok::colon)) {
332 if (Tok.
is(tok::code_completion)) {
338 if (expectIdentifier())
344 if (Tok.
is(tok::less)) {
345 parseObjCTypeArgsOrProtocolQualifiers(
346 nullptr, typeArgsLAngleLoc, typeArgs, typeArgsRAngleLoc, LAngleLoc,
347 protocols, protocolLocs, EndProtoLoc,
350 if (Tok.
is(tok::eof))
357 if (!ProtocolIdents.empty()) {
360 for (
const auto &pair : ProtocolIdents) {
361 protocolLocs.push_back(pair.second);
365 ProtocolIdents, protocols);
367 }
else if (protocols.empty() && Tok.
is(tok::less) &&
368 ParseObjCProtocolReferences(protocols, protocolLocs,
true,
true,
369 LAngleLoc, EndProtoLoc,
374 if (Tok.
isNot(tok::less))
376 superClassId, superClassLoc);
380 getCurScope(), AtLoc, nameId, nameLoc, typeParameterList, superClassId,
381 superClassLoc, typeArgs,
382 SourceRange(typeArgsLAngleLoc, typeArgsRAngleLoc), protocols.data(),
383 protocols.size(), protocolLocs.data(), EndProtoLoc, attrs, &SkipBody);
385 if (Tok.
is(tok::l_brace))
386 ParseObjCClassInstanceVariables(ClsType, tok::objc_protected, AtLoc);
388 ParseObjCInterfaceDeclList(tok::objc_interface, ClsType);
391 auto *PreviousDef = cast<ObjCInterfaceDecl>(SkipBody.
Previous);
397 DiagsEmitter.diagnoseMismatch(PreviousDef, ClsType);
411 bool &addedToDeclSpec) {
414 return Pool.create(
P.getNullabilityKeyword(nullability),
416 nullptr, 0, ParsedAttr::Form::ContextSensitiveKeyword());
423 }
else if (!addedToDeclSpec) {
428 addedToDeclSpec =
true;
460 assert(Tok.
is(tok::less) &&
"Not at the beginning of a type parameter list");
468 auto makeProtocolIdentsIntoTypeParameters = [&]() {
470 for (
const auto &pair : protocolIdents) {
475 typeParams.push_back(typeParam.
get());
478 protocolIdents.clear();
479 mayBeProtocolList =
false;
482 bool invalid =
false;
489 if (Tok.
is(tok::kw___covariant) || Tok.
is(tok::kw___contravariant)) {
490 variance = Tok.
is(tok::kw___covariant)
497 if (mayBeProtocolList) {
500 makeProtocolIdentsIntoTypeParameters();
505 if (!Tok.
is(tok::identifier)) {
507 if (Tok.
is(tok::code_completion)) {
517 Diag(Tok, diag::err_objc_expected_type_parameter);
531 if (mayBeProtocolList) {
534 makeProtocolIdentsIntoTypeParameters();
541 }
else if (mayBeProtocolList) {
544 protocolIdents.push_back(std::make_pair(paramName, paramLoc));
550 getCurScope(), variance, varianceLoc, typeParams.size(), paramName,
551 paramLoc, colonLoc, boundType.
isUsable() ? boundType.
get() :
nullptr);
553 typeParams.push_back(typeParam.
get());
559 if (Tok.
is(tok::greater))
561 }
else if (ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc,
564 SkipUntil({tok::greater, tok::greaterequal, tok::at, tok::minus,
565 tok::minus, tok::plus, tok::colon, tok::l_paren, tok::l_brace,
566 tok::comma, tok::semi },
568 if (Tok.
is(tok::greater))
572 if (mayBeProtocolList) {
577 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_paren)) {
586 makeProtocolIdentsIntoTypeParameters();
601 return invalid ? nullptr : list;
611 return parseObjCTypeParamListOrProtocolRefs(
Scope, lAngleLoc, protocolIdents,
617 switch (DirectiveKind) {
618 case tok::objc_class:
619 case tok::objc_compatibility_alias:
620 case tok::objc_interface:
621 case tok::objc_implementation:
622 case tok::objc_protocol:
651 if (Tok.
isOneOf(tok::minus, tok::plus)) {
652 if (
Decl *methodPrototype =
653 ParseObjCMethodPrototype(MethodImplKind,
false))
654 allMethods.push_back(methodPrototype);
657 if (ExpectAndConsumeSemi(diag::err_expected_semi_after_method_proto)) {
660 if (Tok.
is(tok::semi))
665 if (Tok.
is(tok::l_paren)) {
666 Diag(Tok, diag::err_expected_minus_or_plus);
669 MethodImplKind,
false);
673 if (Tok.
is(tok::semi)) {
685 if (Tok.
is(tok::code_completion)) {
694 if (Tok.
isNot(tok::at)) {
698 if (Tok.
is(tok::r_brace))
707 if (Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
711 DeclEnd, EmptyDeclAttrs,
712 EmptyDeclSpecAttrs));
716 allTUVariables.push_back(ParseDeclarationOrFunctionDefinition(
717 EmptyDeclAttrs, EmptyDeclSpecAttrs));
724 if (NextTok.is(tok::code_completion)) {
731 if (DirectiveKind == tok::objc_end) {
736 }
else if (DirectiveKind == tok::objc_not_keyword) {
737 Diag(NextTok, diag::err_objc_unknown_at);
751 switch (DirectiveKind) {
757 Diag(AtLoc, diag::err_objc_illegal_interface_qual);
762 case tok::objc_required:
763 case tok::objc_optional:
765 if (contextKey != tok::objc_protocol)
766 Diag(AtLoc, diag::err_objc_directive_only_in_protocol);
771 case tok::objc_property:
775 if (Tok.
is(tok::l_paren)) {
777 ParseObjCPropertyAttribute(OCDS);
780 bool addedToDeclSpec =
false;
782 if (FD.D.getIdentifier() ==
nullptr) {
783 Diag(AtLoc, diag::err_objc_property_requires_field_name)
784 << FD.D.getSourceRange();
787 if (FD.BitfieldSize) {
788 Diag(AtLoc, diag::err_objc_property_bitfield)
789 << FD.D.getSourceRange();
813 FD.D.getIdentifier());
815 getCurScope(), AtLoc, LParenLoc, FD, OCDS, GetterSel, SetterSel,
823 ParseStructDeclaration(DS, ObjCPropertyCallback);
825 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
836 Diag(Tok, diag::err_objc_missing_end)
855 P.Diag(nullabilityLoc, diag::warn_nullability_duplicate)
861 P.Diag(nullabilityLoc, diag::err_nullability_conflicting)
893void Parser::ParseObjCPropertyAttribute(
ObjCDeclSpec &DS) {
894 assert(Tok.
getKind() == tok::l_paren);
899 if (Tok.
is(tok::code_completion)) {
914 if (II->
isStr(
"readonly"))
916 else if (II->
isStr(
"assign"))
918 else if (II->
isStr(
"unsafe_unretained"))
920 else if (II->
isStr(
"readwrite"))
922 else if (II->
isStr(
"retain"))
924 else if (II->
isStr(
"strong"))
926 else if (II->
isStr(
"copy"))
928 else if (II->
isStr(
"nonatomic"))
930 else if (II->
isStr(
"atomic"))
932 else if (II->
isStr(
"weak"))
934 else if (II->
isStr(
"getter") || II->
isStr(
"setter")) {
938 unsigned DiagID = IsSetter ? diag::err_objc_expected_equal_for_setter :
939 diag::err_objc_expected_equal_for_getter;
941 if (ExpectAndConsume(tok::equal, DiagID)) {
946 if (Tok.
is(tok::code_completion)) {
959 Diag(Tok, diag::err_objc_expected_selector_for_getter_setter)
969 if (ExpectAndConsume(tok::colon,
970 diag::err_expected_colon_after_setter_name)) {
978 }
else if (II->
isStr(
"nonnull")) {
985 }
else if (II->
isStr(
"nullable")) {
992 }
else if (II->
isStr(
"null_unspecified")) {
999 }
else if (II->
isStr(
"null_resettable")) {
1009 }
else if (II->
isStr(
"class")) {
1011 }
else if (II->
isStr(
"direct")) {
1014 Diag(AttrName, diag::err_objc_expected_property_attr) << II;
1019 if (Tok.
isNot(tok::comma))
1039 bool MethodDefinition) {
1040 assert(Tok.
isOneOf(tok::minus, tok::plus) &&
"expected +/-");
1044 Decl *MDecl = ParseObjCMethodDecl(mLoc, methodType, MethodImplKind,
1074 case tok::exclaimequal:
1076 case tok::pipeequal:
1078 case tok::caretequal: {
1089 case tok::identifier:
1099 case tok::kw_const_cast:
1100 case tok::kw_continue:
1101 case tok::kw_default:
1102 case tok::kw_delete:
1104 case tok::kw_double:
1105 case tok::kw_dynamic_cast:
1108 case tok::kw_explicit:
1109 case tok::kw_export:
1110 case tok::kw_extern:
1114 case tok::kw_friend:
1117 case tok::kw_inline:
1120 case tok::kw_mutable:
1121 case tok::kw_namespace:
1123 case tok::kw_operator:
1124 case tok::kw_private:
1125 case tok::kw_protected:
1126 case tok::kw_public:
1127 case tok::kw_register:
1128 case tok::kw_reinterpret_cast:
1129 case tok::kw_restrict:
1130 case tok::kw_return:
1132 case tok::kw_signed:
1133 case tok::kw_sizeof:
1134 case tok::kw_static:
1135 case tok::kw_static_cast:
1136 case tok::kw_struct:
1137 case tok::kw_switch:
1138 case tok::kw_template:
1143 case tok::kw_typedef:
1144 case tok::kw_typeid:
1145 case tok::kw_typename:
1146 case tok::kw_typeof:
1148 case tok::kw_unsigned:
1150 case tok::kw_virtual:
1152 case tok::kw_volatile:
1153 case tok::kw_wchar_t:
1156 case tok::kw__Complex:
1157 case tok::kw___alignof:
1158 case tok::kw___auto_type:
1167bool Parser::isTokIdentifier_in()
const {
1194void Parser::ParseObjCTypeQualifierList(
ObjCDeclSpec &DS,
1200 if (Tok.
is(tok::code_completion)) {
1207 if (Tok.
isNot(tok::identifier))
1211 for (
unsigned i = 0; i != objc_NumQuals; ++i) {
1212 if (II != ObjCTypeQuals[i] ||
1220 default: llvm_unreachable(
"Unknown decl qualifier");
1238 case objc_null_unspecified:
1263 for (
auto &AL : llvm::reverse(from)) {
1264 if (!AL.isUsedAsTypeAttr()) {
1299 assert((paramAttrs !=
nullptr) ==
1302 assert(Tok.
is(tok::l_paren) &&
"expected (");
1310 ParseObjCTypeQualifierList(DS, context);
1314 if (isTypeSpecifierQualifier() || isObjCInstancetype()) {
1317 declSpec.setObjCQualifiers(&DS);
1318 DeclSpecContext dsContext = DeclSpecContext::DSC_normal;
1320 dsContext = DeclSpecContext::DSC_objc_method_result;
1321 ParseSpecifierQualifierList(declSpec,
AS_none, dsContext);
1323 ParseDeclarator(declarator);
1326 if (!declarator.isInvalidType()) {
1328 bool addedToDeclSpec =
false;
1336 if (!
type.isInvalid())
1346 if (Tok.
is(tok::r_paren))
1350 Diag(Tok, diag::err_expected_type);
1391 bool MethodDefinition) {
1394 if (Tok.
is(tok::code_completion)) {
1404 if (Tok.
is(tok::l_paren))
1410 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1413 if (Tok.
is(tok::code_completion)) {
1425 if (!SelIdent && Tok.
isNot(tok::colon)) {
1426 Diag(Tok, diag::err_expected_selector_for_method)
1434 if (Tok.
isNot(tok::colon)) {
1436 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1442 selLoc, Sel,
nullptr, CParamInfo.data(), CParamInfo.size(), methodAttrs,
1443 MethodImplKind,
false, MethodDefinition);
1460 if (ExpectAndConsume(tok::colon))
1463 ArgInfo.
Type =
nullptr;
1464 if (Tok.
is(tok::l_paren))
1465 ArgInfo.
Type = ParseObjCTypeName(
1470 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1475 if (Tok.
is(tok::code_completion)) {
1477 KeyIdents.push_back(SelIdent);
1479 mType == tok::minus,
1481 ReturnType, KeyIdents);
1485 if (expectIdentifier())
1492 ArgInfos.push_back(ArgInfo);
1493 KeyIdents.push_back(SelIdent);
1494 KeyLocs.push_back(selLoc);
1497 allParamAttrs.takeAllFrom(paramAttrs.
getPool());
1500 if (Tok.
is(tok::code_completion)) {
1503 mType == tok::minus,
1505 ReturnType, KeyIdents);
1510 SelIdent = ParseObjCSelectorPiece(selLoc);
1511 if (!SelIdent && Tok.
isNot(tok::colon))
1516 Diag(ArgInfo.
NameLoc, diag::warn_missing_selector_name) << ArgInfo.
Name;
1517 Diag(ArgInfo.
NameLoc, diag::note_missing_selector_name) << ArgInfo.
Name;
1518 Diag(ColonLoc, diag::note_force_empty_selector_name) << ArgInfo.
Name;
1524 bool isVariadic =
false;
1525 bool cStyleParamWarned =
false;
1527 while (Tok.
is(tok::comma)) {
1529 if (Tok.
is(tok::ellipsis)) {
1534 if (!cStyleParamWarned) {
1535 Diag(Tok, diag::warn_cstyle_param);
1536 cStyleParamWarned =
true;
1539 ParseDeclarationSpecifiers(DS);
1543 ParseDeclarator(ParmDecl);
1547 ParmDecl.getIdentifierLoc(),
1554 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1557 if (KeyIdents.size() == 0)
1564 Sel, &ArgInfos[0], CParamInfo.data(), CParamInfo.size(), methodAttrs,
1565 MethodImplKind, isVariadic, MethodDefinition);
1577 bool WarnOnDeclarations,
bool ForObjCContainer,
1579 bool consumeLastToken) {
1580 assert(Tok.
is(tok::less) &&
"expected <");
1587 if (Tok.
is(tok::code_completion)) {
1593 if (expectIdentifier()) {
1607 if (ParseGreaterThanInTemplateList(LAngleLoc, EndLoc, consumeLastToken,
1613 ProtocolIdents, Protocols);
1618 assert(Tok.
is(tok::less) &&
"Protocol qualifiers start with '<'");
1619 assert(
getLangOpts().
ObjC &&
"Protocol qualifiers only exist in Objective-C");
1624 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
false,
false,
1625 lAngleLoc, rAngleLoc,
1632 Diag(lAngleLoc, diag::warn_objc_protocol_qualifier_missing_id)
1645void Parser::parseObjCTypeArgsOrProtocolQualifiers(
1654 bool consumeLastToken,
1655 bool warnOnIncompleteProtocols) {
1656 assert(Tok.
is(tok::less) &&
"Not at the start of type args or protocols");
1661 bool allSingleIdentifiers =
true;
1669 if (Tok.
is(tok::identifier) &&
1678 if (Tok.
is(tok::code_completion)) {
1681 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1683 identifierLocs[i]));
1696 allSingleIdentifiers =
false;
1702 if (allSingleIdentifiers) {
1705 (void)ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc, consumeLastToken,
1721 warnOnIncompleteProtocols);
1731 bool invalid =
false;
1732 IdentifierInfo *foundProtocolId =
nullptr, *foundValidTypeId =
nullptr;
1737 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1742 const char *prevSpec =
nullptr;
1744 DS.SetTypeSpecType(
TST_typename, identifierLocs[i], prevSpec, diagID,
1752 typeArgs.push_back(fullTypeArg.
get());
1753 if (!foundValidTypeId) {
1754 foundValidTypeId = identifiers[i];
1755 foundValidTypeSrcLoc = identifierLocs[i];
1759 unknownTypeArgs.push_back(identifiers[i]);
1760 unknownTypeArgsLoc.push_back(identifierLocs[i]);
1764 if (!Actions.
LookupProtocol(identifiers[i], identifierLocs[i])) {
1765 unknownTypeArgs.push_back(identifiers[i]);
1766 unknownTypeArgsLoc.push_back(identifierLocs[i]);
1767 }
else if (!foundProtocolId) {
1768 foundProtocolId = identifiers[i];
1769 foundProtocolSrcLoc = identifierLocs[i];
1776 Token CurTypeTok = Tok;
1787 typeArgs.push_back(typeArg.
get());
1788 if (!foundValidTypeId) {
1798 if (foundProtocolId && foundValidTypeId)
1801 foundValidTypeSrcLoc);
1805 if (unknownTypeArgs.size())
1806 for (
unsigned i = 0, e = unknownTypeArgsLoc.size(); i < e; ++i)
1812 (void)ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc, consumeLastToken,
1821 typeArgsLAngleLoc = lAngleLoc;
1822 typeArgsRAngleLoc = rAngleLoc;
1825void Parser::parseObjCTypeArgsAndProtocolQualifiers(
1834 bool consumeLastToken) {
1835 assert(Tok.
is(tok::less));
1838 parseObjCTypeArgsOrProtocolQualifiers(baseType,
1848 if (Tok.
is(tok::eof))
1854 if ((consumeLastToken && Tok.
is(tok::less)) ||
1855 (!consumeLastToken &&
NextToken().is(tok::less))) {
1858 if (!consumeLastToken)
1861 if (!protocols.empty()) {
1863 if (!consumeLastToken)
1865 Diag(Tok, diag::err_objc_type_args_after_protocols)
1866 <<
SourceRange(protocolLAngleLoc, protocolRAngleLoc);
1867 SkipUntil(tok::greater, tok::greatergreater, skipFlags);
1869 ParseObjCProtocolReferences(protocols, protocolLocs,
1872 protocolLAngleLoc, protocolRAngleLoc,
1878TypeResult Parser::parseObjCTypeArgsAndProtocolQualifiers(
1881 bool consumeLastToken,
1883 assert(Tok.
is(tok::less));
1893 parseObjCTypeArgsAndProtocolQualifiers(
type, typeArgsLAngleLoc, typeArgs,
1894 typeArgsRAngleLoc, protocolLAngleLoc,
1895 protocols, protocolLocs,
1896 protocolRAngleLoc, consumeLastToken);
1898 if (Tok.
is(tok::eof))
1902 if (consumeLastToken)
1903 endLoc = PrevTokLocation;
1920void Parser::HelperActionsForIvarDeclarations(
1923 bool RBraceMissing) {
1928 "Ivars should have interfaceDecl as their decl context");
1961 assert(Tok.
is(tok::l_brace) &&
"expected {");
1969 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
1973 if (Tok.
is(tok::semi)) {
1974 ConsumeExtraSemi(InstanceVariableList);
1980 if (Tok.
is(tok::code_completion)) {
1987 case tok::objc_private:
1988 case tok::objc_public:
1989 case tok::objc_protected:
1990 case tok::objc_package:
1996 Diag(Tok, diag::err_objc_unexpected_atend);
2001 HelperActionsForIvarDeclarations(interfaceDecl, atLoc,
2002 T, AllIvarDecls,
true);
2006 Diag(Tok, diag::err_objc_illegal_visibility_spec);
2011 if (Tok.
is(tok::code_completion)) {
2021 if (Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2023 ParseStaticAssertDeclaration(DeclEnd);
2029 "Ivar should have interfaceDecl as its decl context");
2031 FD.D.setObjCIvar(
true);
2033 getCurScope(), FD.D.getDeclSpec().getSourceRange().getBegin(), FD.D,
2034 FD.BitfieldSize, visibility);
2036 AllIvarDecls.push_back(Field);
2042 ParseStructDeclaration(DS, ObjCIvarCallback);
2044 if (Tok.
is(tok::semi)) {
2047 Diag(Tok, diag::err_expected_semi_decl_list);
2052 HelperActionsForIvarDeclarations(interfaceDecl, atLoc,
2053 T, AllIvarDecls,
false);
2076 "ParseObjCAtProtocolDeclaration(): Expected @protocol");
2079 if (Tok.
is(tok::code_completion)) {
2085 MaybeSkipAttributes(tok::objc_protocol);
2087 if (expectIdentifier())
2098 CheckNestedObjCContexts(AtLoc);
2100 if (Tok.
is(tok::comma)) {
2102 ProtocolRefs.push_back(std::make_pair(protocolName, nameLoc));
2107 if (expectIdentifier()) {
2115 if (Tok.
isNot(tok::comma))
2119 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"@protocol"))
2130 if (Tok.
is(tok::less) &&
2131 ParseObjCProtocolReferences(ProtocolRefs, ProtocolLocs,
false,
true,
2132 LAngleLoc, EndProtoLoc,
2138 AtLoc, protocolName, nameLoc, ProtocolRefs.data(), ProtocolRefs.size(),
2139 ProtocolLocs.data(), EndProtoLoc, attrs, &SkipBody);
2141 ParseObjCInterfaceDeclList(tok::objc_protocol, ProtoType);
2143 auto *PreviousDef = cast<ObjCProtocolDecl>(SkipBody.
Previous);
2146 PreviousDef->getDefinition());
2150 DiagsEmitter.diagnoseMismatch(PreviousDef, ProtoType);
2167Parser::ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc,
2170 "ParseObjCAtImplementationDeclaration(): Expected @implementation");
2171 CheckNestedObjCContexts(AtLoc);
2175 if (Tok.
is(tok::code_completion)) {
2181 MaybeSkipAttributes(tok::objc_implementation);
2183 if (expectIdentifier())
2192 if (Tok.
is(tok::less)) {
2196 ObjCTypeParamListScope typeParamScope(Actions,
getCurScope());
2197 if (parseObjCTypeParamListOrProtocolRefs(typeParamScope, lAngleLoc,
2198 protocolIdents, rAngleLoc)) {
2199 Diag(diagLoc, diag::err_objc_parameterized_implementation)
2201 }
else if (lAngleLoc.
isValid()) {
2202 Diag(lAngleLoc, diag::err_unexpected_protocol_qualifier)
2207 if (Tok.
is(tok::l_paren)) {
2213 if (Tok.
is(tok::code_completion)) {
2219 if (Tok.
is(tok::identifier)) {
2223 Diag(Tok, diag::err_expected)
2227 if (Tok.
isNot(tok::r_paren)) {
2228 Diag(Tok, diag::err_expected) << tok::r_paren;
2232 rparenLoc = ConsumeParen();
2233 if (Tok.
is(tok::less)) {
2234 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2238 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
2241 protocolLAngleLoc, protocolRAngleLoc,
2245 AtLoc, nameId, nameLoc, categoryId, categoryLoc, Attrs);
2253 if (expectIdentifier())
2259 AtLoc, nameId, nameLoc, superClassId, superClassLoc, Attrs);
2261 if (Tok.
is(tok::l_brace))
2262 ParseObjCClassInstanceVariables(ObjCImpDecl, tok::objc_private, AtLoc);
2263 else if (Tok.
is(tok::less)) {
2264 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2269 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
2272 protocolLAngleLoc, protocolRAngleLoc,
2276 assert(ObjCImpDecl);
2281 ObjCImplParsingDataRAII ObjCImplParsing(*
this, ObjCImpDecl);
2282 while (!ObjCImplParsing.isFinished() && !isEofOrEom()) {
2284 MaybeParseCXX11Attributes(DeclAttrs);
2287 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs)) {
2289 DeclsInGroup.append(DG.
begin(), DG.
end());
2298Parser::ParseObjCAtEndDeclaration(
SourceRange atEnd) {
2300 "ParseObjCAtEndDeclaration(): Expected @end");
2302 if (CurParsedObjCImpl)
2303 CurParsedObjCImpl->finish(atEnd);
2306 Diag(atEnd.
getBegin(), diag::err_expected_objc_container);
2310Parser::ObjCImplParsingDataRAII::~ObjCImplParsingDataRAII() {
2312 finish(
P.Tok.getLocation());
2313 if (
P.isEofOrEom()) {
2314 P.Diag(
P.Tok, diag::err_objc_missing_end)
2316 P.Diag(Dcl->getBeginLoc(), diag::note_objc_container_start)
2320 P.CurParsedObjCImpl =
nullptr;
2321 assert(LateParsedObjCMethods.empty());
2324void Parser::ObjCImplParsingDataRAII::finish(
SourceRange AtEnd) {
2326 P.Actions.DefaultSynthesizeProperties(
P.getCurScope(), Dcl, AtEnd.
getBegin());
2327 for (
size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
2328 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i],
2331 P.Actions.ActOnAtEnd(
P.getCurScope(), AtEnd);
2334 for (
size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
2335 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i],
2339 for (LateParsedObjCMethodContainer::iterator
2340 I = LateParsedObjCMethods.begin(),
2341 E = LateParsedObjCMethods.end(); I != E; ++I)
2343 LateParsedObjCMethods.clear();
2353 "ParseObjCAtAliasDeclaration(): Expected @compatibility_alias");
2355 if (expectIdentifier())
2359 if (expectIdentifier())
2363 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@compatibility_alias");
2381 "ParseObjCPropertySynthesize(): Expected '@synthesize'");
2385 if (Tok.
is(tok::code_completion)) {
2391 if (Tok.
isNot(tok::identifier)) {
2392 Diag(Tok, diag::err_synthesized_property_name);
2403 if (Tok.
is(tok::code_completion)) {
2409 if (expectIdentifier())
2416 propertyId, propertyIvar, propertyIvarLoc,
2418 if (Tok.
isNot(tok::comma))
2422 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@synthesize");
2435 "ParseObjCPropertyDynamic(): Expected '@dynamic'");
2438 bool isClassProperty =
false;
2439 if (Tok.
is(tok::l_paren)) {
2444 Diag(Tok, diag::err_objc_expected_property_attr) << II;
2448 if (II->
isStr(
"class")) {
2449 isClassProperty =
true;
2450 if (Tok.
isNot(tok::r_paren)) {
2451 Diag(Tok, diag::err_expected) << tok::r_paren;
2456 Diag(AttrName, diag::err_objc_expected_property_attr) << II;
2463 if (Tok.
is(tok::code_completion)) {
2469 if (expectIdentifier()) {
2482 if (Tok.
isNot(tok::comma))
2486 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@dynamic");
2496 if (Tok.
isNot(tok::semi)) {
2504 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@throw");
2514 if (Tok.
isNot(tok::l_paren)) {
2515 Diag(Tok, diag::err_expected_lparen_after) <<
"@synchronized";
2523 if (Tok.
is(tok::r_paren)) {
2526 if (!operand.isInvalid())
2527 Diag(Tok, diag::err_expected) << tok::r_paren;
2534 if (Tok.
isNot(tok::l_brace)) {
2535 if (!operand.isInvalid())
2536 Diag(Tok, diag::err_expected) << tok::l_brace;
2541 if (!operand.isInvalid())
2546 StmtResult body(ParseCompoundStatementBody());
2551 if (operand.isInvalid())
2554 if (body.isInvalid())
2572 bool catch_or_finally_seen =
false;
2575 if (Tok.
isNot(tok::l_brace)) {
2576 Diag(Tok, diag::err_expected) << tok::l_brace;
2582 StmtResult TryBody(ParseCompoundStatementBody());
2584 if (TryBody.isInvalid())
2587 while (Tok.
is(tok::at)) {
2591 Token AfterAt = GetLookAheadToken(1);
2598 Decl *FirstPart =
nullptr;
2600 if (Tok.
is(tok::l_paren)) {
2605 if (Tok.
isNot(tok::ellipsis)) {
2607 ParseDeclarationSpecifiers(DS);
2610 ParseDeclarator(ParmDecl);
2620 if (Tok.
is(tok::r_paren))
2621 RParenLoc = ConsumeParen();
2626 if (Tok.
is(tok::l_brace))
2627 CatchBody = ParseCompoundStatementBody();
2629 Diag(Tok, diag::err_expected) << tok::l_brace;
2630 if (CatchBody.isInvalid())
2638 CatchStmts.push_back(Catch.
get());
2641 Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after)
2645 catch_or_finally_seen =
true;
2647 assert(Tok.
isObjCAtKeyword(tok::objc_finally) &&
"Lookahead confused?");
2649 ParseScope FinallyScope(
this,
2652 bool ShouldCapture =
2659 if (Tok.
is(tok::l_brace))
2660 FinallyBody = ParseCompoundStatementBody();
2662 Diag(Tok, diag::err_expected) << tok::l_brace;
2664 if (FinallyBody.isInvalid()) {
2668 }
else if (ShouldCapture) {
2674 catch_or_finally_seen =
true;
2678 if (!catch_or_finally_seen) {
2679 Diag(atLoc, diag::err_missing_catch_finally);
2694 if (Tok.
isNot(tok::l_brace)) {
2695 Diag(Tok, diag::err_expected) << tok::l_brace;
2702 StmtResult AutoreleasePoolBody(ParseCompoundStatementBody());
2705 if (AutoreleasePoolBody.isInvalid())
2708 AutoreleasePoolBody.get());
2713void Parser::StashAwayMethodOrFunctionBodyTokens(
Decl *MDecl) {
2715 trySkippingFunctionBody()) {
2720 LexedMethod* LM =
new LexedMethod(
this, MDecl);
2721 CurParsedObjCImpl->LateParsedObjCMethods.push_back(LM);
2724 Toks.push_back(Tok);
2725 if (Tok.
is(tok::kw_try)) {
2727 if (Tok.
is(tok::colon)) {
2728 Toks.push_back(Tok);
2730 while (Tok.
isNot(tok::l_brace)) {
2731 ConsumeAndStoreUntil(tok::l_paren, Toks,
false);
2732 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
2735 Toks.push_back(Tok);
2737 else if (Tok.
is(tok::colon)) {
2740 while (Tok.
isNot(tok::l_brace)) {
2741 ConsumeAndStoreUntil(tok::l_paren, Toks,
false);
2742 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
2744 Toks.push_back(Tok);
2748 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
2749 while (Tok.
is(tok::kw_catch)) {
2750 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
2751 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
2757Decl *Parser::ParseObjCMethodDefinition() {
2758 Decl *MDecl = ParseObjCMethodPrototype();
2761 "parsing Objective-C method");
2764 if (Tok.
is(tok::semi)) {
2765 if (CurParsedObjCImpl) {
2766 Diag(Tok, diag::warn_semicolon_before_method_body)
2773 if (Tok.
isNot(tok::l_brace)) {
2774 Diag(Tok, diag::err_expected_method_body);
2780 if (Tok.
isNot(tok::l_brace))
2792 assert (CurParsedObjCImpl
2793 &&
"ParseObjCMethodDefinition - Method out of @implementation");
2795 StashAwayMethodOrFunctionBodyTokens(MDecl);
2800 ParsedStmtContext StmtCtx) {
2801 if (Tok.
is(tok::code_completion)) {
2808 return ParseObjCTryStmt(AtLoc);
2811 return ParseObjCThrowStmt(AtLoc);
2814 return ParseObjCSynchronizedStmt(AtLoc);
2817 return ParseObjCAutoreleasePoolStmt(AtLoc);
2825 ExprStatementTokLoc = AtLoc;
2826 ExprResult Res(ParseExpressionWithLeadingAt(AtLoc));
2836 ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
2837 return handleExprStmt(Res, StmtCtx);
2842 case tok::code_completion:
2852 if (!Tok.
is(tok::numeric_constant)) {
2853 const char *Symbol =
nullptr;
2855 case tok::minus: Symbol =
"-";
break;
2856 case tok::plus: Symbol =
"+";
break;
2857 default: llvm_unreachable(
"missing unary operator case");
2859 Diag(Tok, diag::err_nsnumber_nonliteral_unary)
2865 if (Lit.isInvalid()) {
2871 if (Lit.isInvalid())
2874 return ParsePostfixExpressionSuffix(
2878 case tok::string_literal:
2879 case tok::wide_string_literal:
2880 return ParsePostfixExpressionSuffix(ParseObjCStringLiteral(AtLoc));
2882 case tok::char_constant:
2883 return ParsePostfixExpressionSuffix(ParseObjCCharacterLiteral(AtLoc));
2885 case tok::numeric_constant:
2886 return ParsePostfixExpressionSuffix(ParseObjCNumericLiteral(AtLoc));
2889 case tok::kw___objc_yes:
2890 return ParsePostfixExpressionSuffix(ParseObjCBooleanLiteral(AtLoc,
true));
2892 case tok::kw___objc_no:
2893 return ParsePostfixExpressionSuffix(ParseObjCBooleanLiteral(AtLoc,
false));
2897 return ParsePostfixExpressionSuffix(ParseObjCArrayLiteral(AtLoc));
2901 return ParsePostfixExpressionSuffix(ParseObjCDictionaryLiteral(AtLoc));
2905 return ParsePostfixExpressionSuffix(ParseObjCBoxedExpr(AtLoc));
2912 case tok::objc_encode:
2913 return ParsePostfixExpressionSuffix(ParseObjCEncodeExpression(AtLoc));
2914 case tok::objc_protocol:
2915 return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression(AtLoc));
2916 case tok::objc_selector:
2917 return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression(AtLoc));
2918 case tok::objc_available:
2919 return ParseAvailabilityCheckExpr(AtLoc);
2921 const char *str =
nullptr;
2925 if (GetLookAheadToken(1).is(tok::l_brace) &&
2926 ExprStatementTokLoc == AtLoc) {
2930 : (ch ==
'f' ?
"finally"
2931 : (ch ==
'a' ?
"autoreleasepool" :
nullptr));
2967bool Parser::ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr) {
2970 if (Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_typename,
2971 tok::annot_cxxscope))
2985 TypeOrExpr = Receiver.
get();
2994 ParseCXXSimpleTypeSpecifier(DS);
2996 if (Tok.
is(tok::l_paren)) {
3009 ExprResult Receiver = ParseCXXTypeConstructExpression(DS);
3011 Receiver = ParsePostfixExpressionSuffix(Receiver.
get());
3013 Receiver = ParseRHSOfBinaryExpression(Receiver.
get(),
prec::Comma);
3018 TypeOrExpr = Receiver.
get();
3028 if (
Type.isInvalid())
3032 TypeOrExpr =
Type.get().getAsOpaquePtr();
3041bool Parser::isSimpleObjCMessageExpression() {
3043 "Incorrect start for isSimpleObjCMessageExpression");
3044 return GetLookAheadToken(1).
is(tok::identifier) &&
3045 GetLookAheadToken(2).
is(tok::identifier);
3048bool Parser::isStartOfObjCClassMessageMissingOpenBracket() {
3050 InMessageExpression)
3055 if (Tok.
is(tok::annot_typename))
3057 else if (Tok.
is(tok::identifier))
3065 const Token &AfterNext = GetLookAheadToken(2);
3066 if (AfterNext.
isOneOf(tok::colon, tok::r_square)) {
3067 if (Tok.
is(tok::identifier))
3070 return Tok.
is(tok::annot_typename);
3086ExprResult Parser::ParseObjCMessageExpression() {
3087 assert(Tok.
is(tok::l_square) &&
"'[' expected");
3090 if (Tok.
is(tok::code_completion)) {
3107 return ParseObjCMessageExpressionBody(LBracLoc,
ConsumeToken(),
nullptr,
3112 void *TypeOrExpr =
nullptr;
3113 if (ParseObjCXXMessageReceiver(IsExpr, TypeOrExpr)) {
3119 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
nullptr,
3120 static_cast<Expr *
>(TypeOrExpr));
3122 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
3127 if (Tok.
is(tok::identifier)) {
3132 Name == Ident_super,
3136 return ParseObjCMessageExpressionBody(LBracLoc,
ConsumeToken(),
nullptr,
3140 if (!ReceiverType) {
3148 if (Tok.
is(tok::less)) {
3151 = parseObjCTypeArgsAndProtocolQualifiers(NameLoc, ReceiverType,
3159 ReceiverType = NewReceiverType.
get();
3162 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
3163 ReceiverType,
nullptr);
3178 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
nullptr,
3224 Expr *ReceiverExpr) {
3227 if (Tok.
is(tok::code_completion)) {
3231 std::nullopt,
false);
3232 else if (ReceiverType)
3234 std::nullopt,
false);
3237 std::nullopt,
false);
3247 ExprVector KeyExprs;
3249 if (Tok.
is(tok::colon)) {
3252 KeyIdents.push_back(selIdent);
3253 KeyLocs.push_back(Loc);
3255 if (ExpectAndConsume(tok::colon)) {
3265 if (Tok.
is(tok::code_completion)) {
3271 else if (ReceiverType)
3285 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3286 Expr = ParseBraceInitializer();
3300 KeyExprs.push_back(Res.
get());
3303 if (Tok.
is(tok::code_completion)) {
3309 else if (ReceiverType)
3321 selIdent = ParseObjCSelectorPiece(Loc);
3322 if (!selIdent && Tok.
isNot(tok::colon))
3327 while (Tok.
is(tok::comma)) {
3331 if (Tok.
is(tok::colon))
3334 if (Tok.
is(tok::colon)) {
3335 Diag(commaLoc, diag::note_extra_comma_message_arg) <<
3346 KeyExprs.push_back(Res.
get());
3348 }
else if (!selIdent) {
3349 Diag(Tok, diag::err_expected) << tok::identifier;
3358 if (Tok.
isNot(tok::r_square)) {
3359 Diag(Tok, diag::err_expected)
3360 << (Tok.
is(tok::identifier) ? tok::colon : tok::r_square);
3370 unsigned nKeys = KeyIdents.size();
3372 KeyIdents.push_back(selIdent);
3373 KeyLocs.push_back(Loc);
3379 LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3380 else if (ReceiverType)
3382 LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3384 LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3395 ExprVector AtStrings;
3396 AtLocs.push_back(AtLoc);
3397 AtStrings.push_back(Res.
get());
3399 while (Tok.
is(tok::at)) {
3403 if (!isTokenStringLiteral())
3407 if (Lit.isInvalid())
3410 AtStrings.push_back(Lit.get());
3432 if (Lit.isInvalid()) {
3446 if (Lit.isInvalid()) {
3458 if (Tok.
isNot(tok::l_paren))
3459 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@");
3467 if (ValueExpr.isInvalid())
3473 ValueExpr = Actions.
ActOnParenExpr(LPLoc, RPLoc, ValueExpr.get());
3479 ExprVector ElementExprs;
3482 bool HasInvalidEltExpr =
false;
3483 while (Tok.
isNot(tok::r_square)) {
3496 HasInvalidEltExpr =
true;
3499 if (Tok.
is(tok::ellipsis))
3502 HasInvalidEltExpr =
true;
3504 ElementExprs.push_back(Res.
get());
3506 if (Tok.
is(tok::comma))
3508 else if (Tok.
isNot(tok::r_square))
3509 return ExprError(
Diag(Tok, diag::err_expected_either) << tok::r_square
3514 if (HasInvalidEltExpr)
3524 bool HasInvalidEltExpr =
false;
3525 while (Tok.
isNot(tok::r_brace)) {
3540 if (ExpectAndConsume(tok::colon)) {
3546 if (ValueExpr.isInvalid()) {
3557 if (KeyExpr.
isInvalid() || ValueExpr.isInvalid())
3558 HasInvalidEltExpr =
true;
3570 EllipsisLoc, std::nullopt};
3571 Elements.push_back(Element);
3574 return ExprError(
Diag(Tok, diag::err_expected_either) << tok::r_brace
3579 if (HasInvalidEltExpr)
3591 assert(Tok.
isObjCAtKeyword(tok::objc_encode) &&
"Not an @encode expression!");
3595 if (Tok.
isNot(tok::l_paren))
3596 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@encode");
3618 if (Tok.
isNot(tok::l_paren))
3619 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@protocol");
3624 if (expectIdentifier())
3642 if (Tok.
isNot(tok::l_paren))
3643 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@selector");
3650 bool HasOptionalParen = Tok.
is(tok::l_paren);
3651 if (HasOptionalParen)
3654 if (Tok.
is(tok::code_completion)) {
3662 Tok.
isNot(tok::colon) && Tok.
isNot(tok::coloncolon))
3663 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
3665 KeyIdents.push_back(SelIdent);
3667 unsigned nColons = 0;
3668 if (Tok.
isNot(tok::r_paren)) {
3672 KeyIdents.push_back(
nullptr);
3673 }
else if (ExpectAndConsume(tok::colon))
3677 if (Tok.
is(tok::r_paren))
3680 if (Tok.
is(tok::code_completion)) {
3688 SelIdent = ParseObjCSelectorPiece(Loc);
3689 KeyIdents.push_back(SelIdent);
3690 if (!SelIdent && Tok.
isNot(tok::colon) && Tok.
isNot(tok::coloncolon))
3694 if (HasOptionalParen && Tok.
is(tok::r_paren))
3704void Parser::ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod) {
3706 Decl *MCDecl = LM.D;
3707 bool skip = MCDecl &&
3716 assert(!LM.Toks.empty() &&
"ParseLexedObjCMethodDef - Empty body!");
3724 LM.Toks.push_back(Eof);
3727 LM.Toks.push_back(Tok);
3728 PP.EnterTokenStream(LM.Toks,
true,
true);
3733 assert(Tok.
isOneOf(tok::l_brace, tok::kw_try, tok::colon) &&
3734 "Inline objective-c method not starting with '{' or 'try' or ':'");
3746 if (Tok.
is(tok::kw_try))
3747 ParseFunctionTryBlock(MCDecl, BodyScope);
3749 if (Tok.
is(tok::colon))
3750 ParseConstructorInitializer(MCDecl);
3753 ParseFunctionStatementBody(MCDecl, BodyScope);
Defines the clang::ASTContext interface.
static void addContextSensitiveTypeNullability(Parser &P, Declarator &D, NullabilityKind nullability, SourceLocation nullabilityLoc, bool &addedToDeclSpec)
Add an attribute for a context-sensitive type nullability to the given declarator.
static void diagnoseRedundantPropertyNullability(Parser &P, ObjCDeclSpec &DS, NullabilityKind nullability, SourceLocation nullabilityLoc)
Diagnose redundant or conflicting nullability information.
static bool isTopLevelObjCKeyword(tok::ObjCKeywordKind DirectiveKind)
static void takeDeclAttributes(ParsedAttributesView &attrs, ParsedAttributesView &from)
Take all the decl attributes out of the given list and add them to the given attribute set.
Class to handle popping type parameters when leaving the scope.
ObjCTypeParamListScope(Sema &Actions, Scope *S)
void enter(ObjCTypeParamList *P)
~ObjCTypeParamListScope()
const clang::PrintingPolicy & getPrintingPolicy() const
The result of parsing/analyzing an expression, statement etc.
Attr - This represents one attribute.
bool isGNUAttribute() const
void takeAllFrom(AttributePool &pool)
Take the given pool's allocations and add them to this pool.
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
SourceLocation getOpenLocation() const
SourceLocation getCloseLocation() const
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
Captures information about "declaration specifiers".
ParsedAttributes & getAttributes()
AttributePool & getAttributePool() const
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
SourceLocation getBeginLoc() const LLVM_READONLY
Information about one declarator, including the parsed type information and the identifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const ParsedAttributes & getAttributes() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const ParsedAttributesView & getDeclarationAttributes() const
AttributePool & getAttributePool() const
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
This represents one expression.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
RAII object that makes '>' behave either as an operator or as the closing angle bracket for a templat...
One of these records is kept for each identifier that is lexed.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
tok::ObjCKeywordKind getObjCKeywordID() const
Return the Objective-C keyword ID for the this identifier.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ObjCCategoryDecl - Represents a category declaration.
ObjCContainerDecl - Represents a container for method declarations.
Captures information about "declaration specifiers" specific to Objective-C.
void setObjCDeclQualifier(ObjCDeclQualifier DQVal)
ObjCPropertyAttribute::Kind getPropertyAttributes() const
ObjCDeclQualifier
ObjCDeclQualifier - Qualifier used on types in method declarations.
void setSetterName(IdentifierInfo *name, SourceLocation loc)
const IdentifierInfo * getSetterName() const
ObjCDeclQualifier getObjCDeclQualifier() const
SourceLocation getNullabilityLoc() const
NullabilityKind getNullability() const
void setGetterName(IdentifierInfo *name, SourceLocation loc)
void setNullability(SourceLocation loc, NullabilityKind kind)
const IdentifierInfo * getGetterName() const
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
Represents an ObjC class declaration.
void mergeDuplicateDefinitionWithCommon(const ObjCInterfaceDecl *Definition)
Represents an Objective-C protocol declaration.
void mergeDuplicateDefinitionWithCommon(const ObjCProtocolDecl *Definition)
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Wrapper for void* pointer.
static OpaquePtr getFromOpaquePtr(void *P)
ParsedAttr - Represents a syntactic attribute.
static const ParsedAttributesView & none()
void addAtEnd(ParsedAttr *newAttr)
void remove(ParsedAttr *ToBeRemoved)
ParsedAttributes - A collection of parsed attributes.
AttributePool & getPool() const
void takeAllFrom(ParsedAttributes &Other)
Parser - This implements a parser for the C family of languages.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Preprocessor & getPreprocessor() const
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
bool TryConsumeToken(tok::TokenKind Expected)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Scope * getCurScope() const
const TargetInfo & getTargetInfo() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
friend class ObjCDeclContextSwitch
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
SmallVector< Stmt *, 32 > StmtVector
A SmallVector of statements.
SkipUntilFlags
Control flags for SkipUntil functions.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtSemi
Stop skipping at semicolon.
bool TryAnnotateTypeOrScopeToken(ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
ObjCContainerDecl * getObjCDeclContext() const
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
RAII object used to inform the actions that we're currently parsing a declaration.
A class for parsing a DeclSpec.
A class for parsing a field declarator.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
SourceManager & getSourceManager() const
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
IdentifierTable & getIdentifierTable()
SelectorTable & getSelectorTable()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Scope - A scope is a transient data structure that is used while parsing the program.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ AtCatchScope
This is a scope that corresponds to the Objective-C @catch statement.
@ CompoundStmtScope
This is a compound statement scope.
@ ClassScope
The scope of a struct/union/class definition.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ ObjCMethodScope
This scope corresponds to an Objective-C method body.
@ DeclScope
This is a scope that can contain a declaration.
static Selector constructSetterSelector(IdentifierTable &Idents, SelectorTable &SelTable, const IdentifierInfo *Name)
Return the default setter selector for the given identifier.
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
Selector getNullarySelector(IdentifierInfo *ID)
Smart pointer class that efficiently represents Objective-C method names.
Sema - This implements semantic analysis and AST building for C.
void CodeCompleteObjCProtocolDecl(Scope *S)
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
void ActOnStartOfObjCMethodDef(Scope *S, Decl *D)
ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible and user declared,...
DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef< Decl * > Decls)
ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolName, SourceLocation AtLoc, SourceLocation ProtoLoc, SourceLocation LParenLoc, SourceLocation ProtoIdLoc, SourceLocation RParenLoc)
ParseObjCProtocolExpression - Build protocol expression for @protocol.
Decl * ActOnSkippedFunctionBody(Decl *Decl)
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< IdentifierInfo * > SelIdents)
ObjCCategoryDecl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
void CodeCompleteObjCMessageReceiver(Scope *S)
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList * > TypeParamLists, unsigned NumElts)
ObjCImplementationDecl * ActOnStartClassImplementation(SourceLocation AtClassImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc, const ParsedAttributesView &AttrList)
Decl * ActOnParamDeclarator(Scope *S, Declarator &D, SourceLocation ExplicitThisLoc={})
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
void CodeCompleteObjCAtDirective(Scope *S)
ObjCTypeParamList * actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef< Decl * > typeParams, SourceLocation rAngleLoc)
bool ActOnDuplicateODRHashDefinition(T *Duplicate, T *Previous)
Check ODR hashes for C/ObjC when merging types from modules.
void ActOnTypedefedProtocols(SmallVectorImpl< Decl * > &ProtocolRefs, SmallVectorImpl< SourceLocation > &ProtocolLocs, IdentifierInfo *SuperName, SourceLocation SuperLoc)
ActOnTypedefedProtocols - this action finds protocol list as part of the typedef'ed use for a qualifi...
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
Decl * ActOnProperty(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
void CodeCompleteObjCAtExpression(Scope *S)
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
TypeResult ActOnTypeName(Scope *S, Declarator &D)
ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl * > allMethods=std::nullopt, ArrayRef< DeclGroupPtrTy > allTUVars=std::nullopt)
TypeResult actOnObjCTypeArgsAndProtocolQualifiers(Scope *S, SourceLocation Loc, ParsedType BaseType, SourceLocation TypeArgsLAngleLoc, ArrayRef< ParsedType > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< Decl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build a specialized and/or protocol-qualified Objective-C type.
void CodeCompleteObjCClassForwardDecl(Scope *S)
Decl * ActOnCompatibilityAlias(SourceLocation AtCompatibilityAliasLoc, IdentifierInfo *AliasName, SourceLocation AliasLocation, IdentifierInfo *ClassName, SourceLocation ClassLocation)
ActOnCompatibilityAlias - this action is called after complete parsing of a @compatibility_alias decl...
void ActOnCapturedRegionError()
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
ASTContext & getASTContext() const
void CodeCompleteObjCPropertyDefinition(Scope *S)
bool isObjCMethodDecl(Decl *D)
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
void AddAnyMethodToGlobalPool(Decl *D)
AddAnyMethodToGlobalPool - Add any method, instance or factory to global pool.
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId, SourceLocation ProtocolLoc, IdentifierInfo *TypeArgId, SourceLocation TypeArgLoc, bool SelectProtocolFirst=false)
ObjCProtocolDecl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
void CodeCompleteObjCSelector(Scope *S, ArrayRef< IdentifierInfo * > SelIdents)
void CodeCompleteObjCImplementationDecl(Scope *S)
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
void CodeCompleteObjCPropertySetter(Scope *S)
void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList)
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, unsigned NumParams)
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLocPair > Protocols)
ObjCMessageKind getObjCMessageKind(Scope *S, IdentifierInfo *Name, SourceLocation NameLoc, bool IsSuper, bool HasTrailingDot, ParsedType &ReceiverType)
ExprResult ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
void CodeCompleteObjCAtVisibility(Scope *S)
Decl * ActOnMethodDeclaration(Scope *S, SourceLocation BeginLoc, SourceLocation EndLoc, tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType, ArrayRef< SourceLocation > SelectorLocs, Selector Sel, ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic, bool MethodDefinition)
ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, ArrayRef< Expr * > Strings)
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType typeBound)
@ PCC_ObjCInterface
Code completion occurs within an Objective-C interface, protocol, or category.
@ PCC_ObjCImplementation
Code completion occurs within an Objective-C implementation or category implementation.
@ PCC_Type
Code completion occurs where only a type is permitted.
@ PCC_ObjCInstanceVariableList
Code completion occurs within the list of instance variables in an Objective-C interface,...
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
StmtResult ActOnCapturedRegionEnd(Stmt *S)
ObjCContainerDecl * getObjCDeclContext() const
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, Scope *CurScope)
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression)
Decl * ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, SourceLocation PropertyLoc, bool ImplKind, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar, SourceLocation PropertyIvarLoc, ObjCPropertyQueryKind QueryKind)
ActOnPropertyImplDecl - This routine performs semantic checks and builds the AST node for a property ...
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper=false)
ObjCInterfaceDecl * ActOnStartClassInterface(Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
ExprResult ActOnInstanceMessage(Scope *S, Expr *Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
void actOnObjCTypeArgsOrProtocolQualifiers(Scope *S, ParsedType baseType, SourceLocation lAngleLoc, ArrayRef< IdentifierInfo * > identifiers, ArrayRef< SourceLocation > identifierLocs, SourceLocation rAngleLoc, SourceLocation &typeArgsLAngleLoc, SmallVectorImpl< ParsedType > &typeArgs, SourceLocation &typeArgsRAngleLoc, SourceLocation &protocolLAngleLoc, SmallVectorImpl< Decl * > &protocols, SourceLocation &protocolRAngleLoc, bool warnOnIncompleteProtocols)
Given a list of identifiers (and their locations), resolve the names to either Objective-C protocol q...
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
TypeResult actOnObjCProtocolQualifierType(SourceLocation lAngleLoc, ArrayRef< Decl * > protocols, ArrayRef< SourceLocation > protocolLocs, SourceLocation rAngleLoc)
Build a an Objective-C protocol-qualified 'id' type where no base type was specified.
ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, SourceLocation EncodeLoc, SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc)
void CodeCompleteObjCMethodDecl(Scope *S, std::optional< bool > IsInstanceMethod, ParsedType ReturnType)
ModuleImportState
An enumeration to represent the transition of states in parsing module fragments and imports.
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, bool IsParameter)
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
void CodeCompleteObjCPropertyGetter(Scope *S)
void CodeCompleteObjCAtStatement(Scope *S)
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLocPair > IdentList, const ParsedAttributesView &attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
void CodeCompleteObjCInterfaceDecl(Scope *S)
ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number)
BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the numeric literal expression.
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Decl * ActOnObjCExceptionDecl(Scope *S, Declarator &D)
@ ObjCSuperMessage
The message is sent to 'super'.
@ ObjCClassMessage
The message is a class message, and the identifier is a type name.
@ ObjCInstanceMessage
The message is an instance message.
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitWidth, tok::ObjCKeywordKind visibility)
ActOnIvar - Each ivar field of an objective-c class is passed into this in order to create an IvarDec...
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
bool isSimpleTypeSpecifier(tok::TokenKind Kind) const
Determine whether the token kind starts a simple-type-specifier.
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, ArrayRef< IdentifierLocPair > ProtocolId, SmallVectorImpl< Decl * > &Protocols)
FindProtocolDeclaration - This routine looks up protocols and issues an error if they are not declare...
ObjCContainerKind getObjCContainerKind() const
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ObjCCategoryImplDecl * ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *CatName, SourceLocation CatLoc, const ParsedAttributesView &AttrList)
ActOnStartCategoryImplementation - Perform semantic checks on the category implementation declaration...
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
ExprResult ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors)
ParseObjCSelectorExpression - Build selector expression for @selector.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getBegin() const
void setEnd(SourceLocation e)
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setLength(unsigned Len)
void setKind(tok::TokenKind K)
tok::ObjCKeywordKind getObjCKeywordID() const
Return the ObjC keyword kind.
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)) {....
tok::TokenKind getKind() const
void setEofData(const void *D)
void setLocation(SourceLocation L)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
const void * getEofData() const
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
void startToken()
Reset all flags to cleared.
The base class of the type hierarchy.
bool isObjCObjectOrInterfaceType() const
bool acceptsObjCTypeParams() const
Determines if this is an ObjC interface type that may accept type parameters.
Defines the clang::TargetInfo interface.
@ kind_nullability
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
DirectiveKind
Represents the kind of preprocessor directive or a module declaration that is tracked by the scanner ...
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
@ Property
The type of a property.
@ Result
The result type of a method or function.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
@ Invariant
The parameter is invariant: must match exactly.
@ Contravariant
The parameter is contravariant, e.g., X<T> is a subtype of X when the type parameter is covariant and...
@ Covariant
The parameter is covariant, e.g., X<T> is a subtype of X when the type parameter is covariant and T i...
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
An element in an Objective-C dictionary literal.
ParsedAttributesView ArgAttrs
ArgAttrs - Attribute list for this argument.