23#include "llvm/ADT/SmallVector.h"
24#include "llvm/ADT/StringExtras.h"
31 if (Tok.
is(tok::kw___attribute)) {
32 if (Kind == tok::objc_interface || Kind == tok::objc_protocol)
33 Diag(Tok, diag::err_objc_postfix_attribute_hint)
34 << (
Kind == tok::objc_protocol);
36 Diag(Tok, diag::err_objc_postfix_attribute);
37 ParseGNUAttributes(attrs);
56 if (Tok.
is(tok::code_completion)) {
63 case tok::objc_interface:
64 case tok::objc_protocol:
65 case tok::objc_implementation:
68 llvm::for_each(DeclAttrs, [
this](
const auto &
Attr) {
74 Decl *SingleDecl =
nullptr;
77 return ParseObjCAtClassDeclaration(AtLoc);
78 case tok::objc_interface:
79 SingleDecl = ParseObjCAtInterfaceDeclaration(AtLoc, DeclAttrs);
81 case tok::objc_protocol:
82 return ParseObjCAtProtocolDeclaration(AtLoc, DeclAttrs);
83 case tok::objc_implementation:
84 return ParseObjCAtImplementationDeclaration(AtLoc, DeclAttrs);
86 return ParseObjCAtEndDeclaration(AtLoc);
87 case tok::objc_compatibility_alias:
88 SingleDecl = ParseObjCAtAliasDeclaration(AtLoc);
90 case tok::objc_synthesize:
91 SingleDecl = ParseObjCPropertySynthesize(AtLoc);
93 case tok::objc_dynamic:
94 SingleDecl = ParseObjCPropertyDynamic(AtLoc);
96 case tok::objc_import:
99 SingleDecl = ParseModuleImport(AtLoc, IS);
102 Diag(AtLoc, diag::err_atimport);
106 Diag(AtLoc, diag::err_unexpected_at);
108 SingleDecl =
nullptr;
122 : Actions(Actions), S(S), Params(nullptr) {}
155 MaybeSkipAttributes(tok::objc_class);
156 if (expectIdentifier()) {
166 if (Tok.
is(tok::less))
167 TypeParams = parseObjCTypeParamList();
168 ClassTypeParams.push_back(TypeParams);
174 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"@class"))
190 if (CurParsedObjCImpl) {
191 CurParsedObjCImpl->finish(AtLoc);
195 Diag(AtLoc, diag::err_objc_missing_end)
233 "ParseObjCAtInterfaceDeclaration(): Expected @interface");
234 CheckNestedObjCContexts(AtLoc);
238 if (Tok.
is(tok::code_completion)) {
244 MaybeSkipAttributes(tok::objc_interface);
246 if (expectIdentifier())
259 ObjCTypeParamListScope typeParamScope(Actions,
getCurScope());
260 if (Tok.
is(tok::less))
261 typeParameterList = parseObjCTypeParamListOrProtocolRefs(
262 typeParamScope, LAngleLoc, ProtocolIdents, EndProtoLoc);
264 if (Tok.
is(tok::l_paren) &&
265 !isKnownToBeTypeSpecifier(GetLookAheadToken(1))) {
272 if (Tok.
is(tok::code_completion)) {
279 if (Tok.
is(tok::identifier)) {
284 Diag(Tok, diag::err_expected)
290 if (T.getCloseLocation().isInvalid())
294 assert(LAngleLoc.
isInvalid() &&
"Cannot have already parsed protocols");
297 if (Tok.
is(tok::less) &&
298 ParseObjCProtocolReferences(ProtocolRefs, ProtocolLocs,
true,
true,
299 LAngleLoc, EndProtoLoc,
304 AtLoc, nameId, nameLoc, typeParameterList, categoryId, categoryLoc,
305 ProtocolRefs.data(), ProtocolRefs.size(), ProtocolLocs.data(),
308 if (Tok.
is(tok::l_brace))
309 ParseObjCClassInstanceVariables(CategoryType, tok::objc_private, AtLoc);
311 ParseObjCInterfaceDeclList(tok::objc_not_keyword, CategoryType);
323 if (Tok.
is(tok::colon)) {
327 if (Tok.
is(tok::code_completion)) {
333 if (expectIdentifier())
339 if (Tok.
is(tok::less)) {
340 parseObjCTypeArgsOrProtocolQualifiers(
341 nullptr, typeArgsLAngleLoc, typeArgs, typeArgsRAngleLoc, LAngleLoc,
342 protocols, protocolLocs, EndProtoLoc,
345 if (Tok.
is(tok::eof))
352 if (!ProtocolIdents.empty()) {
355 for (
const auto &pair : ProtocolIdents) {
356 protocolLocs.push_back(pair.second);
360 ProtocolIdents, protocols);
362 }
else if (protocols.empty() && Tok.
is(tok::less) &&
363 ParseObjCProtocolReferences(protocols, protocolLocs,
true,
true,
364 LAngleLoc, EndProtoLoc,
369 if (Tok.
isNot(tok::less))
371 superClassId, superClassLoc);
375 getCurScope(), AtLoc, nameId, nameLoc, typeParameterList, superClassId,
376 superClassLoc, typeArgs,
377 SourceRange(typeArgsLAngleLoc, typeArgsRAngleLoc), protocols.data(),
378 protocols.size(), protocolLocs.data(), EndProtoLoc, attrs, &SkipBody);
380 if (Tok.
is(tok::l_brace))
381 ParseObjCClassInstanceVariables(ClsType, tok::objc_protected, AtLoc);
383 ParseObjCInterfaceDeclList(tok::objc_interface, ClsType);
386 auto *PreviousDef = cast<ObjCInterfaceDecl>(SkipBody.
Previous);
392 DiagsEmitter.diagnoseMismatch(PreviousDef, ClsType);
406 bool &addedToDeclSpec) {
409 return Pool.create(
P.getNullabilityKeyword(nullability),
411 nullptr, 0, ParsedAttr::Form::ContextSensitiveKeyword());
418 }
else if (!addedToDeclSpec) {
423 addedToDeclSpec =
true;
455 assert(Tok.
is(tok::less) &&
"Not at the beginning of a type parameter list");
463 auto makeProtocolIdentsIntoTypeParameters = [&]() {
465 for (
const auto &pair : protocolIdents) {
470 typeParams.push_back(typeParam.
get());
473 protocolIdents.clear();
474 mayBeProtocolList =
false;
477 bool invalid =
false;
484 if (Tok.
is(tok::kw___covariant) || Tok.
is(tok::kw___contravariant)) {
485 variance = Tok.
is(tok::kw___covariant)
492 if (mayBeProtocolList) {
495 makeProtocolIdentsIntoTypeParameters();
500 if (!Tok.
is(tok::identifier)) {
502 if (Tok.
is(tok::code_completion)) {
512 Diag(Tok, diag::err_objc_expected_type_parameter);
526 if (mayBeProtocolList) {
529 makeProtocolIdentsIntoTypeParameters();
536 }
else if (mayBeProtocolList) {
539 protocolIdents.push_back(std::make_pair(paramName, paramLoc));
545 getCurScope(), variance, varianceLoc, typeParams.size(), paramName,
546 paramLoc, colonLoc, boundType.
isUsable() ? boundType.
get() :
nullptr);
548 typeParams.push_back(typeParam.
get());
554 if (Tok.
is(tok::greater))
556 }
else if (ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc,
559 SkipUntil({tok::greater, tok::greaterequal, tok::at, tok::minus,
560 tok::minus, tok::plus, tok::colon, tok::l_paren, tok::l_brace,
561 tok::comma, tok::semi },
563 if (Tok.
is(tok::greater))
567 if (mayBeProtocolList) {
572 if (Tok.
isNot(tok::colon) && Tok.
isNot(tok::l_paren)) {
581 makeProtocolIdentsIntoTypeParameters();
596 return invalid ? nullptr : list;
606 return parseObjCTypeParamListOrProtocolRefs(
Scope, lAngleLoc, protocolIdents,
633 if (Tok.
isOneOf(tok::minus, tok::plus)) {
634 if (
Decl *methodPrototype =
635 ParseObjCMethodPrototype(MethodImplKind,
false))
636 allMethods.push_back(methodPrototype);
639 if (ExpectAndConsumeSemi(diag::err_expected_semi_after_method_proto)) {
642 if (Tok.
is(tok::semi))
647 if (Tok.
is(tok::l_paren)) {
648 Diag(Tok, diag::err_expected_minus_or_plus);
651 MethodImplKind,
false);
655 if (Tok.
is(tok::semi)) {
667 if (Tok.
is(tok::code_completion)) {
676 if (Tok.
isNot(tok::at)) {
680 if (Tok.
is(tok::r_brace))
689 if (Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
693 DeclEnd, EmptyDeclAttrs,
694 EmptyDeclSpecAttrs));
698 allTUVariables.push_back(ParseDeclarationOrFunctionDefinition(
699 EmptyDeclAttrs, EmptyDeclSpecAttrs));
705 if (Tok.
is(tok::code_completion)) {
713 if (DirectiveKind == tok::objc_end) {
717 }
else if (DirectiveKind == tok::objc_not_keyword) {
718 Diag(Tok, diag::err_objc_unknown_at);
726 switch (DirectiveKind) {
732 Diag(AtLoc, diag::err_objc_illegal_interface_qual);
737 case tok::objc_implementation:
738 case tok::objc_interface:
739 Diag(AtLoc, diag::err_objc_missing_end)
746 case tok::objc_required:
747 case tok::objc_optional:
749 if (contextKey != tok::objc_protocol)
750 Diag(AtLoc, diag::err_objc_directive_only_in_protocol);
755 case tok::objc_property:
759 if (Tok.
is(tok::l_paren)) {
761 ParseObjCPropertyAttribute(OCDS);
764 bool addedToDeclSpec =
false;
766 if (FD.D.getIdentifier() ==
nullptr) {
767 Diag(AtLoc, diag::err_objc_property_requires_field_name)
768 << FD.D.getSourceRange();
771 if (FD.BitfieldSize) {
772 Diag(AtLoc, diag::err_objc_property_bitfield)
773 << FD.D.getSourceRange();
797 FD.D.getIdentifier());
799 getCurScope(), AtLoc, LParenLoc, FD, OCDS, GetterSel, SetterSel,
807 ParseStructDeclaration(DS, ObjCPropertyCallback);
809 ExpectAndConsume(tok::semi, diag::err_expected_semi_decl_list);
816 if (Tok.
is(tok::code_completion)) {
823 Diag(Tok, diag::err_objc_missing_end)
842 P.Diag(nullabilityLoc, diag::warn_nullability_duplicate)
848 P.Diag(nullabilityLoc, diag::err_nullability_conflicting)
880void Parser::ParseObjCPropertyAttribute(
ObjCDeclSpec &DS) {
881 assert(Tok.
getKind() == tok::l_paren);
886 if (Tok.
is(tok::code_completion)) {
901 if (II->
isStr(
"readonly"))
903 else if (II->
isStr(
"assign"))
905 else if (II->
isStr(
"unsafe_unretained"))
907 else if (II->
isStr(
"readwrite"))
909 else if (II->
isStr(
"retain"))
911 else if (II->
isStr(
"strong"))
913 else if (II->
isStr(
"copy"))
915 else if (II->
isStr(
"nonatomic"))
917 else if (II->
isStr(
"atomic"))
919 else if (II->
isStr(
"weak"))
921 else if (II->
isStr(
"getter") || II->
isStr(
"setter")) {
925 unsigned DiagID = IsSetter ? diag::err_objc_expected_equal_for_setter :
926 diag::err_objc_expected_equal_for_getter;
928 if (ExpectAndConsume(tok::equal, DiagID)) {
933 if (Tok.
is(tok::code_completion)) {
946 Diag(Tok, diag::err_objc_expected_selector_for_getter_setter)
956 if (ExpectAndConsume(tok::colon,
957 diag::err_expected_colon_after_setter_name)) {
965 }
else if (II->
isStr(
"nonnull")) {
972 }
else if (II->
isStr(
"nullable")) {
979 }
else if (II->
isStr(
"null_unspecified")) {
986 }
else if (II->
isStr(
"null_resettable")) {
996 }
else if (II->
isStr(
"class")) {
998 }
else if (II->
isStr(
"direct")) {
1001 Diag(AttrName, diag::err_objc_expected_property_attr) << II;
1006 if (Tok.
isNot(tok::comma))
1026 bool MethodDefinition) {
1027 assert(Tok.
isOneOf(tok::minus, tok::plus) &&
"expected +/-");
1031 Decl *MDecl = ParseObjCMethodDecl(mLoc, methodType, MethodImplKind,
1061 case tok::exclaimequal:
1063 case tok::pipeequal:
1065 case tok::caretequal: {
1076 case tok::identifier:
1086 case tok::kw_const_cast:
1087 case tok::kw_continue:
1088 case tok::kw_default:
1089 case tok::kw_delete:
1091 case tok::kw_double:
1092 case tok::kw_dynamic_cast:
1095 case tok::kw_explicit:
1096 case tok::kw_export:
1097 case tok::kw_extern:
1101 case tok::kw_friend:
1104 case tok::kw_inline:
1107 case tok::kw_mutable:
1108 case tok::kw_namespace:
1110 case tok::kw_operator:
1111 case tok::kw_private:
1112 case tok::kw_protected:
1113 case tok::kw_public:
1114 case tok::kw_register:
1115 case tok::kw_reinterpret_cast:
1116 case tok::kw_restrict:
1117 case tok::kw_return:
1119 case tok::kw_signed:
1120 case tok::kw_sizeof:
1121 case tok::kw_static:
1122 case tok::kw_static_cast:
1123 case tok::kw_struct:
1124 case tok::kw_switch:
1125 case tok::kw_template:
1130 case tok::kw_typedef:
1131 case tok::kw_typeid:
1132 case tok::kw_typename:
1133 case tok::kw_typeof:
1135 case tok::kw_unsigned:
1137 case tok::kw_virtual:
1139 case tok::kw_volatile:
1140 case tok::kw_wchar_t:
1143 case tok::kw__Complex:
1144 case tok::kw___alignof:
1145 case tok::kw___auto_type:
1154bool Parser::isTokIdentifier_in()
const {
1181void Parser::ParseObjCTypeQualifierList(
ObjCDeclSpec &DS,
1187 if (Tok.
is(tok::code_completion)) {
1194 if (Tok.
isNot(tok::identifier))
1198 for (
unsigned i = 0; i != objc_NumQuals; ++i) {
1199 if (II != ObjCTypeQuals[i] ||
1207 default: llvm_unreachable(
"Unknown decl qualifier");
1225 case objc_null_unspecified:
1250 for (
auto &AL : llvm::reverse(from)) {
1251 if (!AL.isUsedAsTypeAttr()) {
1286 assert((paramAttrs !=
nullptr) ==
1289 assert(Tok.
is(tok::l_paren) &&
"expected (");
1297 ParseObjCTypeQualifierList(DS, context);
1301 if (isTypeSpecifierQualifier() || isObjCInstancetype()) {
1304 declSpec.setObjCQualifiers(&DS);
1305 DeclSpecContext dsContext = DeclSpecContext::DSC_normal;
1307 dsContext = DeclSpecContext::DSC_objc_method_result;
1308 ParseSpecifierQualifierList(declSpec,
AS_none, dsContext);
1310 ParseDeclarator(declarator);
1313 if (!declarator.isInvalidType()) {
1315 bool addedToDeclSpec =
false;
1323 if (!
type.isInvalid())
1333 if (Tok.
is(tok::r_paren))
1337 Diag(Tok, diag::err_expected_type);
1378 bool MethodDefinition) {
1381 if (Tok.
is(tok::code_completion)) {
1391 if (Tok.
is(tok::l_paren))
1397 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1400 if (Tok.
is(tok::code_completion)) {
1412 if (!SelIdent && Tok.
isNot(tok::colon)) {
1413 Diag(Tok, diag::err_expected_selector_for_method)
1421 if (Tok.
isNot(tok::colon)) {
1423 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1429 selLoc, Sel,
nullptr, CParamInfo.data(), CParamInfo.size(), methodAttrs,
1430 MethodImplKind,
false, MethodDefinition);
1447 if (ExpectAndConsume(tok::colon))
1450 ArgInfo.
Type =
nullptr;
1451 if (Tok.
is(tok::l_paren))
1452 ArgInfo.
Type = ParseObjCTypeName(
1457 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1462 if (Tok.
is(tok::code_completion)) {
1464 KeyIdents.push_back(SelIdent);
1466 mType == tok::minus,
1468 ReturnType, KeyIdents);
1472 if (expectIdentifier())
1479 ArgInfos.push_back(ArgInfo);
1480 KeyIdents.push_back(SelIdent);
1481 KeyLocs.push_back(selLoc);
1484 allParamAttrs.takeAllFrom(paramAttrs.
getPool());
1487 if (Tok.
is(tok::code_completion)) {
1490 mType == tok::minus,
1492 ReturnType, KeyIdents);
1497 SelIdent = ParseObjCSelectorPiece(selLoc);
1498 if (!SelIdent && Tok.
isNot(tok::colon))
1503 Diag(ArgInfo.
NameLoc, diag::warn_missing_selector_name) << ArgInfo.
Name;
1504 Diag(ArgInfo.
NameLoc, diag::note_missing_selector_name) << ArgInfo.
Name;
1505 Diag(ColonLoc, diag::note_force_empty_selector_name) << ArgInfo.
Name;
1511 bool isVariadic =
false;
1512 bool cStyleParamWarned =
false;
1514 while (Tok.
is(tok::comma)) {
1516 if (Tok.
is(tok::ellipsis)) {
1521 if (!cStyleParamWarned) {
1522 Diag(Tok, diag::warn_cstyle_param);
1523 cStyleParamWarned =
true;
1526 ParseDeclarationSpecifiers(DS);
1530 ParseDeclarator(ParmDecl);
1534 ParmDecl.getIdentifierLoc(),
1541 MaybeParseAttributes(PAKM_CXX11 | (
getLangOpts().
ObjC ? PAKM_GNU : 0),
1544 if (KeyIdents.size() == 0)
1551 Sel, &ArgInfos[0], CParamInfo.data(), CParamInfo.size(), methodAttrs,
1552 MethodImplKind, isVariadic, MethodDefinition);
1564 bool WarnOnDeclarations,
bool ForObjCContainer,
1566 bool consumeLastToken) {
1567 assert(Tok.
is(tok::less) &&
"expected <");
1574 if (Tok.
is(tok::code_completion)) {
1580 if (expectIdentifier()) {
1594 if (ParseGreaterThanInTemplateList(LAngleLoc, EndLoc, consumeLastToken,
1600 ProtocolIdents, Protocols);
1605 assert(Tok.
is(tok::less) &&
"Protocol qualifiers start with '<'");
1606 assert(
getLangOpts().
ObjC &&
"Protocol qualifiers only exist in Objective-C");
1611 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
false,
false,
1612 lAngleLoc, rAngleLoc,
1619 Diag(lAngleLoc, diag::warn_objc_protocol_qualifier_missing_id)
1632void Parser::parseObjCTypeArgsOrProtocolQualifiers(
1641 bool consumeLastToken,
1642 bool warnOnIncompleteProtocols) {
1643 assert(Tok.
is(tok::less) &&
"Not at the start of type args or protocols");
1648 bool allSingleIdentifiers =
true;
1656 if (Tok.
is(tok::identifier) &&
1665 if (Tok.
is(tok::code_completion)) {
1668 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1670 identifierLocs[i]));
1683 allSingleIdentifiers =
false;
1689 if (allSingleIdentifiers) {
1692 (void)ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc, consumeLastToken,
1708 warnOnIncompleteProtocols);
1718 bool invalid =
false;
1719 IdentifierInfo *foundProtocolId =
nullptr, *foundValidTypeId =
nullptr;
1724 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1729 const char *prevSpec =
nullptr;
1731 DS.SetTypeSpecType(
TST_typename, identifierLocs[i], prevSpec, diagID,
1739 typeArgs.push_back(fullTypeArg.
get());
1740 if (!foundValidTypeId) {
1741 foundValidTypeId = identifiers[i];
1742 foundValidTypeSrcLoc = identifierLocs[i];
1746 unknownTypeArgs.push_back(identifiers[i]);
1747 unknownTypeArgsLoc.push_back(identifierLocs[i]);
1751 if (!Actions.
LookupProtocol(identifiers[i], identifierLocs[i])) {
1752 unknownTypeArgs.push_back(identifiers[i]);
1753 unknownTypeArgsLoc.push_back(identifierLocs[i]);
1754 }
else if (!foundProtocolId) {
1755 foundProtocolId = identifiers[i];
1756 foundProtocolSrcLoc = identifierLocs[i];
1763 Token CurTypeTok = Tok;
1774 typeArgs.push_back(typeArg.
get());
1775 if (!foundValidTypeId) {
1785 if (foundProtocolId && foundValidTypeId)
1788 foundValidTypeSrcLoc);
1792 if (unknownTypeArgs.size())
1793 for (
unsigned i = 0, e = unknownTypeArgsLoc.size(); i < e; ++i)
1799 (void)ParseGreaterThanInTemplateList(lAngleLoc, rAngleLoc, consumeLastToken,
1808 typeArgsLAngleLoc = lAngleLoc;
1809 typeArgsRAngleLoc = rAngleLoc;
1812void Parser::parseObjCTypeArgsAndProtocolQualifiers(
1821 bool consumeLastToken) {
1822 assert(Tok.
is(tok::less));
1825 parseObjCTypeArgsOrProtocolQualifiers(baseType,
1835 if (Tok.
is(tok::eof))
1841 if ((consumeLastToken && Tok.
is(tok::less)) ||
1842 (!consumeLastToken &&
NextToken().is(tok::less))) {
1845 if (!consumeLastToken)
1848 if (!protocols.empty()) {
1850 if (!consumeLastToken)
1852 Diag(Tok, diag::err_objc_type_args_after_protocols)
1853 <<
SourceRange(protocolLAngleLoc, protocolRAngleLoc);
1854 SkipUntil(tok::greater, tok::greatergreater, skipFlags);
1856 ParseObjCProtocolReferences(protocols, protocolLocs,
1859 protocolLAngleLoc, protocolRAngleLoc,
1865TypeResult Parser::parseObjCTypeArgsAndProtocolQualifiers(
1868 bool consumeLastToken,
1870 assert(Tok.
is(tok::less));
1880 parseObjCTypeArgsAndProtocolQualifiers(
type, typeArgsLAngleLoc, typeArgs,
1881 typeArgsRAngleLoc, protocolLAngleLoc,
1882 protocols, protocolLocs,
1883 protocolRAngleLoc, consumeLastToken);
1885 if (Tok.
is(tok::eof))
1889 if (consumeLastToken)
1890 endLoc = PrevTokLocation;
1907void Parser::HelperActionsForIvarDeclarations(
1910 bool RBraceMissing) {
1915 "Ivars should have interfaceDecl as their decl context");
1948 assert(Tok.
is(tok::l_brace) &&
"expected {");
1956 while (Tok.
isNot(tok::r_brace) && !isEofOrEom()) {
1960 if (Tok.
is(tok::semi)) {
1961 ConsumeExtraSemi(InstanceVariableList);
1967 if (Tok.
is(tok::code_completion)) {
1974 case tok::objc_private:
1975 case tok::objc_public:
1976 case tok::objc_protected:
1977 case tok::objc_package:
1983 Diag(Tok, diag::err_objc_unexpected_atend);
1988 HelperActionsForIvarDeclarations(interfaceDecl, atLoc,
1989 T, AllIvarDecls,
true);
1993 Diag(Tok, diag::err_objc_illegal_visibility_spec);
1998 if (Tok.
is(tok::code_completion)) {
2008 if (Tok.
isOneOf(tok::kw_static_assert, tok::kw__Static_assert)) {
2010 ParseStaticAssertDeclaration(DeclEnd);
2016 "Ivar should have interfaceDecl as its decl context");
2018 FD.D.setObjCIvar(
true);
2020 getCurScope(), FD.D.getDeclSpec().getSourceRange().getBegin(), FD.D,
2021 FD.BitfieldSize, visibility);
2023 AllIvarDecls.push_back(Field);
2029 ParseStructDeclaration(DS, ObjCIvarCallback);
2031 if (Tok.
is(tok::semi)) {
2034 Diag(Tok, diag::err_expected_semi_decl_list);
2039 HelperActionsForIvarDeclarations(interfaceDecl, atLoc,
2040 T, AllIvarDecls,
false);
2063 "ParseObjCAtProtocolDeclaration(): Expected @protocol");
2066 if (Tok.
is(tok::code_completion)) {
2072 MaybeSkipAttributes(tok::objc_protocol);
2074 if (expectIdentifier())
2085 CheckNestedObjCContexts(AtLoc);
2087 if (Tok.
is(tok::comma)) {
2089 ProtocolRefs.push_back(std::make_pair(protocolName, nameLoc));
2094 if (expectIdentifier()) {
2102 if (Tok.
isNot(tok::comma))
2106 if (ExpectAndConsume(tok::semi, diag::err_expected_after,
"@protocol"))
2117 if (Tok.
is(tok::less) &&
2118 ParseObjCProtocolReferences(ProtocolRefs, ProtocolLocs,
false,
true,
2119 LAngleLoc, EndProtoLoc,
2125 AtLoc, protocolName, nameLoc, ProtocolRefs.data(), ProtocolRefs.size(),
2126 ProtocolLocs.data(), EndProtoLoc, attrs, &SkipBody);
2128 ParseObjCInterfaceDeclList(tok::objc_protocol, ProtoType);
2130 auto *PreviousDef = cast<ObjCProtocolDecl>(SkipBody.
Previous);
2133 PreviousDef->getDefinition());
2137 DiagsEmitter.diagnoseMismatch(PreviousDef, ProtoType);
2154Parser::ParseObjCAtImplementationDeclaration(
SourceLocation AtLoc,
2157 "ParseObjCAtImplementationDeclaration(): Expected @implementation");
2158 CheckNestedObjCContexts(AtLoc);
2162 if (Tok.
is(tok::code_completion)) {
2168 MaybeSkipAttributes(tok::objc_implementation);
2170 if (expectIdentifier())
2179 if (Tok.
is(tok::less)) {
2183 ObjCTypeParamListScope typeParamScope(Actions,
getCurScope());
2184 if (parseObjCTypeParamListOrProtocolRefs(typeParamScope, lAngleLoc,
2185 protocolIdents, rAngleLoc)) {
2186 Diag(diagLoc, diag::err_objc_parameterized_implementation)
2188 }
else if (lAngleLoc.
isValid()) {
2189 Diag(lAngleLoc, diag::err_unexpected_protocol_qualifier)
2194 if (Tok.
is(tok::l_paren)) {
2200 if (Tok.
is(tok::code_completion)) {
2206 if (Tok.
is(tok::identifier)) {
2210 Diag(Tok, diag::err_expected)
2214 if (Tok.
isNot(tok::r_paren)) {
2215 Diag(Tok, diag::err_expected) << tok::r_paren;
2219 rparenLoc = ConsumeParen();
2220 if (Tok.
is(tok::less)) {
2221 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2225 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
2228 protocolLAngleLoc, protocolRAngleLoc,
2232 AtLoc, nameId, nameLoc, categoryId, categoryLoc, Attrs);
2240 if (expectIdentifier())
2246 AtLoc, nameId, nameLoc, superClassId, superClassLoc, Attrs);
2248 if (Tok.
is(tok::l_brace))
2249 ParseObjCClassInstanceVariables(ObjCImpDecl, tok::objc_private, AtLoc);
2250 else if (Tok.
is(tok::less)) {
2251 Diag(Tok, diag::err_unexpected_protocol_qualifier);
2256 (void)ParseObjCProtocolReferences(protocols, protocolLocs,
2259 protocolLAngleLoc, protocolRAngleLoc,
2263 assert(ObjCImpDecl);
2268 ObjCImplParsingDataRAII ObjCImplParsing(*
this, ObjCImpDecl);
2269 while (!ObjCImplParsing.isFinished() && !isEofOrEom()) {
2271 MaybeParseCXX11Attributes(DeclAttrs);
2274 ParseExternalDeclaration(DeclAttrs, EmptyDeclSpecAttrs)) {
2276 DeclsInGroup.append(DG.
begin(), DG.
end());
2285Parser::ParseObjCAtEndDeclaration(
SourceRange atEnd) {
2287 "ParseObjCAtEndDeclaration(): Expected @end");
2289 if (CurParsedObjCImpl)
2290 CurParsedObjCImpl->finish(atEnd);
2293 Diag(atEnd.
getBegin(), diag::err_expected_objc_container);
2297Parser::ObjCImplParsingDataRAII::~ObjCImplParsingDataRAII() {
2299 finish(
P.Tok.getLocation());
2300 if (
P.isEofOrEom()) {
2301 P.Diag(
P.Tok, diag::err_objc_missing_end)
2303 P.Diag(Dcl->getBeginLoc(), diag::note_objc_container_start)
2307 P.CurParsedObjCImpl =
nullptr;
2308 assert(LateParsedObjCMethods.empty());
2311void Parser::ObjCImplParsingDataRAII::finish(
SourceRange AtEnd) {
2313 P.Actions.DefaultSynthesizeProperties(
P.getCurScope(), Dcl, AtEnd.
getBegin());
2314 for (
size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
2315 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i],
2318 P.Actions.ActOnAtEnd(
P.getCurScope(), AtEnd);
2321 for (
size_t i = 0; i < LateParsedObjCMethods.size(); ++i)
2322 P.ParseLexedObjCMethodDefs(*LateParsedObjCMethods[i],
2326 for (LateParsedObjCMethodContainer::iterator
2327 I = LateParsedObjCMethods.begin(),
2328 E = LateParsedObjCMethods.end(); I != E; ++I)
2330 LateParsedObjCMethods.clear();
2340 "ParseObjCAtAliasDeclaration(): Expected @compatibility_alias");
2342 if (expectIdentifier())
2346 if (expectIdentifier())
2350 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@compatibility_alias");
2368 "ParseObjCPropertySynthesize(): Expected '@synthesize'");
2372 if (Tok.
is(tok::code_completion)) {
2378 if (Tok.
isNot(tok::identifier)) {
2379 Diag(Tok, diag::err_synthesized_property_name);
2390 if (Tok.
is(tok::code_completion)) {
2396 if (expectIdentifier())
2403 propertyId, propertyIvar, propertyIvarLoc,
2405 if (Tok.
isNot(tok::comma))
2409 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@synthesize");
2422 "ParseObjCPropertyDynamic(): Expected '@dynamic'");
2425 bool isClassProperty =
false;
2426 if (Tok.
is(tok::l_paren)) {
2431 Diag(Tok, diag::err_objc_expected_property_attr) << II;
2435 if (II->
isStr(
"class")) {
2436 isClassProperty =
true;
2437 if (Tok.
isNot(tok::r_paren)) {
2438 Diag(Tok, diag::err_expected) << tok::r_paren;
2443 Diag(AttrName, diag::err_objc_expected_property_attr) << II;
2450 if (Tok.
is(tok::code_completion)) {
2456 if (expectIdentifier()) {
2469 if (Tok.
isNot(tok::comma))
2473 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@dynamic");
2483 if (Tok.
isNot(tok::semi)) {
2491 ExpectAndConsume(tok::semi, diag::err_expected_after,
"@throw");
2501 if (Tok.
isNot(tok::l_paren)) {
2502 Diag(Tok, diag::err_expected_lparen_after) <<
"@synchronized";
2510 if (Tok.
is(tok::r_paren)) {
2513 if (!operand.isInvalid())
2514 Diag(Tok, diag::err_expected) << tok::r_paren;
2521 if (Tok.
isNot(tok::l_brace)) {
2522 if (!operand.isInvalid())
2523 Diag(Tok, diag::err_expected) << tok::l_brace;
2528 if (!operand.isInvalid())
2533 StmtResult body(ParseCompoundStatementBody());
2538 if (operand.isInvalid())
2541 if (body.isInvalid())
2559 bool catch_or_finally_seen =
false;
2562 if (Tok.
isNot(tok::l_brace)) {
2563 Diag(Tok, diag::err_expected) << tok::l_brace;
2569 StmtResult TryBody(ParseCompoundStatementBody());
2571 if (TryBody.isInvalid())
2574 while (Tok.
is(tok::at)) {
2578 Token AfterAt = GetLookAheadToken(1);
2585 Decl *FirstPart =
nullptr;
2587 if (Tok.
is(tok::l_paren)) {
2592 if (Tok.
isNot(tok::ellipsis)) {
2594 ParseDeclarationSpecifiers(DS);
2597 ParseDeclarator(ParmDecl);
2607 if (Tok.
is(tok::r_paren))
2608 RParenLoc = ConsumeParen();
2613 if (Tok.
is(tok::l_brace))
2614 CatchBody = ParseCompoundStatementBody();
2616 Diag(Tok, diag::err_expected) << tok::l_brace;
2617 if (CatchBody.isInvalid())
2625 CatchStmts.push_back(Catch.
get());
2628 Diag(AtCatchFinallyLoc, diag::err_expected_lparen_after)
2632 catch_or_finally_seen =
true;
2634 assert(Tok.
isObjCAtKeyword(tok::objc_finally) &&
"Lookahead confused?");
2636 ParseScope FinallyScope(
this,
2639 bool ShouldCapture =
2646 if (Tok.
is(tok::l_brace))
2647 FinallyBody = ParseCompoundStatementBody();
2649 Diag(Tok, diag::err_expected) << tok::l_brace;
2651 if (FinallyBody.isInvalid()) {
2655 }
else if (ShouldCapture) {
2661 catch_or_finally_seen =
true;
2665 if (!catch_or_finally_seen) {
2666 Diag(atLoc, diag::err_missing_catch_finally);
2681 if (Tok.
isNot(tok::l_brace)) {
2682 Diag(Tok, diag::err_expected) << tok::l_brace;
2689 StmtResult AutoreleasePoolBody(ParseCompoundStatementBody());
2692 if (AutoreleasePoolBody.isInvalid())
2695 AutoreleasePoolBody.get());
2700void Parser::StashAwayMethodOrFunctionBodyTokens(
Decl *MDecl) {
2702 trySkippingFunctionBody()) {
2707 LexedMethod* LM =
new LexedMethod(
this, MDecl);
2708 CurParsedObjCImpl->LateParsedObjCMethods.push_back(LM);
2711 Toks.push_back(Tok);
2712 if (Tok.
is(tok::kw_try)) {
2714 if (Tok.
is(tok::colon)) {
2715 Toks.push_back(Tok);
2717 while (Tok.
isNot(tok::l_brace)) {
2718 ConsumeAndStoreUntil(tok::l_paren, Toks,
false);
2719 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
2722 Toks.push_back(Tok);
2724 else if (Tok.
is(tok::colon)) {
2727 while (Tok.
isNot(tok::l_brace)) {
2728 ConsumeAndStoreUntil(tok::l_paren, Toks,
false);
2729 ConsumeAndStoreUntil(tok::r_paren, Toks,
false);
2731 Toks.push_back(Tok);
2735 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
2736 while (Tok.
is(tok::kw_catch)) {
2737 ConsumeAndStoreUntil(tok::l_brace, Toks,
false);
2738 ConsumeAndStoreUntil(tok::r_brace, Toks,
false);
2744Decl *Parser::ParseObjCMethodDefinition() {
2745 Decl *MDecl = ParseObjCMethodPrototype();
2748 "parsing Objective-C method");
2751 if (Tok.
is(tok::semi)) {
2752 if (CurParsedObjCImpl) {
2753 Diag(Tok, diag::warn_semicolon_before_method_body)
2760 if (Tok.
isNot(tok::l_brace)) {
2761 Diag(Tok, diag::err_expected_method_body);
2767 if (Tok.
isNot(tok::l_brace))
2779 assert (CurParsedObjCImpl
2780 &&
"ParseObjCMethodDefinition - Method out of @implementation");
2782 StashAwayMethodOrFunctionBodyTokens(MDecl);
2787 ParsedStmtContext StmtCtx) {
2788 if (Tok.
is(tok::code_completion)) {
2795 return ParseObjCTryStmt(AtLoc);
2798 return ParseObjCThrowStmt(AtLoc);
2801 return ParseObjCSynchronizedStmt(AtLoc);
2804 return ParseObjCAutoreleasePoolStmt(AtLoc);
2812 ExprStatementTokLoc = AtLoc;
2813 ExprResult Res(ParseExpressionWithLeadingAt(AtLoc));
2823 ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
2824 return handleExprStmt(Res, StmtCtx);
2829 case tok::code_completion:
2839 if (!Tok.
is(tok::numeric_constant)) {
2840 const char *Symbol =
nullptr;
2842 case tok::minus: Symbol =
"-";
break;
2843 case tok::plus: Symbol =
"+";
break;
2844 default: llvm_unreachable(
"missing unary operator case");
2846 Diag(Tok, diag::err_nsnumber_nonliteral_unary)
2852 if (Lit.isInvalid()) {
2858 if (Lit.isInvalid())
2861 return ParsePostfixExpressionSuffix(
2865 case tok::string_literal:
2866 case tok::wide_string_literal:
2867 return ParsePostfixExpressionSuffix(ParseObjCStringLiteral(AtLoc));
2869 case tok::char_constant:
2870 return ParsePostfixExpressionSuffix(ParseObjCCharacterLiteral(AtLoc));
2872 case tok::numeric_constant:
2873 return ParsePostfixExpressionSuffix(ParseObjCNumericLiteral(AtLoc));
2876 case tok::kw___objc_yes:
2877 return ParsePostfixExpressionSuffix(ParseObjCBooleanLiteral(AtLoc,
true));
2879 case tok::kw___objc_no:
2880 return ParsePostfixExpressionSuffix(ParseObjCBooleanLiteral(AtLoc,
false));
2884 return ParsePostfixExpressionSuffix(ParseObjCArrayLiteral(AtLoc));
2888 return ParsePostfixExpressionSuffix(ParseObjCDictionaryLiteral(AtLoc));
2892 return ParsePostfixExpressionSuffix(ParseObjCBoxedExpr(AtLoc));
2899 case tok::objc_encode:
2900 return ParsePostfixExpressionSuffix(ParseObjCEncodeExpression(AtLoc));
2901 case tok::objc_protocol:
2902 return ParsePostfixExpressionSuffix(ParseObjCProtocolExpression(AtLoc));
2903 case tok::objc_selector:
2904 return ParsePostfixExpressionSuffix(ParseObjCSelectorExpression(AtLoc));
2905 case tok::objc_available:
2906 return ParseAvailabilityCheckExpr(AtLoc);
2908 const char *str =
nullptr;
2912 if (GetLookAheadToken(1).is(tok::l_brace) &&
2913 ExprStatementTokLoc == AtLoc) {
2917 : (ch ==
'f' ?
"finally"
2918 : (ch ==
'a' ?
"autoreleasepool" :
nullptr));
2954bool Parser::ParseObjCXXMessageReceiver(
bool &IsExpr,
void *&TypeOrExpr) {
2957 if (Tok.
isOneOf(tok::identifier, tok::coloncolon, tok::kw_typename,
2958 tok::annot_cxxscope))
2972 TypeOrExpr = Receiver.
get();
2981 ParseCXXSimpleTypeSpecifier(DS);
2983 if (Tok.
is(tok::l_paren)) {
2996 ExprResult Receiver = ParseCXXTypeConstructExpression(DS);
2998 Receiver = ParsePostfixExpressionSuffix(Receiver.
get());
3000 Receiver = ParseRHSOfBinaryExpression(Receiver.
get(),
prec::Comma);
3005 TypeOrExpr = Receiver.
get();
3015 if (
Type.isInvalid())
3019 TypeOrExpr =
Type.get().getAsOpaquePtr();
3028bool Parser::isSimpleObjCMessageExpression() {
3030 "Incorrect start for isSimpleObjCMessageExpression");
3031 return GetLookAheadToken(1).
is(tok::identifier) &&
3032 GetLookAheadToken(2).
is(tok::identifier);
3035bool Parser::isStartOfObjCClassMessageMissingOpenBracket() {
3037 InMessageExpression)
3042 if (Tok.
is(tok::annot_typename))
3044 else if (Tok.
is(tok::identifier))
3052 const Token &AfterNext = GetLookAheadToken(2);
3053 if (AfterNext.
isOneOf(tok::colon, tok::r_square)) {
3054 if (Tok.
is(tok::identifier))
3057 return Tok.
is(tok::annot_typename);
3073ExprResult Parser::ParseObjCMessageExpression() {
3074 assert(Tok.
is(tok::l_square) &&
"'[' expected");
3077 if (Tok.
is(tok::code_completion)) {
3094 return ParseObjCMessageExpressionBody(LBracLoc,
ConsumeToken(),
nullptr,
3099 void *TypeOrExpr =
nullptr;
3100 if (ParseObjCXXMessageReceiver(IsExpr, TypeOrExpr)) {
3106 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
nullptr,
3107 static_cast<Expr *
>(TypeOrExpr));
3109 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
3114 if (Tok.
is(tok::identifier)) {
3119 Name == Ident_super,
3123 return ParseObjCMessageExpressionBody(LBracLoc,
ConsumeToken(),
nullptr,
3127 if (!ReceiverType) {
3135 if (Tok.
is(tok::less)) {
3138 = parseObjCTypeArgsAndProtocolQualifiers(NameLoc, ReceiverType,
3146 ReceiverType = NewReceiverType.
get();
3149 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
3150 ReceiverType,
nullptr);
3165 return ParseObjCMessageExpressionBody(LBracLoc,
SourceLocation(),
nullptr,
3211 Expr *ReceiverExpr) {
3214 if (Tok.
is(tok::code_completion)) {
3218 std::nullopt,
false);
3219 else if (ReceiverType)
3221 std::nullopt,
false);
3224 std::nullopt,
false);
3234 ExprVector KeyExprs;
3236 if (Tok.
is(tok::colon)) {
3239 KeyIdents.push_back(selIdent);
3240 KeyLocs.push_back(Loc);
3242 if (ExpectAndConsume(tok::colon)) {
3252 if (Tok.
is(tok::code_completion)) {
3258 else if (ReceiverType)
3272 Diag(Tok, diag::warn_cxx98_compat_generalized_initializer_lists);
3273 Expr = ParseBraceInitializer();
3287 KeyExprs.push_back(Res.
get());
3290 if (Tok.
is(tok::code_completion)) {
3296 else if (ReceiverType)
3308 selIdent = ParseObjCSelectorPiece(Loc);
3309 if (!selIdent && Tok.
isNot(tok::colon))
3314 while (Tok.
is(tok::comma)) {
3318 if (Tok.
is(tok::colon))
3321 if (Tok.
is(tok::colon)) {
3322 Diag(commaLoc, diag::note_extra_comma_message_arg) <<
3333 KeyExprs.push_back(Res.
get());
3335 }
else if (!selIdent) {
3336 Diag(Tok, diag::err_expected) << tok::identifier;
3345 if (Tok.
isNot(tok::r_square)) {
3346 Diag(Tok, diag::err_expected)
3347 << (Tok.
is(tok::identifier) ? tok::colon : tok::r_square);
3357 unsigned nKeys = KeyIdents.size();
3359 KeyIdents.push_back(selIdent);
3360 KeyLocs.push_back(Loc);
3366 LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3367 else if (ReceiverType)
3369 LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3371 LBracLoc, KeyLocs, RBracLoc, KeyExprs);
3382 ExprVector AtStrings;
3383 AtLocs.push_back(AtLoc);
3384 AtStrings.push_back(Res.
get());
3386 while (Tok.
is(tok::at)) {
3390 if (!isTokenStringLiteral())
3394 if (Lit.isInvalid())
3397 AtStrings.push_back(Lit.get());
3419 if (Lit.isInvalid()) {
3433 if (Lit.isInvalid()) {
3445 if (Tok.
isNot(tok::l_paren))
3446 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@");
3454 if (ValueExpr.isInvalid())
3460 ValueExpr = Actions.
ActOnParenExpr(LPLoc, RPLoc, ValueExpr.get());
3466 ExprVector ElementExprs;
3469 bool HasInvalidEltExpr =
false;
3470 while (Tok.
isNot(tok::r_square)) {
3483 HasInvalidEltExpr =
true;
3486 if (Tok.
is(tok::ellipsis))
3489 HasInvalidEltExpr =
true;
3491 ElementExprs.push_back(Res.
get());
3493 if (Tok.
is(tok::comma))
3495 else if (Tok.
isNot(tok::r_square))
3496 return ExprError(
Diag(Tok, diag::err_expected_either) << tok::r_square
3501 if (HasInvalidEltExpr)
3511 bool HasInvalidEltExpr =
false;
3512 while (Tok.
isNot(tok::r_brace)) {
3527 if (ExpectAndConsume(tok::colon)) {
3533 if (ValueExpr.isInvalid()) {
3544 if (KeyExpr.
isInvalid() || ValueExpr.isInvalid())
3545 HasInvalidEltExpr =
true;
3557 EllipsisLoc, std::nullopt};
3558 Elements.push_back(Element);
3561 return ExprError(
Diag(Tok, diag::err_expected_either) << tok::r_brace
3566 if (HasInvalidEltExpr)
3578 assert(Tok.
isObjCAtKeyword(tok::objc_encode) &&
"Not an @encode expression!");
3582 if (Tok.
isNot(tok::l_paren))
3583 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@encode");
3605 if (Tok.
isNot(tok::l_paren))
3606 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@protocol");
3611 if (expectIdentifier())
3629 if (Tok.
isNot(tok::l_paren))
3630 return ExprError(
Diag(Tok, diag::err_expected_lparen_after) <<
"@selector");
3637 bool HasOptionalParen = Tok.
is(tok::l_paren);
3638 if (HasOptionalParen)
3641 if (Tok.
is(tok::code_completion)) {
3649 Tok.
isNot(tok::colon) && Tok.
isNot(tok::coloncolon))
3650 return ExprError(
Diag(Tok, diag::err_expected) << tok::identifier);
3652 KeyIdents.push_back(SelIdent);
3654 unsigned nColons = 0;
3655 if (Tok.
isNot(tok::r_paren)) {
3659 KeyIdents.push_back(
nullptr);
3660 }
else if (ExpectAndConsume(tok::colon))
3664 if (Tok.
is(tok::r_paren))
3667 if (Tok.
is(tok::code_completion)) {
3675 SelIdent = ParseObjCSelectorPiece(Loc);
3676 KeyIdents.push_back(SelIdent);
3677 if (!SelIdent && Tok.
isNot(tok::colon) && Tok.
isNot(tok::coloncolon))
3681 if (HasOptionalParen && Tok.
is(tok::r_paren))
3691void Parser::ParseLexedObjCMethodDefs(LexedMethod &LM,
bool parseMethod) {
3693 Decl *MCDecl = LM.D;
3694 bool skip = MCDecl &&
3703 assert(!LM.Toks.empty() &&
"ParseLexedObjCMethodDef - Empty body!");
3711 LM.Toks.push_back(Eof);
3714 LM.Toks.push_back(Tok);
3715 PP.EnterTokenStream(LM.Toks,
true,
true);
3720 assert(Tok.
isOneOf(tok::l_brace, tok::kw_try, tok::colon) &&
3721 "Inline objective-c method not starting with '{' or 'try' or ':'");
3733 if (Tok.
is(tok::kw_try))
3734 ParseFunctionTryBlock(MCDecl, BodyScope);
3736 if (Tok.
is(tok::colon))
3737 ParseConstructorInitializer(MCDecl);
3740 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 void takeDeclAttributes(ParsedAttributesView &attrs, ParsedAttributesView &from)
Take all the decl attributes out of the given list and add them to the given attribute set.
Class to handle popping type parameters when leaving the scope.
ObjCTypeParamListScope(Sema &Actions, Scope *S)
void enter(ObjCTypeParamList *P)
~ObjCTypeParamListScope()
const clang::PrintingPolicy & getPrintingPolicy() const
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
Attr - This represents one attribute.
bool isGNUAttribute() const
void takeAllFrom(AttributePool &pool)
Take the given pool's allocations and add them to this pool.
RAII class that helps handle the parsing of an open/close delimiter pair, such as braces { ....
SourceLocation getOpenLocation() const
SourceLocation getCloseLocation() const
ColonProtectionRAIIObject - This sets the Parser::ColonIsSacred bool and restores it when destroyed.
Captures information about "declaration specifiers".
ParsedAttributes & getAttributes()
AttributePool & getAttributePool() const
Decl - This represents one declaration (or definition), e.g.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
SourceLocation getBeginLoc() const LLVM_READONLY
Information about one declarator, including the parsed type information and the identifier.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
const ParsedAttributes & getAttributes() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
const ParsedAttributesView & getDeclarationAttributes() const
AttributePool & getAttributePool() const
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
This represents one expression.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
RAII object that makes '>' behave either as an operator or as the closing angle bracket for a templat...
One of these records is kept for each identifier that is lexed.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
tok::ObjCKeywordKind getObjCKeywordID() const
Return the Objective-C keyword ID for the this identifier.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ObjCCategoryDecl - Represents a category declaration.
ObjCContainerDecl - Represents a container for method declarations.
Captures information about "declaration specifiers" specific to Objective-C.
void setObjCDeclQualifier(ObjCDeclQualifier DQVal)
ObjCPropertyAttribute::Kind getPropertyAttributes() const
ObjCDeclQualifier
ObjCDeclQualifier - Qualifier used on types in method declarations.
void setSetterName(IdentifierInfo *name, SourceLocation loc)
const IdentifierInfo * getSetterName() const
ObjCDeclQualifier getObjCDeclQualifier() const
SourceLocation getNullabilityLoc() const
NullabilityKind getNullability() const
void setGetterName(IdentifierInfo *name, SourceLocation loc)
void setNullability(SourceLocation loc, NullabilityKind kind)
const IdentifierInfo * getGetterName() const
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal)
Represents an ObjC class declaration.
void mergeDuplicateDefinitionWithCommon(const ObjCInterfaceDecl *Definition)
Represents an Objective-C protocol declaration.
void mergeDuplicateDefinitionWithCommon(const ObjCProtocolDecl *Definition)
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Wrapper for void* pointer.
static OpaquePtr getFromOpaquePtr(void *P)
ParsedAttr - Represents a syntactic attribute.
static const ParsedAttributesView & none()
void addAtEnd(ParsedAttr *newAttr)
void remove(ParsedAttr *ToBeRemoved)
ParsedAttributes - A collection of parsed attributes.
AttributePool & getPool() const
void takeAllFrom(ParsedAttributes &Other)
Parser - This implements a parser for the C family of languages.
TypeResult ParseTypeName(SourceRange *Range=nullptr, DeclaratorContext Context=DeclaratorContext::TypeName, AccessSpecifier AS=AS_none, Decl **OwnedType=nullptr, ParsedAttributes *Attrs=nullptr)
ParseTypeName type-name: [C99 6.7.6] specifier-qualifier-list abstract-declarator[opt].
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Preprocessor & getPreprocessor() const
SourceLocation ConsumeToken()
ConsumeToken - Consume the current 'peek token' and lex the next one.
static TypeResult getTypeAnnotation(const Token &Tok)
getTypeAnnotation - Read a parsed type out of an annotation token.
SourceLocation ConsumeAnyToken(bool ConsumeCodeCompletionTok=false)
ConsumeAnyToken - Dispatch to the right Consume* method based on the current token type.
bool TryConsumeToken(tok::TokenKind Expected)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Scope * getCurScope() const
const TargetInfo & getTargetInfo() const
bool SkipUntil(tok::TokenKind T, SkipUntilFlags Flags=static_cast< SkipUntilFlags >(0))
SkipUntil - Read tokens until we get to the specified token, then consume it (unless StopBeforeMatch ...
friend class ObjCDeclContextSwitch
ExprResult ParseAssignmentExpression(TypeCastState isTypeCast=NotTypeCast)
Parse an expr that doesn't include (top-level) commas.
const LangOptions & getLangOpts() const
ExprResult ParseExpression(TypeCastState isTypeCast=NotTypeCast)
Simple precedence-based parser for binary/ternary operators.
SmallVector< Stmt *, 32 > StmtVector
A SmallVector of statements.
SkipUntilFlags
Control flags for SkipUntil functions.
@ StopBeforeMatch
Stop skipping at specified token, but don't skip the token itself.
@ StopAtSemi
Stop skipping at semicolon.
bool TryAnnotateTypeOrScopeToken(ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No)
TryAnnotateTypeOrScopeToken - If the current token position is on a typename (possibly qualified in C...
ExprResult ParseStringLiteralExpression(bool AllowUserDefinedLiteral=false)
ObjCContainerDecl * getObjCDeclContext() const
const Token & NextToken()
NextToken - This peeks ahead one token and returns it without consuming it.
RAII object used to inform the actions that we're currently parsing a declaration.
A class for parsing a DeclSpec.
A class for parsing a field declarator.
void EnterToken(const Token &Tok, bool IsReinject)
Enters a token in the token stream to be lexed next.
SourceManager & getSourceManager() const
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
IdentifierTable & getIdentifierTable()
SelectorTable & getSelectorTable()
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
PrettyDeclStackTraceEntry - If a crash occurs in the parser while parsing something related to a decl...
A (possibly-)qualified type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Scope - A scope is a transient data structure that is used while parsing the program.
@ FunctionPrototypeScope
This is a scope that corresponds to the parameters within a function prototype.
@ AtCatchScope
This is a scope that corresponds to the Objective-C @catch statement.
@ CompoundStmtScope
This is a compound statement scope.
@ ClassScope
The scope of a struct/union/class definition.
@ FunctionDeclarationScope
This is a scope that corresponds to the parameters within a function prototype for a function declara...
@ FnScope
This indicates that the scope corresponds to a function, which means that labels are set here.
@ ObjCMethodScope
This scope corresponds to an Objective-C method body.
@ DeclScope
This is a scope that can contain a declaration.
static Selector constructSetterSelector(IdentifierTable &Idents, SelectorTable &SelTable, const IdentifierInfo *Name)
Return the default setter selector for the given identifier.
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
Selector getNullarySelector(IdentifierInfo *ID)
Smart pointer class that efficiently represents Objective-C method names.
Sema - This implements semantic analysis and AST building for C.
void CodeCompleteObjCProtocolDecl(Scope *S)
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input, bool IsAfterAmp=false)
void ActOnStartOfObjCMethodDef(Scope *S, Decl *D)
ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible and user declared,...
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, tok::ObjCKeywordKind visibility)
ActOnIvar - Each ivar field of an objective-c class is passed into this in order to create an IvarDec...
DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef< Decl * > Decls)
Decl * ActOnParamDeclarator(Scope *S, Declarator &D)
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolName, SourceLocation AtLoc, SourceLocation ProtoLoc, SourceLocation LParenLoc, SourceLocation ProtoIdLoc, SourceLocation RParenLoc)
ParseObjCProtocolExpression - Build protocol expression for @protocol.
Decl * ActOnSkippedFunctionBody(Decl *Decl)
void CodeCompleteObjCMethodDeclSelector(Scope *S, bool IsInstanceMethod, bool AtParameterName, ParsedType ReturnType, ArrayRef< IdentifierInfo * > SelIdents)
ObjCCategoryDecl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
void CodeCompleteObjCMessageReceiver(Scope *S)
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList * > TypeParamLists, unsigned NumElts)
ObjCImplementationDecl * ActOnStartClassImplementation(SourceLocation AtClassImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc, const ParsedAttributesView &AttrList)
void CodeCompleteObjCAtDirective(Scope *S)
ObjCTypeParamList * actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef< Decl * > typeParams, SourceLocation rAngleLoc)
bool ActOnDuplicateODRHashDefinition(T *Duplicate, T *Previous)
Check ODR hashes for C/ObjC when merging types from modules.
void ActOnTypedefedProtocols(SmallVectorImpl< Decl * > &ProtocolRefs, SmallVectorImpl< SourceLocation > &ProtocolLocs, IdentifierInfo *SuperName, SourceLocation SuperLoc)
ActOnTypedefedProtocols - this action finds protocol list as part of the typedef'ed use for a qualifi...
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
Decl * ActOnProperty(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
void CodeCompleteObjCAtExpression(Scope *S)
void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, IdentifierInfo *PropertyName)
TypeResult ActOnTypeName(Scope *S, Declarator &D)
ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl * > allMethods=std::nullopt, ArrayRef< DeclGroupPtrTy > allTUVars=std::nullopt)
TypeResult actOnObjCTypeArgsAndProtocolQualifiers(Scope *S, SourceLocation Loc, ParsedType BaseType, SourceLocation TypeArgsLAngleLoc, ArrayRef< ParsedType > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< Decl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build a specialized and/or protocol-qualified Objective-C type.
Decl * ActOnCompatibilityAlias(SourceLocation AtCompatibilityAliasLoc, IdentifierInfo *AliasName, SourceLocation AliasLocation, IdentifierInfo *ClassName, SourceLocation ClassLocation)
ActOnCompatibilityAlias - this action is called after complete parsing of a @compatibility_alias decl...
void ActOnCapturedRegionError()
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
ASTContext & getASTContext() const
void CodeCompleteObjCPropertyDefinition(Scope *S)
bool isObjCMethodDecl(Decl *D)
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
void AddAnyMethodToGlobalPool(Decl *D)
AddAnyMethodToGlobalPool - Add any method, instance or factory to global pool.
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId, SourceLocation ProtocolLoc, IdentifierInfo *TypeArgId, SourceLocation TypeArgLoc, bool SelectProtocolFirst=false)
ObjCProtocolDecl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
void CodeCompleteObjCSelector(Scope *S, ArrayRef< IdentifierInfo * > SelIdents)
void CodeCompleteObjCImplementationDecl(Scope *S)
void CodeCompleteObjCInstanceMessage(Scope *S, Expr *Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, ObjCInterfaceDecl *Super=nullptr)
void CodeCompleteObjCPropertySetter(Scope *S)
void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList)
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr, FnBodyKind BodyKind=FnBodyKind::Other)
StmtResult ActOnNullStmt(SourceLocation SemiLoc, bool HasLeadingEmptyMacro=false)
void ActOnCapturedRegionStart(SourceLocation Loc, Scope *CurScope, CapturedRegionKind Kind, unsigned NumParams)
void CodeCompleteObjCProtocolReferences(ArrayRef< IdentifierLocPair > Protocols)
ObjCMessageKind getObjCMessageKind(Scope *S, IdentifierInfo *Name, SourceLocation NameLoc, bool IsSuper, bool HasTrailingDot, ParsedType &ReceiverType)
ExprResult ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
void CodeCompleteObjCAtVisibility(Scope *S)
Decl * ActOnMethodDeclaration(Scope *S, SourceLocation BeginLoc, SourceLocation EndLoc, tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType, ArrayRef< SourceLocation > SelectorLocs, Selector Sel, ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic, bool MethodDefinition)
ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, ArrayRef< Expr * > Strings)
void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType typeBound)
@ PCC_ObjCInterface
Code completion occurs within an Objective-C interface, protocol, or category.
@ PCC_ObjCImplementation
Code completion occurs within an Objective-C implementation or category implementation.
@ PCC_Type
Code completion occurs where only a type is permitted.
@ PCC_ObjCInstanceVariableList
Code completion occurs within the list of instance variables in an Objective-C interface,...
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
StmtResult ActOnCapturedRegionEnd(Stmt *S)
ObjCContainerDecl * getObjCDeclContext() const
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, Scope *CurScope)
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression)
Decl * ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, SourceLocation PropertyLoc, bool ImplKind, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar, SourceLocation PropertyIvarLoc, ObjCPropertyQueryKind QueryKind)
ActOnPropertyImplDecl - This routine performs semantic checks and builds the AST node for a property ...
void ActOnDefaultCtorInitializers(Decl *CDtorDecl)
ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, SourceLocation EllipsisLoc)
Invoked when parsing a template argument followed by an ellipsis, which creates a pack expansion.
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, ArrayRef< IdentifierInfo * > SelIdents, bool AtArgumentExpression, bool IsSuper=false)
ObjCInterfaceDecl * ActOnStartClassInterface(Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions.
ExprResult ActOnInstanceMessage(Scope *S, Expr *Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
void actOnObjCTypeArgsOrProtocolQualifiers(Scope *S, ParsedType baseType, SourceLocation lAngleLoc, ArrayRef< IdentifierInfo * > identifiers, ArrayRef< SourceLocation > identifierLocs, SourceLocation rAngleLoc, SourceLocation &typeArgsLAngleLoc, SmallVectorImpl< ParsedType > &typeArgs, SourceLocation &typeArgsRAngleLoc, SourceLocation &protocolLAngleLoc, SmallVectorImpl< Decl * > &protocols, SourceLocation &protocolRAngleLoc, bool warnOnIncompleteProtocols)
Given a list of identifiers (and their locations), resolve the names to either Objective-C protocol q...
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=nullptr, bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, bool IsClassTemplateDeductionContext=true, ImplicitTypenameContext AllowImplicitTypename=ImplicitTypenameContext::No, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type.
TypeResult actOnObjCProtocolQualifierType(SourceLocation lAngleLoc, ArrayRef< Decl * > protocols, ArrayRef< SourceLocation > protocolLocs, SourceLocation rAngleLoc)
Build a an Objective-C protocol-qualified 'id' type where no base type was specified.
ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, SourceLocation EncodeLoc, SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc)
void CodeCompleteObjCMethodDecl(Scope *S, std::optional< bool > IsInstanceMethod, ParsedType ReturnType)
ModuleImportState
An enumeration to represent the transition of states in parsing module fragments and imports.
@ NotACXX20Module
Not a C++20 TU, or an invalid state was found.
void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, bool IsParameter)
void CodeCompleteOrdinaryName(Scope *S, ParserCompletionContext CompletionContext)
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, const ParsedAttributesView &AttrList)
void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS)
void CodeCompleteObjCPropertyGetter(Scope *S)
void CodeCompleteObjCAtStatement(Scope *S)
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLocPair > IdentList, const ParsedAttributesView &attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
void CodeCompleteObjCInterfaceDecl(Scope *S)
ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number)
BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the numeric literal expression.
void CodeCompleteObjCImplementationCategory(Scope *S, IdentifierInfo *ClassName, SourceLocation ClassNameLoc)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Decl * ActOnObjCExceptionDecl(Scope *S, Declarator &D)
@ ObjCSuperMessage
The message is sent to 'super'.
@ ObjCClassMessage
The message is a class message, and the identifier is a type name.
@ ObjCInstanceMessage
The message is an instance message.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
bool isSimpleTypeSpecifier(tok::TokenKind Kind) const
Determine whether the token kind starts a simple-type-specifier.
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool IsTemplateName=false)
void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, ArrayRef< IdentifierLocPair > ProtocolId, SmallVectorImpl< Decl * > &Protocols)
FindProtocolDeclaration - This routine looks up protocols and issues an error if they are not declare...
ObjCContainerKind getObjCContainerKind() const
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
ObjCCategoryImplDecl * ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *CatName, SourceLocation CatLoc, const ParsedAttributesView &AttrList)
ActOnStartCategoryImplementation - Perform semantic checks on the category implementation declaration...
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, bool RecoverUncorrectedTypos=false, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult { return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
ExprResult ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors)
ParseObjCSelectorExpression - Build selector expression for @selector.
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
A trivial tuple used to represent a source range.
void setBegin(SourceLocation b)
SourceLocation getBegin() const
void setEnd(SourceLocation e)
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Token - This structure provides full information about a lexed token.
IdentifierInfo * getIdentifierInfo() const
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file.
void setLength(unsigned Len)
void setKind(tok::TokenKind K)
tok::ObjCKeywordKind getObjCKeywordID() const
Return the ObjC keyword kind.
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {....
tok::TokenKind getKind() const
void setEofData(const void *D)
void setLocation(SourceLocation L)
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool isNot(tok::TokenKind K) const
bool isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const
Return true if we have an ObjC keyword identifier.
void startToken()
Reset all flags to cleared.
The base class of the type hierarchy.
bool isObjCObjectOrInterfaceType() const
bool acceptsObjCTypeParams() const
Determines if this is an ObjC interface type that may accept type parameters.
Defines the clang::TargetInfo interface.
@ kind_nullability
Indicates that the nullability of the type was spelled with a property attribute rather than a type q...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
DirectiveKind
Represents the kind of preprocessor directive or a module declaration that is tracked by the scanner ...
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
NullabilityKind
Describes the nullability of a particular type.
@ Nullable
Values of this type can be null.
@ Unspecified
Whether values of this type can be null is (explicitly) unspecified.
@ NonNull
Values of this type can never be null.
LLVM_READONLY bool isLetter(unsigned char c)
Return true if this character is an ASCII letter: [a-zA-Z].
@ Property
The type of a property.
@ Result
The result type of a method or function.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
@ Invariant
The parameter is invariant: must match exactly.
@ Contravariant
The parameter is contravariant, e.g., X<T> is a subtype of X when the type parameter is covariant and...
@ Covariant
The parameter is covariant, e.g., X<T> is a subtype of X when the type parameter is covariant and T i...
std::pair< IdentifierInfo *, SourceLocation > IdentifierLocPair
A simple pair of identifier info and location.
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed.
const ParsedAttributesView & getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
An element in an Objective-C dictionary literal.
ParsedAttributesView ArgAttrs
ArgAttrs - Attribute list for this argument.