25 #include "llvm/ADT/SmallVector.h"
26 #include "llvm/ADT/StringExtras.h"
28 using namespace clang;
33 if (Tok.
is(tok::kw___attribute)) {
34 if (
Kind == tok::objc_interface ||
Kind == tok::objc_protocol)
35 Diag(Tok, diag::err_objc_postfix_attribute_hint)
36 << (
Kind == tok::objc_protocol);
38 Diag(Tok, diag::err_objc_postfix_attribute);
39 ParseGNUAttributes(attrs);
58 if (Tok.
is(tok::code_completion)) {
65 case tok::objc_interface:
66 case tok::objc_protocol:
67 case tok::objc_implementation:
70 for (
const auto &
Attr : DeclAttrs) {
76 Decl *SingleDecl =
nullptr;
79 return ParseObjCAtClassDeclaration(AtLoc);
80 case tok::objc_interface:
81 SingleDecl = ParseObjCAtInterfaceDeclaration(AtLoc, DeclAttrs);
83 case tok::objc_protocol:
84 return ParseObjCAtProtocolDeclaration(AtLoc, DeclAttrs);
85 case tok::objc_implementation:
86 return ParseObjCAtImplementationDeclaration(AtLoc, DeclAttrs);
88 return ParseObjCAtEndDeclaration(AtLoc);
89 case tok::objc_compatibility_alias:
90 SingleDecl = ParseObjCAtAliasDeclaration(AtLoc);
92 case tok::objc_synthesize:
93 SingleDecl = ParseObjCPropertySynthesize(AtLoc);
95 case tok::objc_dynamic:
96 SingleDecl = ParseObjCPropertyDynamic(AtLoc);
98 case tok::objc_import:
101 SingleDecl = ParseModuleImport(AtLoc, IS);
104 Diag(AtLoc, diag::err_atimport);
108 Diag(AtLoc, diag::err_unexpected_at);
110 SingleDecl =
nullptr;
124 : Actions(Actions), S(S), Params(nullptr) {}
157 MaybeSkipAttributes(tok::objc_class);
158 if (Tok.
is(tok::code_completion)) {
163 if (expectIdentifier()) {
173 if (Tok.
is(tok::less))
174 TypeParams = parseObjCTypeParamList();
175 ClassTypeParams.push_back(TypeParams);
181 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"@class"))
185 atLoc, ClassNames.data(), ClassLocs.data(), ClassTypeParams,
196 if (CurParsedObjCImpl) {
197 CurParsedObjCImpl->finish(AtLoc);
201 Diag(AtLoc, diag::err_objc_missing_end)
239 "ParseObjCAtInterfaceDeclaration(): Expected @interface");
240 CheckNestedObjCContexts(AtLoc);
244 if (Tok.
is(tok::code_completion)) {
250 MaybeSkipAttributes(tok::objc_interface);
252 if (expectIdentifier())
265 ObjCTypeParamListScope typeParamScope(Actions,
getCurScope());
266 if (Tok.
is(tok::less))
267 typeParameterList = parseObjCTypeParamListOrProtocolRefs(
268 typeParamScope, LAngleLoc, ProtocolIdents, EndProtoLoc);
270 if (Tok.
is(tok::l_paren) &&
271 !isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
278 if (Tok.
is(tok::code_completion)) {
286 if (Tok.
is(tok::identifier)) {
291 Diag(Tok, diag::err_expected)
297 if (
T.getCloseLocation().isInvalid())
301 assert(LAngleLoc.
isInvalid() &&
"Cannot have already parsed protocols");
304 if (Tok.
is(tok::less) &&
305 ParseObjCProtocolReferences(ProtocolRefs, ProtocolLocs,
true,
true,
306 LAngleLoc, EndProtoLoc,
311 AtLoc, nameId, nameLoc, typeParameterList, categoryId, categoryLoc,
312 ProtocolRefs.data(), ProtocolRefs.size(), ProtocolLocs.data(),
315 if (Tok.
is(tok::l_brace))
316 ParseObjCClassInstanceVariables(CategoryType, tok::objc_private, AtLoc);
318 ParseObjCInterfaceDeclList(tok::objc_not_keyword, CategoryType);
330 if (Tok.
is(tok::colon)) {
334 if (Tok.
is(tok::code_completion)) {
341 if (expectIdentifier())
347 if (Tok.
is(tok::less)) {
348 parseObjCTypeArgsOrProtocolQualifiers(
349 nullptr, typeArgsLAngleLoc, typeArgs, typeArgsRAngleLoc, LAngleLoc,
350 protocols, protocolLocs, EndProtoLoc,
360 if (!ProtocolIdents.empty()) {
363 for (
const auto &pair : ProtocolIdents) {
364 protocolLocs.push_back(pair.second);
368 ProtocolIdents, protocols);
370 }
else if (protocols.empty() && Tok.
is(tok::less) &&
371 ParseObjCProtocolReferences(protocols, protocolLocs,
true,
true,
372 LAngleLoc, EndProtoLoc,
377 if (Tok.
isNot(tok::less))
379 superClassId, superClassLoc);
383 getCurScope(), AtLoc, nameId, nameLoc, typeParameterList, superClassId,
384 superClassLoc, typeArgs,
385 SourceRange(typeArgsLAngleLoc, typeArgsRAngleLoc), protocols.data(),
386 protocols.size(), protocolLocs.data(), EndProtoLoc, attrs, &SkipBody);
388 if (Tok.
is(tok::l_brace))
389 ParseObjCClassInstanceVariables(ClsType, tok::objc_protected, AtLoc);
391 ParseObjCInterfaceDeclList(tok::objc_interface, ClsType);
394 auto *PreviousDef = cast<ObjCInterfaceDecl>(SkipBody.
Previous);
400 DiagsEmitter.diagnoseMismatch(PreviousDef, ClsType);
414 bool &addedToDeclSpec) {
417 return Pool.create(
P.getNullabilityKeyword(nullability),
426 }
else if (!addedToDeclSpec) {
431 addedToDeclSpec =
true;
463 assert(Tok.
is(tok::less) &&
"Not at the beginning of a type parameter list");
471 auto makeProtocolIdentsIntoTypeParameters = [&]() {
473 for (
const auto &pair : protocolIdents) {
478 typeParams.push_back(typeParam.
get());
481 protocolIdents.clear();
482 mayBeProtocolList =
false;
485 bool invalid =
false;
492 if (Tok.
is(tok::kw___covariant) || Tok.
is(tok::kw___contravariant)) {
493 variance = Tok.
is(tok::kw___covariant)
500 if (mayBeProtocolList) {
503 makeProtocolIdentsIntoTypeParameters();
508 if (!Tok.
is(tok::identifier)) {
510 if (Tok.
is(tok::code_completion)) {
521 Diag(Tok, diag::err_objc_expected_type_parameter);
535 if (mayBeProtocolList) {
538 makeProtocolIdentsIntoTypeParameters();
545 }
else if (mayBeProtocolList) {
548 protocolIdents.push_back(std::make_pair(paramName, paramLoc));
554 getCurScope(), variance, varianceLoc, typeParams.size(), paramName,
555 paramLoc, colonLoc, boundType.
isUsable() ? boundType.
get() :
nullptr);
557 typeParams.push_back(typeParam.
get());
563 if (Tok.
is(tok::greater))
565 }
else if (ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc,
568 SkipUntil({tok::greater, tok::greaterequal, tok::at, tok::minus,
569 tok::minus, tok::plus, tok::colon, tok::l_paren, tok::l_brace,
570 tok::comma, tok::semi },
572 if (Tok.
is(tok::greater))
576 if (mayBeProtocolList) {
581 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_paren)) {
590 makeProtocolIdentsIntoTypeParameters();
602 return invalid ? nullptr : list;
612 return parseObjCTypeParamListOrProtocolRefs(
Scope, lAngleLoc, protocolIdents,
619 case tok::objc_class:
620 case tok::objc_compatibility_alias:
621 case tok::objc_interface:
622 case tok::objc_implementation:
623 case tok::objc_protocol:
652 if (Tok.
isOneOf(tok::minus, tok::plus)) {
653 if (
Decl *methodPrototype =
654 ParseObjCMethodPrototype(MethodImplKind,
false))
655 allMethods.push_back(methodPrototype);
658 if (ExpectAndConsumeSemi(diag::err_expected_semi_after_method_proto)) {
661 if (Tok.
is(tok::semi))
666 if (Tok.
is(tok::l_paren)) {
667 Diag(Tok, diag::err_expected_minus_or_plus);
670 MethodImplKind,
false);
674 if (Tok.
is(tok::semi)) {
686 if (Tok.
is(tok::code_completion)) {
696 if (Tok.
isNot(tok::at)) {
700 if (Tok.
is(tok::r_brace))
709 if (Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
713 DeclEnd, EmptyDeclAttrs,
714 EmptyDeclSpecAttrs));
718 allTUVariables.push_back(ParseDeclarationOrFunctionDefinition(
719 EmptyDeclAttrs, EmptyDeclSpecAttrs));
726 if (NextTok.is(tok::code_completion)) {
739 Diag(NextTok, diag::err_objc_unknown_at);
759 Diag(AtLoc, diag::err_objc_illegal_interface_qual);
764 case tok::objc_required:
765 case tok::objc_optional:
767 if (contextKey != tok::objc_protocol)
768 Diag(AtLoc, diag::err_objc_directive_only_in_protocol);
773 case tok::objc_property:
777 if (Tok.
is(tok::l_paren)) {
779 ParseObjCPropertyAttribute(OCDS);
782 bool addedToDeclSpec =
false;
784 if (FD.D.getIdentifier() ==
nullptr) {
785 Diag(AtLoc, diag::err_objc_property_requires_field_name)
786 << FD.D.getSourceRange();
789 if (FD.BitfieldSize) {
790 Diag(AtLoc, diag::err_objc_property_bitfield)
791 << FD.D.getSourceRange();
815 FD.D.getIdentifier());
817 getCurScope(), AtLoc, LParenLoc, FD, OCDS, GetterSel, SetterSel,
820 FD.complete(Property);
826 ParseStructDeclaration(DS, ObjCPropertyCallback);
828 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
839 Diag(Tok, diag::err_objc_missing_end)
858 P.Diag(nullabilityLoc, diag::warn_nullability_duplicate)
864 P.Diag(nullabilityLoc, diag::err_nullability_conflicting)
896 void Parser::ParseObjCPropertyAttribute(
ObjCDeclSpec &DS) {
897 assert(Tok.
getKind() == tok::l_paren);
902 if (Tok.
is(tok::code_completion)) {
917 if (II->
isStr(
"readonly"))
919 else if (II->
isStr(
"assign"))
921 else if (II->
isStr(
"unsafe_unretained"))
923 else if (II->
isStr(
"readwrite"))
925 else if (II->
isStr(
"retain"))
927 else if (II->
isStr(
"strong"))
929 else if (II->
isStr(
"copy"))
931 else if (II->
isStr(
"nonatomic"))
933 else if (II->
isStr(
"atomic"))
935 else if (II->
isStr(
"weak"))
937 else if (II->
isStr(
"getter") || II->
isStr(
"setter")) {
941 unsigned DiagID = IsSetter ? diag::err_objc_expected_equal_for_setter :
942 diag::err_objc_expected_equal_for_getter;
944 if (ExpectAndConsume(tok::equal, DiagID)) {
949 if (Tok.
is(tok::code_completion)) {
964 Diag(Tok, diag::err_objc_expected_selector_for_getter_setter)
974 if (ExpectAndConsume(tok::colon,
975 diag::err_expected_colon_after_setter_name)) {
983 }
else if (II->
isStr(
"nonnull")) {
990 }
else if (II->
isStr(
"nullable")) {
997 }
else if (II->
isStr(
"null_unspecified")) {
1004 }
else if (II->
isStr(
"null_resettable")) {
1014 }
else if (II->
isStr(
"class")) {
1016 }
else if (II->
isStr(
"direct")) {
1019 Diag(AttrName, diag::err_objc_expected_property_attr) << II;
1024 if (Tok.
isNot(tok::comma))
1044 bool MethodDefinition) {
1045 assert(Tok.
isOneOf(tok::minus, tok::plus) &&
"expected +/-");
1049 Decl *MDecl = ParseObjCMethodDecl(mLoc, methodType, MethodImplKind,
1079 case tok::exclaimequal:
1081 case tok::pipeequal:
1083 case tok::caretequal: {
1094 case tok::identifier:
1104 case tok::kw_const_cast:
1105 case tok::kw_continue:
1106 case tok::kw_default:
1107 case tok::kw_delete:
1109 case tok::kw_double:
1110 case tok::kw_dynamic_cast:
1113 case tok::kw_explicit:
1114 case tok::kw_export:
1115 case tok::kw_extern:
1119 case tok::kw_friend:
1122 case tok::kw_inline:
1125 case tok::kw_mutable:
1126 case tok::kw_namespace:
1128 case tok::kw_operator:
1129 case tok::kw_private:
1130 case tok::kw_protected:
1131 case tok::kw_public:
1132 case tok::kw_register:
1133 case tok::kw_reinterpret_cast:
1134 case tok::kw_restrict:
1135 case tok::kw_return:
1137 case tok::kw_signed:
1138 case tok::kw_sizeof:
1139 case tok::kw_static:
1140 case tok::kw_static_cast:
1141 case tok::kw_struct:
1142 case tok::kw_switch:
1143 case tok::kw_template:
1148 case tok::kw_typedef:
1149 case tok::kw_typeid:
1150 case tok::kw_typename:
1151 case tok::kw_typeof:
1153 case tok::kw_unsigned:
1155 case tok::kw_virtual:
1157 case tok::kw_volatile:
1158 case tok::kw_wchar_t:
1161 case tok::kw__Complex:
1162 case tok::kw___alignof:
1163 case tok::kw___auto_type:
1172 bool Parser::isTokIdentifier_in()
const {
1199 void Parser::ParseObjCTypeQualifierList(
ObjCDeclSpec &DS,
1205 if (Tok.
is(tok::code_completion)) {
1212 if (Tok.
isNot(tok::identifier))
1216 for (
unsigned i = 0; i != objc_NumQuals; ++i) {
1217 if (II != ObjCTypeQuals[i] ||
1225 default: llvm_unreachable(
"Unknown decl qualifier");
1243 case objc_null_unspecified:
1268 for (
auto &AL : llvm::reverse(from)) {
1269 if (!AL.isUsedAsTypeAttr()) {
1304 assert((paramAttrs !=
nullptr) ==
1307 assert(Tok.
is(tok::l_paren) &&
"expected (");
1315 ParseObjCTypeQualifierList(DS, context);
1319 if (isTypeSpecifierQualifier() || isObjCInstancetype()) {
1322 declSpec.setObjCQualifiers(&DS);
1323 DeclSpecContext dsContext = DeclSpecContext::DSC_normal;
1325 dsContext = DeclSpecContext::DSC_objc_method_result;
1326 ParseSpecifierQualifierList(declSpec,
AS_none, dsContext);
1328 ParseDeclarator(declarator);
1331 if (!declarator.isInvalidType()) {
1333 bool addedToDeclSpec =
false;
1341 if (!
type.isInvalid())
1351 if (Tok.
is(tok::r_paren))
1355 Diag(Tok, diag::err_expected_type);
1396 bool MethodDefinition) {
1399 if (Tok.
is(tok::code_completion)) {
1402 mType == tok::minus,
1410 if (Tok.
is(tok::l_paren))
1416 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().ObjC ? PAKM_GNU : 0),
1419 if (Tok.
is(tok::code_completion)) {
1431 if (!SelIdent && Tok.
isNot(tok::colon)) {
1432 Diag(Tok, diag::err_expected_selector_for_method)
1440 if (Tok.
isNot(tok::colon)) {
1442 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().ObjC ? PAKM_GNU : 0),
1448 selLoc, Sel,
nullptr, CParamInfo.data(), CParamInfo.size(), methodAttrs,
1449 MethodImplKind,
false, MethodDefinition);
1450 PD.complete(Result);
1466 if (ExpectAndConsume(tok::colon))
1469 ArgInfo.
Type =
nullptr;
1470 if (Tok.
is(tok::l_paren))
1471 ArgInfo.
Type = ParseObjCTypeName(
1476 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().ObjC ? PAKM_GNU : 0),
1481 if (Tok.
is(tok::code_completion)) {
1483 KeyIdents.push_back(SelIdent);
1486 true, ReturnType, KeyIdents);
1490 if (expectIdentifier())
1497 ArgInfos.push_back(ArgInfo);
1498 KeyIdents.push_back(SelIdent);
1499 KeyLocs.push_back(selLoc);
1502 allParamAttrs.takeAllFrom(paramAttrs.
getPool());
1505 if (Tok.
is(tok::code_completion)) {
1509 false, ReturnType, KeyIdents);
1514 SelIdent = ParseObjCSelectorPiece(selLoc);
1515 if (!SelIdent && Tok.
isNot(tok::colon))
1520 Diag(ArgInfo.
NameLoc, diag::warn_missing_selector_name) << ArgInfo.
Name;
1521 Diag(ArgInfo.
NameLoc, diag::note_missing_selector_name) << ArgInfo.
Name;
1522 Diag(ColonLoc, diag::note_force_empty_selector_name) << ArgInfo.
Name;
1528 bool isVariadic =
false;
1529 bool cStyleParamWarned =
false;
1531 while (Tok.
is(tok::comma)) {
1533 if (Tok.
is(tok::ellipsis)) {
1538 if (!cStyleParamWarned) {
1539 Diag(Tok, diag::warn_cstyle_param);
1540 cStyleParamWarned =
true;
1543 ParsedTemplateInfo TemplateInfo;
1544 ParseDeclarationSpecifiers(DS, TemplateInfo);
1548 ParseDeclarator(ParmDecl);
1552 ParmDecl.getIdentifierLoc(),
1559 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().ObjC ? PAKM_GNU : 0),
1562 if (KeyIdents.size() == 0)
1569 Sel, &ArgInfos[0], CParamInfo.data(), CParamInfo.size(), methodAttrs,
1570 MethodImplKind, isVariadic, MethodDefinition);
1572 PD.complete(Result);
1582 bool WarnOnDeclarations,
bool ForObjCContainer,
1584 bool consumeLastToken) {
1585 assert(Tok.
is(tok::less) &&
"expected <");
1592 if (Tok.
is(tok::code_completion)) {
1599 if (expectIdentifier()) {
1613 if (ParseGreaterThanInTemplateList(LAngleLoc, EndLoc, consumeLastToken,
1619 ProtocolIdents, Protocols);
1624 assert(Tok.
is(tok::less) &&
"Protocol qualifiers start with '<'");
1625 assert(
getLangOpts().ObjC &&
"Protocol qualifiers only exist in Objective-C");
1630 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
false,
false,
1631 lAngleLoc, rAngleLoc,
1634 lAngleLoc, protocols, protocolLocs, rAngleLoc);
1636 Diag(lAngleLoc, diag::warn_objc_protocol_qualifier_missing_id)
1649 void Parser::parseObjCTypeArgsOrProtocolQualifiers(
1658 bool consumeLastToken,
1659 bool warnOnIncompleteProtocols) {
1660 assert(Tok.
is(tok::less) &&
"Not at the start of type args or protocols");
1665 bool allSingleIdentifiers =
true;
1673 if (Tok.
is(tok::identifier) &&
1682 if (Tok.
is(tok::code_completion)) {
1685 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1687 identifierLocs[i]));
1697 identifierLocPairs);
1702 allSingleIdentifiers =
false;
1708 if (allSingleIdentifiers) {
1711 (void)ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc, consumeLastToken,
1716 getCurScope(), baseType, lAngleLoc, identifiers, identifierLocs,
1717 rAngleLoc, typeArgsLAngleLoc, typeArgs, typeArgsRAngleLoc,
1718 protocolLAngleLoc, protocols, protocolRAngleLoc,
1719 warnOnIncompleteProtocols);
1729 bool invalid =
false;
1730 IdentifierInfo *foundProtocolId =
nullptr, *foundValidTypeId =
nullptr;
1735 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1740 const char *prevSpec =
nullptr;
1742 DS.SetTypeSpecType(
TST_typename, identifierLocs[i], prevSpec, diagID,
1750 typeArgs.push_back(fullTypeArg.
get());
1751 if (!foundValidTypeId) {
1752 foundValidTypeId = identifiers[i];
1753 foundValidTypeSrcLoc = identifierLocs[i];
1757 unknownTypeArgs.push_back(identifiers[i]);
1758 unknownTypeArgsLoc.push_back(identifierLocs[i]);
1763 unknownTypeArgs.push_back(identifiers[i]);
1764 unknownTypeArgsLoc.push_back(identifierLocs[i]);
1765 }
else if (!foundProtocolId) {
1766 foundProtocolId = identifiers[i];
1767 foundProtocolSrcLoc = identifierLocs[i];
1774 Token CurTypeTok = Tok;
1785 typeArgs.push_back(typeArg.
get());
1786 if (!foundValidTypeId) {
1796 if (foundProtocolId && foundValidTypeId)
1798 foundProtocolId, foundProtocolSrcLoc, foundValidTypeId,
1799 foundValidTypeSrcLoc);
1803 if (unknownTypeArgs.size())
1804 for (
unsigned i = 0, e = unknownTypeArgsLoc.size(); i < e; ++i)
1810 (void)ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc, consumeLastToken,
1819 typeArgsLAngleLoc = lAngleLoc;
1820 typeArgsRAngleLoc = rAngleLoc;
1823 void Parser::parseObjCTypeArgsAndProtocolQualifiers(
1832 bool consumeLastToken) {
1833 assert(Tok.
is(tok::less));
1836 parseObjCTypeArgsOrProtocolQualifiers(baseType,
1852 if ((consumeLastToken && Tok.
is(tok::less)) ||
1853 (!consumeLastToken &&
NextToken().is(tok::less))) {
1856 if (!consumeLastToken)
1859 if (!protocols.empty()) {
1861 if (!consumeLastToken)
1863 Diag(Tok, diag::err_objc_type_args_after_protocols)
1864 <<
SourceRange(protocolLAngleLoc, protocolRAngleLoc);
1865 SkipUntil(tok::greater, tok::greatergreater, skipFlags);
1867 ParseObjCProtocolReferences(protocols, protocolLocs,
1870 protocolLAngleLoc, protocolRAngleLoc,
1876 TypeResult Parser::parseObjCTypeArgsAndProtocolQualifiers(
1879 bool consumeLastToken,
1881 assert(Tok.
is(tok::less));
1891 parseObjCTypeArgsAndProtocolQualifiers(
type, typeArgsLAngleLoc, typeArgs,
1892 typeArgsRAngleLoc, protocolLAngleLoc,
1893 protocols, protocolLocs,
1894 protocolRAngleLoc, consumeLastToken);
1900 if (consumeLastToken)
1901 endLoc = PrevTokLocation;
1906 getCurScope(), loc,
type, typeArgsLAngleLoc, typeArgs, typeArgsRAngleLoc,
1907 protocolLAngleLoc, protocols, protocolLocs, protocolRAngleLoc);
1910 void Parser::HelperActionsForIvarDeclarations(
1913 bool RBraceMissing) {
1918 "Ivars should have interfaceDecl as their decl context");
1923 T.getOpenLocation(),
T.getCloseLocation(),
1951 assert(Tok.
is(tok::l_brace) &&
"expected {");
1959 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
1963 if (Tok.
is(tok::semi)) {
1964 ConsumeExtraSemi(InstanceVariableList);
1970 if (Tok.
is(tok::code_completion)) {
1977 case tok::objc_private:
1978 case tok::objc_public:
1979 case tok::objc_protected:
1980 case tok::objc_package:
1986 Diag(Tok, diag::err_objc_unexpected_atend);
1991 HelperActionsForIvarDeclarations(interfaceDecl, atLoc,
1992 T, AllIvarDecls,
true);
1996 Diag(Tok, diag::err_objc_illegal_visibility_spec);
2001 if (Tok.
is(tok::code_completion)) {
2011 if (Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2013 ParseStaticAssertDeclaration(DeclEnd);
2019 "Ivar should have interfaceDecl as its decl context");
2021 FD.D.setObjCIvar(
true);
2023 getCurScope(), FD.D.getDeclSpec().getSourceRange().getBegin(), FD.D,
2024 FD.BitfieldSize, visibility);
2026 AllIvarDecls.push_back(Field);
2033 ParseStructDeclaration(DS, ObjCIvarCallback);
2035 if (Tok.
is(tok::semi)) {
2038 Diag(Tok, diag::err_expected_semi_decl_list);
2043 HelperActionsForIvarDeclarations(interfaceDecl, atLoc,
2044 T, AllIvarDecls,
false);
2067 "ParseObjCAtProtocolDeclaration(): Expected @protocol");
2070 if (Tok.
is(tok::code_completion)) {
2076 MaybeSkipAttributes(tok::objc_protocol);
2078 if (expectIdentifier())
2090 CheckNestedObjCContexts(AtLoc);
2092 if (Tok.
is(tok::comma)) {
2094 ProtocolRefs.push_back(std::make_pair(protocolName, nameLoc));
2099 if (expectIdentifier()) {
2107 if (Tok.
isNot(tok::comma))
2111 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"@protocol"))
2123 if (Tok.
is(tok::less) &&
2124 ParseObjCProtocolReferences(ProtocolRefs, ProtocolLocs,
false,
true,
2125 LAngleLoc, EndProtoLoc,
2131 AtLoc, protocolName, nameLoc, ProtocolRefs.data(), ProtocolRefs.size(),
2132 ProtocolLocs.data(), EndProtoLoc, attrs, &SkipBody);
2134 ParseObjCInterfaceDeclList(tok::objc_protocol, ProtoType);
2136 auto *PreviousDef = cast<ObjCProtocolDecl>(SkipBody.
Previous);
2139 PreviousDef->getDefinition());
2143 DiagsEmitter.diagnoseMismatch(PreviousDef, ProtoType);
2160 Parser::ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc,
2163 "ParseObjCAtImplementationDeclaration(): Expected @implementation");
2164 CheckNestedObjCContexts(AtLoc);
2168 if (Tok.
is(tok::code_completion)) {
2174 MaybeSkipAttributes(tok::objc_implementation);
2176 if (expectIdentifier())
2185 if (Tok.
is(tok::less)) {
2189 ObjCTypeParamListScope typeParamScope(Actions,
getCurScope());
2190 if (parseObjCTypeParamListOrProtocolRefs(typeParamScope, lAngleLoc,
2191 protocolIdents, rAngleLoc)) {
2192 Diag(diagLoc, diag::err_objc_parameterized_implementation)
2194 }
else if (lAngleLoc.
isValid()) {
2195 Diag(lAngleLoc, diag::err_unexpected_protocol_qualifier)
2200 if (Tok.
is(tok::l_paren)) {
2206 if (Tok.
is(tok::code_completion)) {
2213 if (Tok.
is(tok::identifier)) {
2217 Diag(Tok, diag::err_expected)
2221 if (Tok.
isNot(tok::r_paren)) {
2222 Diag(Tok, diag::err_expected) << tok::r_paren;
2226 rparenLoc = ConsumeParen();
2227 if (Tok.
is(tok::less)) {
2228 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2232 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
2235 protocolLAngleLoc, protocolRAngleLoc,
2239 AtLoc, nameId, nameLoc, categoryId, categoryLoc, Attrs);
2247 if (expectIdentifier())
2253 AtLoc, nameId, nameLoc, superClassId, superClassLoc, Attrs);
2255 if (Tok.
is(tok::l_brace))
2256 ParseObjCClassInstanceVariables(ObjCImpDecl, tok::objc_private, AtLoc);
2257 else if (Tok.
is(tok::less)) {
2258 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2263 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
2266 protocolLAngleLoc, protocolRAngleLoc,
2270 assert(ObjCImpDecl);
2275 ObjCImplParsingDataRAII ObjCImplParsing(*
this, ObjCImpDecl);
2276 while (!ObjCImplParsing.isFinished() && !isEofOrEom()) {
2278 MaybeParseCXX11Attributes(DeclAttrs);
2281 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs)) {
2283 DeclsInGroup.append(DG.
begin(), DG.
end());
2293 Parser::ParseObjCAtEndDeclaration(
SourceRange atEnd) {
2295 "ParseObjCAtEndDeclaration(): Expected @end");
2297 if (CurParsedObjCImpl)
2298 CurParsedObjCImpl->finish(atEnd);
2301 Diag(atEnd.
getBegin(), diag::err_expected_objc_container);
2305 Parser::ObjCImplParsingDataRAII::~ObjCImplParsingDataRAII() {
2307 finish(
P.Tok.getLocation());
2308 if (
P.isEofOrEom()) {
2309 P.Diag(
P.Tok, diag::err_objc_missing_end)
2311 P.Diag(Dcl->getBeginLoc(), diag::note_objc_container_start)
2315 P.CurParsedObjCImpl =
nullptr;
2316 assert(LateParsedObjCMethods.empty());
2319 void Parser::ObjCImplParsingDataRAII::finish(
SourceRange AtEnd) {
2321 P.Actions.ObjC().DefaultSynthesizeProperties(
P.getCurScope(), Dcl,
2323 for (
size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
2324 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i],
2327 P.Actions.ObjC().ActOnAtEnd(
P.getCurScope(), AtEnd);
2330 for (
size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
2331 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i],
2335 for (LateParsedObjCMethodContainer::iterator
2336 I = LateParsedObjCMethods.begin(),
2337 E = LateParsedObjCMethods.end(); I != E; ++I)
2339 LateParsedObjCMethods.clear();
2349 "ParseObjCAtAliasDeclaration(): Expected @compatibility_alias");
2351 if (expectIdentifier())
2355 if (expectIdentifier())
2359 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@compatibility_alias");
2377 "ParseObjCPropertySynthesize(): Expected '@synthesize'");
2381 if (Tok.
is(tok::code_completion)) {
2388 if (Tok.
isNot(tok::identifier)) {
2389 Diag(Tok, diag::err_synthesized_property_name);
2400 if (Tok.
is(tok::code_completion)) {
2407 if (expectIdentifier())
2413 getCurScope(), atLoc, propertyLoc,
true, propertyId, propertyIvar,
2415 if (Tok.
isNot(tok::comma))
2419 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@synthesize");
2432 "ParseObjCPropertyDynamic(): Expected '@dynamic'");
2435 bool isClassProperty =
false;
2436 if (Tok.
is(tok::l_paren)) {
2441 Diag(Tok, diag::err_objc_expected_property_attr) << II;
2445 if (II->
isStr(
"class")) {
2446 isClassProperty =
true;
2447 if (Tok.
isNot(tok::r_paren)) {
2448 Diag(Tok, diag::err_expected) << tok::r_paren;
2453 Diag(AttrName, diag::err_objc_expected_property_attr) << II;
2460 if (Tok.
is(tok::code_completion)) {
2467 if (expectIdentifier()) {
2475 getCurScope(), atLoc, propertyLoc,
false, propertyId,
nullptr,
2480 if (Tok.
isNot(tok::comma))
2484 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@dynamic");
2494 if (Tok.
isNot(tok::semi)) {
2502 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@throw");
2512 if (Tok.
isNot(tok::l_paren)) {
2513 Diag(Tok, diag::err_expected_lparen_after) <<
"@synchronized";
2521 if (Tok.
is(tok::r_paren)) {
2524 if (!operand.isInvalid())
2525 Diag(Tok, diag::err_expected) << tok::r_paren;
2532 if (Tok.
isNot(tok::l_brace)) {
2533 if (!operand.isInvalid())
2534 Diag(Tok, diag::err_expected) << tok::l_brace;
2539 if (!operand.isInvalid())
2545 StmtResult body(ParseCompoundStatementBody());
2550 if (operand.isInvalid())
2553 if (body.isInvalid())
2572 bool catch_or_finally_seen =
false;
2575 if (Tok.
isNot(tok::l_brace)) {
2576 Diag(Tok, diag::err_expected) << tok::l_brace;
2582 StmtResult TryBody(ParseCompoundStatementBody());
2584 if (TryBody.isInvalid())
2587 while (Tok.
is(tok::at)) {
2591 Token AfterAt = GetLookAheadToken(1);
2598 Decl *FirstPart =
nullptr;
2600 if (Tok.
is(tok::l_paren)) {
2605 if (Tok.
isNot(tok::ellipsis)) {
2607 ParsedTemplateInfo TemplateInfo;
2608 ParseDeclarationSpecifiers(DS, TemplateInfo);
2611 ParseDeclarator(ParmDecl);
2622 if (Tok.
is(tok::r_paren))
2623 RParenLoc = ConsumeParen();
2628 if (Tok.
is(tok::l_brace))
2629 CatchBody = ParseCompoundStatementBody();
2631 Diag(Tok, diag::err_expected) << tok::l_brace;
2632 if (CatchBody.isInvalid())
2636 AtCatchFinallyLoc, RParenLoc, FirstPart, CatchBody.get());
2637 if (!Catch.isInvalid())
2638 CatchStmts.push_back(Catch.get());
2641 Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after)
2645 catch_or_finally_seen =
true;
2647 assert(Tok.
isObjCAtKeyword(tok::objc_finally) &&
"Lookahead confused?");
2649 ParseScope FinallyScope(
this,
2652 bool ShouldCapture =
2659 if (Tok.
is(tok::l_brace))
2660 FinallyBody = ParseCompoundStatementBody();
2662 Diag(Tok, diag::err_expected) << tok::l_brace;
2664 if (FinallyBody.isInvalid()) {
2668 }
else if (ShouldCapture) {
2674 catch_or_finally_seen =
true;
2678 if (!catch_or_finally_seen) {
2679 Diag(atLoc, diag::err_missing_catch_finally);
2693 if (Tok.
isNot(tok::l_brace)) {
2694 Diag(Tok, diag::err_expected) << tok::l_brace;
2701 StmtResult AutoreleasePoolBody(ParseCompoundStatementBody());
2704 if (AutoreleasePoolBody.isInvalid())
2707 AutoreleasePoolBody.get());
2712 void Parser::StashAwayMethodOrFunctionBodyTokens(
Decl *MDecl) {
2714 trySkippingFunctionBody()) {
2719 LexedMethod* LM =
new LexedMethod(
this, MDecl);
2720 CurParsedObjCImpl->LateParsedObjCMethods.push_back(LM);
2723 Toks.push_back(Tok);
2724 if (Tok.
is(tok::kw_try)) {
2726 if (Tok.
is(tok::colon)) {
2727 Toks.push_back(Tok);
2729 while (Tok.
isNot(tok::l_brace)) {
2730 ConsumeAndStoreUntil(tok::l_paren, Toks,
false);
2731 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
2734 Toks.push_back(Tok);
2736 else if (Tok.
is(tok::colon)) {
2739 while (Tok.
isNot(tok::l_brace)) {
2740 ConsumeAndStoreUntil(tok::l_paren, Toks,
false);
2741 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
2743 Toks.push_back(Tok);
2747 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
2748 while (Tok.
is(tok::kw_catch)) {
2749 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
2750 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
2756 Decl *Parser::ParseObjCMethodDefinition() {
2757 Decl *MDecl = ParseObjCMethodPrototype();
2760 "parsing Objective-C method");
2763 if (Tok.
is(tok::semi)) {
2764 if (CurParsedObjCImpl) {
2765 Diag(Tok, diag::warn_semicolon_before_method_body)
2772 if (Tok.
isNot(tok::l_brace)) {
2773 Diag(Tok, diag::err_expected_method_body);
2779 if (Tok.
isNot(tok::l_brace))
2791 assert (CurParsedObjCImpl
2792 &&
"ParseObjCMethodDefinition - Method out of @implementation");
2794 StashAwayMethodOrFunctionBodyTokens(MDecl);
2799 ParsedStmtContext StmtCtx) {
2800 if (Tok.
is(tok::code_completion)) {
2807 return ParseObjCTryStmt(AtLoc);
2810 return ParseObjCThrowStmt(AtLoc);
2813 return ParseObjCSynchronizedStmt(AtLoc);
2816 return ParseObjCAutoreleasePoolStmt(AtLoc);
2824 ExprStatementTokLoc = AtLoc;
2825 ExprResult Res(ParseExpressionWithLeadingAt(AtLoc));
2835 ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
2836 return handleExprStmt(Res, StmtCtx);
2841 case tok::code_completion:
2851 if (!Tok.
is(tok::numeric_constant)) {
2852 const char *Symbol =
nullptr;
2854 case tok::minus: Symbol =
"-";
break;
2855 case tok::plus: Symbol =
"+";
break;
2856 default: llvm_unreachable(
"missing unary operator case");
2858 Diag(Tok, diag::err_nsnumber_nonliteral_unary)
2864 if (Lit.isInvalid()) {
2870 if (Lit.isInvalid())
2873 return ParsePostfixExpressionSuffix(
2877 case tok::string_literal:
2878 case tok::wide_string_literal:
2879 return ParsePostfixExpressionSuffix(ParseObjCStringLiteral(AtLoc));
2881 case tok::char_constant:
2882 return ParsePostfixExpressionSuffix(ParseObjCCharacterLiteral(AtLoc));
2884 case tok::numeric_constant:
2885 return ParsePostfixExpressionSuffix(ParseObjCNumericLiteral(AtLoc));
2888 case tok::kw___objc_yes:
2889 return ParsePostfixExpressionSuffix(ParseObjCBooleanLiteral(AtLoc,
true));
2891 case tok::kw___objc_no:
2892 return ParsePostfixExpressionSuffix(ParseObjCBooleanLiteral(AtLoc,
false));
2896 return ParsePostfixExpressionSuffix(ParseObjCArrayLiteral(AtLoc));
2900 return ParsePostfixExpressionSuffix(ParseObjCDictionaryLiteral(AtLoc));
2904 return ParsePostfixExpressionSuffix(ParseObjCBoxedExpr(AtLoc));
2911 case tok::objc_encode:
2912 return ParsePostfixExpressionSuffix(ParseObjCEncodeExpression(AtLoc));
2913 case tok::objc_protocol:
2914 return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression(AtLoc));
2915 case tok::objc_selector:
2916 return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression(AtLoc));
2917 case tok::objc_available:
2918 return ParseAvailabilityCheckExpr(AtLoc);
2920 const char *str =
nullptr;
2924 if (GetLookAheadToken(1).is(tok::l_brace) &&
2925 ExprStatementTokLoc == AtLoc) {
2929 : (ch ==
'f' ?
"finally"
2930 : (ch ==
'a' ?
"autoreleasepool" :
nullptr));
2966 bool Parser::ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr) {
2969 if (Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_typename,
2970 tok::annot_cxxscope))
2984 TypeOrExpr = Receiver.
get();
2993 ParseCXXSimpleTypeSpecifier(DS);
2995 if (Tok.
is(tok::l_paren)) {
3008 ExprResult Receiver = ParseCXXTypeConstructExpression(DS);
3010 Receiver = ParsePostfixExpressionSuffix(Receiver.
get());
3012 Receiver = ParseRHSOfBinaryExpression(Receiver.
get(),
prec::Comma);
3017 TypeOrExpr = Receiver.
get();
3027 if (
Type.isInvalid())
3031 TypeOrExpr =
Type.get().getAsOpaquePtr();
3040 bool Parser::isSimpleObjCMessageExpression() {
3042 "Incorrect start for isSimpleObjCMessageExpression");
3043 return GetLookAheadToken(1).
is(tok::identifier) &&
3044 GetLookAheadToken(2).
is(tok::identifier);
3047 bool Parser::isStartOfObjCClassMessageMissingOpenBracket() {
3049 InMessageExpression)
3054 if (Tok.
is(tok::annot_typename))
3056 else if (Tok.
is(tok::identifier))
3064 const Token &AfterNext = GetLookAheadToken(2);
3065 if (AfterNext.
isOneOf(tok::colon, tok::r_square)) {
3066 if (Tok.
is(tok::identifier))
3069 return Tok.
is(tok::annot_typename);
3085 ExprResult Parser::ParseObjCMessageExpression() {
3086 assert(Tok.
is(tok::l_square) &&
"'[' expected");
3089 if (Tok.
is(tok::code_completion)) {
3106 return ParseObjCMessageExpressionBody(LBracLoc,
ConsumeToken(),
nullptr,
3111 void *TypeOrExpr =
nullptr;
3112 if (ParseObjCXXMessageReceiver(IsExpr, TypeOrExpr)) {
3118 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
nullptr,
3119 static_cast<Expr *
>(TypeOrExpr));
3121 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
3126 if (Tok.
is(tok::identifier)) {
3131 getCurScope(), Name, NameLoc, Name == Ident_super,
3132 NextToken().is(tok::period), ReceiverType)) {
3134 return ParseObjCMessageExpressionBody(LBracLoc,
ConsumeToken(),
nullptr,
3138 if (!ReceiverType) {
3146 if (Tok.
is(tok::less)) {
3149 = parseObjCTypeArgsAndProtocolQualifiers(NameLoc, ReceiverType,
3157 ReceiverType = NewReceiverType.
get();
3160 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
3161 ReceiverType,
nullptr);
3176 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
nullptr,
3222 Expr *ReceiverExpr) {
3225 if (Tok.
is(tok::code_completion)) {
3230 else if (ReceiverType)
3232 getCurScope(), ReceiverType, std::nullopt,
false);
3235 getCurScope(), ReceiverExpr, std::nullopt,
false);
3245 ExprVector KeyExprs;
3247 if (Tok.
is(tok::colon)) {
3250 KeyIdents.push_back(selIdent);
3251 KeyLocs.push_back(
Loc);
3253 if (ExpectAndConsume(tok::colon)) {
3263 if (Tok.
is(tok::code_completion)) {
3269 else if (ReceiverType)
3283 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3284 Expr = ParseBraceInitializer();
3298 KeyExprs.push_back(Res.
get());
3301 if (Tok.
is(tok::code_completion)) {
3307 else if (ReceiverType)
3319 selIdent = ParseObjCSelectorPiece(
Loc);
3320 if (!selIdent && Tok.
isNot(tok::colon))
3325 while (Tok.
is(tok::comma)) {
3329 if (Tok.
is(tok::colon))
3332 if (Tok.
is(tok::colon)) {
3333 Diag(commaLoc, diag::note_extra_comma_message_arg) <<
3344 KeyExprs.push_back(Res.
get());
3346 }
else if (!selIdent) {
3347 Diag(Tok, diag::err_expected) << tok::identifier;
3356 if (Tok.
isNot(tok::r_square)) {
3357 Diag(Tok, diag::err_expected)
3358 << (Tok.
is(tok::identifier) ? tok::colon : tok::r_square);
3368 unsigned nKeys = KeyIdents.size();
3370 KeyIdents.push_back(selIdent);
3371 KeyLocs.push_back(
Loc);
3377 getCurScope(), SuperLoc, Sel, LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3378 else if (ReceiverType)
3380 LBracLoc, KeyLocs, RBracLoc,
3383 getCurScope(), ReceiverExpr, Sel, LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3394 ExprVector AtStrings;
3395 AtLocs.push_back(AtLoc);
3396 AtStrings.push_back(Res.
get());
3398 while (Tok.
is(tok::at)) {
3402 if (!isTokenStringLiteral())
3406 if (Lit.isInvalid())
3409 AtStrings.push_back(Lit.get());
3431 if (Lit.isInvalid()) {
3445 if (Lit.isInvalid()) {
3457 if (Tok.
isNot(tok::l_paren))
3458 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@");
3463 if (
T.consumeClose())
3466 if (ValueExpr.isInvalid())
3472 ValueExpr = Actions.
ActOnParenExpr(LPLoc, RPLoc, ValueExpr.get());
3478 ExprVector ElementExprs;
3481 bool HasInvalidEltExpr =
false;
3482 while (Tok.
isNot(tok::r_square)) {
3495 HasInvalidEltExpr =
true;
3498 if (Tok.
is(tok::ellipsis))
3501 HasInvalidEltExpr =
true;
3503 ElementExprs.push_back(Res.
get());
3505 if (Tok.
is(tok::comma))
3507 else if (Tok.
isNot(tok::r_square))
3508 return ExprError(
Diag(Tok, diag::err_expected_either) << tok::r_square
3513 if (HasInvalidEltExpr)
3523 bool HasInvalidEltExpr =
false;
3524 while (Tok.
isNot(tok::r_brace)) {
3539 if (ExpectAndConsume(tok::colon)) {
3545 if (ValueExpr.isInvalid()) {
3556 if (KeyExpr.
isInvalid() || ValueExpr.isInvalid())
3557 HasInvalidEltExpr =
true;
3569 EllipsisLoc, std::nullopt};
3570 Elements.push_back(Element);
3573 return ExprError(
Diag(Tok, diag::err_expected_either) << tok::r_brace
3578 if (HasInvalidEltExpr)
3590 assert(Tok.
isObjCAtKeyword(tok::objc_encode) &&
"Not an @encode expression!");
3594 if (Tok.
isNot(tok::l_paren))
3595 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@encode");
3608 AtLoc, EncLoc,
T.getOpenLocation(), Ty.
get(),
T.getCloseLocation());
3617 if (Tok.
isNot(tok::l_paren))
3618 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@protocol");
3623 if (expectIdentifier())
3632 protocolId, AtLoc, ProtoLoc,
T.getOpenLocation(), ProtoIdLoc,
3633 T.getCloseLocation());
3641 if (Tok.
isNot(tok::l_paren))
3642 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@selector");
3649 bool HasOptionalParen = Tok.
is(tok::l_paren);
3650 if (HasOptionalParen)
3653 if (Tok.
is(tok::code_completion)) {
3661 Tok.
isNot(tok::colon) && Tok.
isNot(tok::coloncolon))
3662 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
3664 KeyIdents.push_back(SelIdent);
3666 unsigned nColons = 0;
3667 if (Tok.
isNot(tok::r_paren)) {
3671 KeyIdents.push_back(
nullptr);
3672 }
else if (ExpectAndConsume(tok::colon))
3676 if (Tok.
is(tok::r_paren))
3679 if (Tok.
is(tok::code_completion)) {
3688 SelIdent = ParseObjCSelectorPiece(
Loc);
3689 KeyIdents.push_back(SelIdent);
3690 if (!SelIdent && Tok.
isNot(tok::colon) && Tok.
isNot(tok::coloncolon))
3694 if (HasOptionalParen && Tok.
is(tok::r_paren))
3699 Sel, AtLoc, SelectorLoc,
T.getOpenLocation(),
T.getCloseLocation(),
3703 void Parser::ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod) {
3705 Decl *MCDecl = LM.D;
3715 assert(!LM.Toks.empty() &&
"ParseLexedObjCMethodDef - Empty body!");
3723 LM.Toks.push_back(Eof);
3726 LM.Toks.push_back(Tok);
3727 PP.EnterTokenStream(LM.Toks,
true,
true);
3732 assert(Tok.
isOneOf(tok::l_brace, tok::kw_try, tok::colon) &&
3733 "Inline objective-c method not starting with '{' or 'try' or ':'");
3746 if (Tok.
is(tok::kw_try))
3747 ParseFunctionTryBlock(MCDecl, BodyScope);
3749 if (Tok.
is(tok::colon))
3750 ParseConstructorInitializer(MCDecl);
3753 ParseFunctionStatementBody(MCDecl, BodyScope);
Defines the clang::ASTContext interface.
static void addContextSensitiveTypeNullability(Parser &P, Declarator &D, NullabilityKind nullability, SourceLocation nullabilityLoc, bool &addedToDeclSpec)
Add an attribute for a context-sensitive type nullability to the given declarator.
static void diagnoseRedundantPropertyNullability(Parser &P, ObjCDeclSpec &DS, NullabilityKind nullability, SourceLocation nullabilityLoc)
Diagnose redundant or conflicting nullability information.
static bool isTopLevelObjCKeyword(tok::ObjCKeywordKind DirectiveKind)
static void takeDeclAttributes(ParsedAttributesView &attrs, ParsedAttributesView &from)
Take all the decl attributes out of the given list and add them to the given attribute set.
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".
ParsedAttributes & getAttributes()
AttributePool & getAttributePool() const
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
SourceLocation getBeginLoc() const LLVM_READONLY
Information about one declarator, including the parsed type information and the identifier.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
AttributePool & getAttributePool() const
const ParsedAttributesView & getDeclarationAttributes() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const ParsedAttributes & getAttributes() const
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
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)
ObjCDeclQualifier getObjCDeclQualifier() const
const IdentifierInfo * getGetterName() const
SourceLocation getNullabilityLoc() const
NullabilityKind getNullability() const
void setGetterName(IdentifierInfo *name, SourceLocation loc)
void setNullability(SourceLocation loc, NullabilityKind kind)
const IdentifierInfo * getSetterName() 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)
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
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.
Scope * getCurScope() const
ObjCContainerDecl * getObjCDeclContext() const
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
bool TryConsumeToken(tok::TokenKind Expected)
const LangOptions & getLangOpts() const
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
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
const TargetInfo & getTargetInfo() const
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
Preprocessor & getPreprocessor() const
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)
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
IdentifierTable & getIdentifierTable()
SelectorTable & getSelectorTable()
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 ...
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)
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)
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.
ASTContext & getASTContext() const
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)
SemaCodeCompletion & CodeCompletion()
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.
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)
IdentifierInfo * getIdentifierInfo() const
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.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
ActionResult< Stmt * > StmtResult
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.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
An element in an Objective-C dictionary literal.
ParsedAttributesView ArgAttrs
ArgAttrs - Attribute list for this argument.