30#include "llvm/ADT/DenseMap.h"
31#include "llvm/ADT/DenseSet.h"
58 if (result->isObjCId()) {
60 }
else if (result->isObjCClass()) {
64 assert(resultClass &&
"unexpected object type!");
69 if (receiverTypeIfCall.
isNull() &&
79 if (receiverTypeIfCall.
isNull())
86 if (!receiverClass)
return false;
89 assert(receiverClass &&
"method not associated with a class!");
103 if (receiverTypeIfCall.
isNull() &&
104 SemaRef.getSourceManager().isInSystemHeader(loc)) {
105 method->
addAttr(UnavailableAttr::CreateImplicit(Context,
"",
106 UnavailableAttr::IR_ARCInitReturnsUnrelated, loc));
111 Diag(loc, diag::err_arc_init_method_unrelated_result_type);
120 if (OldD->
hasAttr<NoEscapeAttr>() && !NewD->
hasAttr<NoEscapeAttr>()) {
121 S.
Diag(NewD->
getLocation(), diag::warn_overriding_method_missing_noescape);
158 CurrentClass = Cat->getClassInterface();
159 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(DC))
160 CurrentClass = Impl->getClassInterface();
162 = dyn_cast<ObjCCategoryImplDecl>(DC))
163 CurrentClass = CatImpl->getClassInterface();
168 diag::warn_related_result_type_compatibility_class)
169 << Context.getObjCInterfaceType(CurrentClass)
174 diag::warn_related_result_type_compatibility_protocol)
181 diag::note_related_result_type_family)
186 diag::note_related_result_type_overridden);
189 if ((NewMethod->
hasAttr<NSReturnsRetainedAttr>() !=
190 Overridden->
hasAttr<NSReturnsRetainedAttr>())) {
193 ? diag::err_nsreturns_retained_attribute_mismatch
194 : diag::warn_nsreturns_retained_attribute_mismatch)
198 if ((NewMethod->
hasAttr<NSReturnsNotRetainedAttr>() !=
199 Overridden->
hasAttr<NSReturnsNotRetainedAttr>())) {
202 ? diag::err_nsreturns_retained_attribute_mismatch
203 : diag::warn_nsreturns_retained_attribute_mismatch)
212 ni != ne && oi != oe; ++ni, ++oi) {
215 if (newDecl->
hasAttr<NSConsumedAttr>() !=
216 oldDecl->
hasAttr<NSConsumedAttr>()) {
219 ? diag::err_nsconsumed_attribute_mismatch
220 : diag::warn_nsconsumed_attribute_mismatch);
246 if (!Context.hasSameType(method->
getReturnType(), Context.VoidTy)) {
265 method->
addAttr(NSConsumesSelfAttr::CreateImplicit(Context));
269 if (method->
hasAttr<NSReturnsRetainedAttr>())
277 if (method->
hasAttr<NSReturnsRetainedAttr>() ||
278 method->
hasAttr<NSReturnsNotRetainedAttr>() ||
279 method->
hasAttr<NSReturnsAutoreleasedAttr>())
284 method->
addAttr(NSReturnsRetainedAttr::CreateImplicit(Context));
292 bool IsCategory =
false;
293 StringRef RealizedPlatform;
295 nullptr, VersionTuple(),
301 if (RealizedPlatform.empty())
305 if (RealizedPlatform.ends_with(
"_app_extension"))
307 S.
Diag(ImplLoc, diag::warn_unavailable_def);
312 if (
const auto *CD = dyn_cast<ObjCCategoryDecl>(ND)) {
313 if (!CD->getClassInterface()->isDeprecated())
315 ND = CD->getClassInterface();
320 S.
Diag(ImplLoc, diag::warn_deprecated_def)
354 T = PT->getPointeeType();
356 T = RT->getPointeeType();
363 return !
T.getLocalQualifiers().hasObjCLifetime();
370 SemaRef.ImplicitlyRetainedSelfLocs.clear();
371 assert((
SemaRef.getCurMethodDecl() ==
nullptr) &&
"Methodparsing confused");
374 SemaRef.PushExpressionEvaluationContext(
375 SemaRef.ExprEvalContexts.back().Context);
385 diag::err_func_def_incomplete_result))
389 SemaRef.PushDeclContext(FnBodyScope, MDecl);
407 if (!Param->isInvalidDecl() &&
getLangOpts().ObjCAutoRefCount &&
409 Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) <<
412 if (Param->getIdentifier())
413 SemaRef.PushOnScopeChains(Param, FnBodyScope);
455 ImplDeclOfMethodDecl = OID->getImplementation();
456 else if (
ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(ContDeclOfMethodDecl)) {
457 if (CD->IsClassExtension()) {
459 ImplDeclOfMethodDecl = OID->getImplementation();
461 ImplDeclOfMethodDecl = CD->getImplementation();
465 if (!ImplDeclOfMethodDecl || ImplDeclOfMethodDecl != ImplDeclOfMethodDef)
471 SemaRef.getCurFunction()->ObjCIsDesignatedInit =
true;
472 SemaRef.getCurFunction()->ObjCWarnForNoDesignatedInitChain =
473 IC->getSuperClass() !=
nullptr;
474 }
else if (IC->hasDesignatedInitializers()) {
475 SemaRef.getCurFunction()->ObjCIsSecondaryInit =
true;
476 SemaRef.getCurFunction()->ObjCWarnForNoInitDelegation =
true;
489 SemaRef.getCurFunction()->ObjCShouldCallSuper =
true;
493 SemaRef.getCurFunction()->ObjCShouldCallSuper =
true;
499 SemaRef.getCurFunction()->ObjCShouldCallSuper =
500 (SuperMethod && SuperMethod->
hasAttr<ObjCRequiresSuperAttr>());
507 SemaRef.applyFunctionAttributesBeforeParsingBody(D);
517 ObjCInterfaceValidatorCCC() : CurrentIDecl(
nullptr) {}
519 : CurrentIDecl(IDecl) {}
521 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
526 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
527 return std::make_unique<ObjCInterfaceValidatorCCC>(*
this);
531 ObjCInterfaceDecl *CurrentIDecl;
539 unsigned NumProtoRefs,
544 for (
unsigned i = 0; i < NumProtoRefs; ++i) {
565 ObjCInterfaceValidatorCCC CCC(IDecl);
569 SemaRef.diagnoseTypo(Corrected,
PDiag(diag::err_undef_superclass_suggest)
570 << SuperName << ClassName);
576 Diag(SuperLoc, diag::err_recursive_superclass)
577 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
581 dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
585 if (SuperClassDecl) {
586 (void)
SemaRef.DiagnoseUseOfDecl(SuperClassDecl, SuperLoc);
587 SuperClassType = Context.getObjCInterfaceType(SuperClassDecl);
590 if (PrevDecl && !SuperClassDecl) {
594 dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
596 if (
T->isObjCObjectType()) {
598 SuperClassDecl = dyn_cast<ObjCInterfaceDecl>(IDecl);
599 SuperClassType = Context.getTypeDeclType(
606 (void)
SemaRef.DiagnoseUseOfDecl(
617 if (!SuperClassDecl) {
618 Diag(SuperLoc, diag::err_redefinition_different_kind) << SuperName;
623 if (!isa_and_nonnull<TypedefNameDecl>(PrevDecl)) {
625 Diag(SuperLoc, diag::err_undef_superclass)
626 << SuperName << ClassName <<
SourceRange(AtInterfaceLoc, ClassLoc);
627 else if (
SemaRef.RequireCompleteType(
628 SuperLoc, SuperClassType, diag::err_forward_superclass,
631 SuperClassDecl =
nullptr;
636 if (SuperClassType.
isNull()) {
637 assert(!SuperClassDecl &&
"Failed to set SuperClassType?");
643 if (!SuperTypeArgs.empty()) {
645 S, SuperLoc,
SemaRef.CreateParsedType(SuperClassType,
nullptr),
646 SuperTypeArgsRange.
getBegin(), SuperTypeArgs,
653 SemaRef.GetTypeFromParser(fullSuperClassType.
get(), &SuperClassTInfo);
656 if (!SuperClassTInfo) {
657 SuperClassTInfo = Context.getTrivialTypeSourceInfo(SuperClassType,
674 if (parsedTypeBound) {
677 SemaRef.GetTypeFromParser(parsedTypeBound, &typeBoundInfo);
686 diag::err_objc_type_param_bound_missing_pointer)
687 << typeBound << paramName
696 typeBound = Context.getObjCObjectPointerType(typeBound);
706 diag::err_objc_type_param_bound_nonobject)
707 << typeBound << paramName;
710 typeBoundInfo =
nullptr;
719 bool diagnosed =
false;
723 rangeToRemove =
attr.getLocalSourceRange();
724 if (
attr.getTypePtr()->getImmediateNullability()) {
726 diag::err_objc_type_param_bound_explicit_nullability)
727 << paramName << typeBound
737 diag::err_objc_type_param_bound_qualified)
738 << paramName << typeBound
748 if (!quals.
empty()) {
758 if (!typeBoundInfo) {
760 typeBoundInfo = Context.getTrivialTypeSourceInfo(Context.getObjCIdType());
765 varianceLoc,
index, paramLoc, paramName,
766 colonLoc, typeBoundInfo);
778 typeParamsIn.size());
784 llvm::SmallDenseMap<IdentifierInfo *, ObjCTypeParamDecl *> knownParams;
785 for (
auto *typeParam : typeParams) {
786 auto known = knownParams.find(typeParam->getIdentifier());
787 if (known != knownParams.end()) {
788 Diag(typeParam->getLocation(), diag::err_objc_type_param_redecl)
789 << typeParam->getIdentifier()
792 typeParam->setInvalidDecl();
794 knownParams.insert(std::make_pair(typeParam->getIdentifier(), typeParam));
797 SemaRef.PushOnScopeChains(typeParam, S,
false);
807 for (
auto *typeParam : *typeParamList) {
808 if (!typeParam->isInvalidDecl()) {
810 SemaRef.IdResolver.RemoveDecl(typeParam);
818 enum class TypeParamListContext {
832 TypeParamListContext newContext) {
834 if (prevTypeParams->
size() != newTypeParams->
size()) {
836 if (newTypeParams->
size() > prevTypeParams->
size()) {
837 diagLoc = newTypeParams->
begin()[prevTypeParams->
size()]->getLocation();
842 S.
Diag(diagLoc, diag::err_objc_type_param_arity_mismatch)
843 <<
static_cast<unsigned>(newContext)
844 << (newTypeParams->
size() > prevTypeParams->
size())
845 << prevTypeParams->
size()
846 << newTypeParams->
size();
852 for (
unsigned i = 0, n = prevTypeParams->
size(); i != n; ++i) {
859 newContext != TypeParamListContext::Definition) {
879 diag::err_objc_type_param_variance_conflict)
880 <<
static_cast<unsigned>(newTypeParam->
getVariance())
882 <<
static_cast<unsigned>(prevTypeParam->
getVariance())
891 StringRef newVarianceStr
898 (newVarianceStr +
" ").str());
925 S.
Diag(newBoundRange.
getBegin(), diag::err_objc_type_param_bound_conflict)
949 if (newContext == TypeParamListContext::ForwardDeclaration ||
950 newContext == TypeParamListContext::Definition) {
958 diag::err_objc_type_param_bound_missing)
961 << (newContext == TypeParamListContext::ForwardDeclaration)
980 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
983 assert(ClassName &&
"Missing class identifier");
989 SemaRef.forRedeclarationInCurContext());
992 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
1019 if (typeParamList) {
1023 TypeParamListContext::Definition)) {
1024 typeParamList =
nullptr;
1027 Diag(ClassLoc, diag::err_objc_parameterized_forward_class_first)
1029 Diag(prevTypeParamList->getLAngleLoc(), diag::note_previous_decl)
1034 for (
auto *typeParam : *prevTypeParamList) {
1036 Context,
SemaRef.CurContext, typeParam->getVariance(),
1039 Context.getTrivialTypeSourceInfo(
1040 typeParam->getUnderlyingType())));
1053 ClassName, typeParamList, PrevIDecl, ClassLoc);
1057 if (SkipBody && (!
SemaRef.hasVisibleDefinition(Def) ||
1058 SemaRef.isFromSameSingleIncludeHeader(Def, ClassLoc))) {
1060 SkipBody->
New = IDecl;
1063 Diag(AtInterfaceLoc, diag::err_duplicate_class_def)
1065 Diag(Def->getLocation(), diag::note_previous_definition);
1071 SemaRef.ProcessDeclAttributeList(
SemaRef.TUScope, IDecl, AttrList);
1073 SemaRef.ProcessAPINotes(IDecl);
1077 SemaRef.mergeDeclAttributes(IDecl, PrevIDecl);
1093 ClassName, ClassLoc,
1094 SuperName, SuperLoc, SuperTypeArgs,
1095 SuperTypeArgsRange);
1103 NumProtoRefs, ProtoLocs);
1105 ProtoLocs, Context);
1128 if (
const TypedefNameDecl *TDecl = dyn_cast_or_null<TypedefNameDecl>(IDecl)) {
1129 QualType T = TDecl->getUnderlyingType();
1130 if (
T->isObjCObjectType())
1132 ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end());
1137 ProtocolLocs.append(OPT->getNumProtocols(), SuperLoc);
1153 SemaRef.forRedeclarationInCurContext());
1155 Diag(AliasLocation, diag::err_conflicting_aliasing_type) << AliasName;
1162 SemaRef.forRedeclarationInCurContext());
1164 dyn_cast_or_null<TypedefNameDecl>(CDeclU)) {
1165 QualType T = TDecl->getUnderlyingType();
1166 if (
T->isObjCObjectType()) {
1168 ClassName = IDecl->getIdentifier();
1169 CDeclU =
SemaRef.LookupSingleName(
1171 SemaRef.forRedeclarationInCurContext());
1177 Diag(ClassLocation, diag::warn_undef_interface) << ClassName;
1185 Context,
SemaRef.CurContext, AtLoc, AliasName, CDecl);
1199 E = PList.
end(); I != E; ++I) {
1201 if (PDecl->getIdentifier() == PName) {
1202 Diag(Ploc, diag::err_protocol_has_circular_dependency);
1203 Diag(PrevLoc, diag::note_previous_definition);
1207 if (!PDecl->hasDefinition())
1211 PDecl->getLocation(), PDecl->getReferencedProtocols()))
1226 assert(ProtocolName &&
"Missing protocol identifier");
1228 ProtocolName, ProtocolLoc,
SemaRef.forRedeclarationInCurContext());
1236 ProtocolLoc, AtProtoInterfaceLoc,
1239 if (SkipBody && (!
SemaRef.hasVisibleDefinition(Def) ||
1240 SemaRef.isFromSameSingleIncludeHeader(Def, ProtocolLoc))) {
1242 SkipBody->
New = PDecl;
1246 Diag(ProtocolLoc, diag::warn_duplicate_protocol_def) << ProtocolName;
1247 Diag(Def->getLocation(), diag::note_previous_definition);
1262 ProtocolName, ProtocolLoc, PrevDecl->
getLocation(), PList);
1267 ProtocolLoc, AtProtoInterfaceLoc,
1274 SemaRef.ProcessDeclAttributeList(
SemaRef.TUScope, PDecl, AttrList);
1276 SemaRef.ProcessAPINotes(PDecl);
1280 SemaRef.mergeDeclAttributes(PDecl, PrevDecl);
1282 if (!err && NumProtoRefs ) {
1285 NumProtoRefs, ProtoLocs);
1287 ProtoLocs, Context);
1299 UndefinedProtocol = PDecl;
1305 UndefinedProtocol = PI;
1315 bool ForObjCContainer,
1328 SemaRef.diagnoseTypo(Corrected,
1329 PDiag(diag::err_undeclared_protocol_suggest)
1330 << Pair.getIdentifierInfo());
1334 Diag(Pair.getLoc(), diag::err_undeclared_protocol)
1335 << Pair.getIdentifierInfo();
1344 if (!ForObjCContainer) {
1345 (void)
SemaRef.DiagnoseUseOfDecl(PDecl, Pair.getLoc());
1353 if (WarnOnDeclarations &&
1355 Diag(Pair.getLoc(), diag::warn_undef_protocolref)
1356 << Pair.getIdentifierInfo();
1357 Diag(UndefinedProtocol->
getLocation(), diag::note_protocol_decl_undefined)
1358 << UndefinedProtocol;
1360 Protocols.push_back(PDecl);
1367class ObjCTypeArgOrProtocolValidatorCCC final
1372 ObjCTypeArgOrProtocolValidatorCCC(
ASTContext &context,
1374 : Context(context), LookupKind(lookupKind) { }
1376 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
1396 type->isDependentType() ||
1414 std::unique_ptr<CorrectionCandidateCallback> clone()
override {
1415 return std::make_unique<ObjCTypeArgOrProtocolValidatorCCC>(*
this);
1424 bool SelectProtocolFirst) {
1425 Diag(TypeArgLoc, diag::err_objc_type_args_and_protocols)
1426 << SelectProtocolFirst << TypeArgId << ProtocolId
1437 bool warnOnIncompleteProtocols) {
1441 unsigned numProtocolsResolved = 0;
1442 auto resolvedAsProtocols = [&] {
1443 assert(numProtocolsResolved == identifiers.size() &&
"Unresolved protocols");
1450 bool allAreTypeNames =
false;
1454 baseClass = objcObjectType->getInterface();
1457 if (typeParams->size() == numProtocolsResolved) {
1459 allAreTypeNames =
true;
1466 for (
unsigned i = 0, n = protocols.size(); i != n; ++i) {
1471 if (!warnOnIncompleteProtocols) {
1472 (void)
SemaRef.DiagnoseUseOfDecl(proto, identifierLocs[i]);
1483 if (warnOnIncompleteProtocols &&
1485 Diag(identifierLocs[i], diag::warn_undef_protocolref)
1494 if (allAreTypeNames) {
1496 SemaRef.LookupSingleName(S, identifiers[i], identifierLocs[i],
1500 firstClassNameLoc = identifierLocs[i];
1503 allAreTypeNames =
false;
1506 allAreTypeNames =
false;
1515 if (allAreTypeNames && firstClassNameLoc.
isValid()) {
1517 Context.CollectInheritedProtocols(baseClass, knownProtocols);
1518 bool allProtocolsDeclared =
true;
1519 for (
auto *proto : protocols) {
1521 allProtocolsDeclared =
false;
1526 if (allProtocolsDeclared) {
1527 Diag(firstClassNameLoc, diag::warn_objc_redundant_qualified_class_type)
1530 SemaRef.getLocForEndOfToken(firstClassNameLoc),
" *");
1534 protocolLAngleLoc = lAngleLoc;
1535 protocolRAngleLoc = rAngleLoc;
1536 assert(protocols.size() == identifierLocs.size());
1540 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1542 protocols.push_back(proto);
1544 ++numProtocolsResolved;
1548 if (numProtocolsResolved == identifiers.size())
1549 return resolvedAsProtocols();
1555 typedef llvm::PointerUnion<TypeDecl *, ObjCInterfaceDecl *> TypeOrClassDecl;
1557 unsigned numTypeDeclsResolved = 0;
1558 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1562 typeDecls.push_back(TypeOrClassDecl());
1566 if (
auto typeDecl = dyn_cast<TypeDecl>(
decl)) {
1567 typeDecls.push_back(typeDecl);
1568 ++numTypeDeclsResolved;
1572 if (
auto objcClass = dyn_cast<ObjCInterfaceDecl>(
decl)) {
1573 typeDecls.push_back(objcClass);
1574 ++numTypeDeclsResolved;
1578 typeDecls.push_back(TypeOrClassDecl());
1585 auto resolveTypeReference = [&](TypeOrClassDecl typeDecl,
SourceLocation loc)
1589 const char* prevSpec;
1592 if (
auto *actualTypeDecl = dyn_cast<TypeDecl *>(typeDecl))
1595 std::nullopt, actualTypeDecl);
1601 parsedType, Context.getPrintingPolicy());
1622 Diag(loc, diag::err_objc_type_arg_missing_star)
1628 return SemaRef.ActOnTypeName(D);
1633 auto resolvedAsTypeDecls = [&] {
1637 assert(numTypeDeclsResolved == identifiers.size() &&
"Unresolved type decl");
1639 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1641 TypeResult type = resolveTypeReference(typeDecls[i], identifierLocs[i]);
1642 if (!
type.isUsable()) {
1647 typeArgs.push_back(
type.get());
1650 typeArgsLAngleLoc = lAngleLoc;
1651 typeArgsRAngleLoc = rAngleLoc;
1656 if (numTypeDeclsResolved == identifiers.size())
1657 return resolvedAsTypeDecls();
1663 for (
unsigned i = 0, n = identifiers.size(); i != n; ++i) {
1666 if (protocols[i] || typeDecls[i]) {
1672 if (protocols[i] && typeDecls[i])
1695 identifiers[i], identifierLocs[i],
1696 protocols[i] !=
nullptr);
1704 ObjCTypeArgOrProtocolValidatorCCC CCC(Context, lookupKind);
1711 SemaRef.diagnoseTypo(corrected,
1712 PDiag(diag::err_undeclared_protocol_suggest)
1715 protocols[i] = proto;
1716 ++numProtocolsResolved;
1722 SemaRef.diagnoseTypo(corrected,
1723 PDiag(diag::err_unknown_typename_suggest)
1726 typeDecls[i] = typeDecl;
1727 ++numTypeDeclsResolved;
1733 SemaRef.diagnoseTypo(corrected,
1734 PDiag(diag::err_unknown_type_or_class_name_suggest)
1735 << identifiers[i] <<
true);
1737 typeDecls[i] = objcClass;
1738 ++numTypeDeclsResolved;
1744 Diag(identifierLocs[i],
1747 ? diag::err_undeclared_protocol
1748 : diag::err_unknown_typename))
1757 if (numProtocolsResolved == identifiers.size())
1758 return resolvedAsProtocols();
1761 assert(numTypeDeclsResolved == identifiers.size() &&
"Not all types?");
1762 return resolvedAsTypeDecls();
1773 llvm::DenseMap<Selector, const ObjCMethodDecl*> MethodMap;
1774 for (
auto *MD : ID->methods())
1775 MethodMap[MD->getSelector()] = MD;
1777 if (MethodMap.empty())
1784 Diag(
Method->getLocation(), diag::err_duplicate_method_decl)
1785 <<
Method->getDeclName();
1800 Ident, IdentPair.getLoc(),
SemaRef.forRedeclarationInCurContext());
1803 IdentPair.getLoc(), AtProtocolLoc, PrevDecl);
1808 SemaRef.ProcessDeclAttributeList(
SemaRef.TUScope, PDecl, attrList);
1812 SemaRef.mergeDeclAttributes(PDecl, PrevDecl);
1814 DeclsInGroup.push_back(PDecl);
1817 return SemaRef.BuildDeclaratorGroup(DeclsInGroup);
1824 Decl *
const *ProtoRefs,
unsigned NumProtoRefs,
1834 SemaRef.RequireCompleteType(ClassLoc, Context.getObjCInterfaceType(IDecl),
1835 diag::err_category_forward_interface,
1836 CategoryName ==
nullptr)) {
1841 AtInterfaceLoc, ClassLoc, CategoryLoc,
1842 CategoryName, IDecl, typeParamList);
1844 SemaRef.CurContext->addDecl(CDecl);
1847 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1853 Diag(ClassLoc, diag::err_class_extension_after_impl) << ClassName;
1855 diag::note_implementation_declared);
1863 Diag(CategoryLoc, diag::warn_dup_category_def)
1864 << ClassName << CategoryName;
1865 Diag(
Previous->getLocation(), diag::note_previous_definition);
1870 if (typeParamList) {
1873 SemaRef, prevTypeParamList, typeParamList,
1874 CategoryName ? TypeParamListContext::Category
1875 : TypeParamListContext::Extension))
1876 typeParamList =
nullptr;
1879 diag::err_objc_parameterized_category_nonclass)
1880 << (CategoryName !=
nullptr)
1884 typeParamList =
nullptr;
1889 ClassLoc, CategoryLoc, CategoryName, IDecl,
1892 SemaRef.CurContext->addDecl(CDecl);
1897 SemaRef.ProcessDeclAttributeList(
SemaRef.TUScope, CDecl, AttrList);
1902 NumProtoRefs, ProtoLocs);
1904 ProtoLocs, Context);
1908 NumProtoRefs, Context);
1933 ClassLoc, CatLoc, CatName, IDecl,
1941 ClassLoc, AtCatImplLoc, CatLoc);
1944 Diag(ClassLoc, diag::err_undef_interface) << ClassName;
1946 }
else if (
SemaRef.RequireCompleteType(ClassLoc,
1947 Context.getObjCInterfaceType(IDecl),
1948 diag::err_undef_interface)) {
1956 SemaRef.CurContext->addDecl(CDecl);
1960 if (IDecl && IDecl->
hasAttr<ObjCRuntimeVisibleAttr>()) {
1961 Diag(ClassLoc, diag::err_objc_runtime_visible_category)
1968 Diag(ClassLoc, diag::err_dup_implementation_category) << ClassName
1971 diag::note_previous_definition);
1996 SemaRef.forRedeclarationInCurContext());
1998 Diag(ClassLoc, diag::err_redefinition_different_kind) << ClassName;
2000 }
else if ((IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl))) {
2003 SemaRef.RequireCompleteType(ClassLoc, Context.getObjCInterfaceType(IDecl),
2004 diag::warn_undef_interface);
2008 ObjCInterfaceValidatorCCC CCC{};
2017 Corrected,
PDiag(diag::warn_undef_interface_suggest) << ClassName,
2020 Diag(ClassLoc, diag::warn_undef_interface) << ClassName;
2026 if (SuperClassname) {
2029 SemaRef.LookupSingleName(
SemaRef.TUScope, SuperClassname, SuperClassLoc,
2032 Diag(SuperClassLoc, diag::err_redefinition_different_kind)
2036 SDecl = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
2040 Diag(SuperClassLoc, diag::err_undef_superclass)
2041 << SuperClassname << ClassName;
2045 Diag(SuperClassLoc, diag::err_conflicting_super_class)
2061 nullptr, ClassLoc,
true);
2066 Context.getObjCInterfaceType(SDecl),
2084 ClassLoc, AtClassImplLoc, SuperClassLoc);
2086 SemaRef.ProcessDeclAttributeList(
SemaRef.TUScope, IMPDecl, Attrs);
2097 Diag(ClassLoc, diag::err_dup_implementation_class) << ClassName;
2099 diag::note_previous_definition);
2113 Diag(ClassLoc, diag::err_objc_runtime_visible_subclass)
2126 DeclsInGroup.reserve(Decls.size() + 1);
2128 for (
unsigned i = 0, e = Decls.size(); i != e; ++i) {
2129 Decl *Dcl = Decls[i];
2134 DeclsInGroup.push_back(Dcl);
2137 DeclsInGroup.push_back(ObjCImpDecl);
2141 if (
auto *ImplD = dyn_cast<ObjCImplementationDecl>(ObjCImpDecl))
2142 if (!ImplD->ivar_empty())
2145 return SemaRef.BuildDeclaratorGroup(DeclsInGroup);
2151 assert(ImpDecl &&
"missing implementation decl");
2162 for (
unsigned i = 0, e = numIvars; i != e; ++i) {
2179 assert(ivars &&
"missing @implementation ivars");
2183 for (
unsigned i = 0; i < numIvars; i++) {
2188 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
2196 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
2213 for (; numIvars > 0 && IVI != IVE; ++IVI) {
2216 assert (ImplIvar &&
"missing implementation ivar");
2217 assert (ClsIvar &&
"missing class ivar");
2220 if (!Context.hasSameType(ImplIvar->
getType(), ClsIvar->
getType())) {
2228 diag::err_conflicting_ivar_bitwidth)
2231 diag::note_previous_definition);
2243 Diag(ivars[j]->getLocation(), diag::err_inconsistent_ivar_count);
2244 else if (IVI != IVE)
2245 Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count);
2267 S.
Diag(Impl->getLocation(), DiagID);
2273 std::string FixItStr;
2274 llvm::raw_string_ostream Out(FixItStr);
2275 method->print(Out, Impl->getASTContext().getPrintingPolicy());
2285 S.
Diag(MethodLoc, diag::note_method_declared_at) << method;
2334 Context.ObjCQualifiedIdTypesAreCompatible(A, B,
false);
2350 return Context.canAssignObjCInterfaces(A, B);
2361 (y &
~Decl::OBJC_TQ_CSNullability);
2367 bool IsProtocolMethodDecl,
2368 bool IsOverridingMode,
2370 if (IsProtocolMethodDecl &&
2376 ? diag::warn_conflicting_overriding_ret_type_modifiers
2377 : diag::warn_conflicting_ret_type_modifiers))
2386 if (Warn && IsOverridingMode &&
2394 diag::warn_conflicting_nullability_attr_overriding_ret_types)
2411 IsOverridingMode ? diag::warn_conflicting_overriding_ret_types
2412 : diag::warn_conflicting_ret_types;
2428 IsOverridingMode ? diag::warn_non_covariant_overriding_ret_types
2429 : diag::warn_non_covariant_ret_types;
2438 ? diag::note_previous_declaration
2439 : diag::note_previous_definition)
2449 bool IsProtocolMethodDecl,
2450 bool IsOverridingMode,
2452 if (IsProtocolMethodDecl &&
2456 if (IsOverridingMode)
2458 diag::warn_conflicting_overriding_param_modifiers)
2462 diag::warn_conflicting_param_modifiers)
2474 if (Warn && IsOverridingMode &&
2478 diag::warn_conflicting_nullability_attr_overriding_param_types)
2493 IsOverridingMode ? diag::warn_conflicting_overriding_param_types
2494 : diag::warn_conflicting_param_types;
2510 IsOverridingMode ? diag::warn_non_contravariant_overriding_param_types
2511 : diag::warn_non_contravariant_param_types;
2517 << MethodImpl->
getDeclName() << IfaceTy << ImplTy;
2519 (IsOverridingMode ? diag::note_previous_declaration
2520 : diag::note_previous_definition))
2531 if (implFamily == declFamily)
return false;
2543 unsigned errorID = diag::err_arc_lost_method_convention;
2544 unsigned noteID = diag::note_arc_lost_method_convention;
2547 family = implFamily;
2548 errorID = diag::err_arc_gained_method_convention;
2549 noteID = diag::note_arc_gained_method_convention;
2553 enum FamilySelector {
2554 F_alloc, F_copy, F_mutableCopy = F_copy, F_init, F_new
2556 FamilySelector familySelector = FamilySelector();
2559 case OMF_None: llvm_unreachable(
"logic error, no method convention");
2573 case OMF_init: familySelector = F_init;
break;
2574 case OMF_alloc: familySelector = F_alloc;
break;
2575 case OMF_copy: familySelector = F_copy;
break;
2577 case OMF_new: familySelector = F_new;
break;
2580 enum ReasonSelector { R_NonObjectReturn, R_UnrelatedReturn };
2581 ReasonSelector reasonSelector;
2586 reasonSelector = R_UnrelatedReturn;
2588 reasonSelector = R_NonObjectReturn;
2592 S.
Diag(
decl->getLocation(), noteID) <<
int(familySelector) <<
int(reasonSelector);
2599 bool IsProtocolMethodDecl) {
2605 IsProtocolMethodDecl,
false,
true);
2610 IM != EM && IF != EF; ++IM, ++IF) {
2612 IsProtocolMethodDecl,
false,
true);
2617 diag::warn_conflicting_variadic);
2624 bool IsProtocolMethodDecl) {
2632 IM != EM && IF != EF; ++IM, ++IF) {
2634 IsProtocolMethodDecl,
true,
true);
2639 diag::warn_conflicting_overriding_variadic);
2648 bool IsProtocolMethodDecl) {
2658 if (MethodDecl->
hasAttr<UnavailableAttr>() ||
2659 MethodDecl->
hasAttr<DeprecatedAttr>())
2663 IsProtocolMethodDecl,
false,
false);
2668 IM != EM && IF != EF; ++IM, ++IF) {
2670 *IF, IsProtocolMethodDecl,
false,
false);
2682 diag::warn_category_method_impl_match);
2699 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>())
2701 for (
const auto *PI : PDecl->
protocols())
2727 : dyn_cast<ObjCInterfaceDecl>(CDecl);
2728 assert (IDecl &&
"CheckProtocolMethodDefs - IDecl is null");
2744 if (PDecl->
hasAttr<ObjCExplicitProtocolImplAttr>()) {
2745 if (!ProtocolsExplictImpl) {
2767 if (InsMap.count(fISelector))
2786 if (method->getImplementationControl() !=
2788 !method->isPropertyAccessor() &&
2789 !InsMap.count(method->getSelector()) &&
2791 method->getSelector(),
true ,
2804 method->getSelector(),
true ,
2806 if (
C || MethodInClass->isPropertyAccessor())
2808 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2816 if (method->getImplementationControl() !=
2818 !ClsMap.count(method->getSelector()) &&
2820 method->getSelector(),
false ,
2822 true ,
nullptr ))) {
2830 unsigned DIAG = diag::warn_unimplemented_protocol_method;
2839 ProtocolsExplictImpl);
2849 bool WarnCategoryMethodImpl) {
2853 if (!InsMapSeen.insert(I->getSelector()).second)
2855 if (!I->isPropertyAccessor() &&
2856 !InsMap.count(I->getSelector())) {
2859 diag::warn_undef_method_impl);
2865 "Expected to find the method through lookup as well");
2867 if (ImpMethodDecl) {
2871 if (!WarnCategoryMethodImpl)
2874 else if (!I->isPropertyAccessor())
2883 if (!ClsMapSeen.insert(I->getSelector()).second)
2885 if (!I->isPropertyAccessor() &&
2886 !ClsMap.count(I->getSelector())) {
2889 diag::warn_undef_method_impl);
2894 "Expected to find the method through lookup as well");
2896 if (ImpMethodDecl) {
2900 if (!WarnCategoryMethodImpl)
2903 else if (!I->isPropertyAccessor())
2912 for (
auto *PI : PD->protocols())
2914 IMPDecl, PI, IncompleteImpl,
false,
2915 WarnCategoryMethodImpl);
2922 if (!WarnCategoryMethodImpl) {
2923 for (
auto *Cat : I->visible_categories())
2925 IMPDecl, Cat, IncompleteImpl,
2926 ImmediateClass && Cat->IsClassExtension(),
2927 WarnCategoryMethodImpl);
2930 for (
auto *Ext : I->visible_extensions())
2932 IMPDecl, Ext, IncompleteImpl,
false,
2933 WarnCategoryMethodImpl);
2937 for (
auto *PI : I->all_referenced_protocols())
2939 IMPDecl, PI, IncompleteImpl,
false,
2940 WarnCategoryMethodImpl);
2944 if (!WarnCategoryMethodImpl && I->getSuperClass())
2947 I->getSuperClass(), IncompleteImpl,
false);
2978 if (SuperIDecl && SuperIDecl->
lookupMethod(Sel,
false))
2982 if (InsMap.empty() && ClsMap.empty())
2986 bool IncompleteImpl =
false;
2989 IncompleteImpl,
false,
2995 bool IncompleteImpl) {
3000 InsMap.insert(I->getSelector());
3008 const auto *P = PImpl->getPropertyDecl();
3011 InsMap.insert(P->getGetterName());
3012 if (!P->getSetterName().isNull())
3013 InsMap.insert(P->getSetterName());
3020 bool SynthesizeProperties =
getLangOpts().ObjCDefaultSynthProperties &&
3022 !IDecl->isObjCRequiresPropertyDefs();
3031 ClsMap.insert(I->getSelector());
3038 IncompleteImpl,
true);
3043 dyn_cast<ObjCCategoryImplDecl>(IMPDecl))
3054 for (
auto *PI : I->all_referenced_protocols())
3056 ClsMap, I, ExplicitImplProtocols);
3060 if (!
C->IsClassExtension()) {
3061 for (
auto *P :
C->protocols())
3063 ClsMap, CDecl, ExplicitImplProtocols);
3068 llvm_unreachable(
"invalid ObjCContainerDecl type.");
3077 for (
unsigned i = 0; i != NumElts; ++i) {
3081 SemaRef.forRedeclarationInCurContext());
3092 Diag(AtClassLoc, diag::err_redefinition_different_kind) << IdentList[i];
3100 Diag(AtClassLoc, diag::warn_forward_class_redefinition)
3110 = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl);
3132 if (PrevIDecl && TypeParams) {
3136 SemaRef, PrevTypeParams, TypeParams,
3137 TypeParamListContext::ForwardDeclaration)) {
3138 TypeParams =
nullptr;
3142 Diag(IdentLocs[i], diag::err_objc_parameterized_forward_class)
3145 Diag(Def->getLocation(), diag::note_defined_here)
3148 TypeParams =
nullptr;
3153 Context,
SemaRef.CurContext, AtClassLoc, ClassName, TypeParams,
3154 PrevIDecl, IdentLocs[i]);
3158 SemaRef.mergeDeclAttributes(IDecl, PrevIDecl);
3162 DeclsInGroup.push_back(IDecl);
3165 return SemaRef.BuildDeclaratorGroup(DeclsInGroup);
3170 const Type *left,
const Type *right);
3176 Context.getCanonicalType(leftQT).getUnqualifiedType().getTypePtr();
3178 Context.getCanonicalType(rightQT).getUnqualifiedType().getTypePtr();
3180 if (left == right)
return true;
3192 TypeInfo LeftTI = Context.getTypeInfo(left);
3193 TypeInfo RightTI = Context.getTypeInfo(right);
3228 return (leftSK == rightSK);
3234 assert(lt && rt && lt != rt);
3249 TypeInfo LeftTI = Context.getTypeInfo(lt);
3250 TypeInfo RightTI = Context.getTypeInfo(rt);
3260 for (; li != le && ri != re; ++li, ++ri) {
3261 if (!
matchTypes(Context, strategy, li->getType(), ri->getType()))
3264 return (li == le && ri == re);
3286 (left->
hasAttr<NSReturnsRetainedAttr>()
3287 != right->
hasAttr<NSReturnsRetainedAttr>() ||
3288 left->
hasAttr<NSConsumesSelfAttr>()
3289 != right->
hasAttr<NSConsumesSelfAttr>()))
3296 for (; li != le && ri != re; ++li, ++ri) {
3297 assert(ri != right->
param_end() &&
"Param mismatch");
3304 lparm->
hasAttr<NSConsumedAttr>() != rparm->hasAttr<NSConsumedAttr>())
3312 auto *MethodProtocol = dyn_cast<ObjCProtocolDecl>(Method->getDeclContext());
3313 auto *MethodInListProtocol =
3317 if ((MethodProtocol && !MethodInListProtocol) ||
3318 (!MethodProtocol && MethodInListProtocol))
3321 if (MethodProtocol && MethodInListProtocol)
3327 return MethodInterface == MethodInListInterface;
3335 dyn_cast<ObjCCategoryDecl>(
Method->getDeclContext()))
3336 if (!CD->IsClassExtension() && List->
getBits() < 2)
3367 if (!SameDeclaration ||
3372 if (!
Method->isDefined())
3377 if (
Method->isDeprecated() && SameDeclaration &&
3379 ListWithSameDeclaration = List;
3381 if (
Method->isUnavailable() && SameDeclaration &&
3382 !ListWithSameDeclaration &&
3384 ListWithSameDeclaration = List;
3403 if (
Method->isDeprecated()) {
3409 if (
Method->isUnavailable()) {
3422 if (ListWithSameDeclaration) {
3426 ListWithSameDeclaration->
setNext(List);
3436 assert(
SemaRef.ExternalSource &&
"We need an external AST source");
3437 SemaRef.ExternalSource->ReadMethodPool(Sel);
3443 SemaRef.ExternalSource->updateOutOfDateSelector(Sel);
3457 Method->setDefined(impl);
3491 if (TypeBound->isObjCId())
3495 auto *BoundInterface = TypeBound->getInterface();
3496 assert(BoundInterface &&
"unexpected object type!");
3500 auto *MethodProtocol = dyn_cast<ObjCProtocolDecl>(Method->getDeclContext());
3501 if (MethodProtocol) {
3511 return MethodInterface == BoundInterface ||
3512 MethodInterface->isSuperClassOf(BoundInterface) ||
3513 BoundInterface->isSuperClassOf(MethodInterface);
3515 llvm_unreachable(
"unknown method context");
3522 bool InstanceFirst,
bool CheckTheOther,
const ObjCObjectType *TypeBound) {
3526 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3534 if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) {
3536 Methods.push_back(M->getMethod());
3540 if (!Methods.empty())
3541 return Methods.size() > 1;
3550 if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) {
3552 Methods.push_back(M->getMethod());
3555 return Methods.size() > 1;
3563 FilteredMethods.push_back(BestMethod);
3565 for (
auto *M : Methods)
3566 if (M != BestMethod && !M->
hasAttr<UnavailableAttr>())
3567 FilteredMethods.push_back(M);
3569 if (FilteredMethods.size() > 1)
3573 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3584 bool receiverIdOrClass,
3589 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3594 ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second;
3596 if (M->getMethod() && M->getMethod()->isUnconditionallyVisible())
3597 return M->getMethod();
3604 bool receiverIdOrClass) {
3606 bool issueDiagnostic =
false, issueError =
false;
3610 bool strictSelectorMatch =
3611 receiverIdOrClass &&
3614 if (strictSelectorMatch) {
3615 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3617 issueDiagnostic =
true;
3626 if (!strictSelectorMatch ||
3627 (issueDiagnostic &&
getLangOpts().ObjCAutoRefCount))
3628 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3632 issueDiagnostic =
true;
3639 if (issueDiagnostic) {
3641 Diag(R.getBegin(), diag::err_arc_multiple_method_decl) << Sel << R;
3642 else if (strictSelectorMatch)
3643 Diag(R.getBegin(), diag::warn_strict_multiple_method_decl) << Sel << R;
3645 Diag(R.getBegin(), diag::warn_multiple_method_decl) << Sel << R;
3647 Diag(Methods[0]->getBeginLoc(),
3648 issueError ? diag::note_possibility : diag::note_using)
3649 << Methods[0]->getSourceRange();
3650 for (
unsigned I = 1, N = Methods.size(); I != N; ++I) {
3651 Diag(Methods[I]->getBeginLoc(), diag::note_also_found)
3652 << Methods[I]->getSourceRange();
3658 GlobalMethodPool::iterator Pos =
MethodPool.find(Sel);
3662 auto &Methods = Pos->second;
3665 if (
Method->getMethod() &&
3666 (
Method->getMethod()->isDefined() ||
3667 Method->getMethod()->isPropertyAccessor()))
3668 return Method->getMethod();
3672 if (
Method->getMethod() &&
3673 (
Method->getMethod()->isDefined() ||
3674 Method->getMethod()->isPropertyAccessor()))
3675 return Method->getMethod();
3683 const unsigned MaxEditDistance = 1;
3684 unsigned BestEditDistance = MaxEditDistance + 1;
3685 std::string MethodName = Method->getSelector().getAsString();
3687 unsigned MinPossibleEditDistance =
abs((
int)MethodName.size() - (
int)Typo.size());
3688 if (MinPossibleEditDistance > 0 &&
3689 Typo.size() / MinPossibleEditDistance < 1)
3691 unsigned EditDistance = Typo.edit_distance(MethodName,
true, MaxEditDistance);
3692 if (EditDistance > MaxEditDistance)
3694 if (EditDistance == BestEditDistance)
3695 BestMethod.push_back(Method);
3696 else if (EditDistance < BestEditDistance) {
3698 BestMethod.push_back(Method);
3717 bool ObjectIsId =
true, ObjectIsClass =
true;
3719 ObjectIsId = ObjectIsClass =
false;
3724 ObjectType =
QualType(ObjCPtr->getInterfaceType(), 0);
3725 ObjectIsId = ObjectIsClass =
false;
3728 ObjectIsClass =
false;
3734 for (GlobalMethodPool::iterator b =
MethodPool.begin(),
3738 if (M->getMethod() &&
3739 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3740 (M->getMethod()->getSelector() != Sel)) {
3742 Methods.push_back(M->getMethod());
3743 else if (!ObjectIsClass &&
3745 SemaRef, M->getMethod()->getSelector(), ObjectType))
3746 Methods.push_back(M->getMethod());
3750 if (M->getMethod() &&
3751 (M->getMethod()->getSelector().getNumArgs() == NumArgs) &&
3752 (M->getMethod()->getSelector() != Sel)) {
3754 Methods.push_back(M->getMethod());
3755 else if (!ObjectIsId &&
3757 SemaRef, M->getMethod()->getSelector(), ObjectType))
3758 Methods.push_back(M->getMethod());
3763 for (
unsigned i = 0, e = Methods.size(); i < e; i++) {
3767 return (SelectedMethods.size() == 1) ? SelectedMethods[0] :
nullptr;
3777 for (
auto *Ivar : ID->ivars()) {
3778 if (Ivar->isInvalidDecl())
3783 Diag(Ivar->getLocation(), diag::err_duplicate_member) << II;
3785 Ivar->setInvalidDecl();
3795 for (
auto ivar = ID->getClassInterface()->all_declared_ivar_begin();
3796 ivar; ivar = ivar->getNextIvar()) {
3797 if (ivar->isInvalidDecl())
continue;
3800 S.
Diag(ivar->getLocation(), diag::err_arc_weak_disabled);
3802 S.
Diag(ivar->getLocation(), diag::err_arc_weak_no_runtime);
3814 for (
auto ivar = ID->all_declared_ivar_begin(); ivar;
3815 ivar = ivar->getNextIvar()) {
3816 if (ivar->isInvalidDecl())
3822 S.
Diag(ivar->getLocation(), diag::err_flexible_array_arc_retainable);
3823 ivar->setInvalidDecl();
3829 switch (
SemaRef.CurContext->getDeclKind()) {
3830 case Decl::ObjCInterface:
3832 case Decl::ObjCProtocol:
3834 case Decl::ObjCCategory:
3838 case Decl::ObjCImplementation:
3840 case Decl::ObjCCategoryImpl:
3849 if (
T->isIncompleteArrayType())
3851 const auto *RD =
T->getAsRecordDecl();
3852 return RD && RD->hasFlexibleArrayMember();
3859 if ((IntfDecl = dyn_cast<ObjCInterfaceDecl>(OCD))) {
3860 Ivars = IntfDecl->
ivars();
3861 }
else if (
auto *ImplDecl = dyn_cast<ObjCImplementationDecl>(OCD)) {
3862 IntfDecl = ImplDecl->getClassInterface();
3863 Ivars = ImplDecl->
ivars();
3864 }
else if (
auto *CategoryDecl = dyn_cast<ObjCCategoryDecl>(OCD)) {
3865 if (CategoryDecl->IsClassExtension()) {
3866 IntfDecl = CategoryDecl->getClassInterface();
3867 Ivars = CategoryDecl->
ivars();
3873 for (
auto *ivar : Ivars) {
3875 S.
Diag(ivar->getLocation(), diag::warn_variable_sized_ivar_visibility)
3876 << ivar->getDeclName() << ivar->getType();
3888 if (ivar->isInvalidDecl() || !ivar->getNextIvar())
3891 bool IsInvalidIvar =
false;
3893 S.
Diag(ivar->getLocation(), diag::err_flexible_array_not_at_end)
3894 << ivar->getDeclName() << IvarTy
3896 IsInvalidIvar =
true;
3899 S.
Diag(ivar->getLocation(), diag::err_objc_variable_sized_type_not_at_end)
3900 << ivar->getDeclName() << IvarTy;
3901 IsInvalidIvar =
true;
3903 if (IsInvalidIvar) {
3904 S.
Diag(ivar->getNextIvar()->getLocation(),
3905 diag::note_next_ivar_declaration)
3906 << ivar->getNextIvar()->getSynthesize();
3907 ivar->setInvalidDecl();
3915 (Ivars.begin() == Ivars.end()) ?
nullptr : *Ivars.begin();
3918 while (SuperClass && SuperClass->
ivar_empty())
3922 std::advance(IvarIter, SuperClass->
ivar_size() - 1);
3926 diag::warn_superclass_variable_sized_type_not_at_end)
3941 const llvm::iterator_range<ObjCProtocolList::iterator> &Protocols) {
3942 for (
auto *PI : Protocols)
3953 for (
auto *MD : PDecl->
methods()) {
3954 if (!MD->isPropertyAccessor()) {
3955 if (
const auto *CMD =
3956 IDecl->getMethod(MD->getSelector(), MD->isInstanceMethod())) {
3957 if (CMD->isDirectMethod())
3958 DirectMembers.push_back(CMD);
3963 if (
const auto *CPD = IDecl->FindPropertyVisibleInPrimaryClass(
3964 PD->getIdentifier(),
3965 PD->isClassProperty()
3968 if (CPD->isDirectProperty())
3969 DirectMembers.push_back(CPD);
3972 if (!DirectMembers.empty()) {
3973 S.
Diag(CDecl->
getLocation(), diag::err_objc_direct_protocol_conformance)
3975 for (
const auto *MD : DirectMembers)
3976 S.
Diag(MD->getLocation(), diag::note_direct_member_here);
3993 assert(AtEnd.
isValid() &&
"Invalid location for '@end'");
3996 Decl *ClassDecl = OCD;
3998 bool isInterfaceDeclKind =
4007 if (
auto *OID = dyn_cast<ObjCImplementationDecl>(
SemaRef.CurContext)) {
4008 for (
auto *PropImpl : OID->property_impls()) {
4009 if (
auto *Getter = PropImpl->getGetterMethodDecl())
4010 if (Getter->isSynthesizedAccessorStub())
4011 OID->addDecl(Getter);
4012 if (
auto *Setter = PropImpl->getSetterMethodDecl())
4013 if (Setter->isSynthesizedAccessorStub())
4014 OID->addDecl(Setter);
4019 llvm::DenseMap<Selector, const ObjCMethodDecl*> InsMap;
4020 llvm::DenseMap<Selector, const ObjCMethodDecl*> ClsMap;
4022 for (
unsigned i = 0, e = allMethods.size(); i != e; i++ ) {
4024 cast_or_null<ObjCMethodDecl>(allMethods[i]);
4027 if (
Method->isInstanceMethod()) {
4032 if ((isInterfaceDeclKind && PrevMethod && !
match)
4033 || (checkIdenticalMethods &&
match)) {
4034 Diag(
Method->getLocation(), diag::err_duplicate_method_decl)
4035 <<
Method->getDeclName();
4037 Method->setInvalidDecl();
4040 Method->setAsRedeclaration(PrevMethod);
4041 if (!Context.getSourceManager().isInSystemHeader(
4043 Diag(
Method->getLocation(), diag::warn_duplicate_method_decl)
4044 <<
Method->getDeclName();
4056 if ((isInterfaceDeclKind && PrevMethod && !
match)
4057 || (checkIdenticalMethods &&
match)) {
4058 Diag(
Method->getLocation(), diag::err_duplicate_method_decl)
4059 <<
Method->getDeclName();
4061 Method->setInvalidDecl();
4064 Method->setAsRedeclaration(PrevMethod);
4065 if (!Context.getSourceManager().isInSystemHeader(
4067 Diag(
Method->getLocation(), diag::warn_duplicate_method_decl)
4068 <<
Method->getDeclName();
4083 if (
C->IsClassExtension()) {
4092 if (CDecl->getIdentifier())
4096 for (
auto *I : CDecl->properties())
4098 CDecl->setAtEndRange(AtEnd);
4101 IC->setAtEndRange(AtEnd);
4108 for (
const auto *Ext : IDecl->visible_extensions()) {
4109 for (
const auto *
Property : Ext->instance_properties()) {
4112 = IC->FindPropertyImplDecl(
Property->getIdentifier(),
4114 if (PIDecl->getPropertyImplementation()
4118 for (
const auto *Ext : IDecl->visible_extensions()) {
4120 Ext->getInstanceMethod(
Property->getGetterName()))
4121 GetterMethod->setPropertyAccessor(
true);
4124 = Ext->getInstanceMethod(
Property->getSetterName()))
4125 SetterMethod->setPropertyAccessor(
true);
4133 if (IDecl->hasDesignatedInitializers())
4138 bool HasRootClassAttr = IDecl->hasAttr<ObjCRootClassAttr>();
4139 if (IDecl->getSuperClass() ==
nullptr) {
4142 if (!HasRootClassAttr) {
4145 Diag(DeclLoc, diag::warn_objc_root_class_missing)
4146 << IDecl->getIdentifier();
4154 Diag(SuperClassLoc, diag::note_objc_needs_superclass)
4157 Diag(SuperClassLoc, diag::note_objc_needs_superclass);
4160 }
else if (HasRootClassAttr) {
4162 Diag(IDecl->getLocation(), diag::err_objc_root_class_subclass);
4170 if (IDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
4171 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
4172 Diag(IC->getLocation(), diag::err_restricted_superclass_mismatch);
4173 Diag(Super->getLocation(), diag::note_class_declared);
4177 if (IDecl->hasAttr<ObjCClassStubAttr>())
4178 Diag(IC->getLocation(), diag::err_implementation_of_class_stub);
4181 while (IDecl->getSuperClass()) {
4183 IDecl = IDecl->getSuperClass();
4189 dyn_cast<ObjCCategoryImplDecl>(ClassDecl)) {
4190 CatImplClass->setAtEndRange(AtEnd);
4196 = IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier())) {
4200 }
else if (
const auto *IntfDecl = dyn_cast<ObjCInterfaceDecl>(ClassDecl)) {
4202 if (!IntfDecl->hasAttr<ObjCSubclassingRestrictedAttr>() &&
4203 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) {
4204 Diag(IntfDecl->getLocation(), diag::err_restricted_superclass_mismatch);
4205 Diag(Super->getLocation(), diag::note_class_declared);
4209 if (IntfDecl->hasAttr<ObjCClassStubAttr>() &&
4210 !IntfDecl->hasAttr<ObjCSubclassingRestrictedAttr>())
4211 Diag(IntfDecl->getLocation(), diag::err_class_stub_subclassing_mismatch);
4214 if (isInterfaceDeclKind) {
4216 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
4219 if (
VarDecl *VDecl = dyn_cast<VarDecl>(*I)) {
4220 if (!VDecl->hasExternalStorage())
4221 Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass);
4227 for (
unsigned i = 0, e = allTUVars.size(); i != e; i++) {
4230 (*I)->setTopLevelDeclInObjCContainer();
4231 SemaRef.Consumer.HandleTopLevelDeclInObjCContainer(DG);
4234 SemaRef.ActOnDocumentableDecl(ClassDecl);
4251 QualType ResultType = Method->getReturnType();
4259 if (ResultObjectType->isObjCIdType() ||
4260 ResultObjectType->isObjCQualifiedIdType())
4265 = ResultObjectType->getInterfaceDecl()) {
4271 if (ResultClass->isSuperClassOf(CurrentClass))
4287class OverrideSearch {
4289 const ObjCMethodDecl *
Method;
4290 llvm::SmallSetVector<ObjCMethodDecl*, 4> Overridden;
4294 OverrideSearch(Sema &S,
const ObjCMethodDecl *method) :
Method(method) {
4299 SemaObjC::GlobalMethodPool::iterator it =
4300 S.
ObjC().MethodPool.find(selector);
4302 if (!S.getExternalSource()) return;
4303 S.ObjC().ReadMethodPool(selector);
4305 it = S.ObjC().MethodPool.find(selector);
4306 if (it == S.ObjC().MethodPool.end())
4309 const ObjCMethodList &list =
4311 if (!list.getMethod())
return;
4313 const ObjCContainerDecl *container
4319 if (
const ObjCCategoryDecl *Category =
4320 dyn_cast<ObjCCategoryDecl>(container)) {
4321 searchFromContainer(container);
4322 if (
const ObjCInterfaceDecl *
Interface = Category->getClassInterface())
4325 searchFromContainer(container);
4329 typedef decltype(Overridden)::iterator iterator;
4330 iterator begin()
const {
return Overridden.begin(); }
4331 iterator end()
const {
return Overridden.end(); }
4334 void searchFromContainer(
const ObjCContainerDecl *container) {
4338#define OBJCCONTAINER(type, base) \
4340 searchFrom(cast<type##Decl>(container)); \
4342#define ABSTRACT_DECL(expansion)
4343#define DECL(type, base) \
4345#include "clang/AST/DeclNodes.inc"
4346 llvm_unreachable(
"not an ObjC container!");
4350 void searchFrom(
const ObjCProtocolDecl *protocol) {
4359 void searchFrom(
const ObjCCategoryDecl *category) {
4366 void searchFrom(
const ObjCCategoryImplDecl *impl) {
4372 if (ObjCInterfaceDecl *
Interface = category->getClassInterface())
4381 void searchFrom(
const ObjCInterfaceDecl *iface) {
4398 void searchFrom(
const ObjCImplementationDecl *impl) {
4405 void search(
const ObjCProtocolList &protocols) {
4406 for (
const auto *Proto : protocols)
4410 void search(
const ObjCContainerDecl *container) {
4413 Method->isInstanceMethod(),
4418 Overridden.insert(meth);
4428 searchFromContainer(container);
4436 const auto *
attr = overridden->
getAttr<ObjCDirectAttr>();
4438 Diag(
attr->getLocation(), diag::note_previous_declaration);
4440 const auto *
attr = method->
getAttr<ObjCDirectAttr>();
4441 Diag(
attr->getLocation(), diag::err_objc_direct_on_override)
4453 auto IsMethodInCurrentClass = [CurrentClass](
const ObjCMethodDecl *M) {
4455 return M->getClassInterface()->getCanonicalDecl() ==
4459 OverrideSearch overrides(
SemaRef, ObjCMethod);
4465 bool hasOverriddenMethodsInBaseOrProtocol =
false;
4467 if (!hasOverriddenMethodsInBaseOrProtocol) {
4469 !IsMethodInCurrentClass(overridden) || overridden->isOverriding()) {
4471 hasOverriddenMethodsInBaseOrProtocol =
true;
4480 GlobalMethodPool::iterator It =
4485 unsigned CategCount = List.
getBits();
4486 if (CategCount > 0) {
4489 if (CategCount > 1 ||
4491 OverrideSearch overrides(
SemaRef, overridden);
4494 !IsMethodInCurrentClass(SuperOverridden)) {
4496 hasOverriddenMethodsInBaseOrProtocol =
true;
4497 overridden->setOverriding(
true);
4512 SemaRef.mergeObjCMethodDecls(ObjCMethod, overridden);
4514 if (ObjCMethod->
isImplicit() && overridden->isImplicit())
4523 if (CurrentClass && overridden->
getDeclContext() != CurrentClass &&
4525 !overridden->isImplicit() ) {
4529 PrevE = overridden->param_end();
4530 for (; ParamI != E && PrevI != PrevE; ++ParamI, ++PrevI) {
4531 assert(PrevI != overridden->param_end() &&
"Param mismatch");
4536 if (!Context.typesAreCompatible(T1, T2)) {
4537 Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super)
4539 Diag(overridden->getLocation(), diag::note_previous_declaration);
4546 ObjCMethod->
setOverriding(hasOverriddenMethodsInBaseOrProtocol);
4556 bool prevUsesCSKeyword) {
4558 auto nullability =
type->getNullability();
4562 if (nullability.has_value() == prevNullability.has_value()) {
4568 if (*nullability == *prevNullability)
4572 S.
Diag(loc, diag::err_nullability_conflicting)
4593 if (prevMethod->
hasAttr<ObjCRequiresSuperAttr>() &&
4594 !method->
hasAttr<ObjCRequiresSuperAttr>()) {
4597 ObjCRequiresSuperAttr::CreateImplicit(S.
Context,
4614 unsigned numPrevParams = prevMethod->
param_size();
4615 for (
unsigned i = 0, n = std::min(numParams, numPrevParams); i != n; ++i) {
4635 llvm::Triple::x86 &&
4636 "x86-specific check invoked for a different target");
4639 for (
const ParmVarDecl *P : Method->parameters()) {
4640 if (P->getType()->isVectorType()) {
4641 Loc = P->getBeginLoc();
4647 if (Method->getReturnType()->isVectorType()) {
4648 Loc = Method->getReturnTypeSourceRange().getBegin();
4649 T = Method->getReturnType();
4657 VersionTuple AcceptedInVersion;
4658 if (Triple.getOS() == llvm::Triple::IOS)
4659 AcceptedInVersion = VersionTuple(9);
4660 else if (Triple.isMacOSX())
4661 AcceptedInVersion = VersionTuple(10, 11);
4667 SemaRef.
Diag(Loc, diag::err_objc_method_unsupported_param_ret_type)
4668 <<
T << (Method->getReturnType()->isVectorType() ? 1
4670 << (Triple.isMacOSX() ?
"macOS 10.11" :
"iOS 9");
4674 if (!Method->isDirectMethod() && !Method->hasAttr<UnavailableAttr>() &&
4675 CD->
hasAttr<ObjCDirectMembersAttr>()) {
4677 ObjCDirectAttr::CreateImplicit(S.
Context, Method->getLocation()));
4684 auto Sel = Method->getSelector();
4685 bool isInstance = Method->isInstanceMethod();
4686 bool diagnosed =
false;
4689 if (diagnosed || IMD->isImplicit())
4691 if (Method->isDirectMethod() || IMD->isDirectMethod()) {
4692 S.
Diag(Method->getLocation(), diag::err_objc_direct_duplicate_decl)
4693 << Method->isDirectMethod() << 0 << IMD->isDirectMethod()
4694 << Method->getDeclName();
4695 S.
Diag(IMD->getLocation(), diag::note_previous_declaration);
4713 if (
auto *IMD = IDecl->
getMethod(Sel, isInstance))
4716 if (Impl != ImpDecl)
4721 if (
auto *IMD = Cat->getMethod(Sel, isInstance))
4723 else if (
auto CatImpl = Cat->getImplementation())
4724 if (CatImpl != ImpDecl)
4725 if (
auto *IMD = Cat->getMethod(Sel, isInstance))
4732 bool MethodDefinition) {
4737 if (!ArgInfo.
Type) {
4738 ArgType = Context.getObjCIdType();
4745 SemaRef.forRedeclarationInCurContext());
4747 if (R.isSingleResult()) {
4751 (MethodDefinition ? diag::warn_method_param_redefinition
4752 : diag::warn_method_param_declaration))
4764 Context.getTranslationUnitDecl(), StartLoc, ArgInfo.
NameLoc, ArgInfo.
Name,
4766 Param->setObjCMethodScopeInfo(ParamIndex);
4767 Param->setObjCDeclQualifier(
4773 if (Param->hasAttr<BlocksAttr>()) {
4774 Diag(Param->getLocation(), diag::err_block_not_allowed_on)
4775 << diag::NotAllowedBlockVarReason::NonlocalVariable;
4776 Param->setInvalidDecl();
4780 SemaRef.IdResolver.AddDecl(Param);
4793 bool isVariadic,
bool MethodDefinition) {
4796 if (!
SemaRef.CurContext->isObjCContainer()) {
4797 Diag(MethodLoc, diag::err_missing_method_context);
4804 bool HasRelatedResultType =
false;
4807 resultDeclType =
SemaRef.GetTypeFromParser(ReturnType, &ReturnTInfo);
4809 if (
SemaRef.CheckFunctionReturnType(resultDeclType, MethodLoc))
4812 QualType bareResultType = resultDeclType;
4813 (void)AttributedType::stripOuterNullability(bareResultType);
4814 HasRelatedResultType = (bareResultType == Context.getObjCInstanceType());
4816 resultDeclType = Context.getObjCIdType();
4817 Diag(MethodLoc, diag::warn_missing_method_return_type)
4822 Context, MethodLoc, EndLoc, Sel, resultDeclType, ReturnTInfo,
4823 SemaRef.CurContext, MethodType == tok::minus, isVariadic,
4826 MethodDeclKind == tok::objc_optional
4829 HasRelatedResultType);
4832 for (
unsigned I = 0; I < Sel.
getNumArgs(); ++I) {
4835 SemaRef.ProcessAPINotes(Param);
4836 Params.push_back(Param);
4839 for (
unsigned i = 0, e = CNumArgs; i != e; ++i) {
4843 ArgType = Context.getObjCIdType();
4848 Param->setDeclContext(ObjCMethod);
4849 Params.push_back(Param);
4856 SemaRef.ProcessDeclAttributeList(
SemaRef.TUScope, ObjCMethod, AttrList);
4858 SemaRef.ProcessAPINotes(ObjCMethod);
4862 if (
ObjCImplDecl *ImpDecl = dyn_cast<ObjCImplDecl>(ClassDecl)) {
4863 if (MethodType == tok::minus) {
4864 PrevMethod = ImpDecl->getInstanceMethod(Sel);
4865 ImpDecl->addInstanceMethod(ObjCMethod);
4867 PrevMethod = ImpDecl->getClassMethod(Sel);
4868 ImpDecl->addClassMethod(ObjCMethod);
4877 if (
auto *Setter = PropertyImpl->getSetterMethodDecl())
4878 if (Setter->getSelector() == Sel &&
4880 assert(Setter->isSynthesizedAccessorStub() &&
"autosynth stub expected");
4881 PropertyImpl->setSetterMethodDecl(ObjCMethod);
4883 if (
auto *Getter = PropertyImpl->getGetterMethodDecl())
4884 if (Getter->getSelector() == Sel &&
4886 assert(Getter->isSynthesizedAccessorStub() &&
"autosynth stub expected");
4887 PropertyImpl->setGetterMethodDecl(ObjCMethod);
4901 const auto *
attr = CanonicalMD->
getAttr<ObjCDirectAttr>();
4903 ObjCDirectAttr::CreateImplicit(Context,
attr->getLocation()));
4910 if (
auto *IMD = IDecl->lookupMethod(ObjCMethod->
getSelector(),
4930 if (IDecl == IMD->getClassInterface()) {
4931 auto diagContainerMismatch = [&] {
4932 int decl = 0, impl = 0;
4934 if (
auto *Cat = dyn_cast<ObjCCategoryDecl>(IMD->getDeclContext()))
4935 decl = Cat->IsClassExtension() ? 1 : 2;
4938 impl = 1 + (
decl != 0);
4941 diag::err_objc_direct_impl_decl_mismatch)
4943 Diag(IMD->getLocation(), diag::note_previous_declaration);
4947 const auto *
attr = ObjCMethod->
getAttr<ObjCDirectAttr>();
4949 diagContainerMismatch();
4950 }
else if (!IMD->isDirectMethod()) {
4951 Diag(
attr->getLocation(), diag::err_objc_direct_missing_on_decl);
4952 Diag(IMD->getLocation(), diag::note_previous_declaration);
4954 }
else if (IMD->isDirectMethod()) {
4955 const auto *
attr = IMD->getAttr<ObjCDirectAttr>();
4957 diagContainerMismatch();
4960 ObjCDirectAttr::CreateImplicit(Context,
attr->getLocation()));
4979 for (
auto *
C : IDecl->visible_categories())
4980 for (
auto &P :
C->protocols())
4981 if (
auto *IMD = P->lookupMethod(ObjCMethod->
getSelector(),
4984 IMD->parameters().size() &&
4985 "Methods have different number of parameters");
4986 auto OI = IMD->param_begin(), OE = IMD->param_end();
4988 for (; OI != OE; ++OI, ++NI)
5022 if (!CurrentClass) {
5024 CurrentClass = Cat->getClassInterface();
5025 else if (
ObjCImplDecl *Impl = dyn_cast<ObjCImplDecl>(ClassDecl))
5026 CurrentClass = Impl->getClassInterface();
5028 = dyn_cast<ObjCCategoryImplDecl>(ClassDecl))
5029 CurrentClass = CatImpl->getClassInterface();
5037 bool ARCError =
false;
5045 bool InferRelatedResultType =
false;
5071 if (InferRelatedResultType &&
5076 if (MethodDefinition &&
5077 Context.getTargetInfo().getTriple().getArch() == llvm::Triple::x86)
5082 if (
const auto *
attr = ObjCMethod->
getAttr<AvailabilityAttr>()) {
5085 Diag(
attr->getLocation(), diag::warn_availability_on_static_initializer)
5087 ObjCMethod->
dropAttr<AvailabilityAttr>();
5094 SemaRef.ActOnDocumentableDecl(ObjCMethod);
5108 SemaRef.getCurLexicalContext()->getRedeclContext()))
5111 Diag(D->
getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope);
5126 Diag(DeclStart, diag::err_undef_interface) << ClassName;
5130 Diag(DeclStart, diag::err_atdef_nonfragile_interface);
5136 Context.DeepCollectObjCIvars(
Class,
true, Ivars);
5138 for (
unsigned i = 0; i < Ivars.size(); i++) {
5144 ID->getIdentifier(), ID->getType(),
5146 Decls.push_back(FD);
5151 D != Decls.end(); ++D) {
5154 SemaRef.PushOnScopeChains(FD, S);
5172 Diag(IdLoc, diag::err_arg_with_address_space);
5180 }
else if (
T->isDependentType()) {
5182 }
else if (
T->isObjCQualifiedIdType()) {
5184 Diag(IdLoc, diag::err_illegal_qualifiers_on_catch_parm);
5185 }
else if (
T->isObjCIdType()) {
5187 }
else if (!
T->isObjCObjectPointerType()) {
5189 Diag(IdLoc, diag::err_catch_param_not_objc_type);
5192 Diag(IdLoc, diag::err_catch_param_not_objc_type);
5197 New->setExceptionVariable(
true);
5204 New->setInvalidDecl();
5225 diag::err_invalid_thread)
5234 SemaRef.CheckExtraCXXDefaultArguments(D);
5249 New->setInvalidDecl();
5259 if (
New->hasAttr<BlocksAttr>())
5260 Diag(
New->getLocation(), diag::err_block_not_allowed_on)
5261 << diag::NotAllowedBlockVarReason::NonlocalVariable;
5272 QualType QT = Context.getBaseElementType(Iv->getType());
5274 Ivars.push_back(Iv);
5283 SemaRef.ExternalSource->ReadReferencedSelectors(Sels);
5284 for (
unsigned I = 0, N = Sels.size(); I != N; ++I)
5292 !Context.AnyObjCImplementation())
5295 Selector Sel = SelectorAndLocation.first;
5298 Diag(Loc, diag::warn_unimplemented_selector) << Sel;
5305 if (
Method->isClassMethod())
5315 if ((PDecl =
Method->findPropertyDecl()))
5321 IV->getIdentifier());
5336 bool InvokedSelfMethod;
5341 InvokedSelfMethod(
false) {
5347 AccessedIvar =
true;
5353 bool VisitObjCMessageExpr(ObjCMessageExpr *E)
override {
5356 InvokedSelfMethod =
true;
5369 unsigned DIAG = diag::warn_unused_property_backing_ivar;
5379 if (CurMethod->isSynthesizedAccessorStub())
5382 UnusedBackingIvarChecker Checker(
SemaRef, CurMethod, IV);
5383 Checker.TraverseStmt(CurMethod->getBody());
5384 if (Checker.AccessedIvar)
5391 if (!IV->
isReferenced() || !Checker.InvokedSelfMethod) {
5411 if (
T->isArrayType()) {
5412 if (!
T.isConstQualified()) {
5413 if (
SemaRef.DelayedDiagnostics.shouldDelayDiagnostics())
5414 SemaRef.DelayedDiagnostics.add(
5416 NameLoc, diag::err_arc_array_param_no_ownership,
T,
false));
5418 Diag(NameLoc, diag::err_arc_array_param_no_ownership)
5423 Lifetime =
T->getObjCARCImplicitLifetime();
5425 T = Context.getLifetimeQualifiedType(
T, Lifetime);
5432 bool DoTypoCorrection) {
5438 if (!IDecl && DoTypoCorrection) {
5445 SemaRef.diagnoseTypo(
C,
PDiag(diag::err_undef_interface_suggest) << Id);
5463 unsigned kind = -1U;
5465 if (var->hasAttr<BlocksAttr>())
5467 else if (!var->hasLocalStorage())
5476 Diag(
decl->getLocation(), diag::err_arc_autoreleasing_var) <<
kind;
5480 if (!
type->isObjCLifetimeType())
5483 lifetime =
type->getObjCARCImplicitLifetime();
5484 type = Context.getLifetimeQualifiedType(
type, lifetime);
5491 var->getTLSKind()) {
5492 Diag(var->getLocation(), diag::err_arc_thread_ownership)
5502 return (dyn_cast_or_null<ObjCContainerDecl>(
SemaRef.CurContext));
5515 for (
unsigned i = 0; i < ivars.size(); i++) {
5517 if (Field->isInvalidDecl())
5527 InitSeq.Perform(
SemaRef, InitEntity, InitKind, {});
5528 MemberInit =
SemaRef.MaybeCreateExprWithCleanups(MemberInit);
5531 if (!MemberInit.get() || MemberInit.isInvalid())
5537 AllToInit.push_back(
Member);
5540 if (
auto *RD = Context.getBaseElementType(Field->getType())
5541 ->getAsCXXRecordDecl()) {
5544 SemaRef.CheckDestructorAccess(
5546 PDiag(diag::err_access_dtor_ivar)
5547 << Context.getBaseElementType(Field->getType()));
5560 switch (ivarVisibility) {
5562 llvm_unreachable(
"Unknown visitibility kind");
5563 case tok::objc_private:
5565 case tok::objc_public:
5567 case tok::objc_protected:
5569 case tok::objc_package:
5590 if (Context.getLangOpts().PointerAuthObjcInterfaceSel &&
5591 !
T.getPointerAuth()) {
5592 if (Context.isObjCSelType(
T.getUnqualifiedType())) {
5593 if (
auto PAQ = Context.getObjCMemberSelTypePtrAuth())
5594 T = Context.getPointerAuthType(
T, PAQ);
5601 SemaRef.VerifyBitField(Loc, II,
T,
false, BitWidth)
5610 if (
T->isReferenceType()) {
5611 Diag(Loc, diag::err_ivar_reference_type);
5616 else if (
T->isVariablyModifiedType()) {
5617 if (!
SemaRef.tryToFixVariablyModifiedVarType(
5618 TInfo,
T, Loc, diag::err_typecheck_ivar_variable_size))
5633 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
5637 EnclosingContext = IMPDecl->getClassInterface();
5638 assert(EnclosingContext &&
"Implementation has no class interface!");
5640 EnclosingContext = EnclosingDecl;
5644 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
5648 EnclosingContext = EnclosingDecl;
5654 II,
T, TInfo, ac, BitWidth);
5656 if (
T->containsErrors())
5663 if (PrevDecl &&
SemaRef.isDeclInScope(PrevDecl, EnclosingContext, S) &&
5665 Diag(Loc, diag::err_duplicate_member) << II;
5672 SemaRef.ProcessDeclAttributes(S, NewID, D);
5688 SemaRef.IdResolver.AddDecl(NewID);
5693 Diag(Loc, diag::warn_ivars_in_interface);
Defines the clang::ASTContext interface.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
#define DIAG(ENUM, CLASS, DEFAULT_SEVERITY, DESC, GROUP, SFINAE, NOWERROR, SHOWINSYSHEADER, SHOWINSYSMACRO, DEFERRABLE, CATEGORY, STABLE_ID, LEGACY_STABLE_IDS)
static QualType getObjectType(APValue::LValueBase B)
Retrieves the "underlying object type" of the given expression, as used by __builtin_object_size.
llvm::MachO::Record Record
*collection of selector each with an associated kind and an ordered *collection of selectors A selector has a kind
@ ForVisibleRedeclaration
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
static bool IsVariableSizedType(QualType T)
static void DiagnoseVariableSizedIvars(Sema &S, ObjCContainerDecl *OCD)
static bool HasExplicitOwnershipAttr(Sema &S, ParmVarDecl *Param)
HasExplicitOwnershipAttr - returns true when pointer to ObjC pointer has explicit ownership attribute...
static void checkObjCDirectMethodClashes(Sema &S, ObjCInterfaceDecl *IDecl, ObjCMethodDecl *Method, ObjCImplDecl *ImpDecl=nullptr)
static bool CheckMethodOverrideParam(Sema &S, ObjCMethodDecl *MethodImpl, ObjCMethodDecl *MethodDecl, ParmVarDecl *ImplVar, ParmVarDecl *IfaceVar, bool IsProtocolMethodDecl, bool IsOverridingMode, bool Warn)
static SourceRange getTypeRange(TypeSourceInfo *TSI)
std::unique_ptr< ProtocolNameSet > LazyProtocolNameSet
static bool CheckMethodOverrideReturn(Sema &S, ObjCMethodDecl *MethodImpl, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl, bool IsOverridingMode, bool Warn)
static void DiagnoseCategoryDirectMembersProtocolConformance(Sema &S, ObjCProtocolDecl *PDecl, ObjCCategoryDecl *CDecl)
static bool checkTypeParamListConsistency(Sema &S, ObjCTypeParamList *prevTypeParams, ObjCTypeParamList *newTypeParams, TypeParamListContext newContext)
Check consistency between two Objective-C type parameter lists, e.g., between a category/extension an...
static void HelperSelectorsForTypoCorrection(SmallVectorImpl< const ObjCMethodDecl * > &BestMethod, StringRef Typo, const ObjCMethodDecl *Method)
static bool objcModifiersConflict(Decl::ObjCDeclQualifier x, Decl::ObjCDeclQualifier y)
Determine whether two set of Objective-C declaration qualifiers conflict.
static bool shouldWarnUndefinedMethod(const ObjCMethodDecl *M)
static bool FilterMethodsByTypeBound(ObjCMethodDecl *Method, const ObjCObjectType *TypeBound)
Return true if the given method is wthin the type bound.
static void DiagnoseObjCImplementedDeprecations(Sema &S, const NamedDecl *ND, SourceLocation ImplLoc)
static void findProtocolsWithExplicitImpls(const ObjCProtocolDecl *PDecl, ProtocolNameSet &PNS)
static bool matchTypes(ASTContext &Context, SemaObjC::MethodMatchStrategy strategy, QualType leftQT, QualType rightQT)
static void DiagnoseRetainableFlexibleArrayMember(Sema &S, ObjCInterfaceDecl *ID)
Diagnose attempts to use flexible array member with retainable object type.
static void mergeInterfaceMethodToImpl(Sema &S, ObjCMethodDecl *method, ObjCMethodDecl *prevMethod)
Merge information from the declaration of a method in the @interface (or a category/extension) into t...
static bool HelperIsMethodInObjCType(Sema &S, Selector Sel, QualType ObjectType)
static SemaObjC::ResultTypeCompatibilityKind CheckRelatedResultTypeCompatibility(Sema &S, ObjCMethodDecl *Method, ObjCInterfaceDecl *CurrentClass)
Check whether the declared result type of the given Objective-C method declaration is compatible with...
static ObjCIvarDecl::AccessControl TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility)
TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value.
static void CheckProtocolMethodDefs(Sema &S, ObjCImplDecl *Impl, ObjCProtocolDecl *PDecl, bool &IncompleteImpl, const SemaObjC::SelectorSet &InsMap, const SemaObjC::SelectorSet &ClsMap, ObjCContainerDecl *CDecl, LazyProtocolNameSet &ProtocolsExplictImpl)
CheckProtocolMethodDefs - This routine checks unimplemented methods Declared in protocol,...
static void WarnUndefinedMethod(Sema &S, ObjCImplDecl *Impl, ObjCMethodDecl *method, bool &IncompleteImpl, unsigned DiagID, NamedDecl *NeededFor=nullptr)
static bool NestedProtocolHasNoDefinition(ObjCProtocolDecl *PDecl, ObjCProtocolDecl *&UndefinedProtocol)
static bool isObjCTypeSubstitutable(ASTContext &Context, const ObjCObjectPointerType *A, const ObjCObjectPointerType *B, bool rejectId)
Determines if type B can be substituted for type A.
llvm::DenseSet< IdentifierInfo * > ProtocolNameSet
FIXME: Type hierarchies in Objective-C can be deep.
static QualType mergeTypeNullabilityForRedecl(Sema &S, SourceLocation loc, QualType type, bool usesCSKeyword, SourceLocation prevLoc, QualType prevType, bool prevUsesCSKeyword)
Merge type nullability from for a redeclaration of the same entity, producing the updated type of the...
static bool diagnoseNoescape(const ParmVarDecl *NewD, const ParmVarDecl *OldD, Sema &S)
Issue a warning if the parameter of the overridden method is non-escaping but the parameter of the ov...
static bool isAcceptableMethodMismatch(ObjCMethodDecl *chosen, ObjCMethodDecl *other)
Determines if this is an "acceptable" loose mismatch in the global method pool.
static void mergeObjCDirectMembers(Sema &S, Decl *CD, ObjCMethodDecl *Method)
static void DiagnoseWeakIvars(Sema &S, ObjCImplementationDecl *ID)
Diagnose attempts to define ARC-__weak ivars when __weak is disabled.
static void checkObjCMethodX86VectorTypes(Sema &SemaRef, const ObjCMethodDecl *Method)
Verify that the method parameters/return value have types that are supported by the x86 target.
static bool checkMethodFamilyMismatch(Sema &S, ObjCMethodDecl *impl, ObjCMethodDecl *decl)
In ARC, check whether the conventional meanings of the two methods match.
static bool isMethodContextSameForKindofLookup(ObjCMethodDecl *Method, ObjCMethodDecl *MethodInList)
static bool tryMatchRecordTypes(ASTContext &Context, SemaObjC::MethodMatchStrategy strategy, const Type *left, const Type *right)
static Decl::ObjCDeclQualifier CvtQTToAstBitMask(ObjCDeclSpec::ObjCDeclQualifier PQTVal)
CvtQTToAstBitMask - utility routine to produce an AST bitmask for objective-c's type qualifier from t...
static void diagnoseUseOfProtocols(Sema &TheSema, ObjCContainerDecl *CD, ObjCProtocolDecl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs)
This file declares semantic analysis for Objective-C.
Defines the SourceManager interface.
__DEVICE__ long long abs(long long __n)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void adjustObjCTypeParamBoundType(const ObjCTypeParamDecl *Orig, ObjCTypeParamDecl *New) const
QualType getAttributedType(attr::Kind attrKind, QualType modifiedType, QualType equivalentType, const Attr *attr=nullptr) const
const LangOptions & getLangOpts() const
SelectorTable & Selectors
const clang::PrintingPolicy & getPrintingPolicy() const
void ResetObjCLayout(const ObjCInterfaceDecl *D)
CanQualType getCanonicalTypeDeclType(const TypeDecl *TD) const
static bool hasSameType(QualType T1, QualType T2)
Determine whether the given types T1 and T2 are equivalent.
const TargetInfo & getTargetInfo() const
bool hasSameNullabilityTypeQualifier(QualType SubT, QualType SuperT, bool IsParam) const
static bool hasSameUnqualifiedType(QualType T1, QualType T2)
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void addObjCSubClass(const ObjCInterfaceDecl *D, const ObjCInterfaceDecl *SubClass)
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
Type source information for an attributed type.
Represents a C++ base or member initializer.
Represents a C++ destructor within a class.
SourceRange getRange() const
bool isSet() const
Deprecated.
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isFileContext() const
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void addDecl(Decl *D)
Add the declaration D into this context.
Decl::Kind getDeclKind() const
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
Captures information about "declaration specifiers".
bool isModulePrivateSpecified() const
static const TST TST_typename
ThreadStorageClassSpecifier TSCS
void ClearStorageClassSpecs()
SourceLocation getStorageClassSpecLoc() const
SCS getStorageClassSpec() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
void SetRangeEnd(SourceLocation Loc)
void SetRangeStart(SourceLocation Loc)
SCS
storage-class-specifier
TSCS getThreadStorageClassSpec() const
bool isInlineSpecified() const
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
SourceLocation getThreadStorageClassSpecLoc() const
SourceLocation getInlineSpecLoc() const
Decl - This represents one declaration (or definition), e.g.
SourceLocation getEndLoc() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple(), StringRef *RealizedPlatform=nullptr) const
Determine the availability of the given declaration.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isUnconditionallyVisible() const
Determine whether this declaration is definitely visible to name lookup, independent of whether the o...
void setTopLevelDeclInObjCContainer(bool V=true)
bool isReferenced() const
Whether any declaration of this entity was referenced.
ObjCDeclQualifier
ObjCDeclQualifier - 'Qualifiers' written next to the return and parameter types in method declaration...
@ OBJC_TQ_CSNullability
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
bool isInvalidDecl() const
SourceLocation getLocation() const
bool isDeprecated(std::string *Message=nullptr) const
Determine whether this declaration is marked 'deprecated'.
void setImplicit(bool I=true)
DeclContext * getDeclContext()
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to DC.
void setLexicalDeclContext(DeclContext *DC)
TypeSourceInfo * getTypeSourceInfo() const
Information about one declarator, including the parsed type information and the identifier.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
SourceLocation getIdentifierLoc() const
void setInvalidType(bool Val=true)
const CXXScopeSpec & getCXXScopeSpec() const
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &&attrs, SourceLocation EndLoc)
AddTypeInfo - Add a chunk to this declarator.
bool isInvalidType() const
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
const IdentifierInfo * getIdentifier() const
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
This represents one expression.
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
unsigned getBitWidthValue() const
Computes the bit width of this field, if this is a bit field.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
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.
One of these records is kept for each identifier that is lexed.
A simple pair of identifier info and location.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
Describes the kind of initialization being performed, along with location information for tokens rela...
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
Describes the sequence of initializations required to initialize a given object or reference with a s...
Describes an entity that is being initialized.
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a member subobject.
clang::ObjCRuntime ObjCRuntime
Represents the results of name lookup.
This represents a decl that may have a name.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
void setModulePrivate()
Specify that this declaration was marked as being private to the module in which it was defined.
static ObjCAtDefsFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW)
ObjCCategoryDecl - Represents a category declaration.
static ObjCCategoryDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, const IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, ObjCTypeParamList *typeParamList, SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCCategoryImplDecl * getImplementation() const
ObjCInterfaceDecl * getClassInterface()
bool IsClassExtension() const
const ObjCProtocolList & getReferencedProtocols() const
void setImplementation(ObjCCategoryImplDecl *ImplD)
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
ObjCCategoryDecl * getCategoryDecl() const
static ObjCCategoryImplDecl * Create(ASTContext &C, DeclContext *DC, const IdentifierInfo *Id, ObjCInterfaceDecl *classInterface, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation CategoryNameLoc)
ObjCCompatibleAliasDecl - Represents alias of a class.
static ObjCCompatibleAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl *aliasedClass)
ObjCContainerDecl - Represents a container for method declarations.
ObjCMethodDecl * getMethod(Selector Sel, bool isInstance, bool AllowHidden=false) const
method_range methods() const
instmeth_range instance_methods() const
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
void setAtEndRange(SourceRange atEnd)
ObjCMethodDecl * getClassMethod(Selector Sel, bool AllowHidden=false) const
prop_range properties() const
classmeth_range class_methods() const
ObjCMethodDecl * getInstanceMethod(Selector Sel, bool AllowHidden=false) const
Captures information about "declaration specifiers" specific to Objective-C.
ObjCDeclQualifier
ObjCDeclQualifier - Qualifier used on types in method declarations.
ObjCDeclQualifier getObjCDeclQualifier() const
propimpl_range property_impls() const
const ObjCInterfaceDecl * getClassInterface() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
static ObjCImplementationDecl * Create(ASTContext &C, DeclContext *DC, ObjCInterfaceDecl *classInterface, ObjCInterfaceDecl *superDecl, SourceLocation nameLoc, SourceLocation atStartLoc, SourceLocation superLoc=SourceLocation(), SourceLocation IvarLBraceLoc=SourceLocation(), SourceLocation IvarRBraceLoc=SourceLocation())
void setIvarInitializers(ASTContext &C, CXXCtorInitializer **initializers, unsigned numInitializers)
const ObjCInterfaceDecl * getSuperClass() const
Represents an ObjC class declaration.
void mergeClassExtensionProtocolList(ObjCProtocolDecl *const *List, unsigned Num, ASTContext &C)
mergeClassExtensionProtocolList - Merge class extension's protocol list into the protocol list for th...
ObjCTypeParamList * getTypeParamList() const
Retrieve the type parameters of this class.
ObjCInterfaceDecl * lookupInheritedClass(const IdentifierInfo *ICName)
lookupInheritedClass - This method returns ObjCInterfaceDecl * of the super class whose name is passe...
ivar_iterator ivar_end() const
static ObjCInterfaceDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation atLoc, const IdentifierInfo *Id, ObjCTypeParamList *typeParamList, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc=SourceLocation(), bool isInternal=false)
unsigned ivar_size() const
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
bool hasDefinition() const
Determine whether this class has been defined.
all_protocol_range all_referenced_protocols() const
visible_extensions_range visible_extensions() const
bool isImplicitInterfaceDecl() const
isImplicitInterfaceDecl - check that this is an implicitly declared ObjCInterfaceDecl node.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
ObjCCategoryDecl * FindCategoryDeclaration(const IdentifierInfo *CategoryId) const
FindCategoryDeclaration - Finds category declaration in the list of categories for this class and ret...
ivar_iterator ivar_begin() const
llvm::iterator_range< specific_decl_iterator< ObjCIvarDecl > > ivar_range
void setImplementation(ObjCImplementationDecl *ImplD)
known_categories_range known_categories() const
void setSuperClass(TypeSourceInfo *superClass)
const ObjCProtocolList & getReferencedProtocols() const
ObjCMethodDecl * lookupMethod(Selector Sel, bool isInstance, bool shallowCategoryLookup=false, bool followSuper=true, const ObjCCategoryDecl *C=nullptr) const
lookupMethod - This method returns an instance/class method by looking in the class,...
ObjCImplementationDecl * getImplementation() const
void setEndOfDefinitionLoc(SourceLocation LE)
void startDefinition()
Starts the definition of this Objective-C class, taking it from a forward declaration (@class) to a d...
visible_categories_range visible_categories() const
ObjCInterfaceDecl * getCanonicalDecl() override
Retrieves the canonical declaration of this Objective-C class.
ObjCInterfaceDecl * getSuperClass() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
void startDuplicateDefinitionForComparison()
Starts the definition without sharing it with other redeclarations.
bool isSuperClassOf(const ObjCInterfaceDecl *I) const
isSuperClassOf - Return true if this class is the specified class or is a super class of the specifie...
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
Represents typeof(type), a C23 feature and GCC extension, or `typeof_unqual(type),...
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCIvarDecl * getNextIvar()
static ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
ObjCIvarRefExpr - A reference to an ObjC instance variable.
ObjCList - This is a simple template class used to hold various lists of decls etc,...
void set(T *const *InList, unsigned Elts, ASTContext &Ctx)
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
@ Instance
The receiver is an object instance.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
ObjCMethodDecl - Represents an instance or class method declaration.
bool isDesignatedInitializerForTheInterface(const ObjCMethodDecl **InitMethod=nullptr) const
Returns true if the method selector resolves to a designated initializer in the class's interface.
ImplicitParamDecl * getSelfDecl() const
void setObjCDeclQualifier(ObjCDeclQualifier QV)
void setDefined(bool isDefined)
ObjCDeclQualifier getObjCDeclQualifier() const
ArrayRef< ParmVarDecl * > parameters() const
unsigned param_size() const
static ObjCMethodDecl * Create(ASTContext &C, SourceLocation beginLoc, SourceLocation endLoc, Selector SelInfo, QualType T, TypeSourceInfo *ReturnTInfo, DeclContext *contextDecl, bool isInstance=true, bool isVariadic=false, bool isPropertyAccessor=false, bool isSynthesizedAccessorStub=false, bool isImplicitlyDeclared=false, bool isDefined=false, ObjCImplementationControl impControl=ObjCImplementationControl::None, bool HasRelatedResultType=false)
param_const_iterator param_end() const
param_const_iterator param_begin() const
ObjCMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void setMethodParams(ASTContext &C, ArrayRef< ParmVarDecl * > Params, ArrayRef< SourceLocation > SelLocs={})
Sets the method's parameters and selector source locations.
void setRelatedResultType(bool RRT=true)
Note whether this method has a related result type.
bool isSynthesizedAccessorStub() const
SourceLocation getSelectorLoc(unsigned Index) const
SourceRange getReturnTypeSourceRange() const
void setOverriding(bool IsOver)
const ParmVarDecl *const * param_const_iterator
bool hasRelatedResultType() const
Determine whether this method has a result type that is related to the message receiver's type.
SourceLocation getBeginLoc() const LLVM_READONLY
bool isDirectMethod() const
True if the method is tagged as objc_direct.
Selector getSelector() const
ImplicitParamDecl * getCmdDecl() const
bool isInstanceMethod() const
void setReturnType(QualType T)
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implicit parameters.
QualType getReturnType() const
ParmVarDecl *const * param_iterator
ObjCImplementationControl getImplementationControl() const
bool isClassMethod() const
ObjCInterfaceDecl * getClassInterface()
Wraps an ObjCPointerType with source location information.
void setStarLoc(SourceLocation Loc)
Represents a pointer to an Objective C object.
bool isObjCQualifiedIdType() const
True if this is equivalent to 'id.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
Represents one property declaration in an Objective-C interface.
ObjCIvarDecl * getPropertyIvarDecl() const
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
Represents an Objective-C protocol declaration.
void startDuplicateDefinitionForComparison()
Starts the definition without sharing it with other redeclarations.
bool hasDefinition() const
Determine whether this protocol has a definition.
bool isThisDeclarationADefinition() const
Determine whether this particular declaration is also the definition.
static ObjCProtocolDecl * Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl)
const ObjCProtocolList & getReferencedProtocols() const
void setProtocolList(ObjCProtocolDecl *const *List, unsigned Num, const SourceLocation *Locs, ASTContext &C)
setProtocolList - Set the list of protocols that this interface implements.
ObjCProtocolDecl * getDefinition()
Retrieve the definition of this protocol, if any.
void startDefinition()
Starts the definition of this Objective-C protocol.
protocol_range protocols() const
The basic abstraction for the target Objective-C runtime.
bool isNeXTFamily() const
Is this runtime basically of the NeXT family of runtimes?
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
bool isFragile() const
The inverse of isNonFragile(): does this runtime follow the set of implied behaviors for a "fragile" ...
Represents the declaration of an Objective-C type parameter.
static ObjCTypeParamDecl * Create(ASTContext &ctx, DeclContext *dc, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, SourceLocation nameLoc, IdentifierInfo *name, SourceLocation colonLoc, TypeSourceInfo *boundInfo)
bool hasExplicitBound() const
Whether this type parameter has an explicitly-written type bound, e.g., "T : NSView".
ObjCTypeParamVariance getVariance() const
Determine the variance of this type parameter.
void setVariance(ObjCTypeParamVariance variance)
Set the variance of this type parameter.
SourceLocation getVarianceLoc() const
Retrieve the location of the variance keyword.
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
SourceRange getSourceRange() const
unsigned size() const
Determine the number of type parameters in this list.
ObjCTypeParamDecl * back() const
static ObjCTypeParamList * create(ASTContext &ctx, SourceLocation lAngleLoc, ArrayRef< ObjCTypeParamDecl * > typeParams, SourceLocation rAngleLoc)
Create a new Objective-C type parameter list.
SourceLocation getLAngleLoc() const
Represents a parameter to a function.
ObjCDeclQualifier getObjCDeclQualifier() const
static const ParsedAttributesView & none()
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
bool hasQualifiers() const
Determine whether this type has any qualifiers.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
static std::string getAsString(SplitQualType split, const PrintingPolicy &Policy)
The collection of all-type qualifiers we support.
void removeCVRQualifiers(unsigned mask)
@ OCL_ExplicitNone
This object can be modified without requiring retains or releases.
@ OCL_None
There is no lifetime qualification on this type.
@ OCL_Weak
Reading or writing from this object requires a barrier call.
@ OCL_Autoreleasing
Assigning into this object requires a lifetime extension.
std::string getAsString() const
Represents a struct/union/class.
bool hasFlexibleArrayMember() const
field_iterator field_end() const
specific_decl_iterator< FieldDecl > field_iterator
field_iterator field_begin() const
Base for LValueReferenceType and RValueReferenceType.
Scope - A scope is a transient data structure that is used while parsing the program.
bool isDeclScope(const Decl *D) const
isDeclScope - Return true if this is the scope that the specified decl is declared in.
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred within this scope.
Selector getSelector(unsigned NumArgs, const IdentifierInfo **IIV)
Can create any sort of selector.
Smart pointer class that efficiently represents Objective-C method names.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
std::string getAsString() const
Derive the full selector name (e.g.
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
bool isUnarySelector() const
unsigned getNumArgs() const
A generic diagnostic builder for errors which may or may not be deferred.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ASTContext & getASTContext() const
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
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,...
void ActOnSuperClassOfClassInterface(Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange)
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
void DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD)
DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which backs the property is n...
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
WarnExactTypedMethods - This routine issues a warning if method implementation declaration matches ex...
const ObjCMethodDecl * SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType())
void ProcessPropertyDecl(ObjCPropertyDecl *property)
Process the specified property declaration and create decls for the setters and getters as needed.
TypeResult actOnObjCTypeArgsAndProtocolQualifiers(Scope *S, SourceLocation Loc, ParsedType BaseType, SourceLocation TypeArgsLAngleLoc, ArrayRef< ParsedType > TypeArgs, SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc, ArrayRef< Decl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc)
Build a specialized and/or protocol-qualified Objective-C type.
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
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 diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
void updateOutOfDateSelector(Selector Sel)
llvm::SmallPtrSet< Selector, 8 > SelectorSet
void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList)
ObjCImplementationDecl * ActOnStartClassImplementation(SourceLocation AtClassImplLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, const IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc, const ParsedAttributesView &AttrList)
bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass, SmallVectorImpl< ObjCMethodDecl * > &Methods)
Decl * ActOnObjCExceptionDecl(Scope *S, Declarator &D)
bool CheckObjCDeclScope(Decl *D)
Checks that the Objective-C declaration is declared in the global scope.
DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType typeBound)
ObjCIvarDecl * GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, const ObjCPropertyDecl *&PDecl) const
GetIvarBackingPropertyAccessor - If method is a property setter/getter and it property has a backing ...
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
ObjCContainerKind getObjCContainerKind() const
ObjCInterfaceDecl * getObjCInterfaceDecl(const IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
ParmVarDecl * ActOnMethodParmDeclaration(Scope *S, ObjCArgInfo &ArgInfo, int ParamIndex, bool MethodDefinition)
DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef< Decl * > Decls)
ObjCContainerDecl * getObjCDeclContext() const
void WarnConflictingTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, const ObjCMethodDecl *PrevMethod, MethodMatchStrategy strategy=MMS_strict)
MatchTwoMethodDeclarations - Checks if two methods' type match and returns true, or false,...
void MatchAllMethodDeclarations(const SelectorSet &InsMap, const SelectorSet &ClsMap, SelectorSet &InsMapSeen, SelectorSet &ClsMapSeen, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool &IncompleteImpl, bool ImmediateClass, bool WarnCategoryMethodImpl=false)
MatchAllMethodDeclarations - Check methods declaraed in interface or or protocol against those declar...
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D)
void ActOnObjCContainerFinishDefinition()
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 DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID)
DiagnoseDuplicateIvars - Check for duplicate ivars in the entire class at the start of @implementatio...
bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall)
Check whether the given method, which must be in the 'init' family, is a valid member of that family.
void CheckConflictingOverridingMethod(ObjCMethodDecl *Method, ObjCMethodDecl *Overridden, bool IsProtocolMethodDecl)
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)
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...
bool CheckForwardProtocolDeclarationForCircularDependency(IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc, const ObjCList< ObjCProtocolDecl > &PList)
void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties)
DiagnoseUnimplementedProperties - This routine warns on those properties which must be implemented by...
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
AtomicPropertySetterGetterRules - This routine enforces the rule (via warning) when atomic property h...
void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, ArrayRef< IdentifierLoc > ProtocolId, SmallVectorImpl< Decl * > &Protocols)
FindProtocolDeclaration - This routine looks up protocols and issues an error if they are not declare...
void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, ObjCInterfaceDecl *ID)
DiagnoseClassExtensionDupMethods - Check for duplicate declaration of a class method in its extension...
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...
bool inferObjCARCLifetime(ValueDecl *decl)
void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden)
Check whether the given new method is a valid override of the given overridden method,...
Decl * ActOnMethodDeclaration(Scope *S, SourceLocation BeginLoc, SourceLocation EndLoc, tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType, ArrayRef< SourceLocation > SelectorLocs, Selector Sel, ParmVarDecl **ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic, bool MethodDefinition)
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...
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl * > &Ivars)
CollectIvarsToConstructOrDestruct - Collect those ivars which require initialization.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Find the protocol with the given name, if any.
QualType AdjustParameterTypeForObjCAutoRefCount(QualType T, SourceLocation NameLoc, TypeSourceInfo *TSInfo)
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
ObjCProtocolDecl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
ResultTypeCompatibilityKind
Describes the compatibility of a result type with its method.
void DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl< ObjCMethodDecl * > &Methods, Selector Sel, SourceRange R, bool receiverIdOrClass)
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList * > TypeParamLists, unsigned NumElts)
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLoc > IdentList, const ParsedAttributesView &attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, const IdentifierInfo *ClassName, SmallVectorImpl< Decl * > &Decls)
Called whenever @defs(ClassName) is encountered in the source.
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId, SourceLocation ProtocolLoc, IdentifierInfo *TypeArgId, SourceLocation TypeArgLoc, bool SelectProtocolFirst=false)
bool CollectMultipleMethodsInGlobalPool(Selector Sel, SmallVectorImpl< ObjCMethodDecl * > &Methods, bool InstanceFirst, bool CheckTheOther, const ObjCObjectType *TypeBound=nullptr)
We first select the type of the method: Instance or Factory, then collect all methods with that type.
void CheckObjCMethodDirectOverrides(ObjCMethodDecl *method, ObjCMethodDecl *overridden)
void DiagnoseUseOfUnimplementedSelectors()
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl * > allMethods={}, ArrayRef< DeclGroupPtrTy > allTUVars={})
void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP)
CheckCategoryVsClassMethodMatches - Checks that methods implemented in category matches with those im...
void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool IncompleteImpl=false)
ImplMethodsVsClassMethods - This is main routine to warn if any method remains unimplemented in the c...
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
ObjCMethodDecl * LookupImplementedMethodInGlobalPool(Selector Sel)
LookupImplementedMethodInGlobalPool - Returns the method which has an implementation.
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
void AddAnyMethodToGlobalPool(Decl *D)
AddAnyMethodToGlobalPool - Add any method, instance or factory to global pool.
@ OCK_CategoryImplementation
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
void ActOnObjCContainerStartDefinition(ObjCContainerDecl *IDecl)
Sema - This implements semantic analysis and AST building for C.
LookupNameKind
Describes the kind of name lookup to perform.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupObjCProtocolName
Look up the name of an Objective-C protocol.
@ LookupMemberName
Member name lookup, which finds the names of class/struct/union members.
@ LookupAnyName
Look up any declaration with any name.
bool DiagnoseUseOfDecl(NamedDecl *D, ArrayRef< SourceLocation > Locs, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false, ObjCInterfaceDecl *ClassReceiver=nullptr, bool SkipTrailingRequiresClause=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics.
ASTContext & getASTContext() const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const LangOptions & getLangOpts() const
IntrusiveRefCntPtr< ExternalSemaSource > ExternalSource
Source of additional semantic information.
DiagnosticsEngine & Diags
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
SourceLocation getBeginLoc() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled.
Represents a declaration of a type.
SourceLocation getBeginLoc() const LLVM_READONLY
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
void pushFullCopy(TypeLoc L)
Pushes a copy of the given TypeLoc onto this builder.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
Base wrapper for a particular "section" of type source info.
TypeLoc findExplicitQualifierLoc() const
Find a type with the location of an explicit type qualifier.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
SourceLocation getEndLoc() const
Get the end source location.
SourceLocation getBeginLoc() const
Get the begin source location.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
QualType getType() const
Return the type wrapped by this type source info.
The base class of the type hierarchy.
bool isIncompleteArrayType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
const T * castAs() const
Member-template castAs<specific type>.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
bool isScalarType() const
bool isObjCQualifiedIdType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
bool isObjCIdType() const
bool isObjCObjectType() const
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isObjCObjectPointerType() const
bool isObjCQualifiedClassType() const
bool isObjCClassType() const
const T * getAs() const
Member-template getAs<specific type>'.
bool isRecordType() const
bool isObjCIndependentClassType() const
NullabilityKindOrNone getNullability() const
Determine the nullability of the given type.
Base class for declarations which introduce a typedef-name.
TypeSourceInfo * getTypeSourceInfo() const
QualType getUnderlyingType() const
Simple class containing the result of Sema::CorrectTypo.
DeclClass * getCorrectionDeclAs() const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
Defines the clang::TargetInfo interface.
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
ActionResult< Decl * > DeclResult
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
ObjCMethodFamily
A family of Objective-C methods.
@ OMF_None
No particular method family.
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword.
@ Property
The type of a property.
ActionResult< ParsedType > TypeResult
const FunctionProtoType * T
Selector GetNullarySelector(StringRef name, ASTContext &Ctx)
Utility function for constructing a nullary selector.
@ Class
The "class" keyword.
AvailabilityResult
Captures the result of checking the availability of a declaration.
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor
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...
U cast(CodeGen::Address addr)
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
@ Interface
The "__interface" keyword introduces the elaborated-type-specifier.
@ None
No keyword precedes the qualified type name.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
ActionResult< Expr * > ExprResult
Visibility
Describes the different kinds of visibility that a declaration may have.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed.
static DeclaratorChunk getPointer(unsigned TypeQuals, SourceLocation Loc, SourceLocation ConstQualLoc, SourceLocation VolatileQualLoc, SourceLocation RestrictQualLoc, SourceLocation AtomicQualLoc, SourceLocation UnalignedQualLoc, SourceLocation OverflowBehaviorLoc={}, bool OverflowBehaviorIsWrap=false)
Return a DeclaratorChunk for a pointer.
a linked list of methods with the same selector name but different signatures.
ObjCMethodDecl * getMethod() const
void setMethod(ObjCMethodDecl *M)
void setNext(ObjCMethodList *L)
void setHasMoreThanOneDecl(bool B)
bool hasMoreThanOneDecl() const
ObjCMethodList * getNext() const
ParsedAttributesView ArgAttrs
ArgAttrs - Attribute list for this argument.