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(),
1563 for (
auto &ArgInfo : ArgInfos) {
1565 getCurScope(), ArgInfo, ObjCParamInfo.size(), MethodDefinition);
1566 ObjCParamInfo.push_back(Param);
1571 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1574 if (KeyIdents.size() == 0)
1581 Sel, ObjCParamInfo.data(), CParamInfo.data(), CParamInfo.size(),
1582 methodAttrs, MethodImplKind, isVariadic, MethodDefinition);
1594 bool WarnOnDeclarations,
bool ForObjCContainer,
1596 bool consumeLastToken) {
1597 assert(Tok.
is(tok::less) &&
"expected <");
1604 if (Tok.
is(tok::code_completion)) {
1611 if (expectIdentifier()) {
1625 if (ParseGreaterThanInTemplateList(LAngleLoc, EndLoc, consumeLastToken,
1631 ProtocolIdents, Protocols);
1636 assert(Tok.
is(tok::less) &&
"Protocol qualifiers start with '<'");
1637 assert(
getLangOpts().
ObjC &&
"Protocol qualifiers only exist in Objective-C");
1642 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
false,
false,
1643 lAngleLoc, rAngleLoc,
1646 lAngleLoc, protocols, protocolLocs, rAngleLoc);
1648 Diag(lAngleLoc, diag::warn_objc_protocol_qualifier_missing_id)
1661void Parser::parseObjCTypeArgsOrProtocolQualifiers(
1670 bool consumeLastToken,
1671 bool warnOnIncompleteProtocols) {
1672 assert(Tok.
is(tok::less) &&
"Not at the start of type args or protocols");
1677 bool allSingleIdentifiers =
true;
1685 if (Tok.
is(tok::identifier) &&
1694 if (Tok.
is(tok::code_completion)) {
1697 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1699 identifierLocs[i]));
1709 identifierLocPairs);
1714 allSingleIdentifiers =
false;
1720 if (allSingleIdentifiers) {
1723 (void)ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc, consumeLastToken,
1728 getCurScope(), baseType, lAngleLoc, identifiers, identifierLocs,
1729 rAngleLoc, typeArgsLAngleLoc, typeArgs, typeArgsRAngleLoc,
1730 protocolLAngleLoc, protocols, protocolRAngleLoc,
1731 warnOnIncompleteProtocols);
1741 bool invalid =
false;
1742 IdentifierInfo *foundProtocolId =
nullptr, *foundValidTypeId =
nullptr;
1747 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1752 const char *prevSpec =
nullptr;
1754 DS.SetTypeSpecType(
TST_typename, identifierLocs[i], prevSpec, diagID,
1762 typeArgs.push_back(fullTypeArg.
get());
1763 if (!foundValidTypeId) {
1764 foundValidTypeId = identifiers[i];
1765 foundValidTypeSrcLoc = identifierLocs[i];
1769 unknownTypeArgs.push_back(identifiers[i]);
1770 unknownTypeArgsLoc.push_back(identifierLocs[i]);
1775 unknownTypeArgs.push_back(identifiers[i]);
1776 unknownTypeArgsLoc.push_back(identifierLocs[i]);
1777 }
else if (!foundProtocolId) {
1778 foundProtocolId = identifiers[i];
1779 foundProtocolSrcLoc = identifierLocs[i];
1786 Token CurTypeTok = Tok;
1797 typeArgs.push_back(typeArg.
get());
1798 if (!foundValidTypeId) {
1808 if (foundProtocolId && foundValidTypeId)
1810 foundProtocolId, foundProtocolSrcLoc, foundValidTypeId,
1811 foundValidTypeSrcLoc);
1815 if (unknownTypeArgs.size())
1816 for (
unsigned i = 0, e = unknownTypeArgsLoc.size(); i < e; ++i)
1822 (void)ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc, consumeLastToken,
1831 typeArgsLAngleLoc = lAngleLoc;
1832 typeArgsRAngleLoc = rAngleLoc;
1835void Parser::parseObjCTypeArgsAndProtocolQualifiers(
1844 bool consumeLastToken) {
1845 assert(Tok.
is(tok::less));
1848 parseObjCTypeArgsOrProtocolQualifiers(baseType,
1858 if (Tok.
is(tok::eof))
1864 if ((consumeLastToken && Tok.
is(tok::less)) ||
1865 (!consumeLastToken &&
NextToken().is(tok::less))) {
1868 if (!consumeLastToken)
1871 if (!protocols.empty()) {
1873 if (!consumeLastToken)
1875 Diag(Tok, diag::err_objc_type_args_after_protocols)
1876 <<
SourceRange(protocolLAngleLoc, protocolRAngleLoc);
1877 SkipUntil(tok::greater, tok::greatergreater, skipFlags);
1879 ParseObjCProtocolReferences(protocols, protocolLocs,
1882 protocolLAngleLoc, protocolRAngleLoc,
1888TypeResult Parser::parseObjCTypeArgsAndProtocolQualifiers(
1891 bool consumeLastToken,
1893 assert(Tok.
is(tok::less));
1903 parseObjCTypeArgsAndProtocolQualifiers(
type, typeArgsLAngleLoc, typeArgs,
1904 typeArgsRAngleLoc, protocolLAngleLoc,
1905 protocols, protocolLocs,
1906 protocolRAngleLoc, consumeLastToken);
1908 if (Tok.
is(tok::eof))
1912 if (consumeLastToken)
1913 endLoc = PrevTokLocation;
1918 getCurScope(), loc,
type, typeArgsLAngleLoc, typeArgs, typeArgsRAngleLoc,
1919 protocolLAngleLoc, protocols, protocolLocs, protocolRAngleLoc);
1922void Parser::HelperActionsForIvarDeclarations(
1925 bool RBraceMissing) {
1930 "Ivars should have interfaceDecl as their decl context");
1935 T.getOpenLocation(),
T.getCloseLocation(),
1963 assert(Tok.
is(tok::l_brace) &&
"expected {");
1971 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
1975 if (Tok.
is(tok::semi)) {
1976 ConsumeExtraSemi(InstanceVariableList);
1982 if (Tok.
is(tok::code_completion)) {
1989 case tok::objc_private:
1990 case tok::objc_public:
1991 case tok::objc_protected:
1992 case tok::objc_package:
1998 Diag(Tok, diag::err_objc_unexpected_atend);
2003 HelperActionsForIvarDeclarations(interfaceDecl, atLoc,
2004 T, AllIvarDecls,
true);
2008 Diag(Tok, diag::err_objc_illegal_visibility_spec);
2013 if (Tok.
is(tok::code_completion)) {
2023 if (Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2025 ParseStaticAssertDeclaration(DeclEnd);
2031 "Ivar should have interfaceDecl as its decl context");
2033 FD.D.setObjCIvar(
true);
2035 getCurScope(), FD.D.getDeclSpec().getSourceRange().getBegin(), FD.D,
2036 FD.BitfieldSize, visibility);
2038 AllIvarDecls.push_back(Field);
2045 ParseStructDeclaration(DS, ObjCIvarCallback);
2047 if (Tok.
is(tok::semi)) {
2050 Diag(Tok, diag::err_expected_semi_decl_list);
2055 HelperActionsForIvarDeclarations(interfaceDecl, atLoc,
2056 T, AllIvarDecls,
false);
2079 "ParseObjCAtProtocolDeclaration(): Expected @protocol");
2082 if (Tok.
is(tok::code_completion)) {
2088 MaybeSkipAttributes(tok::objc_protocol);
2090 if (expectIdentifier())
2102 CheckNestedObjCContexts(AtLoc);
2104 if (Tok.
is(tok::comma)) {
2106 ProtocolRefs.push_back(std::make_pair(protocolName, nameLoc));
2111 if (expectIdentifier()) {
2119 if (Tok.
isNot(tok::comma))
2123 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"@protocol"))
2135 if (Tok.
is(tok::less) &&
2136 ParseObjCProtocolReferences(ProtocolRefs, ProtocolLocs,
false,
true,
2137 LAngleLoc, EndProtoLoc,
2143 AtLoc, protocolName, nameLoc, ProtocolRefs.data(), ProtocolRefs.size(),
2144 ProtocolLocs.data(), EndProtoLoc, attrs, &SkipBody);
2146 ParseObjCInterfaceDeclList(tok::objc_protocol, ProtoType);
2148 auto *PreviousDef = cast<ObjCProtocolDecl>(SkipBody.
Previous);
2151 PreviousDef->getDefinition());
2155 DiagsEmitter.diagnoseMismatch(PreviousDef, ProtoType);
2172Parser::ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc,
2175 "ParseObjCAtImplementationDeclaration(): Expected @implementation");
2176 CheckNestedObjCContexts(AtLoc);
2180 if (Tok.
is(tok::code_completion)) {
2186 MaybeSkipAttributes(tok::objc_implementation);
2188 if (expectIdentifier())
2197 if (Tok.
is(tok::less)) {
2201 ObjCTypeParamListScope typeParamScope(Actions,
getCurScope());
2202 if (parseObjCTypeParamListOrProtocolRefs(typeParamScope, lAngleLoc,
2203 protocolIdents, rAngleLoc)) {
2204 Diag(diagLoc, diag::err_objc_parameterized_implementation)
2206 }
else if (lAngleLoc.
isValid()) {
2207 Diag(lAngleLoc, diag::err_unexpected_protocol_qualifier)
2212 if (Tok.
is(tok::l_paren)) {
2218 if (Tok.
is(tok::code_completion)) {
2225 if (Tok.
is(tok::identifier)) {
2229 Diag(Tok, diag::err_expected)
2233 if (Tok.
isNot(tok::r_paren)) {
2234 Diag(Tok, diag::err_expected) << tok::r_paren;
2238 rparenLoc = ConsumeParen();
2239 if (Tok.
is(tok::less)) {
2240 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2244 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
2247 protocolLAngleLoc, protocolRAngleLoc,
2251 AtLoc, nameId, nameLoc, categoryId, categoryLoc, Attrs);
2259 if (expectIdentifier())
2265 AtLoc, nameId, nameLoc, superClassId, superClassLoc, Attrs);
2267 if (Tok.
is(tok::l_brace))
2268 ParseObjCClassInstanceVariables(ObjCImpDecl, tok::objc_private, AtLoc);
2269 else if (Tok.
is(tok::less)) {
2270 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2275 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
2278 protocolLAngleLoc, protocolRAngleLoc,
2282 assert(ObjCImpDecl);
2287 ObjCImplParsingDataRAII ObjCImplParsing(*
this, ObjCImpDecl);
2288 while (!ObjCImplParsing.isFinished() && !isEofOrEom()) {
2290 MaybeParseCXX11Attributes(DeclAttrs);
2293 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs)) {
2295 DeclsInGroup.append(DG.
begin(), DG.
end());
2305Parser::ParseObjCAtEndDeclaration(
SourceRange atEnd) {
2307 "ParseObjCAtEndDeclaration(): Expected @end");
2309 if (CurParsedObjCImpl)
2310 CurParsedObjCImpl->finish(atEnd);
2313 Diag(atEnd.
getBegin(), diag::err_expected_objc_container);
2317Parser::ObjCImplParsingDataRAII::~ObjCImplParsingDataRAII() {
2319 finish(
P.Tok.getLocation());
2320 if (
P.isEofOrEom()) {
2321 P.Diag(
P.Tok, diag::err_objc_missing_end)
2323 P.Diag(Dcl->getBeginLoc(), diag::note_objc_container_start)
2327 P.CurParsedObjCImpl =
nullptr;
2328 assert(LateParsedObjCMethods.empty());
2331void Parser::ObjCImplParsingDataRAII::finish(
SourceRange AtEnd) {
2333 P.Actions.ObjC().DefaultSynthesizeProperties(
P.getCurScope(), Dcl,
2335 for (
size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
2336 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i],
2339 P.Actions.ObjC().ActOnAtEnd(
P.getCurScope(), AtEnd);
2342 for (
size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
2343 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i],
2347 for (LateParsedObjCMethodContainer::iterator
2348 I = LateParsedObjCMethods.begin(),
2349 E = LateParsedObjCMethods.end(); I !=
E; ++I)
2351 LateParsedObjCMethods.clear();
2361 "ParseObjCAtAliasDeclaration(): Expected @compatibility_alias");
2363 if (expectIdentifier())
2367 if (expectIdentifier())
2371 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@compatibility_alias");
2389 "ParseObjCPropertySynthesize(): Expected '@synthesize'");
2393 if (Tok.
is(tok::code_completion)) {
2400 if (Tok.
isNot(tok::identifier)) {
2401 Diag(Tok, diag::err_synthesized_property_name);
2412 if (Tok.
is(tok::code_completion)) {
2419 if (expectIdentifier())
2425 getCurScope(), atLoc, propertyLoc,
true, propertyId, propertyIvar,
2427 if (Tok.
isNot(tok::comma))
2431 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@synthesize");
2444 "ParseObjCPropertyDynamic(): Expected '@dynamic'");
2447 bool isClassProperty =
false;
2448 if (Tok.
is(tok::l_paren)) {
2453 Diag(Tok, diag::err_objc_expected_property_attr) << II;
2457 if (II->
isStr(
"class")) {
2458 isClassProperty =
true;
2459 if (Tok.
isNot(tok::r_paren)) {
2460 Diag(Tok, diag::err_expected) << tok::r_paren;
2465 Diag(AttrName, diag::err_objc_expected_property_attr) << II;
2472 if (Tok.
is(tok::code_completion)) {
2479 if (expectIdentifier()) {
2487 getCurScope(), atLoc, propertyLoc,
false, propertyId,
nullptr,
2492 if (Tok.
isNot(tok::comma))
2496 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@dynamic");
2506 if (Tok.
isNot(tok::semi)) {
2514 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@throw");
2524 if (Tok.
isNot(tok::l_paren)) {
2525 Diag(Tok, diag::err_expected_lparen_after) <<
"@synchronized";
2533 if (Tok.
is(tok::r_paren)) {
2536 if (!operand.isInvalid())
2537 Diag(Tok, diag::err_expected) << tok::r_paren;
2544 if (Tok.
isNot(tok::l_brace)) {
2545 if (!operand.isInvalid())
2546 Diag(Tok, diag::err_expected) << tok::l_brace;
2551 if (!operand.isInvalid())
2557 StmtResult body(ParseCompoundStatementBody());
2562 if (operand.isInvalid())
2565 if (body.isInvalid())
2584 bool catch_or_finally_seen =
false;
2587 if (Tok.
isNot(tok::l_brace)) {
2588 Diag(Tok, diag::err_expected) << tok::l_brace;
2594 StmtResult TryBody(ParseCompoundStatementBody());
2596 if (TryBody.isInvalid())
2599 while (Tok.
is(tok::at)) {
2603 Token AfterAt = GetLookAheadToken(1);
2610 Decl *FirstPart =
nullptr;
2612 if (Tok.
is(tok::l_paren)) {
2617 if (Tok.
isNot(tok::ellipsis)) {
2619 ParsedTemplateInfo TemplateInfo;
2620 ParseDeclarationSpecifiers(DS, TemplateInfo);
2623 ParseDeclarator(ParmDecl);
2634 if (Tok.
is(tok::r_paren))
2635 RParenLoc = ConsumeParen();
2640 if (Tok.
is(tok::l_brace))
2641 CatchBody = ParseCompoundStatementBody();
2643 Diag(Tok, diag::err_expected) << tok::l_brace;
2644 if (CatchBody.isInvalid())
2648 AtCatchFinallyLoc, RParenLoc, FirstPart, CatchBody.get());
2650 CatchStmts.push_back(Catch.
get());
2653 Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after)
2657 catch_or_finally_seen =
true;
2659 assert(Tok.
isObjCAtKeyword(tok::objc_finally) &&
"Lookahead confused?");
2661 ParseScope FinallyScope(
this,
2664 bool ShouldCapture =
2671 if (Tok.
is(tok::l_brace))
2672 FinallyBody = ParseCompoundStatementBody();
2674 Diag(Tok, diag::err_expected) << tok::l_brace;
2676 if (FinallyBody.isInvalid()) {
2680 }
else if (ShouldCapture) {
2686 catch_or_finally_seen =
true;
2690 if (!catch_or_finally_seen) {
2691 Diag(atLoc, diag::err_missing_catch_finally);
2705 if (Tok.
isNot(tok::l_brace)) {
2706 Diag(Tok, diag::err_expected) << tok::l_brace;
2713 StmtResult AutoreleasePoolBody(ParseCompoundStatementBody());
2716 if (AutoreleasePoolBody.isInvalid())
2719 AutoreleasePoolBody.get());
2724void Parser::StashAwayMethodOrFunctionBodyTokens(
Decl *MDecl) {
2726 trySkippingFunctionBody()) {
2731 LexedMethod* LM =
new LexedMethod(
this, MDecl);
2732 CurParsedObjCImpl->LateParsedObjCMethods.push_back(LM);
2735 Toks.push_back(Tok);
2736 if (Tok.
is(tok::kw_try)) {
2738 if (Tok.
is(tok::colon)) {
2739 Toks.push_back(Tok);
2741 while (Tok.
isNot(tok::l_brace)) {
2742 ConsumeAndStoreUntil(tok::l_paren, Toks,
false);
2743 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
2746 Toks.push_back(Tok);
2748 else if (Tok.
is(tok::colon)) {
2751 while (Tok.
isNot(tok::l_brace)) {
2752 ConsumeAndStoreUntil(tok::l_paren, Toks,
false);
2753 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
2755 Toks.push_back(Tok);
2759 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
2760 while (Tok.
is(tok::kw_catch)) {
2761 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
2762 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
2768Decl *Parser::ParseObjCMethodDefinition() {
2769 Decl *MDecl = ParseObjCMethodPrototype();
2772 "parsing Objective-C method");
2775 if (Tok.
is(tok::semi)) {
2776 if (CurParsedObjCImpl) {
2777 Diag(Tok, diag::warn_semicolon_before_method_body)
2784 if (Tok.
isNot(tok::l_brace)) {
2785 Diag(Tok, diag::err_expected_method_body);
2791 if (Tok.
isNot(tok::l_brace))
2803 assert (CurParsedObjCImpl
2804 &&
"ParseObjCMethodDefinition - Method out of @implementation");
2806 StashAwayMethodOrFunctionBodyTokens(MDecl);
2811 ParsedStmtContext StmtCtx) {
2812 if (Tok.
is(tok::code_completion)) {
2819 return ParseObjCTryStmt(AtLoc);
2822 return ParseObjCThrowStmt(AtLoc);
2825 return ParseObjCSynchronizedStmt(AtLoc);
2828 return ParseObjCAutoreleasePoolStmt(AtLoc);
2836 ExprStatementTokLoc = AtLoc;
2837 ExprResult Res(ParseExpressionWithLeadingAt(AtLoc));
2847 ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
2848 return handleExprStmt(Res, StmtCtx);
2853 case tok::code_completion:
2863 if (!Tok.
is(tok::numeric_constant)) {
2864 const char *Symbol =
nullptr;
2866 case tok::minus: Symbol =
"-";
break;
2867 case tok::plus: Symbol =
"+";
break;
2868 default: llvm_unreachable(
"missing unary operator case");
2870 Diag(Tok, diag::err_nsnumber_nonliteral_unary)
2876 if (Lit.isInvalid()) {
2882 if (Lit.isInvalid())
2885 return ParsePostfixExpressionSuffix(
2889 case tok::string_literal:
2890 case tok::wide_string_literal:
2891 return ParsePostfixExpressionSuffix(ParseObjCStringLiteral(AtLoc));
2893 case tok::char_constant:
2894 return ParsePostfixExpressionSuffix(ParseObjCCharacterLiteral(AtLoc));
2896 case tok::numeric_constant:
2897 return ParsePostfixExpressionSuffix(ParseObjCNumericLiteral(AtLoc));
2900 case tok::kw___objc_yes:
2901 return ParsePostfixExpressionSuffix(ParseObjCBooleanLiteral(AtLoc,
true));
2903 case tok::kw___objc_no:
2904 return ParsePostfixExpressionSuffix(ParseObjCBooleanLiteral(AtLoc,
false));
2908 return ParsePostfixExpressionSuffix(ParseObjCArrayLiteral(AtLoc));
2912 return ParsePostfixExpressionSuffix(ParseObjCDictionaryLiteral(AtLoc));
2916 return ParsePostfixExpressionSuffix(ParseObjCBoxedExpr(AtLoc));
2923 case tok::objc_encode:
2924 return ParsePostfixExpressionSuffix(ParseObjCEncodeExpression(AtLoc));
2925 case tok::objc_protocol:
2926 return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression(AtLoc));
2927 case tok::objc_selector:
2928 return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression(AtLoc));
2929 case tok::objc_available:
2930 return ParseAvailabilityCheckExpr(AtLoc);
2932 const char *str =
nullptr;
2936 if (GetLookAheadToken(1).is(tok::l_brace) &&
2937 ExprStatementTokLoc == AtLoc) {
2941 : (ch ==
'f' ?
"finally"
2942 : (ch ==
'a' ?
"autoreleasepool" :
nullptr));
2978bool Parser::ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr) {
2981 if (Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_typename,
2982 tok::annot_cxxscope))
2996 TypeOrExpr = Receiver.
get();
3005 ParseCXXSimpleTypeSpecifier(DS);
3007 if (Tok.
is(tok::l_paren)) {
3020 ExprResult Receiver = ParseCXXTypeConstructExpression(DS);
3022 Receiver = ParsePostfixExpressionSuffix(Receiver.
get());
3024 Receiver = ParseRHSOfBinaryExpression(Receiver.
get(),
prec::Comma);
3029 TypeOrExpr = Receiver.
get();
3039 if (
Type.isInvalid())
3043 TypeOrExpr =
Type.get().getAsOpaquePtr();
3052bool Parser::isSimpleObjCMessageExpression() {
3054 "Incorrect start for isSimpleObjCMessageExpression");
3055 return GetLookAheadToken(1).
is(tok::identifier) &&
3056 GetLookAheadToken(2).
is(tok::identifier);
3059bool Parser::isStartOfObjCClassMessageMissingOpenBracket() {
3061 InMessageExpression)
3066 if (Tok.
is(tok::annot_typename))
3068 else if (Tok.
is(tok::identifier))
3076 const Token &AfterNext = GetLookAheadToken(2);
3077 if (AfterNext.
isOneOf(tok::colon, tok::r_square)) {
3078 if (Tok.
is(tok::identifier))
3081 return Tok.
is(tok::annot_typename);
3097ExprResult Parser::ParseObjCMessageExpression() {
3098 assert(Tok.
is(tok::l_square) &&
"'[' expected");
3101 if (Tok.
is(tok::code_completion)) {
3118 return ParseObjCMessageExpressionBody(LBracLoc,
ConsumeToken(),
nullptr,
3123 void *TypeOrExpr =
nullptr;
3124 if (ParseObjCXXMessageReceiver(IsExpr, TypeOrExpr)) {
3130 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
nullptr,
3131 static_cast<Expr *
>(TypeOrExpr));
3133 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
3138 if (Tok.
is(tok::identifier)) {
3143 getCurScope(), Name, NameLoc, Name == Ident_super,
3144 NextToken().is(tok::period), ReceiverType)) {
3146 return ParseObjCMessageExpressionBody(LBracLoc,
ConsumeToken(),
nullptr,
3150 if (!ReceiverType) {
3158 if (Tok.
is(tok::less)) {
3161 = parseObjCTypeArgsAndProtocolQualifiers(NameLoc, ReceiverType,
3169 ReceiverType = NewReceiverType.
get();
3172 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
3173 ReceiverType,
nullptr);
3188 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
nullptr,
3234 Expr *ReceiverExpr) {
3237 if (Tok.
is(tok::code_completion)) {
3242 else if (ReceiverType)
3257 ExprVector KeyExprs;
3259 if (Tok.
is(tok::colon)) {
3262 KeyIdents.push_back(selIdent);
3263 KeyLocs.push_back(
Loc);
3265 if (ExpectAndConsume(tok::colon)) {
3275 if (Tok.
is(tok::code_completion)) {
3281 else if (ReceiverType)
3295 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3296 Expr = ParseBraceInitializer();
3310 KeyExprs.push_back(Res.
get());
3313 if (Tok.
is(tok::code_completion)) {
3319 else if (ReceiverType)
3331 selIdent = ParseObjCSelectorPiece(
Loc);
3332 if (!selIdent && Tok.
isNot(tok::colon))
3337 while (Tok.
is(tok::comma)) {
3341 if (Tok.
is(tok::colon))
3344 if (Tok.
is(tok::colon)) {
3345 Diag(commaLoc, diag::note_extra_comma_message_arg) <<
3356 KeyExprs.push_back(Res.
get());
3358 }
else if (!selIdent) {
3359 Diag(Tok, diag::err_expected) << tok::identifier;
3368 if (Tok.
isNot(tok::r_square)) {
3369 Diag(Tok, diag::err_expected)
3370 << (Tok.
is(tok::identifier) ? tok::colon : tok::r_square);
3380 unsigned nKeys = KeyIdents.size();
3382 KeyIdents.push_back(selIdent);
3383 KeyLocs.push_back(
Loc);
3389 getCurScope(), SuperLoc, Sel, LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3390 else if (ReceiverType)
3392 LBracLoc, KeyLocs, RBracLoc,
3395 getCurScope(), ReceiverExpr, Sel, LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3406 ExprVector AtStrings;
3407 AtLocs.push_back(AtLoc);
3408 AtStrings.push_back(Res.
get());
3410 while (Tok.
is(tok::at)) {
3414 if (!isTokenStringLiteral())
3418 if (Lit.isInvalid())
3421 AtStrings.push_back(Lit.get());
3443 if (Lit.isInvalid()) {
3457 if (Lit.isInvalid()) {
3469 if (Tok.
isNot(tok::l_paren))
3470 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@");
3475 if (
T.consumeClose())
3478 if (ValueExpr.isInvalid())
3484 ValueExpr = Actions.
ActOnParenExpr(LPLoc, RPLoc, ValueExpr.get());
3490 ExprVector ElementExprs;
3493 bool HasInvalidEltExpr =
false;
3494 while (Tok.
isNot(tok::r_square)) {
3507 HasInvalidEltExpr =
true;
3510 if (Tok.
is(tok::ellipsis))
3513 HasInvalidEltExpr =
true;
3515 ElementExprs.push_back(Res.
get());
3517 if (Tok.
is(tok::comma))
3519 else if (Tok.
isNot(tok::r_square))
3520 return ExprError(
Diag(Tok, diag::err_expected_either) << tok::r_square
3525 if (HasInvalidEltExpr)
3535 bool HasInvalidEltExpr =
false;
3536 while (Tok.
isNot(tok::r_brace)) {
3551 if (ExpectAndConsume(tok::colon)) {
3557 if (ValueExpr.isInvalid()) {
3568 if (KeyExpr.
isInvalid() || ValueExpr.isInvalid())
3569 HasInvalidEltExpr =
true;
3581 EllipsisLoc, std::nullopt};
3582 Elements.push_back(Element);
3585 return ExprError(
Diag(Tok, diag::err_expected_either) << tok::r_brace
3590 if (HasInvalidEltExpr)
3602 assert(Tok.
isObjCAtKeyword(tok::objc_encode) &&
"Not an @encode expression!");
3606 if (Tok.
isNot(tok::l_paren))
3607 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@encode");
3620 AtLoc, EncLoc,
T.getOpenLocation(), Ty.
get(),
T.getCloseLocation());
3629 if (Tok.
isNot(tok::l_paren))
3630 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@protocol");
3635 if (expectIdentifier())
3644 protocolId, AtLoc, ProtoLoc,
T.getOpenLocation(), ProtoIdLoc,
3645 T.getCloseLocation());
3653 if (Tok.
isNot(tok::l_paren))
3654 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@selector");
3661 bool HasOptionalParen = Tok.
is(tok::l_paren);
3662 if (HasOptionalParen)
3665 if (Tok.
is(tok::code_completion)) {
3673 Tok.
isNot(tok::colon) && Tok.
isNot(tok::coloncolon))
3674 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
3676 KeyIdents.push_back(SelIdent);
3678 unsigned nColons = 0;
3679 if (Tok.
isNot(tok::r_paren)) {
3683 KeyIdents.push_back(
nullptr);
3684 }
else if (ExpectAndConsume(tok::colon))
3688 if (Tok.
is(tok::r_paren))
3691 if (Tok.
is(tok::code_completion)) {
3700 SelIdent = ParseObjCSelectorPiece(
Loc);
3701 KeyIdents.push_back(SelIdent);
3702 if (!SelIdent && Tok.
isNot(tok::colon) && Tok.
isNot(tok::coloncolon))
3706 if (HasOptionalParen && Tok.
is(tok::r_paren))
3711 Sel, AtLoc, SelectorLoc,
T.getOpenLocation(),
T.getCloseLocation(),
3715void Parser::ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod) {
3717 Decl *MCDecl = LM.D;
3727 assert(!LM.Toks.empty() &&
"ParseLexedObjCMethodDef - Empty body!");
3735 LM.Toks.push_back(Eof);
3738 LM.Toks.push_back(Tok);
3739 PP.EnterTokenStream(LM.Toks,
true,
true);
3744 assert(Tok.
isOneOf(tok::l_brace, tok::kw_try, tok::colon) &&
3745 "Inline objective-c method not starting with '{' or 'try' or ':'");
3758 if (Tok.
is(tok::kw_try))
3759 ParseFunctionTryBlock(MCDecl, BodyScope);
3761 if (Tok.
is(tok::colon))
3762 ParseConstructorInitializer(MCDecl);
3765 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)
Represents a parameter to a function.
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
ParmVarDecl * ActOnMethodParmDeclaration(Scope *S, ObjCArgInfo &ArgInfo, int ParamIndex, bool MethodDefinition)
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)
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)
Decl * ActOnMethodDeclaration(Scope *S, SourceLocation BeginLoc, SourceLocation EndLoc, tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType, ArrayRef< SourceLocation > SelectorLocs, Selector Sel, ParmVarDecl **ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic, bool MethodDefinition)
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)
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)
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl * > allMethods={}, ArrayRef< DeclGroupPtrTy > allTUVars={})
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.