26#include "llvm/ADT/SmallVector.h"
27#include "llvm/ADT/StringExtras.h"
34 if (Tok.
is(tok::kw___attribute)) {
35 if (Kind == tok::objc_interface || Kind == tok::objc_protocol)
36 Diag(Tok, diag::err_objc_postfix_attribute_hint)
37 << (
Kind == tok::objc_protocol);
39 Diag(Tok, diag::err_objc_postfix_attribute);
40 ParseGNUAttributes(attrs);
59 if (Tok.
is(tok::code_completion)) {
66 case tok::objc_interface:
67 case tok::objc_protocol:
68 case tok::objc_implementation:
71 for (
const auto &
Attr : DeclAttrs) {
77 Decl *SingleDecl =
nullptr;
80 return ParseObjCAtClassDeclaration(AtLoc);
81 case tok::objc_interface:
82 SingleDecl = ParseObjCAtInterfaceDeclaration(AtLoc, DeclAttrs);
84 case tok::objc_protocol:
85 return ParseObjCAtProtocolDeclaration(AtLoc, DeclAttrs);
86 case tok::objc_implementation:
87 return ParseObjCAtImplementationDeclaration(AtLoc, DeclAttrs);
89 return ParseObjCAtEndDeclaration(AtLoc);
90 case tok::objc_compatibility_alias:
91 SingleDecl = ParseObjCAtAliasDeclaration(AtLoc);
93 case tok::objc_synthesize:
94 SingleDecl = ParseObjCPropertySynthesize(AtLoc);
96 case tok::objc_dynamic:
97 SingleDecl = ParseObjCPropertyDynamic(AtLoc);
99 case tok::objc_import:
102 SingleDecl = ParseModuleImport(AtLoc, IS);
105 Diag(AtLoc, diag::err_atimport);
109 Diag(AtLoc, diag::err_unexpected_at);
111 SingleDecl =
nullptr;
125 : Actions(Actions), S(S), Params(nullptr) {}
158 MaybeSkipAttributes(tok::objc_class);
159 if (Tok.
is(tok::code_completion)) {
164 if (expectIdentifier()) {
174 if (Tok.
is(tok::less))
175 TypeParams = parseObjCTypeParamList();
176 ClassTypeParams.push_back(TypeParams);
182 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"@class"))
186 atLoc, ClassNames.data(), ClassLocs.data(), ClassTypeParams,
197 if (CurParsedObjCImpl) {
198 CurParsedObjCImpl->finish(AtLoc);
202 Diag(AtLoc, diag::err_objc_missing_end)
240 "ParseObjCAtInterfaceDeclaration(): Expected @interface");
241 CheckNestedObjCContexts(AtLoc);
245 if (Tok.
is(tok::code_completion)) {
251 MaybeSkipAttributes(tok::objc_interface);
253 if (expectIdentifier())
266 ObjCTypeParamListScope typeParamScope(Actions,
getCurScope());
267 if (Tok.
is(tok::less))
268 typeParameterList = parseObjCTypeParamListOrProtocolRefs(
269 typeParamScope, LAngleLoc, ProtocolIdents, EndProtoLoc);
271 if (Tok.
is(tok::l_paren) &&
272 !isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
279 if (Tok.
is(tok::code_completion)) {
287 if (Tok.
is(tok::identifier)) {
292 Diag(Tok, diag::err_expected)
298 if (
T.getCloseLocation().isInvalid())
302 assert(LAngleLoc.
isInvalid() &&
"Cannot have already parsed protocols");
305 if (Tok.
is(tok::less) &&
306 ParseObjCProtocolReferences(ProtocolRefs, ProtocolLocs,
true,
true,
307 LAngleLoc, EndProtoLoc,
312 AtLoc, nameId, nameLoc, typeParameterList, categoryId, categoryLoc,
313 ProtocolRefs.data(), ProtocolRefs.size(), ProtocolLocs.data(),
316 if (Tok.
is(tok::l_brace))
317 ParseObjCClassInstanceVariables(CategoryType, tok::objc_private, AtLoc);
319 ParseObjCInterfaceDeclList(tok::objc_not_keyword, CategoryType);
331 if (Tok.
is(tok::colon)) {
335 if (Tok.
is(tok::code_completion)) {
342 if (expectIdentifier())
348 if (Tok.
is(tok::less)) {
349 parseObjCTypeArgsOrProtocolQualifiers(
350 nullptr, typeArgsLAngleLoc, typeArgs, typeArgsRAngleLoc, LAngleLoc,
351 protocols, protocolLocs, EndProtoLoc,
354 if (Tok.
is(tok::eof))
361 if (!ProtocolIdents.empty()) {
364 for (
const auto &pair : ProtocolIdents) {
365 protocolLocs.push_back(pair.second);
369 ProtocolIdents, protocols);
371 }
else if (protocols.empty() && Tok.
is(tok::less) &&
372 ParseObjCProtocolReferences(protocols, protocolLocs,
true,
true,
373 LAngleLoc, EndProtoLoc,
378 if (Tok.
isNot(tok::less))
380 superClassId, superClassLoc);
384 getCurScope(), AtLoc, nameId, nameLoc, typeParameterList, superClassId,
385 superClassLoc, typeArgs,
386 SourceRange(typeArgsLAngleLoc, typeArgsRAngleLoc), protocols.data(),
387 protocols.size(), protocolLocs.data(), EndProtoLoc, attrs, &SkipBody);
389 if (Tok.
is(tok::l_brace))
390 ParseObjCClassInstanceVariables(ClsType, tok::objc_protected, AtLoc);
392 ParseObjCInterfaceDeclList(tok::objc_interface, ClsType);
395 auto *PreviousDef = cast<ObjCInterfaceDecl>(SkipBody.
Previous);
401 DiagsEmitter.diagnoseMismatch(PreviousDef, ClsType);
415 bool &addedToDeclSpec) {
418 return Pool.create(
P.getNullabilityKeyword(nullability),
420 nullptr, 0, ParsedAttr::Form::ContextSensitiveKeyword());
423 if (
D.getNumTypeObjects() > 0) {
426 getNullabilityAttr(
D.getAttributePool()));
427 }
else if (!addedToDeclSpec) {
430 D.getMutableDeclSpec().getAttributes().addAtEnd(
431 getNullabilityAttr(
D.getMutableDeclSpec().getAttributes().getPool()));
432 addedToDeclSpec =
true;
464 assert(Tok.
is(tok::less) &&
"Not at the beginning of a type parameter list");
472 auto makeProtocolIdentsIntoTypeParameters = [&]() {
474 for (
const auto &pair : protocolIdents) {
479 typeParams.push_back(typeParam.
get());
482 protocolIdents.clear();
483 mayBeProtocolList =
false;
486 bool invalid =
false;
493 if (Tok.
is(tok::kw___covariant) || Tok.
is(tok::kw___contravariant)) {
494 variance = Tok.
is(tok::kw___covariant)
501 if (mayBeProtocolList) {
504 makeProtocolIdentsIntoTypeParameters();
509 if (!Tok.
is(tok::identifier)) {
511 if (Tok.
is(tok::code_completion)) {
522 Diag(Tok, diag::err_objc_expected_type_parameter);
536 if (mayBeProtocolList) {
539 makeProtocolIdentsIntoTypeParameters();
546 }
else if (mayBeProtocolList) {
549 protocolIdents.push_back(std::make_pair(paramName, paramLoc));
555 getCurScope(), variance, varianceLoc, typeParams.size(), paramName,
556 paramLoc, colonLoc, boundType.
isUsable() ? boundType.
get() :
nullptr);
558 typeParams.push_back(typeParam.
get());
564 if (Tok.
is(tok::greater))
566 }
else if (ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc,
569 SkipUntil({tok::greater, tok::greaterequal, tok::at, tok::minus,
570 tok::minus, tok::plus, tok::colon, tok::l_paren, tok::l_brace,
571 tok::comma, tok::semi },
573 if (Tok.
is(tok::greater))
577 if (mayBeProtocolList) {
582 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_paren)) {
591 makeProtocolIdentsIntoTypeParameters();
603 return invalid ? nullptr : list;
613 return parseObjCTypeParamListOrProtocolRefs(
Scope, lAngleLoc, protocolIdents,
619 switch (DirectiveKind) {
620 case tok::objc_class:
621 case tok::objc_compatibility_alias:
622 case tok::objc_interface:
623 case tok::objc_implementation:
624 case tok::objc_protocol:
653 if (Tok.
isOneOf(tok::minus, tok::plus)) {
654 if (
Decl *methodPrototype =
655 ParseObjCMethodPrototype(MethodImplKind,
false))
656 allMethods.push_back(methodPrototype);
659 if (ExpectAndConsumeSemi(diag::err_expected_semi_after_method_proto)) {
662 if (Tok.
is(tok::semi))
667 if (Tok.
is(tok::l_paren)) {
668 Diag(Tok, diag::err_expected_minus_or_plus);
671 MethodImplKind,
false);
675 if (Tok.
is(tok::semi)) {
687 if (Tok.
is(tok::code_completion)) {
697 if (Tok.
isNot(tok::at)) {
701 if (Tok.
is(tok::r_brace))
710 if (Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
714 DeclEnd, EmptyDeclAttrs,
715 EmptyDeclSpecAttrs));
719 allTUVariables.push_back(ParseDeclarationOrFunctionDefinition(
720 EmptyDeclAttrs, EmptyDeclSpecAttrs));
727 if (NextTok.is(tok::code_completion)) {
734 if (DirectiveKind == tok::objc_end) {
739 }
else if (DirectiveKind == tok::objc_not_keyword) {
740 Diag(NextTok, diag::err_objc_unknown_at);
754 switch (DirectiveKind) {
760 Diag(AtLoc, diag::err_objc_illegal_interface_qual);
765 case tok::objc_required:
766 case tok::objc_optional:
768 if (contextKey != tok::objc_protocol)
769 Diag(AtLoc, diag::err_objc_directive_only_in_protocol);
774 case tok::objc_property:
778 if (Tok.
is(tok::l_paren)) {
780 ParseObjCPropertyAttribute(OCDS);
783 bool addedToDeclSpec =
false;
785 if (FD.D.getIdentifier() ==
nullptr) {
786 Diag(AtLoc, diag::err_objc_property_requires_field_name)
787 << FD.D.getSourceRange();
790 if (FD.BitfieldSize) {
791 Diag(AtLoc, diag::err_objc_property_bitfield)
792 << FD.D.getSourceRange();
816 FD.D.getIdentifier());
818 getCurScope(), AtLoc, LParenLoc, FD, OCDS, GetterSel, SetterSel,
827 ParseStructDeclaration(DS, ObjCPropertyCallback);
829 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
840 Diag(Tok, diag::err_objc_missing_end)
859 P.Diag(nullabilityLoc, diag::warn_nullability_duplicate)
865 P.Diag(nullabilityLoc, diag::err_nullability_conflicting)
897void Parser::ParseObjCPropertyAttribute(
ObjCDeclSpec &DS) {
898 assert(Tok.
getKind() == tok::l_paren);
903 if (Tok.
is(tok::code_completion)) {
918 if (II->
isStr(
"readonly"))
920 else if (II->
isStr(
"assign"))
922 else if (II->
isStr(
"unsafe_unretained"))
924 else if (II->
isStr(
"readwrite"))
926 else if (II->
isStr(
"retain"))
928 else if (II->
isStr(
"strong"))
930 else if (II->
isStr(
"copy"))
932 else if (II->
isStr(
"nonatomic"))
934 else if (II->
isStr(
"atomic"))
936 else if (II->
isStr(
"weak"))
938 else if (II->
isStr(
"getter") || II->
isStr(
"setter")) {
942 unsigned DiagID = IsSetter ? diag::err_objc_expected_equal_for_setter :
943 diag::err_objc_expected_equal_for_getter;
945 if (ExpectAndConsume(tok::equal, DiagID)) {
950 if (Tok.
is(tok::code_completion)) {
965 Diag(Tok, diag::err_objc_expected_selector_for_getter_setter)
975 if (ExpectAndConsume(tok::colon,
976 diag::err_expected_colon_after_setter_name)) {
984 }
else if (II->
isStr(
"nonnull")) {
991 }
else if (II->
isStr(
"nullable")) {
998 }
else if (II->
isStr(
"null_unspecified")) {
1005 }
else if (II->
isStr(
"null_resettable")) {
1015 }
else if (II->
isStr(
"class")) {
1017 }
else if (II->
isStr(
"direct")) {
1020 Diag(AttrName, diag::err_objc_expected_property_attr) << II;
1025 if (Tok.
isNot(tok::comma))
1045 bool MethodDefinition) {
1046 assert(Tok.
isOneOf(tok::minus, tok::plus) &&
"expected +/-");
1050 Decl *MDecl = ParseObjCMethodDecl(mLoc, methodType, MethodImplKind,
1080 case tok::exclaimequal:
1082 case tok::pipeequal:
1084 case tok::caretequal: {
1095 case tok::identifier:
1105 case tok::kw_const_cast:
1106 case tok::kw_continue:
1107 case tok::kw_default:
1108 case tok::kw_delete:
1110 case tok::kw_double:
1111 case tok::kw_dynamic_cast:
1114 case tok::kw_explicit:
1115 case tok::kw_export:
1116 case tok::kw_extern:
1120 case tok::kw_friend:
1123 case tok::kw_inline:
1126 case tok::kw_mutable:
1127 case tok::kw_namespace:
1129 case tok::kw_operator:
1130 case tok::kw_private:
1131 case tok::kw_protected:
1132 case tok::kw_public:
1133 case tok::kw_register:
1134 case tok::kw_reinterpret_cast:
1135 case tok::kw_restrict:
1136 case tok::kw_return:
1138 case tok::kw_signed:
1139 case tok::kw_sizeof:
1140 case tok::kw_static:
1141 case tok::kw_static_cast:
1142 case tok::kw_struct:
1143 case tok::kw_switch:
1144 case tok::kw_template:
1149 case tok::kw_typedef:
1150 case tok::kw_typeid:
1151 case tok::kw_typename:
1152 case tok::kw_typeof:
1154 case tok::kw_unsigned:
1156 case tok::kw_virtual:
1158 case tok::kw_volatile:
1159 case tok::kw_wchar_t:
1162 case tok::kw__Complex:
1163 case tok::kw___alignof:
1164 case tok::kw___auto_type:
1173bool Parser::isTokIdentifier_in()
const {
1200void Parser::ParseObjCTypeQualifierList(
ObjCDeclSpec &DS,
1206 if (Tok.
is(tok::code_completion)) {
1213 if (Tok.
isNot(tok::identifier))
1217 for (
unsigned i = 0; i != objc_NumQuals; ++i) {
1218 if (II != ObjCTypeQuals[i] ||
1226 default: llvm_unreachable(
"Unknown decl qualifier");
1244 case objc_null_unspecified:
1269 for (
auto &AL : llvm::reverse(from)) {
1270 if (!AL.isUsedAsTypeAttr()) {
1283 assert(
D.getDeclarationAttributes().empty());
1292 for (
unsigned i = 0, e =
D.getNumTypeObjects(); i != e; ++i)
1305 assert((paramAttrs !=
nullptr) ==
1308 assert(Tok.
is(tok::l_paren) &&
"expected (");
1316 ParseObjCTypeQualifierList(DS, context);
1320 if (isTypeSpecifierQualifier() || isObjCInstancetype()) {
1323 declSpec.setObjCQualifiers(&DS);
1324 DeclSpecContext dsContext = DeclSpecContext::DSC_normal;
1326 dsContext = DeclSpecContext::DSC_objc_method_result;
1327 ParseSpecifierQualifierList(declSpec,
AS_none, dsContext);
1329 ParseDeclarator(declarator);
1332 if (!declarator.isInvalidType()) {
1334 bool addedToDeclSpec =
false;
1342 if (!
type.isInvalid())
1352 if (Tok.
is(tok::r_paren))
1356 Diag(Tok, diag::err_expected_type);
1397 bool MethodDefinition) {
1400 if (Tok.
is(tok::code_completion)) {
1403 mType == tok::minus,
1411 if (Tok.
is(tok::l_paren))
1417 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1420 if (Tok.
is(tok::code_completion)) {
1432 if (!SelIdent && Tok.
isNot(tok::colon)) {
1433 Diag(Tok, diag::err_expected_selector_for_method)
1441 if (Tok.
isNot(tok::colon)) {
1443 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1449 selLoc, Sel,
nullptr, CParamInfo.data(), CParamInfo.size(), methodAttrs,
1450 MethodImplKind,
false, MethodDefinition);
1467 if (ExpectAndConsume(tok::colon))
1470 ArgInfo.
Type =
nullptr;
1471 if (Tok.
is(tok::l_paren))
1472 ArgInfo.
Type = ParseObjCTypeName(
1477 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1482 if (Tok.
is(tok::code_completion)) {
1484 KeyIdents.push_back(SelIdent);
1487 true, ReturnType, KeyIdents);
1491 if (expectIdentifier())
1498 ArgInfos.push_back(ArgInfo);
1499 KeyIdents.push_back(SelIdent);
1500 KeyLocs.push_back(selLoc);
1503 allParamAttrs.takeAllFrom(paramAttrs.
getPool());
1506 if (Tok.
is(tok::code_completion)) {
1510 false, ReturnType, KeyIdents);
1515 SelIdent = ParseObjCSelectorPiece(selLoc);
1516 if (!SelIdent && Tok.
isNot(tok::colon))
1521 Diag(ArgInfo.
NameLoc, diag::warn_missing_selector_name) << ArgInfo.
Name;
1522 Diag(ArgInfo.
NameLoc, diag::note_missing_selector_name) << ArgInfo.
Name;
1523 Diag(ColonLoc, diag::note_force_empty_selector_name) << ArgInfo.
Name;
1529 bool isVariadic =
false;
1530 bool cStyleParamWarned =
false;
1532 while (Tok.
is(tok::comma)) {
1534 if (Tok.
is(tok::ellipsis)) {
1539 if (!cStyleParamWarned) {
1540 Diag(Tok, diag::warn_cstyle_param);
1541 cStyleParamWarned =
true;
1544 ParsedTemplateInfo TemplateInfo;
1545 ParseDeclarationSpecifiers(DS, TemplateInfo);
1549 ParseDeclarator(ParmDecl);
1553 ParmDecl.getIdentifierLoc(),
1560 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1563 if (KeyIdents.size() == 0)
1570 Sel, &ArgInfos[0], CParamInfo.data(), CParamInfo.size(), methodAttrs,
1571 MethodImplKind, isVariadic, MethodDefinition);
1583 bool WarnOnDeclarations,
bool ForObjCContainer,
1585 bool consumeLastToken) {
1586 assert(Tok.
is(tok::less) &&
"expected <");
1593 if (Tok.
is(tok::code_completion)) {
1600 if (expectIdentifier()) {
1614 if (ParseGreaterThanInTemplateList(LAngleLoc, EndLoc, consumeLastToken,
1620 ProtocolIdents, Protocols);
1625 assert(Tok.
is(tok::less) &&
"Protocol qualifiers start with '<'");
1626 assert(
getLangOpts().
ObjC &&
"Protocol qualifiers only exist in Objective-C");
1631 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
false,
false,
1632 lAngleLoc, rAngleLoc,
1635 lAngleLoc, protocols, protocolLocs, rAngleLoc);
1637 Diag(lAngleLoc, diag::warn_objc_protocol_qualifier_missing_id)
1650void Parser::parseObjCTypeArgsOrProtocolQualifiers(
1659 bool consumeLastToken,
1660 bool warnOnIncompleteProtocols) {
1661 assert(Tok.
is(tok::less) &&
"Not at the start of type args or protocols");
1666 bool allSingleIdentifiers =
true;
1674 if (Tok.
is(tok::identifier) &&
1683 if (Tok.
is(tok::code_completion)) {
1686 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1688 identifierLocs[i]));
1698 identifierLocPairs);
1703 allSingleIdentifiers =
false;
1709 if (allSingleIdentifiers) {
1712 (void)ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc, consumeLastToken,
1717 getCurScope(), baseType, lAngleLoc, identifiers, identifierLocs,
1718 rAngleLoc, typeArgsLAngleLoc, typeArgs, typeArgsRAngleLoc,
1719 protocolLAngleLoc, protocols, protocolRAngleLoc,
1720 warnOnIncompleteProtocols);
1730 bool invalid =
false;
1731 IdentifierInfo *foundProtocolId =
nullptr, *foundValidTypeId =
nullptr;
1736 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1741 const char *prevSpec =
nullptr;
1743 DS.SetTypeSpecType(
TST_typename, identifierLocs[i], prevSpec, diagID,
1751 typeArgs.push_back(fullTypeArg.
get());
1752 if (!foundValidTypeId) {
1753 foundValidTypeId = identifiers[i];
1754 foundValidTypeSrcLoc = identifierLocs[i];
1758 unknownTypeArgs.push_back(identifiers[i]);
1759 unknownTypeArgsLoc.push_back(identifierLocs[i]);
1764 unknownTypeArgs.push_back(identifiers[i]);
1765 unknownTypeArgsLoc.push_back(identifierLocs[i]);
1766 }
else if (!foundProtocolId) {
1767 foundProtocolId = identifiers[i];
1768 foundProtocolSrcLoc = identifierLocs[i];
1775 Token CurTypeTok = Tok;
1786 typeArgs.push_back(typeArg.
get());
1787 if (!foundValidTypeId) {
1797 if (foundProtocolId && foundValidTypeId)
1799 foundProtocolId, foundProtocolSrcLoc, foundValidTypeId,
1800 foundValidTypeSrcLoc);
1804 if (unknownTypeArgs.size())
1805 for (
unsigned i = 0, e = unknownTypeArgsLoc.size(); i < e; ++i)
1811 (void)ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc, consumeLastToken,
1820 typeArgsLAngleLoc = lAngleLoc;
1821 typeArgsRAngleLoc = rAngleLoc;
1824void Parser::parseObjCTypeArgsAndProtocolQualifiers(
1833 bool consumeLastToken) {
1834 assert(Tok.
is(tok::less));
1837 parseObjCTypeArgsOrProtocolQualifiers(baseType,
1847 if (Tok.
is(tok::eof))
1853 if ((consumeLastToken && Tok.
is(tok::less)) ||
1854 (!consumeLastToken &&
NextToken().is(tok::less))) {
1857 if (!consumeLastToken)
1860 if (!protocols.empty()) {
1862 if (!consumeLastToken)
1864 Diag(Tok, diag::err_objc_type_args_after_protocols)
1865 <<
SourceRange(protocolLAngleLoc, protocolRAngleLoc);
1866 SkipUntil(tok::greater, tok::greatergreater, skipFlags);
1868 ParseObjCProtocolReferences(protocols, protocolLocs,
1871 protocolLAngleLoc, protocolRAngleLoc,
1877TypeResult Parser::parseObjCTypeArgsAndProtocolQualifiers(
1880 bool consumeLastToken,
1882 assert(Tok.
is(tok::less));
1892 parseObjCTypeArgsAndProtocolQualifiers(
type, typeArgsLAngleLoc, typeArgs,
1893 typeArgsRAngleLoc, protocolLAngleLoc,
1894 protocols, protocolLocs,
1895 protocolRAngleLoc, consumeLastToken);
1897 if (Tok.
is(tok::eof))
1901 if (consumeLastToken)
1902 endLoc = PrevTokLocation;
1907 getCurScope(), loc,
type, typeArgsLAngleLoc, typeArgs, typeArgsRAngleLoc,
1908 protocolLAngleLoc, protocols, protocolLocs, protocolRAngleLoc);
1911void Parser::HelperActionsForIvarDeclarations(
1914 bool RBraceMissing) {
1919 "Ivars should have interfaceDecl as their decl context");
1924 T.getOpenLocation(),
T.getCloseLocation(),
1952 assert(Tok.
is(tok::l_brace) &&
"expected {");
1960 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
1964 if (Tok.
is(tok::semi)) {
1965 ConsumeExtraSemi(InstanceVariableList);
1971 if (Tok.
is(tok::code_completion)) {
1978 case tok::objc_private:
1979 case tok::objc_public:
1980 case tok::objc_protected:
1981 case tok::objc_package:
1987 Diag(Tok, diag::err_objc_unexpected_atend);
1992 HelperActionsForIvarDeclarations(interfaceDecl, atLoc,
1993 T, AllIvarDecls,
true);
1997 Diag(Tok, diag::err_objc_illegal_visibility_spec);
2002 if (Tok.
is(tok::code_completion)) {
2012 if (Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2014 ParseStaticAssertDeclaration(DeclEnd);
2020 "Ivar should have interfaceDecl as its decl context");
2022 FD.D.setObjCIvar(
true);
2024 getCurScope(), FD.D.getDeclSpec().getSourceRange().getBegin(), FD.D,
2025 FD.BitfieldSize, visibility);
2027 AllIvarDecls.push_back(Field);
2034 ParseStructDeclaration(DS, ObjCIvarCallback);
2036 if (Tok.
is(tok::semi)) {
2039 Diag(Tok, diag::err_expected_semi_decl_list);
2044 HelperActionsForIvarDeclarations(interfaceDecl, atLoc,
2045 T, AllIvarDecls,
false);
2068 "ParseObjCAtProtocolDeclaration(): Expected @protocol");
2071 if (Tok.
is(tok::code_completion)) {
2077 MaybeSkipAttributes(tok::objc_protocol);
2079 if (expectIdentifier())
2091 CheckNestedObjCContexts(AtLoc);
2093 if (Tok.
is(tok::comma)) {
2095 ProtocolRefs.push_back(std::make_pair(protocolName, nameLoc));
2100 if (expectIdentifier()) {
2108 if (Tok.
isNot(tok::comma))
2112 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"@protocol"))
2124 if (Tok.
is(tok::less) &&
2125 ParseObjCProtocolReferences(ProtocolRefs, ProtocolLocs,
false,
true,
2126 LAngleLoc, EndProtoLoc,
2132 AtLoc, protocolName, nameLoc, ProtocolRefs.data(), ProtocolRefs.size(),
2133 ProtocolLocs.data(), EndProtoLoc, attrs, &SkipBody);
2135 ParseObjCInterfaceDeclList(tok::objc_protocol, ProtoType);
2137 auto *PreviousDef = cast<ObjCProtocolDecl>(SkipBody.
Previous);
2140 PreviousDef->getDefinition());
2144 DiagsEmitter.diagnoseMismatch(PreviousDef, ProtoType);
2161Parser::ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc,
2164 "ParseObjCAtImplementationDeclaration(): Expected @implementation");
2165 CheckNestedObjCContexts(AtLoc);
2169 if (Tok.
is(tok::code_completion)) {
2175 MaybeSkipAttributes(tok::objc_implementation);
2177 if (expectIdentifier())
2186 if (Tok.
is(tok::less)) {
2190 ObjCTypeParamListScope typeParamScope(Actions,
getCurScope());
2191 if (parseObjCTypeParamListOrProtocolRefs(typeParamScope, lAngleLoc,
2192 protocolIdents, rAngleLoc)) {
2193 Diag(diagLoc, diag::err_objc_parameterized_implementation)
2195 }
else if (lAngleLoc.
isValid()) {
2196 Diag(lAngleLoc, diag::err_unexpected_protocol_qualifier)
2201 if (Tok.
is(tok::l_paren)) {
2207 if (Tok.
is(tok::code_completion)) {
2214 if (Tok.
is(tok::identifier)) {
2218 Diag(Tok, diag::err_expected)
2222 if (Tok.
isNot(tok::r_paren)) {
2223 Diag(Tok, diag::err_expected) << tok::r_paren;
2227 rparenLoc = ConsumeParen();
2228 if (Tok.
is(tok::less)) {
2229 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2233 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
2236 protocolLAngleLoc, protocolRAngleLoc,
2240 AtLoc, nameId, nameLoc, categoryId, categoryLoc, Attrs);
2248 if (expectIdentifier())
2254 AtLoc, nameId, nameLoc, superClassId, superClassLoc, Attrs);
2256 if (Tok.
is(tok::l_brace))
2257 ParseObjCClassInstanceVariables(ObjCImpDecl, tok::objc_private, AtLoc);
2258 else if (Tok.
is(tok::less)) {
2259 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2264 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
2267 protocolLAngleLoc, protocolRAngleLoc,
2271 assert(ObjCImpDecl);
2276 ObjCImplParsingDataRAII ObjCImplParsing(*
this, ObjCImpDecl);
2277 while (!ObjCImplParsing.isFinished() && !isEofOrEom()) {
2279 MaybeParseCXX11Attributes(DeclAttrs);
2282 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs)) {
2284 DeclsInGroup.append(DG.
begin(), DG.
end());
2294Parser::ParseObjCAtEndDeclaration(
SourceRange atEnd) {
2296 "ParseObjCAtEndDeclaration(): Expected @end");
2298 if (CurParsedObjCImpl)
2299 CurParsedObjCImpl->finish(atEnd);
2302 Diag(atEnd.
getBegin(), diag::err_expected_objc_container);
2306Parser::ObjCImplParsingDataRAII::~ObjCImplParsingDataRAII() {
2308 finish(
P.Tok.getLocation());
2309 if (
P.isEofOrEom()) {
2310 P.Diag(
P.Tok, diag::err_objc_missing_end)
2312 P.Diag(Dcl->getBeginLoc(), diag::note_objc_container_start)
2316 P.CurParsedObjCImpl =
nullptr;
2317 assert(LateParsedObjCMethods.empty());
2320void Parser::ObjCImplParsingDataRAII::finish(
SourceRange AtEnd) {
2322 P.Actions.ObjC().DefaultSynthesizeProperties(
P.getCurScope(), Dcl,
2324 for (
size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
2325 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i],
2328 P.Actions.ObjC().ActOnAtEnd(
P.getCurScope(), AtEnd);
2331 for (
size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
2332 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i],
2336 for (LateParsedObjCMethodContainer::iterator
2337 I = LateParsedObjCMethods.begin(),
2338 E = LateParsedObjCMethods.end(); I !=
E; ++I)
2340 LateParsedObjCMethods.clear();
2350 "ParseObjCAtAliasDeclaration(): Expected @compatibility_alias");
2352 if (expectIdentifier())
2356 if (expectIdentifier())
2360 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@compatibility_alias");
2378 "ParseObjCPropertySynthesize(): Expected '@synthesize'");
2382 if (Tok.
is(tok::code_completion)) {
2389 if (Tok.
isNot(tok::identifier)) {
2390 Diag(Tok, diag::err_synthesized_property_name);
2401 if (Tok.
is(tok::code_completion)) {
2408 if (expectIdentifier())
2414 getCurScope(), atLoc, propertyLoc,
true, propertyId, propertyIvar,
2416 if (Tok.
isNot(tok::comma))
2420 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@synthesize");
2433 "ParseObjCPropertyDynamic(): Expected '@dynamic'");
2436 bool isClassProperty =
false;
2437 if (Tok.
is(tok::l_paren)) {
2442 Diag(Tok, diag::err_objc_expected_property_attr) << II;
2446 if (II->
isStr(
"class")) {
2447 isClassProperty =
true;
2448 if (Tok.
isNot(tok::r_paren)) {
2449 Diag(Tok, diag::err_expected) << tok::r_paren;
2454 Diag(AttrName, diag::err_objc_expected_property_attr) << II;
2461 if (Tok.
is(tok::code_completion)) {
2468 if (expectIdentifier()) {
2476 getCurScope(), atLoc, propertyLoc,
false, propertyId,
nullptr,
2481 if (Tok.
isNot(tok::comma))
2485 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@dynamic");
2495 if (Tok.
isNot(tok::semi)) {
2503 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@throw");
2513 if (Tok.
isNot(tok::l_paren)) {
2514 Diag(Tok, diag::err_expected_lparen_after) <<
"@synchronized";
2522 if (Tok.
is(tok::r_paren)) {
2525 if (!operand.isInvalid())
2526 Diag(Tok, diag::err_expected) << tok::r_paren;
2533 if (Tok.
isNot(tok::l_brace)) {
2534 if (!operand.isInvalid())
2535 Diag(Tok, diag::err_expected) << tok::l_brace;
2540 if (!operand.isInvalid())
2546 StmtResult body(ParseCompoundStatementBody());
2551 if (operand.isInvalid())
2554 if (body.isInvalid())
2573 bool catch_or_finally_seen =
false;
2576 if (Tok.
isNot(tok::l_brace)) {
2577 Diag(Tok, diag::err_expected) << tok::l_brace;
2583 StmtResult TryBody(ParseCompoundStatementBody());
2585 if (TryBody.isInvalid())
2588 while (Tok.
is(tok::at)) {
2592 Token AfterAt = GetLookAheadToken(1);
2599 Decl *FirstPart =
nullptr;
2601 if (Tok.
is(tok::l_paren)) {
2606 if (Tok.
isNot(tok::ellipsis)) {
2608 ParsedTemplateInfo TemplateInfo;
2609 ParseDeclarationSpecifiers(DS, TemplateInfo);
2612 ParseDeclarator(ParmDecl);
2623 if (Tok.
is(tok::r_paren))
2624 RParenLoc = ConsumeParen();
2629 if (Tok.
is(tok::l_brace))
2630 CatchBody = ParseCompoundStatementBody();
2632 Diag(Tok, diag::err_expected) << tok::l_brace;
2633 if (CatchBody.isInvalid())
2637 AtCatchFinallyLoc, RParenLoc, FirstPart, CatchBody.get());
2639 CatchStmts.push_back(Catch.
get());
2642 Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after)
2646 catch_or_finally_seen =
true;
2648 assert(Tok.
isObjCAtKeyword(tok::objc_finally) &&
"Lookahead confused?");
2650 ParseScope FinallyScope(
this,
2653 bool ShouldCapture =
2660 if (Tok.
is(tok::l_brace))
2661 FinallyBody = ParseCompoundStatementBody();
2663 Diag(Tok, diag::err_expected) << tok::l_brace;
2665 if (FinallyBody.isInvalid()) {
2669 }
else if (ShouldCapture) {
2675 catch_or_finally_seen =
true;
2679 if (!catch_or_finally_seen) {
2680 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 getCurScope(), Name, NameLoc, Name == Ident_super,
3133 NextToken().is(tok::period), ReceiverType)) {
3135 return ParseObjCMessageExpressionBody(LBracLoc,
ConsumeToken(),
nullptr,
3139 if (!ReceiverType) {
3147 if (Tok.
is(tok::less)) {
3150 = parseObjCTypeArgsAndProtocolQualifiers(NameLoc, ReceiverType,
3158 ReceiverType = NewReceiverType.
get();
3161 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
3162 ReceiverType,
nullptr);
3177 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
nullptr,
3223 Expr *ReceiverExpr) {
3226 if (Tok.
is(tok::code_completion)) {
3231 else if (ReceiverType)
3233 getCurScope(), ReceiverType, std::nullopt,
false);
3236 getCurScope(), ReceiverExpr, std::nullopt,
false);
3246 ExprVector KeyExprs;
3248 if (Tok.
is(tok::colon)) {
3251 KeyIdents.push_back(selIdent);
3252 KeyLocs.push_back(
Loc);
3254 if (ExpectAndConsume(tok::colon)) {
3264 if (Tok.
is(tok::code_completion)) {
3270 else if (ReceiverType)
3284 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3285 Expr = ParseBraceInitializer();
3299 KeyExprs.push_back(Res.
get());
3302 if (Tok.
is(tok::code_completion)) {
3308 else if (ReceiverType)
3320 selIdent = ParseObjCSelectorPiece(
Loc);
3321 if (!selIdent && Tok.
isNot(tok::colon))
3326 while (Tok.
is(tok::comma)) {
3330 if (Tok.
is(tok::colon))
3333 if (Tok.
is(tok::colon)) {
3334 Diag(commaLoc, diag::note_extra_comma_message_arg) <<
3345 KeyExprs.push_back(Res.
get());
3347 }
else if (!selIdent) {
3348 Diag(Tok, diag::err_expected) << tok::identifier;
3357 if (Tok.
isNot(tok::r_square)) {
3358 Diag(Tok, diag::err_expected)
3359 << (Tok.
is(tok::identifier) ? tok::colon : tok::r_square);
3369 unsigned nKeys = KeyIdents.size();
3371 KeyIdents.push_back(selIdent);
3372 KeyLocs.push_back(
Loc);
3378 getCurScope(), SuperLoc, Sel, LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3379 else if (ReceiverType)
3381 LBracLoc, KeyLocs, RBracLoc,
3384 getCurScope(), ReceiverExpr, Sel, 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) <<
"@");
3464 if (
T.consumeClose())
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");
3609 AtLoc, EncLoc,
T.getOpenLocation(), Ty.
get(),
T.getCloseLocation());
3618 if (Tok.
isNot(tok::l_paren))
3619 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@protocol");
3624 if (expectIdentifier())
3633 protocolId, AtLoc, ProtoLoc,
T.getOpenLocation(), ProtoIdLoc,
3634 T.getCloseLocation());
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)) {
3689 SelIdent = ParseObjCSelectorPiece(
Loc);
3690 KeyIdents.push_back(SelIdent);
3691 if (!SelIdent && Tok.
isNot(tok::colon) && Tok.
isNot(tok::coloncolon))
3695 if (HasOptionalParen && Tok.
is(tok::r_paren))
3700 Sel, AtLoc, SelectorLoc,
T.getOpenLocation(),
T.getCloseLocation(),
3704void Parser::ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod) {
3706 Decl *MCDecl = LM.D;
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 ':'");
3747 if (Tok.
is(tok::kw_try))
3748 ParseFunctionTryBlock(MCDecl, BodyScope);
3750 if (Tok.
is(tok::colon))
3751 ParseConstructorInitializer(MCDecl);
3754 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.
This file declares facilities that support code completion.
This file declares semantic analysis for Objective-C.
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 { ....
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
Captures information about "declaration specifiers".
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.
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 getNullarySelector(const IdentifierInfo *ID)
Selector getSelector(unsigned NumArgs, const IdentifierInfo **IIV)
Can create any sort of selector.
Smart pointer class that efficiently represents Objective-C method names.
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
void CodeCompleteObjCClassForwardDecl(Scope *S)
void CodeCompleteObjCAtStatement(Scope *S)
void CodeCompleteObjCMessageReceiver(Scope *S)
void CodeCompleteObjCProtocolDecl(Scope *S)
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
@ PCC_Type
Code completion occurs where only a type is permitted.
@ PCC_ObjCImplementation
Code completion occurs within an Objective-C implementation or category implementation.
@ PCC_ObjCInterface
Code completion occurs within an Objective-C interface, protocol, or category.
@ PCC_ObjCInstanceVariableList
Code completion occurs within the list of instance variables in an Objective-C interface,...
void CodeCompleteObjCAtDirective(Scope *S)
void CodeCompleteObjCPropertySetter(Scope *S)
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCInterfaceDecl(Scope *S)
void CodeCompleteObjCAtExpression(Scope *S)
void CodeCompleteObjCPropertyDefinition(Scope *S)
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression)
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< const IdentifierInfo * > SelIdents)
void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCSelector(Scope *S, ArrayRef< const IdentifierInfo * > SelIdents)
void CodeCompleteObjCImplementationDecl(Scope *S)
void CodeCompleteObjCMethodDecl(Scope *S, std::optional< bool > IsInstanceMethod, ParsedType ReturnType)
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLocPair > Protocols)
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCAtVisibility(Scope *S)
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< const IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper=false)
void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, bool IsParameter)
void CodeCompleteObjCPropertyGetter(Scope *S)
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...
void ActOnStartOfObjCMethodDef(Scope *S, Decl *D)
ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible and user declared,...
ObjCMessageKind getObjCMessageKind(Scope *S, IdentifierInfo *Name, SourceLocation NameLoc, bool IsSuper, bool HasTrailingDot, ParsedType &ReceiverType)
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
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.
ExprResult ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors)
ParseObjCSelectorExpression - Build selector expression for @selector.
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 popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList)
ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number)
BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the numeric literal expression.
ObjCImplementationDecl * ActOnStartClassImplementation(SourceLocation AtClassImplLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, const IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc, const ParsedAttributesView &AttrList)
Decl * ActOnObjCExceptionDecl(Scope *S, Declarator &D)
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType typeBound)
ObjCContainerKind getObjCContainerKind() const
DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef< Decl * > Decls)
ObjCContainerDecl * getObjCDeclContext() const
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
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)
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
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.
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...
ObjCTypeParamList * actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef< Decl * > typeParams, SourceLocation rAngleLoc)
ObjCCategoryDecl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, const IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, SourceLocation EncodeLoc, SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc)
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...
Decl * ActOnProperty(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
ExprResult ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
ObjCCategoryImplDecl * ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, const IdentifierInfo *CatName, SourceLocation CatLoc, const ParsedAttributesView &AttrList)
ActOnStartCategoryImplementation - Perform semantic checks on the category implementation declaration...
ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, ArrayRef< Expr * > Strings)
ExprResult ActOnObjCBoolLiteral(SourceLocation AtLoc, SourceLocation ValueLoc, bool Value)
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 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...
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLocPair > IdentList, const ParsedAttributesView &attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Find the protocol with the given name, if any.
StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, Scope *CurScope)
ObjCProtocolDecl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl * > allMethods=std::nullopt, ArrayRef< DeclGroupPtrTy > allTUVars=std::nullopt)
ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolName, SourceLocation AtLoc, SourceLocation ProtoLoc, SourceLocation LParenLoc, SourceLocation ProtoIdLoc, SourceLocation RParenLoc)
ParseObjCProtocolExpression - Build protocol expression for @protocol.
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList * > TypeParamLists, unsigned NumElts)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
@ ObjCClassMessage
The message is a class message, and the identifier is a type name.
@ ObjCInstanceMessage
The message is an instance message.
@ ObjCSuperMessage
The message is sent to 'super'.
bool isObjCMethodDecl(Decl *D)
ExprResult ActOnInstanceMessage(Scope *S, Expr *Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId, SourceLocation ProtocolLoc, IdentifierInfo *TypeArgId, SourceLocation TypeArgLoc, bool SelectProtocolFirst=false)
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
void AddAnyMethodToGlobalPool(Decl *D)
AddAnyMethodToGlobalPool - Add any method, instance or factory to global pool.
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...
Records and restores the CurFPFeatures state on entry/exit of compound statements.
Sema - This implements semantic analysis and AST building for C.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
Unary Operators. 'Tok' is the token for the operator.
Decl * ActOnSkippedFunctionBody(Decl *Decl)
Decl * ActOnParamDeclarator(Scope *S, Declarator &D, SourceLocation ExplicitThisLoc={})
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
bool ActOnDuplicateODRHashDefinition(T *Duplicate, T *Previous)
Check ODR hashes for C/ObjC when merging types from modules.
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
void ActOnCapturedRegionError()
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
ASTContext & getASTContext() const
SemaCodeCompletion & CodeCompletion()
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)
StmtResult ActOnCapturedRegionEnd(Stmt *S)
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...
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
TypeResult ActOnTypeName(Declarator &D)
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
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.
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 ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
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.
bool isSimpleTypeSpecifier(const LangOptions &LangOpts) const
Determine whether the token kind starts a simple-type-specifier.
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.
The JSON file list parser is used to communicate input to InstallAPI.
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.
const FunctionProtoType * T
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.
An element in an Objective-C dictionary literal.
ParsedAttributesView ArgAttrs
ArgAttrs - Attribute list for this argument.