Lines Matching +full:oe +full:- +full:extra +full:- +full:delay
1 //===--- SemaDeclObjC.cpp - Semantic Analysis for ObjC Declarations -------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
39 /// \param receiverTypeIfCall - if null, check this as if declaring it;
40 /// if non-null, check this as if making a call to it with the given
48 if (method->isInvalidDecl()) return true; in checkInitMethod()
57 method->getReturnType()->castAs<ObjCObjectPointerType>()->getObjectType(); in checkInitMethod()
59 if (result->isObjCId()) { in checkInitMethod()
61 } else if (result->isObjCClass()) { in checkInitMethod()
64 ObjCInterfaceDecl *resultClass = result->getInterface(); in checkInitMethod()
69 if (!resultClass->hasDefinition()) { in checkInitMethod()
71 !isa<ObjCImplementationDecl>(method->getDeclContext())) in checkInitMethod()
79 if (isa<ObjCProtocolDecl>(method->getDeclContext())) { in checkInitMethod()
83 receiverClass = receiverTypeIfCall->castAs<ObjCObjectPointerType>() in checkInitMethod()
84 ->getInterfaceDecl(); in checkInitMethod()
89 receiverClass = method->getClassInterface(); in checkInitMethod()
94 if (receiverClass->isSuperClassOf(resultClass) || in checkInitMethod()
95 resultClass->isSuperClassOf(receiverClass)) in checkInitMethod()
100 SourceLocation loc = method->getLocation(); in checkInitMethod()
106 method->addAttr(UnavailableAttr::CreateImplicit(Context, "", in checkInitMethod()
113 method->setInvalidDecl(); in checkInitMethod()
117 /// Issue a warning if the parameter of the overridden method is non-escaping
121 if (OldD->hasAttr<NoEscapeAttr>() && !NewD->hasAttr<NoEscapeAttr>()) { in diagnoseNoescape()
122 S.Diag(NewD->getLocation(), diag::warn_overriding_method_missing_noescape); in diagnoseNoescape()
123 S.Diag(OldD->getLocation(), diag::note_overridden_marked_noescape); in diagnoseNoescape()
131 /// defines a method taking a non-escaping parameter.
136 S.Diag(CD->getLocation(), diag::note_cat_conform_to_noescape_prot) in diagnoseNoescape()
137 << CD->IsClassExtension() << PD in diagnoseNoescape()
138 << cast<ObjCMethodDecl>(NewD->getDeclContext()); in diagnoseNoescape()
144 if (Overridden->hasRelatedResultType() && in CheckObjCMethodOverride()
145 !NewMethod->hasRelatedResultType()) { in CheckObjCMethodOverride()
150 QualType ResultType = NewMethod->getReturnType(); in CheckObjCMethodOverride()
151 SourceRange ResultTypeRange = NewMethod->getReturnTypeSourceRange(); in CheckObjCMethodOverride()
155 = dyn_cast<ObjCInterfaceDecl>(NewMethod->getDeclContext()); in CheckObjCMethodOverride()
157 DeclContext *DC = NewMethod->getDeclContext(); in CheckObjCMethodOverride()
159 CurrentClass = Cat->getClassInterface(); in CheckObjCMethodOverride()
161 CurrentClass = Impl->getClassInterface(); in CheckObjCMethodOverride()
164 CurrentClass = CatImpl->getClassInterface(); in CheckObjCMethodOverride()
168 Diag(NewMethod->getLocation(), in CheckObjCMethodOverride()
174 Diag(NewMethod->getLocation(), in CheckObjCMethodOverride()
180 if (ObjCMethodFamily Family = Overridden->getMethodFamily()) in CheckObjCMethodOverride()
181 Diag(Overridden->getLocation(), in CheckObjCMethodOverride()
186 Diag(Overridden->getLocation(), in CheckObjCMethodOverride()
190 if ((NewMethod->hasAttr<NSReturnsRetainedAttr>() != in CheckObjCMethodOverride()
191 Overridden->hasAttr<NSReturnsRetainedAttr>())) { in CheckObjCMethodOverride()
192 Diag(NewMethod->getLocation(), in CheckObjCMethodOverride()
197 Diag(Overridden->getLocation(), diag::note_previous_decl) << "method"; in CheckObjCMethodOverride()
199 if ((NewMethod->hasAttr<NSReturnsNotRetainedAttr>() != in CheckObjCMethodOverride()
200 Overridden->hasAttr<NSReturnsNotRetainedAttr>())) { in CheckObjCMethodOverride()
201 Diag(NewMethod->getLocation(), in CheckObjCMethodOverride()
206 Diag(Overridden->getLocation(), diag::note_previous_decl) << "method"; in CheckObjCMethodOverride()
209 ObjCMethodDecl::param_const_iterator oi = Overridden->param_begin(), in CheckObjCMethodOverride()
210 oe = Overridden->param_end(); in CheckObjCMethodOverride() local
211 for (ObjCMethodDecl::param_iterator ni = NewMethod->param_begin(), in CheckObjCMethodOverride()
212 ne = NewMethod->param_end(); in CheckObjCMethodOverride()
213 ni != ne && oi != oe; ++ni, ++oi) { in CheckObjCMethodOverride()
216 if (newDecl->hasAttr<NSConsumedAttr>() != in CheckObjCMethodOverride()
217 oldDecl->hasAttr<NSConsumedAttr>()) { in CheckObjCMethodOverride()
218 Diag(newDecl->getLocation(), in CheckObjCMethodOverride()
222 Diag(oldDecl->getLocation(), diag::note_previous_decl) << "parameter"; in CheckObjCMethodOverride()
229 /// Check a method declaration for compatibility with the Objective-C
233 ObjCMethodFamily family = method->getMethodFamily(); in CheckARCMethodDecl()
247 if (!Context.hasSameType(method->getReturnType(), Context.VoidTy)) { in CheckARCMethodDecl()
248 SourceRange ResultTypeRange = method->getReturnTypeSourceRange(); in CheckARCMethodDecl()
250 Diag(method->getLocation(), diag::err_dealloc_bad_result_type) in CheckARCMethodDecl()
251 << method->getReturnType() in CheckARCMethodDecl()
252 << FixItHint::CreateInsertion(method->getSelectorLoc(0), "(void)"); in CheckARCMethodDecl()
254 Diag(method->getLocation(), diag::err_dealloc_bad_result_type) in CheckARCMethodDecl()
255 << method->getReturnType() in CheckARCMethodDecl()
266 method->addAttr(NSConsumesSelfAttr::CreateImplicit(Context)); in CheckARCMethodDecl()
270 if (method->hasAttr<NSReturnsRetainedAttr>()) in CheckARCMethodDecl()
278 if (method->hasAttr<NSReturnsRetainedAttr>() || in CheckARCMethodDecl()
279 method->hasAttr<NSReturnsNotRetainedAttr>() || in CheckARCMethodDecl()
280 method->hasAttr<NSReturnsAutoreleasedAttr>()) in CheckARCMethodDecl()
285 method->addAttr(NSReturnsRetainedAttr::CreateImplicit(Context)); in CheckARCMethodDecl()
295 AvailabilityResult Availability = ND->getAvailability( in DiagnoseObjCImplementedDeprecations()
309 S.Diag(ND->getLocation(), diag::note_method_declared_at) in DiagnoseObjCImplementedDeprecations()
310 << ND->getDeclName(); in DiagnoseObjCImplementedDeprecations()
314 if (!CD->getClassInterface()->isDeprecated()) in DiagnoseObjCImplementedDeprecations()
316 ND = CD->getClassInterface(); in DiagnoseObjCImplementedDeprecations()
327 S.Diag(ND->getLocation(), diag::note_method_declared_at) in DiagnoseObjCImplementedDeprecations()
328 << ND->getDeclName(); in DiagnoseObjCImplementedDeprecations()
330 S.Diag(ND->getLocation(), diag::note_previous_decl) in DiagnoseObjCImplementedDeprecations()
334 /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global
342 if (MDecl->isInstanceMethod()) in AddAnyMethodToGlobalPool()
348 /// HasExplicitOwnershipAttr - returns true when pointer to ObjC pointer
352 QualType T = Param->getType(); in HasExplicitOwnershipAttr()
354 if (const PointerType *PT = T->getAs<PointerType>()) { in HasExplicitOwnershipAttr()
355 T = PT->getPointeeType(); in HasExplicitOwnershipAttr()
356 } else if (const ReferenceType *RT = T->getAs<ReferenceType>()) { in HasExplicitOwnershipAttr()
357 T = RT->getPointeeType(); in HasExplicitOwnershipAttr()
367 /// ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible
382 QualType ResultType = MDecl->getReturnType(); in ActOnStartOfObjCMethodDef()
383 if (!ResultType->isDependentType() && !ResultType->isVoidType() && in ActOnStartOfObjCMethodDef()
384 !MDecl->isInvalidDecl() && in ActOnStartOfObjCMethodDef()
385 SemaRef.RequireCompleteType(MDecl->getLocation(), ResultType, in ActOnStartOfObjCMethodDef()
387 MDecl->setInvalidDecl(); in ActOnStartOfObjCMethodDef()
397 MDecl->createImplicitParams(Context, MDecl->getClassInterface()); in ActOnStartOfObjCMethodDef()
399 SemaRef.PushOnScopeChains(MDecl->getSelfDecl(), FnBodyScope); in ActOnStartOfObjCMethodDef()
400 SemaRef.PushOnScopeChains(MDecl->getCmdDecl(), FnBodyScope); in ActOnStartOfObjCMethodDef()
403 SemaRef.CheckParmsForFunctionDef(MDecl->parameters(), in ActOnStartOfObjCMethodDef()
407 for (auto *Param : MDecl->parameters()) { in ActOnStartOfObjCMethodDef()
408 if (!Param->isInvalidDecl() && getLangOpts().ObjCAutoRefCount && in ActOnStartOfObjCMethodDef()
410 Diag(Param->getLocation(), diag::warn_arc_strong_pointer_objc_pointer) << in ActOnStartOfObjCMethodDef()
411 Param->getType(); in ActOnStartOfObjCMethodDef()
413 if (Param->getIdentifier()) in ActOnStartOfObjCMethodDef()
419 switch (MDecl->getMethodFamily()) { in ActOnStartOfObjCMethodDef()
424 Diag(MDecl->getLocation(), diag::err_arc_illegal_method_def) in ActOnStartOfObjCMethodDef()
425 << 0 << MDecl->getSelector(); in ActOnStartOfObjCMethodDef()
443 // Warn on deprecated methods under -Wdeprecated-implementations, in ActOnStartOfObjCMethodDef()
445 if (ObjCInterfaceDecl *IC = MDecl->getClassInterface()) { in ActOnStartOfObjCMethodDef()
447 IC->lookupMethod(MDecl->getSelector(), MDecl->isInstanceMethod()); in ActOnStartOfObjCMethodDef()
451 dyn_cast<ObjCImplDecl>(MDecl->getDeclContext()); in ActOnStartOfObjCMethodDef()
453 dyn_cast<ObjCContainerDecl>(IMD->getDeclContext()); in ActOnStartOfObjCMethodDef()
456 ImplDeclOfMethodDecl = OID->getImplementation(); in ActOnStartOfObjCMethodDef()
458 if (CD->IsClassExtension()) { in ActOnStartOfObjCMethodDef()
459 if (ObjCInterfaceDecl *OID = CD->getClassInterface()) in ActOnStartOfObjCMethodDef()
460 ImplDeclOfMethodDecl = OID->getImplementation(); in ActOnStartOfObjCMethodDef()
462 ImplDeclOfMethodDecl = CD->getImplementation(); in ActOnStartOfObjCMethodDef()
467 DiagnoseObjCImplementedDeprecations(SemaRef, IMD, MDecl->getLocation()); in ActOnStartOfObjCMethodDef()
470 if (MDecl->getMethodFamily() == OMF_init) { in ActOnStartOfObjCMethodDef()
471 if (MDecl->isDesignatedInitializerForTheInterface()) { in ActOnStartOfObjCMethodDef()
472 SemaRef.getCurFunction()->ObjCIsDesignatedInit = true; in ActOnStartOfObjCMethodDef()
473 SemaRef.getCurFunction()->ObjCWarnForNoDesignatedInitChain = in ActOnStartOfObjCMethodDef()
474 IC->getSuperClass() != nullptr; in ActOnStartOfObjCMethodDef()
475 } else if (IC->hasDesignatedInitializers()) { in ActOnStartOfObjCMethodDef()
476 SemaRef.getCurFunction()->ObjCIsSecondaryInit = true; in ActOnStartOfObjCMethodDef()
477 SemaRef.getCurFunction()->ObjCWarnForNoInitDelegation = true; in ActOnStartOfObjCMethodDef()
485 if (const ObjCInterfaceDecl *SuperClass = IC->getSuperClass()) { in ActOnStartOfObjCMethodDef()
486 ObjCMethodFamily Family = MDecl->getMethodFamily(); in ActOnStartOfObjCMethodDef()
490 SemaRef.getCurFunction()->ObjCShouldCallSuper = true; in ActOnStartOfObjCMethodDef()
494 SemaRef.getCurFunction()->ObjCShouldCallSuper = true; in ActOnStartOfObjCMethodDef()
498 SuperClass->lookupMethod(MDecl->getSelector(), in ActOnStartOfObjCMethodDef()
499 MDecl->isInstanceMethod()); in ActOnStartOfObjCMethodDef()
500 SemaRef.getCurFunction()->ObjCShouldCallSuper = in ActOnStartOfObjCMethodDef()
501 (SuperMethod && SuperMethod->hasAttr<ObjCRequiresSuperAttr>()); in ActOnStartOfObjCMethodDef()
513 // Callback to only accept typo corrections that are Objective-C classes.
579 IDecl->setEndOfDefinitionLoc(ClassLoc); in ActOnSuperClassOfClassInterface()
596 QualType T = TDecl->getUnderlyingType(); in ActOnSuperClassOfClassInterface()
597 if (T->isObjCObjectType()) { in ActOnSuperClassOfClassInterface()
598 if (NamedDecl *IDecl = T->castAs<ObjCObjectType>()->getInterface()) { in ActOnSuperClassOfClassInterface()
619 Diag(PrevDecl->getLocation(), diag::note_previous_definition); in ActOnSuperClassOfClassInterface()
629 SuperClassDecl->getDeclName(), ClassName, in ActOnSuperClassOfClassInterface()
661 IDecl->setSuperClass(SuperClassTInfo); in ActOnSuperClassOfClassInterface()
662 IDecl->setEndOfDefinitionLoc(SuperClassTInfo->getTypeLoc().getEndLoc()); in ActOnSuperClassOfClassInterface()
671 // If there was an explicitly-provided type bound, check it. in actOnObjCTypeParam()
674 // The type bound can be any Objective-C pointer type. in actOnObjCTypeParam()
677 if (typeBound->isObjCObjectPointerType()) { in actOnObjCTypeParam()
679 } else if (typeBound->isObjCObjectType()) { in actOnObjCTypeParam()
680 // The user forgot the * on an Objective-C pointer type, e.g., in actOnObjCTypeParam()
683 SemaRef.getLocForEndOfToken(typeBoundInfo->getTypeLoc().getEndLoc()); in actOnObjCTypeParam()
684 Diag(typeBoundInfo->getTypeLoc().getBeginLoc(), in actOnObjCTypeParam()
692 builder.pushFullCopy(typeBoundInfo->getTypeLoc()); in actOnObjCTypeParam()
694 // Create the Objective-C pointer type. in actOnObjCTypeParam()
704 Diag(typeBoundInfo->getTypeLoc().getBeginLoc(), in actOnObjCTypeParam()
715 QualType typeBound = typeBoundInfo->getType(); in actOnObjCTypeParam()
716 TypeLoc qual = typeBoundInfo->getTypeLoc().findExplicitQualifierLoc(); in actOnObjCTypeParam()
723 if (attr.getTypePtr()->getImmediateNullability()) { in actOnObjCTypeParam()
735 : typeBoundInfo->getTypeLoc().getBeginLoc(), in actOnObjCTypeParam()
773 // We know that the array only contains Objective-C type parameters. in actOnObjCTypeParamList()
780 // We do this now because Objective-C type parameters aren't pushed into in actOnObjCTypeParamList()
785 auto known = knownParams.find(typeParam->getIdentifier()); in actOnObjCTypeParamList()
787 Diag(typeParam->getLocation(), diag::err_objc_type_param_redecl) in actOnObjCTypeParamList()
788 << typeParam->getIdentifier() in actOnObjCTypeParamList()
789 << SourceRange(known->second->getLocation()); in actOnObjCTypeParamList()
791 typeParam->setInvalidDecl(); in actOnObjCTypeParamList()
793 knownParams.insert(std::make_pair(typeParam->getIdentifier(), typeParam)); in actOnObjCTypeParamList()
807 if (!typeParam->isInvalidDecl()) { in popObjCTypeParamList()
808 S->RemoveDecl(typeParam); in popObjCTypeParamList()
815 /// The context in which an Objective-C type parameter list occurs, for use
825 /// Check consistency between two Objective-C type parameter lists, e.g.,
833 if (prevTypeParams->size() != newTypeParams->size()) { in checkTypeParamListConsistency()
835 if (newTypeParams->size() > prevTypeParams->size()) { in checkTypeParamListConsistency()
836 diagLoc = newTypeParams->begin()[prevTypeParams->size()]->getLocation(); in checkTypeParamListConsistency()
838 diagLoc = S.getLocForEndOfToken(newTypeParams->back()->getEndLoc()); in checkTypeParamListConsistency()
843 << (newTypeParams->size() > prevTypeParams->size()) in checkTypeParamListConsistency()
844 << prevTypeParams->size() in checkTypeParamListConsistency()
845 << newTypeParams->size(); in checkTypeParamListConsistency()
851 for (unsigned i = 0, n = prevTypeParams->size(); i != n; ++i) { in checkTypeParamListConsistency()
852 ObjCTypeParamDecl *prevTypeParam = prevTypeParams->begin()[i]; in checkTypeParamListConsistency()
853 ObjCTypeParamDecl *newTypeParam = newTypeParams->begin()[i]; in checkTypeParamListConsistency()
856 if (newTypeParam->getVariance() != prevTypeParam->getVariance()) { in checkTypeParamListConsistency()
857 if (newTypeParam->getVariance() == ObjCTypeParamVariance::Invariant && in checkTypeParamListConsistency()
861 newTypeParam->setVariance(prevTypeParam->getVariance()); in checkTypeParamListConsistency()
862 } else if (prevTypeParam->getVariance() in checkTypeParamListConsistency()
864 !(isa<ObjCInterfaceDecl>(prevTypeParam->getDeclContext()) && in checkTypeParamListConsistency()
865 cast<ObjCInterfaceDecl>(prevTypeParam->getDeclContext()) in checkTypeParamListConsistency()
866 ->getDefinition() == prevTypeParam->getDeclContext())) { in checkTypeParamListConsistency()
873 SourceLocation diagLoc = newTypeParam->getVarianceLoc(); in checkTypeParamListConsistency()
875 diagLoc = newTypeParam->getBeginLoc(); in checkTypeParamListConsistency()
879 << static_cast<unsigned>(newTypeParam->getVariance()) in checkTypeParamListConsistency()
880 << newTypeParam->getDeclName() in checkTypeParamListConsistency()
881 << static_cast<unsigned>(prevTypeParam->getVariance()) in checkTypeParamListConsistency()
882 << prevTypeParam->getDeclName(); in checkTypeParamListConsistency()
883 switch (prevTypeParam->getVariance()) { in checkTypeParamListConsistency()
885 diag << FixItHint::CreateRemoval(newTypeParam->getVarianceLoc()); in checkTypeParamListConsistency()
891 = prevTypeParam->getVariance() == ObjCTypeParamVariance::Covariant in checkTypeParamListConsistency()
894 if (newTypeParam->getVariance() in checkTypeParamListConsistency()
896 diag << FixItHint::CreateInsertion(newTypeParam->getBeginLoc(), in checkTypeParamListConsistency()
899 diag << FixItHint::CreateReplacement(newTypeParam->getVarianceLoc(), in checkTypeParamListConsistency()
906 S.Diag(prevTypeParam->getLocation(), diag::note_objc_type_param_here) in checkTypeParamListConsistency()
907 << prevTypeParam->getDeclName(); in checkTypeParamListConsistency()
910 newTypeParam->setVariance(prevTypeParam->getVariance()); in checkTypeParamListConsistency()
915 if (S.Context.hasSameType(prevTypeParam->getUnderlyingType(), in checkTypeParamListConsistency()
916 newTypeParam->getUnderlyingType())) in checkTypeParamListConsistency()
921 if (newTypeParam->hasExplicitBound()) { in checkTypeParamListConsistency()
922 SourceRange newBoundRange = newTypeParam->getTypeSourceInfo() in checkTypeParamListConsistency()
923 ->getTypeLoc().getSourceRange(); in checkTypeParamListConsistency()
925 << newTypeParam->getUnderlyingType() in checkTypeParamListConsistency()
926 << newTypeParam->getDeclName() in checkTypeParamListConsistency()
927 << prevTypeParam->hasExplicitBound() in checkTypeParamListConsistency()
928 << prevTypeParam->getUnderlyingType() in checkTypeParamListConsistency()
929 << (newTypeParam->getDeclName() == prevTypeParam->getDeclName()) in checkTypeParamListConsistency()
930 << prevTypeParam->getDeclName() in checkTypeParamListConsistency()
933 prevTypeParam->getUnderlyingType().getAsString( in checkTypeParamListConsistency()
936 S.Diag(prevTypeParam->getLocation(), diag::note_objc_type_param_here) in checkTypeParamListConsistency()
937 << prevTypeParam->getDeclName(); in checkTypeParamListConsistency()
952 = S.getLocForEndOfToken(newTypeParam->getLocation()); in checkTypeParamListConsistency()
954 = " : " + prevTypeParam->getUnderlyingType().getAsString( in checkTypeParamListConsistency()
956 S.Diag(newTypeParam->getLocation(), in checkTypeParamListConsistency()
958 << prevTypeParam->getUnderlyingType() in checkTypeParamListConsistency()
959 << newTypeParam->getDeclName() in checkTypeParamListConsistency()
963 S.Diag(prevTypeParam->getLocation(), diag::note_objc_type_param_here) in checkTypeParamListConsistency()
964 << prevTypeParam->getDeclName(); in checkTypeParamListConsistency()
992 Diag(PrevDecl->getLocation(), diag::note_previous_definition); in ActOnStartClassInterface()
998 if (PrevIDecl && PrevIDecl->getIdentifier() != ClassName) { in ActOnStartClassInterface()
1008 // otherwise we will break IdentifierResolver and redecls-chain invariants. in ActOnStartClassInterface()
1011 ClassName = PrevIDecl->getIdentifier(); in ActOnStartClassInterface()
1017 if (ObjCTypeParamList *prevTypeParamList = PrevIDecl->getTypeParamList()) { in ActOnStartClassInterface()
1028 Diag(prevTypeParamList->getLAngleLoc(), diag::note_previous_decl) in ActOnStartClassInterface()
1035 Context, SemaRef.CurContext, typeParam->getVariance(), in ActOnStartClassInterface()
1036 SourceLocation(), typeParam->getIndex(), SourceLocation(), in ActOnStartClassInterface()
1037 typeParam->getIdentifier(), SourceLocation(), in ActOnStartClassInterface()
1039 typeParam->getUnderlyingType()))); in ActOnStartClassInterface()
1055 if (ObjCInterfaceDecl *Def = PrevIDecl->getDefinition()) { in ActOnStartClassInterface()
1057 SkipBody->CheckSameAsPrevious = true; in ActOnStartClassInterface()
1058 SkipBody->New = IDecl; in ActOnStartClassInterface()
1059 SkipBody->Previous = Def; in ActOnStartClassInterface()
1062 << PrevIDecl->getDeclName(); in ActOnStartClassInterface()
1063 Diag(Def->getLocation(), diag::note_previous_definition); in ActOnStartClassInterface()
1064 IDecl->setInvalidDecl(); in ActOnStartClassInterface()
1081 if (SkipBody && SkipBody->CheckSameAsPrevious) in ActOnStartClassInterface()
1082 IDecl->startDuplicateDefinitionForComparison(); in ActOnStartClassInterface()
1083 else if (!IDecl->hasDefinition()) in ActOnStartClassInterface()
1084 IDecl->startDefinition(); in ActOnStartClassInterface()
1095 IDecl->setEndOfDefinitionLoc(ClassLoc); in ActOnStartClassInterface()
1102 IDecl->setProtocolList((ObjCProtocolDecl*const*)ProtoRefs, NumProtoRefs, in ActOnStartClassInterface()
1104 IDecl->setEndOfDefinitionLoc(EndProtoLoc); in ActOnStartClassInterface()
1112 /// ActOnTypedefedProtocols - this action finds protocol list as part of the
1127 QualType T = TDecl->getUnderlyingType(); in ActOnTypedefedProtocols()
1128 if (T->isObjCObjectType()) in ActOnTypedefedProtocols()
1129 if (const ObjCObjectType *OPT = T->getAs<ObjCObjectType>()) { in ActOnTypedefedProtocols()
1130 ProtocolRefs.append(OPT->qual_begin(), OPT->qual_end()); in ActOnTypedefedProtocols()
1135 ProtocolLocs.append(OPT->getNumProtocols(), SuperLoc); in ActOnTypedefedProtocols()
1140 /// ActOnCompatibilityAlias - this action is called after complete parsing of
1154 Diag(ADecl->getLocation(), diag::note_previous_declaration); in ActOnCompatibilityAlias()
1163 QualType T = TDecl->getUnderlyingType(); in ActOnCompatibilityAlias()
1164 if (T->isObjCObjectType()) { in ActOnCompatibilityAlias()
1165 if (NamedDecl *IDecl = T->castAs<ObjCObjectType>()->getInterface()) { in ActOnCompatibilityAlias()
1166 ClassName = IDecl->getIdentifier(); in ActOnCompatibilityAlias()
1177 Diag(CDeclU->getLocation(), diag::note_previous_declaration); in ActOnCompatibilityAlias()
1198 if (ObjCProtocolDecl *PDecl = LookupProtocol((*I)->getIdentifier(), Ploc)) { in CheckForwardProtocolDeclarationForCircularDependency()
1199 if (PDecl->getIdentifier() == PName) { in CheckForwardProtocolDeclarationForCircularDependency()
1205 if (!PDecl->hasDefinition()) in CheckForwardProtocolDeclarationForCircularDependency()
1209 PDecl->getLocation(), PDecl->getReferencedProtocols())) in CheckForwardProtocolDeclarationForCircularDependency()
1228 if (ObjCProtocolDecl *Def = PrevDecl? PrevDecl->getDefinition() : nullptr) { in ActOnStartProtocolInterface()
1238 SkipBody->CheckSameAsPrevious = true; in ActOnStartProtocolInterface()
1239 SkipBody->New = PDecl; in ActOnStartProtocolInterface()
1240 SkipBody->Previous = Def; in ActOnStartProtocolInterface()
1244 Diag(Def->getLocation(), diag::note_previous_definition); in ActOnStartProtocolInterface()
1251 PDecl->startDuplicateDefinitionForComparison(); in ActOnStartProtocolInterface()
1255 // only happen if this protocol was forward-declared. in ActOnStartProtocolInterface()
1259 ProtocolName, ProtocolLoc, PrevDecl->getLocation(), PList); in ActOnStartProtocolInterface()
1268 PDecl->startDefinition(); in ActOnStartProtocolInterface()
1283 PDecl->setProtocolList((ObjCProtocolDecl*const*)ProtoRefs, NumProtoRefs, in ActOnStartProtocolInterface()
1294 if (!PDecl->hasDefinition() || in NestedProtocolHasNoDefinition()
1295 !PDecl->getDefinition()->isUnconditionallyVisible()) { in NestedProtocolHasNoDefinition()
1300 for (auto *PI : PDecl->protocols()) in NestedProtocolHasNoDefinition()
1308 /// FindProtocolDeclaration - This routine looks up protocols and
1334 if (!PDecl->isThisDeclarationADefinition() && PDecl->getDefinition()) in FindProtocolDeclaration()
1335 PDecl = PDecl->getDefinition(); in FindProtocolDeclaration()
1337 // For an objc container, delay protocol reference checking until after we in FindProtocolDeclaration()
1351 Diag(UndefinedProtocol->getLocation(), diag::note_protocol_decl_undefined) in FindProtocolDeclaration()
1360 // Objective-C protocols or valid Objective-C type arguments.
1390 if (type->isObjCObjectPointerType() || in ValidateCandidate()
1391 type->isBlockPointerType() || in ValidateCandidate()
1392 type->isDependentType() || in ValidateCandidate()
1393 type->isObjCObjectType()) in ValidateCandidate()
1399 // If we have an Objective-C class type, accept it; there will in ValidateCandidate()
1449 if (const auto *objcObjectType = base->getAs<ObjCObjectType>()) { in actOnObjCTypeArgsOrProtocolQualifiers()
1450 baseClass = objcObjectType->getInterface(); in actOnObjCTypeArgsOrProtocolQualifiers()
1452 if (auto typeParams = baseClass->getTypeParamList()) { in actOnObjCTypeArgsOrProtocolQualifiers()
1453 if (typeParams->size() == numProtocolsResolved) { in actOnObjCTypeArgsOrProtocolQualifiers()
1465 // For an objc container, delay protocol reference checking until after we in actOnObjCTypeArgsOrProtocolQualifiers()
1472 if (!proto->isThisDeclarationADefinition() && proto->getDefinition()) in actOnObjCTypeArgsOrProtocolQualifiers()
1473 proto = proto->getDefinition(); in actOnObjCTypeArgsOrProtocolQualifiers()
1482 << proto->getDeclName(); in actOnObjCTypeArgsOrProtocolQualifiers()
1483 Diag(forwardDecl->getLocation(), diag::note_protocol_decl_undefined) in actOnObjCTypeArgsOrProtocolQualifiers()
1508 // one is an Objective-C class name. Check whether all of the in actOnObjCTypeArgsOrProtocolQualifiers()
1524 << baseClass->getDeclName() << SourceRange(lAngleLoc, rAngleLoc) in actOnObjCTypeArgsOrProtocolQualifiers()
1548 // Objective-C class names. The latter is technically ill-formed, in actOnObjCTypeArgsOrProtocolQualifiers()
1580 // Objective-C class declaration. in actOnObjCTypeArgsOrProtocolQualifiers()
1582 -> TypeResult { in actOnObjCTypeArgsOrProtocolQualifiers()
1603 // If we have a typedef of an Objective-C class type that is missing a '*', in actOnObjCTypeArgsOrProtocolQualifiers()
1605 if (type->getAs<ObjCInterfaceType>()) { in actOnObjCTypeArgsOrProtocolQualifiers()
1649 // Objective-C class names, we have type arguments. in actOnObjCTypeArgsOrProtocolQualifiers()
1725 // Did we find an Objective-C class? in actOnObjCTypeArgsOrProtocolQualifiers()
1759 /// DiagnoseClassExtensionDupMethods - Check for duplicate declaration of
1768 for (auto *MD : ID->methods()) in DiagnoseClassExtensionDupMethods()
1769 MethodMap[MD->getSelector()] = MD; in DiagnoseClassExtensionDupMethods()
1773 for (const auto *Method : CAT->methods()) { in DiagnoseClassExtensionDupMethods()
1774 const ObjCMethodDecl *&PrevMethod = MethodMap[Method->getSelector()]; in DiagnoseClassExtensionDupMethods()
1776 (PrevMethod->isInstanceMethod() == Method->isInstanceMethod()) && in DiagnoseClassExtensionDupMethods()
1778 Diag(Method->getLocation(), diag::err_duplicate_method_decl) in DiagnoseClassExtensionDupMethods()
1779 << Method->getDeclName(); in DiagnoseClassExtensionDupMethods()
1780 Diag(PrevMethod->getLocation(), diag::note_previous_declaration); in DiagnoseClassExtensionDupMethods()
1785 /// ActOnForwardProtocolDeclaration - Handle \@protocol foo;
1837 CDecl->setInvalidDecl(); in ActOnStartCategoryInterface()
1838 SemaRef.CurContext->addDecl(CDecl); in ActOnStartCategoryInterface()
1846 if (!CategoryName && IDecl->getImplementation()) { in ActOnStartCategoryInterface()
1848 Diag(IDecl->getImplementation()->getLocation(), in ActOnStartCategoryInterface()
1855 = IDecl->FindCategoryDeclaration(CategoryName)) { in ActOnStartCategoryInterface()
1859 Diag(Previous->getLocation(), diag::note_previous_definition); in ActOnStartCategoryInterface()
1865 if (auto prevTypeParamList = IDecl->getTypeParamList()) { in ActOnStartCategoryInterface()
1872 Diag(typeParamList->getLAngleLoc(), in ActOnStartCategoryInterface()
1876 << typeParamList->getSourceRange(); in ActOnStartCategoryInterface()
1886 SemaRef.CurContext->addDecl(CDecl); in ActOnStartCategoryInterface()
1897 CDecl->setProtocolList((ObjCProtocolDecl*const*)ProtoRefs, NumProtoRefs, in ActOnStartCategoryInterface()
1900 if (CDecl->IsClassExtension()) in ActOnStartCategoryInterface()
1901 IDecl->mergeClassExtensionProtocolList((ObjCProtocolDecl*const*)ProtoRefs, in ActOnStartCategoryInterface()
1910 /// ActOnStartCategoryImplementation - Perform semantic checks on the
1920 if (IDecl && IDecl->hasDefinition()) { in ActOnStartCategoryImplementation()
1921 CatIDecl = IDecl->FindCategoryDeclaration(CatName); in ActOnStartCategoryImplementation()
1929 CatIDecl->setImplicit(); in ActOnStartCategoryImplementation()
1939 CDecl->setInvalidDecl(); in ActOnStartCategoryImplementation()
1943 CDecl->setInvalidDecl(); in ActOnStartCategoryImplementation()
1950 SemaRef.CurContext->addDecl(CDecl); in ActOnStartCategoryImplementation()
1954 if (IDecl && IDecl->hasAttr<ObjCRuntimeVisibleAttr>()) { in ActOnStartCategoryImplementation()
1956 << IDecl->getDeclName(); in ActOnStartCategoryImplementation()
1961 if (CatIDecl->getImplementation()) { in ActOnStartCategoryImplementation()
1964 Diag(CatIDecl->getImplementation()->getLocation(), in ActOnStartCategoryImplementation()
1966 CDecl->setInvalidDecl(); in ActOnStartCategoryImplementation()
1968 CatIDecl->setImplementation(CDecl); in ActOnStartCategoryImplementation()
1970 // -Wdeprecated-implementations flag. in ActOnStartCategoryImplementation()
1972 CDecl->getLocation()); in ActOnStartCategoryImplementation()
1993 Diag(PrevDecl->getLocation(), diag::note_previous_definition); in ActOnStartClassImplementation()
2008 // code-modification hint or use the typo name for recovery, because in ActOnStartClassImplementation()
2028 Diag(PrevDecl->getLocation(), diag::note_previous_definition); in ActOnStartClassImplementation()
2031 if (SDecl && !SDecl->hasDefinition()) in ActOnStartClassImplementation()
2036 else if (IDecl && !declaresSameEntity(IDecl->getSuperClass(), SDecl)) { in ActOnStartClassImplementation()
2040 << SDecl->getDeclName(); in ActOnStartClassImplementation()
2041 Diag(SDecl->getLocation(), diag::note_previous_definition); in ActOnStartClassImplementation()
2057 IDecl->startDefinition(); in ActOnStartClassImplementation()
2059 IDecl->setSuperClass(Context.getTrivialTypeSourceInfo( in ActOnStartClassImplementation()
2062 IDecl->setEndOfDefinitionLoc(SuperClassLoc); in ActOnStartClassImplementation()
2064 IDecl->setEndOfDefinitionLoc(ClassLoc); in ActOnStartClassImplementation()
2072 if (!IDecl->hasDefinition()) in ActOnStartClassImplementation()
2073 IDecl->startDefinition(); in ActOnStartClassImplementation()
2089 if (IDecl->getImplementation()) { in ActOnStartClassImplementation()
2092 Diag(IDecl->getImplementation()->getLocation(), in ActOnStartClassImplementation()
2094 IMPDecl->setInvalidDecl(); in ActOnStartClassImplementation()
2096 IDecl->setImplementation(IMPDecl); in ActOnStartClassImplementation()
2099 // -Wdeprecated-implementations flag. in ActOnStartClassImplementation()
2100 DiagnoseObjCImplementedDeprecations(SemaRef, IDecl, IMPDecl->getLocation()); in ActOnStartClassImplementation()
2105 if (IDecl->getSuperClass() && in ActOnStartClassImplementation()
2106 IDecl->getSuperClass()->hasAttr<ObjCRuntimeVisibleAttr>()) { in ActOnStartClassImplementation()
2108 << IDecl->getDeclName() in ActOnStartClassImplementation()
2109 << IDecl->getSuperClass()->getDeclName(); in ActOnStartClassImplementation()
2126 if (Dcl->getDeclContext()->isFileContext()) in ActOnFinishObjCImplementation()
2127 Dcl->setTopLevelDeclInObjCContainer(); in ActOnFinishObjCImplementation()
2141 ObjCInterfaceDecl* IDecl = ImpDecl->getClassInterface(); in CheckImplementationIvars()
2144 /// Check case of non-existing \@interface decl. in CheckImplementationIvars()
2145 /// (legacy objective-c \@implementation decl without an \@interface decl). in CheckImplementationIvars()
2147 if (IDecl->isImplicitInterfaceDecl()) { in CheckImplementationIvars()
2148 IDecl->setEndOfDefinitionLoc(RBrace); in CheckImplementationIvars()
2151 ivars[i]->setLexicalDeclContext(ImpDecl); in CheckImplementationIvars()
2153 // ObjCInterfaceDecl while in a 'non-fragile' runtime the ivar is in CheckImplementationIvars()
2154 // only in the ObjCImplementationDecl. In the non-fragile case the ivar in CheckImplementationIvars()
2157 IDecl->makeDeclVisibleInContext(ivars[i]); in CheckImplementationIvars()
2158 ImpDecl->addDecl(ivars[i]); in CheckImplementationIvars()
2169 if (ImpDecl->getSuperClass()) in CheckImplementationIvars()
2170 Diag(ImpDecl->getLocation(), diag::warn_on_superclass_use); in CheckImplementationIvars()
2174 IDecl->getIvarDecl(ImplIvar->getIdentifier())) { in CheckImplementationIvars()
2175 Diag(ImplIvar->getLocation(), diag::err_duplicate_ivar_declaration); in CheckImplementationIvars()
2176 Diag(ClsIvar->getLocation(), diag::note_previous_definition); in CheckImplementationIvars()
2180 for (const auto *CDecl : IDecl->visible_extensions()) { in CheckImplementationIvars()
2182 CDecl->getIvarDecl(ImplIvar->getIdentifier())) { in CheckImplementationIvars()
2183 Diag(ImplIvar->getLocation(), diag::err_duplicate_ivar_declaration); in CheckImplementationIvars()
2184 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition); in CheckImplementationIvars()
2189 ImplIvar->setLexicalDeclContext(ImpDecl); in CheckImplementationIvars()
2190 IDecl->makeDeclVisibleInContext(ImplIvar); in CheckImplementationIvars()
2191 ImpDecl->addDecl(ImplIvar); in CheckImplementationIvars()
2200 IVI = IDecl->ivar_begin(), IVE = IDecl->ivar_end(); in CheckImplementationIvars()
2208 if (!Context.hasSameType(ImplIvar->getType(), ClsIvar->getType())) { in CheckImplementationIvars()
2209 Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_type) in CheckImplementationIvars()
2210 << ImplIvar->getIdentifier() in CheckImplementationIvars()
2211 << ImplIvar->getType() << ClsIvar->getType(); in CheckImplementationIvars()
2212 Diag(ClsIvar->getLocation(), diag::note_previous_definition); in CheckImplementationIvars()
2213 } else if (ImplIvar->isBitField() && ClsIvar->isBitField() && in CheckImplementationIvars()
2214 ImplIvar->getBitWidthValue(Context) != in CheckImplementationIvars()
2215 ClsIvar->getBitWidthValue(Context)) { in CheckImplementationIvars()
2216 Diag(ImplIvar->getBitWidth()->getBeginLoc(), in CheckImplementationIvars()
2218 << ImplIvar->getIdentifier(); in CheckImplementationIvars()
2219 Diag(ClsIvar->getBitWidth()->getBeginLoc(), in CheckImplementationIvars()
2223 if (ImplIvar->getIdentifier() != ClsIvar->getIdentifier()) { in CheckImplementationIvars()
2224 Diag(ImplIvar->getLocation(), diag::err_conflicting_ivar_name) in CheckImplementationIvars()
2225 << ImplIvar->getIdentifier() << ClsIvar->getIdentifier(); in CheckImplementationIvars()
2226 Diag(ClsIvar->getLocation(), diag::note_previous_definition); in CheckImplementationIvars()
2228 --numIvars; in CheckImplementationIvars()
2232 Diag(ivars[j]->getLocation(), diag::err_inconsistent_ivar_count); in CheckImplementationIvars()
2234 Diag(IVI->getLocation(), diag::err_inconsistent_ivar_count); in CheckImplementationIvars()
2239 return M->getAvailability() != AR_Unavailable; in shouldWarnUndefinedMethod()
2256 S.Diag(Impl->getLocation(), DiagID); in WarnUndefinedMethod()
2264 method->print(Out, Impl->getASTContext().getPrintingPolicy()); in WarnUndefinedMethod()
2267 SourceLocation Loc = Impl->getAtEndRange().getBegin(); in WarnUndefinedMethod()
2272 SourceLocation MethodLoc = method->getBeginLoc(); in WarnUndefinedMethod()
2283 /// Object types in Objective-C describe the minimum requirements for an
2287 /// anywhere that we may use an instance of B - it will implement all of the
2307 /// for explicit down-casting by callers.
2314 // Reject a protocol-unqualified id. in isObjCTypeSubstitutable()
2315 if (rejectId && B->isObjCIdType()) return false; in isObjCTypeSubstitutable()
2321 if (B->isObjCQualifiedIdType()) { in isObjCTypeSubstitutable()
2322 return A->isObjCQualifiedIdType() && in isObjCTypeSubstitutable()
2334 if (B->isObjCQualifiedIdType()) return false; in isObjCTypeSubstitutable()
2337 // Now we know that A and B are (potentially-qualified) class types. The in isObjCTypeSubstitutable()
2343 return (TSI ? TSI->getTypeLoc().getSourceRange() : SourceRange()); in getTypeRange()
2346 /// Determine whether two set of Objective-C declaration qualifiers conflict.
2360 objcModifiersConflict(MethodDecl->getObjCDeclQualifier(), in CheckMethodOverrideReturn()
2361 MethodImpl->getObjCDeclQualifier())) { in CheckMethodOverrideReturn()
2363 S.Diag(MethodImpl->getLocation(), in CheckMethodOverrideReturn()
2367 << MethodImpl->getDeclName() in CheckMethodOverrideReturn()
2368 << MethodImpl->getReturnTypeSourceRange(); in CheckMethodOverrideReturn()
2369 S.Diag(MethodDecl->getLocation(), diag::note_previous_declaration) in CheckMethodOverrideReturn()
2370 << MethodDecl->getReturnTypeSourceRange(); in CheckMethodOverrideReturn()
2376 !isa<ObjCImplementationDecl>(MethodImpl->getDeclContext()) && in CheckMethodOverrideReturn()
2377 !S.Context.hasSameNullabilityTypeQualifier(MethodImpl->getReturnType(), in CheckMethodOverrideReturn()
2378 MethodDecl->getReturnType(), in CheckMethodOverrideReturn()
2380 auto nullabilityMethodImpl = *MethodImpl->getReturnType()->getNullability(); in CheckMethodOverrideReturn()
2381 auto nullabilityMethodDecl = *MethodDecl->getReturnType()->getNullability(); in CheckMethodOverrideReturn()
2382 S.Diag(MethodImpl->getLocation(), in CheckMethodOverrideReturn()
2385 ((MethodImpl->getObjCDeclQualifier() & in CheckMethodOverrideReturn()
2388 ((MethodDecl->getObjCDeclQualifier() & in CheckMethodOverrideReturn()
2390 S.Diag(MethodDecl->getLocation(), diag::note_previous_declaration); in CheckMethodOverrideReturn()
2393 if (S.Context.hasSameUnqualifiedType(MethodImpl->getReturnType(), in CheckMethodOverrideReturn()
2394 MethodDecl->getReturnType())) in CheckMethodOverrideReturn()
2406 MethodImpl->getReturnType()->getAs<ObjCObjectPointerType>()) { in CheckMethodOverrideReturn()
2408 MethodDecl->getReturnType()->getAs<ObjCObjectPointerType>()) { in CheckMethodOverrideReturn()
2409 // Allow non-matching return types as long as they don't violate in CheckMethodOverrideReturn()
2412 // or that are more-qualified versions of the declared type. in CheckMethodOverrideReturn()
2422 S.Diag(MethodImpl->getLocation(), DiagID) in CheckMethodOverrideReturn()
2423 << MethodImpl->getDeclName() << MethodDecl->getReturnType() in CheckMethodOverrideReturn()
2424 << MethodImpl->getReturnType() in CheckMethodOverrideReturn()
2425 << MethodImpl->getReturnTypeSourceRange(); in CheckMethodOverrideReturn()
2426 S.Diag(MethodDecl->getLocation(), IsOverridingMode in CheckMethodOverrideReturn()
2429 << MethodDecl->getReturnTypeSourceRange(); in CheckMethodOverrideReturn()
2442 objcModifiersConflict(ImplVar->getObjCDeclQualifier(), in CheckMethodOverrideParam()
2443 IfaceVar->getObjCDeclQualifier())) { in CheckMethodOverrideParam()
2446 S.Diag(ImplVar->getLocation(), in CheckMethodOverrideParam()
2448 << getTypeRange(ImplVar->getTypeSourceInfo()) in CheckMethodOverrideParam()
2449 << MethodImpl->getDeclName(); in CheckMethodOverrideParam()
2450 else S.Diag(ImplVar->getLocation(), in CheckMethodOverrideParam()
2452 << getTypeRange(ImplVar->getTypeSourceInfo()) in CheckMethodOverrideParam()
2453 << MethodImpl->getDeclName(); in CheckMethodOverrideParam()
2454 S.Diag(IfaceVar->getLocation(), diag::note_previous_declaration) in CheckMethodOverrideParam()
2455 << getTypeRange(IfaceVar->getTypeSourceInfo()); in CheckMethodOverrideParam()
2461 QualType ImplTy = ImplVar->getType(); in CheckMethodOverrideParam()
2462 QualType IfaceTy = IfaceVar->getType(); in CheckMethodOverrideParam()
2464 !isa<ObjCImplementationDecl>(MethodImpl->getDeclContext()) && in CheckMethodOverrideParam()
2466 S.Diag(ImplVar->getLocation(), in CheckMethodOverrideParam()
2468 << DiagNullabilityKind(*ImplTy->getNullability(), in CheckMethodOverrideParam()
2469 ((ImplVar->getObjCDeclQualifier() & in CheckMethodOverrideParam()
2471 << DiagNullabilityKind(*IfaceTy->getNullability(), in CheckMethodOverrideParam()
2472 ((IfaceVar->getObjCDeclQualifier() & in CheckMethodOverrideParam()
2474 S.Diag(IfaceVar->getLocation(), diag::note_previous_declaration); in CheckMethodOverrideParam()
2488 ImplTy->getAs<ObjCObjectPointerType>()) { in CheckMethodOverrideParam()
2490 IfaceTy->getAs<ObjCObjectPointerType>()) { in CheckMethodOverrideParam()
2491 // Allow non-matching argument types as long as they don't in CheckMethodOverrideParam()
2504 S.Diag(ImplVar->getLocation(), DiagID) in CheckMethodOverrideParam()
2505 << getTypeRange(ImplVar->getTypeSourceInfo()) in CheckMethodOverrideParam()
2506 << MethodImpl->getDeclName() << IfaceTy << ImplTy; in CheckMethodOverrideParam()
2507 S.Diag(IfaceVar->getLocation(), in CheckMethodOverrideParam()
2510 << getTypeRange(IfaceVar->getTypeSourceInfo()); in CheckMethodOverrideParam()
2518 ObjCMethodFamily implFamily = impl->getMethodFamily(); in checkMethodFamilyMismatch()
2519 ObjCMethodFamily declFamily = decl->getMethodFamily(); in checkMethodFamilyMismatch()
2528 if (impl->isInvalidDecl() || decl->isInvalidDecl()) return true; in checkMethodFamilyMismatch()
2574 if (unmatched->getReturnType()->isObjCObjectPointerType()) { in checkMethodFamilyMismatch()
2580 S.Diag(impl->getLocation(), errorID) << int(familySelector) << int(reasonSelector); in checkMethodFamilyMismatch()
2581 S.Diag(decl->getLocation(), noteID) << int(familySelector) << int(reasonSelector); in checkMethodFamilyMismatch()
2596 for (ObjCMethodDecl::param_iterator IM = ImpMethodDecl->param_begin(), in WarnConflictingTypedMethods()
2597 IF = MethodDecl->param_begin(), EM = ImpMethodDecl->param_end(), in WarnConflictingTypedMethods()
2598 EF = MethodDecl->param_end(); in WarnConflictingTypedMethods()
2604 if (ImpMethodDecl->isVariadic() != MethodDecl->isVariadic()) { in WarnConflictingTypedMethods()
2605 Diag(ImpMethodDecl->getLocation(), in WarnConflictingTypedMethods()
2607 Diag(MethodDecl->getLocation(), diag::note_previous_declaration); in WarnConflictingTypedMethods()
2618 for (ObjCMethodDecl::param_iterator IM = Method->param_begin(), in CheckConflictingOverridingMethod()
2619 IF = Overridden->param_begin(), EM = Method->param_end(), in CheckConflictingOverridingMethod()
2620 EF = Overridden->param_end(); in CheckConflictingOverridingMethod()
2626 if (Method->isVariadic() != Overridden->isVariadic()) { in CheckConflictingOverridingMethod()
2627 Diag(Method->getLocation(), in CheckConflictingOverridingMethod()
2629 Diag(Overridden->getLocation(), diag::note_previous_declaration); in CheckConflictingOverridingMethod()
2633 /// WarnExactTypedMethods - This routine issues a warning if method
2642 if (MethodDecl->getImplementationControl() == in WarnExactTypedMethods()
2647 if (MethodDecl->hasAttr<UnavailableAttr>() || in WarnExactTypedMethods()
2648 MethodDecl->hasAttr<DeprecatedAttr>()) in WarnExactTypedMethods()
2654 for (ObjCMethodDecl::param_iterator IM = ImpMethodDecl->param_begin(), in WarnExactTypedMethods()
2655 IF = MethodDecl->param_begin(), EM = ImpMethodDecl->param_end(), in WarnExactTypedMethods()
2656 EF = MethodDecl->param_end(); in WarnExactTypedMethods()
2664 match = (ImpMethodDecl->isVariadic() == MethodDecl->isVariadic()); in WarnExactTypedMethods()
2666 match = !(MethodDecl->isClassMethod() && in WarnExactTypedMethods()
2667 MethodDecl->getSelector() == GetNullarySelector("load", Context)); in WarnExactTypedMethods()
2670 Diag(ImpMethodDecl->getLocation(), in WarnExactTypedMethods()
2672 Diag(MethodDecl->getLocation(), diag::note_method_declared_at) in WarnExactTypedMethods()
2673 << MethodDecl->getDeclName(); in WarnExactTypedMethods()
2677 /// FIXME: Type hierarchies in Objective-C can be deep. We could most likely
2688 if (PDecl->hasAttr<ObjCExplicitProtocolImplAttr>()) in findProtocolsWithExplicitImpls()
2689 PNS.insert(PDecl->getIdentifier()); in findProtocolsWithExplicitImpls()
2690 for (const auto *PI : PDecl->protocols()) in findProtocolsWithExplicitImpls()
2702 for (const auto *I : Super->all_referenced_protocols()) in findProtocolsWithExplicitImpls()
2705 findProtocolsWithExplicitImpls(Super->getSuperClass(), PNS); in findProtocolsWithExplicitImpls()
2708 /// CheckProtocolMethodDefs - This routine checks unimplemented methods
2715 ObjCInterfaceDecl *IDecl = C ? C->getClassInterface() in CheckProtocolMethodDefs()
2717 assert (IDecl && "CheckProtocolMethodDefs - IDecl is null"); in CheckProtocolMethodDefs()
2719 ObjCInterfaceDecl *Super = IDecl->getSuperClass(); in CheckProtocolMethodDefs()
2733 if (PDecl->hasAttr<ObjCExplicitProtocolImplAttr>()) { in CheckProtocolMethodDefs()
2738 if (ProtocolsExplictImpl->contains(PDecl->getIdentifier())) in CheckProtocolMethodDefs()
2759 NSIDecl = IDecl->lookupInheritedClass(&S.Context.Idents.get("NSProxy")); in CheckProtocolMethodDefs()
2763 if (!PDecl->isThisDeclarationADefinition() && in CheckProtocolMethodDefs()
2764 PDecl->getDefinition()) in CheckProtocolMethodDefs()
2765 PDecl = PDecl->getDefinition(); in CheckProtocolMethodDefs()
2774 for (auto *method : PDecl->instance_methods()) { in CheckProtocolMethodDefs()
2775 if (method->getImplementationControl() != in CheckProtocolMethodDefs()
2777 !method->isPropertyAccessor() && in CheckProtocolMethodDefs()
2778 !InsMap.count(method->getSelector()) && in CheckProtocolMethodDefs()
2779 (!Super || !Super->lookupMethod( in CheckProtocolMethodDefs()
2780 method->getSelector(), true /* instance */, in CheckProtocolMethodDefs()
2792 if (ObjCMethodDecl *MethodInClass = IDecl->lookupMethod( in CheckProtocolMethodDefs()
2793 method->getSelector(), true /* instance */, in CheckProtocolMethodDefs()
2795 if (C || MethodInClass->isPropertyAccessor()) in CheckProtocolMethodDefs()
2798 if (!S.Diags.isIgnored(DIAG, Impl->getLocation())) { in CheckProtocolMethodDefs()
2804 for (auto *method : PDecl->class_methods()) { in CheckProtocolMethodDefs()
2805 if (method->getImplementationControl() != in CheckProtocolMethodDefs()
2807 !ClsMap.count(method->getSelector()) && in CheckProtocolMethodDefs()
2808 (!Super || !Super->lookupMethod( in CheckProtocolMethodDefs()
2809 method->getSelector(), false /* class method */, in CheckProtocolMethodDefs()
2813 if (C && IDecl->lookupMethod(method->getSelector(), in CheckProtocolMethodDefs()
2820 if (!S.Diags.isIgnored(DIAG, Impl->getLocation())) { in CheckProtocolMethodDefs()
2826 for (auto *PI : PDecl->protocols()) in CheckProtocolMethodDefs()
2831 /// MatchAllMethodDeclarations - Check methods declared in interface
2841 for (auto *I : CDecl->instance_methods()) { in MatchAllMethodDeclarations()
2842 if (!InsMapSeen.insert(I->getSelector()).second) in MatchAllMethodDeclarations()
2844 if (!I->isPropertyAccessor() && in MatchAllMethodDeclarations()
2845 !InsMap.count(I->getSelector())) { in MatchAllMethodDeclarations()
2852 IMPDecl->getInstanceMethod(I->getSelector()); in MatchAllMethodDeclarations()
2853 assert(CDecl->getInstanceMethod(I->getSelector(), true/*AllowHidden*/) && in MatchAllMethodDeclarations()
2858 if (ImpMethodDecl->isSynthesizedAccessorStub()) in MatchAllMethodDeclarations()
2863 else if (!I->isPropertyAccessor()) in MatchAllMethodDeclarations()
2871 for (auto *I : CDecl->class_methods()) { in MatchAllMethodDeclarations()
2872 if (!ClsMapSeen.insert(I->getSelector()).second) in MatchAllMethodDeclarations()
2874 if (!I->isPropertyAccessor() && in MatchAllMethodDeclarations()
2875 !ClsMap.count(I->getSelector())) { in MatchAllMethodDeclarations()
2881 IMPDecl->getClassMethod(I->getSelector()); in MatchAllMethodDeclarations()
2882 assert(CDecl->getClassMethod(I->getSelector(), true/*AllowHidden*/) && in MatchAllMethodDeclarations()
2887 if (ImpMethodDecl->isSynthesizedAccessorStub()) in MatchAllMethodDeclarations()
2892 else if (!I->isPropertyAccessor()) in MatchAllMethodDeclarations()
2901 for (auto *PI : PD->protocols()) in MatchAllMethodDeclarations()
2912 for (auto *Cat : I->visible_categories()) in MatchAllMethodDeclarations()
2915 ImmediateClass && Cat->IsClassExtension(), in MatchAllMethodDeclarations()
2919 for (auto *Ext : I->visible_extensions()) in MatchAllMethodDeclarations()
2926 for (auto *PI : I->all_referenced_protocols()) in MatchAllMethodDeclarations()
2933 if (!WarnCategoryMethodImpl && I->getSuperClass()) in MatchAllMethodDeclarations()
2936 I->getSuperClass(), IncompleteImpl, false); in MatchAllMethodDeclarations()
2940 /// CheckCategoryVsClassMethodMatches - Checks that methods implemented in
2946 ObjCCategoryDecl *CatDecl = CatIMPDecl->getCategoryDecl(); in CheckCategoryVsClassMethodMatches()
2949 ObjCInterfaceDecl *IDecl = CatDecl->getClassInterface(); in CheckCategoryVsClassMethodMatches()
2952 ObjCInterfaceDecl *SuperIDecl = IDecl->getSuperClass(); in CheckCategoryVsClassMethodMatches()
2955 for (const auto *I : CatIMPDecl->instance_methods()) { in CheckCategoryVsClassMethodMatches()
2956 Selector Sel = I->getSelector(); in CheckCategoryVsClassMethodMatches()
2960 if (SuperIDecl && SuperIDecl->lookupMethod(Sel, true)) in CheckCategoryVsClassMethodMatches()
2965 for (const auto *I : CatIMPDecl->class_methods()) { in CheckCategoryVsClassMethodMatches()
2966 Selector Sel = I->getSelector(); in CheckCategoryVsClassMethodMatches()
2967 if (SuperIDecl && SuperIDecl->lookupMethod(Sel, false)) in CheckCategoryVsClassMethodMatches()
2988 for (const auto *I : IMPDecl->instance_methods()) in ImplMethodsVsClassMethods()
2989 InsMap.insert(I->getSelector()); in ImplMethodsVsClassMethods()
2992 for (const auto *PImpl : IMPDecl->property_impls()) { in ImplMethodsVsClassMethods()
2994 if (PImpl->getPropertyImplementation() != ObjCPropertyImplDecl::Dynamic) in ImplMethodsVsClassMethods()
2997 const auto *P = PImpl->getPropertyDecl(); in ImplMethodsVsClassMethods()
3000 InsMap.insert(P->getGetterName()); in ImplMethodsVsClassMethods()
3001 if (!P->getSetterName().isNull()) in ImplMethodsVsClassMethods()
3002 InsMap.insert(P->getSetterName()); in ImplMethodsVsClassMethods()
3011 !IDecl->isObjCRequiresPropertyDefs(); in ImplMethodsVsClassMethods()
3015 // Diagnose null-resettable synthesized setters. in ImplMethodsVsClassMethods()
3019 for (const auto *I : IMPDecl->class_methods()) in ImplMethodsVsClassMethods()
3020 ClsMap.insert(I->getSelector()); in ImplMethodsVsClassMethods()
3043 for (auto *PI : I->all_referenced_protocols()) in ImplMethodsVsClassMethods()
3049 if (!C->IsClassExtension()) { in ImplMethodsVsClassMethods()
3050 for (auto *P : C->protocols()) in ImplMethodsVsClassMethods()
3080 if (!TDD || !TDD->getUnderlyingType()->isObjCObjectType()) { in ActOnForwardClassDeclaration()
3082 Diag(PrevDecl->getLocation(), diag::note_previous_definition); in ActOnForwardClassDeclaration()
3088 if (isa<ObjCObjectType>(TDD->getUnderlyingType())) { in ActOnForwardClassDeclaration()
3091 Diag(PrevDecl->getLocation(), diag::note_previous_definition); in ActOnForwardClassDeclaration()
3102 if (PrevIDecl && PrevIDecl->getIdentifier() != ClassName) { in ActOnForwardClassDeclaration()
3112 // otherwise we will break IdentifierResolver and redecls-chain invariants. in ActOnForwardClassDeclaration()
3115 ClassName = PrevIDecl->getIdentifier(); in ActOnForwardClassDeclaration()
3122 if (ObjCTypeParamList *PrevTypeParams = PrevIDecl->getTypeParamList()) { in ActOnForwardClassDeclaration()
3129 } else if (ObjCInterfaceDecl *Def = PrevIDecl->getDefinition()) { in ActOnForwardClassDeclaration()
3133 << TypeParams->getSourceRange(); in ActOnForwardClassDeclaration()
3134 Diag(Def->getLocation(), diag::note_defined_here) in ActOnForwardClassDeclaration()
3144 IDecl->setAtEndRange(IdentLocs[i]); in ActOnForwardClassDeclaration()
3175 if (left->isIncompleteType() || right->isIncompleteType()) return false; in matchTypes()
3178 // validate the basic, low-level compatibility of the two types. in matchTypes()
3189 // Consider all the kinds of non-dependent canonical types: in matchTypes()
3190 // - functions and arrays aren't possible as return and parameter types in matchTypes()
3192 // - vector types of equal size can be arbitrarily mixed in matchTypes()
3196 // - references should only match references of identical type in matchTypes()
3197 // - structs, unions, and Objective-C objects must match more-or-less in matchTypes()
3199 // - everything else should be a scalar in matchTypes()
3200 if (!left->isScalarType() || !right->isScalarType()) in matchTypes()
3204 // all non-member pointers together. in matchTypes()
3205 Type::ScalarTypeKind leftSK = left->getScalarTypeKind(); in matchTypes()
3206 Type::ScalarTypeKind rightSK = right->getScalarTypeKind(); in matchTypes()
3226 RecordDecl *left = cast<RecordType>(lt)->getDecl(); in tryMatchRecordTypes()
3227 RecordDecl *right = cast<RecordType>(rt)->getDecl(); in tryMatchRecordTypes()
3229 // Require union-hood to match. in tryMatchRecordTypes()
3230 if (left->isUnion() != right->isUnion()) return false; in tryMatchRecordTypes()
3232 // Require an exact match if either is non-POD. in tryMatchRecordTypes()
3233 if ((isa<CXXRecordDecl>(left) && !cast<CXXRecordDecl>(left)->isPOD()) || in tryMatchRecordTypes()
3234 (isa<CXXRecordDecl>(right) && !cast<CXXRecordDecl>(right)->isPOD())) in tryMatchRecordTypes()
3247 RecordDecl::field_iterator li = left->field_begin(), le = left->field_end(); in tryMatchRecordTypes()
3248 RecordDecl::field_iterator ri = right->field_begin(), re = right->field_end(); in tryMatchRecordTypes()
3250 if (!matchTypes(Context, strategy, li->getType(), ri->getType())) in tryMatchRecordTypes()
3256 /// MatchTwoMethodDeclarations - Checks that two methods have matching type and
3263 if (!matchTypes(Context, strategy, left->getReturnType(), in MatchTwoMethodDeclarations()
3264 right->getReturnType())) in MatchTwoMethodDeclarations()
3268 if (!left->isUnconditionallyVisible() || !right->isUnconditionallyVisible()) in MatchTwoMethodDeclarations()
3271 if (left->isDirectMethod() != right->isDirectMethod()) in MatchTwoMethodDeclarations()
3275 (left->hasAttr<NSReturnsRetainedAttr>() in MatchTwoMethodDeclarations()
3276 != right->hasAttr<NSReturnsRetainedAttr>() || in MatchTwoMethodDeclarations()
3277 left->hasAttr<NSConsumesSelfAttr>() in MatchTwoMethodDeclarations()
3278 != right->hasAttr<NSConsumesSelfAttr>())) in MatchTwoMethodDeclarations()
3282 li = left->param_begin(), le = left->param_end(), ri = right->param_begin(), in MatchTwoMethodDeclarations()
3283 re = right->param_end(); in MatchTwoMethodDeclarations()
3286 assert(ri != right->param_end() && "Param mismatch"); in MatchTwoMethodDeclarations()
3289 if (!matchTypes(Context, strategy, lparm->getType(), rparm->getType())) in MatchTwoMethodDeclarations()
3293 lparm->hasAttr<NSConsumedAttr>() != rparm->hasAttr<NSConsumedAttr>()) in MatchTwoMethodDeclarations()
3301 auto *MethodProtocol = dyn_cast<ObjCProtocolDecl>(Method->getDeclContext()); in isMethodContextSameForKindofLookup()
3303 dyn_cast<ObjCProtocolDecl>(MethodInList->getDeclContext()); in isMethodContextSameForKindofLookup()
3313 ObjCInterfaceDecl *MethodInterface = Method->getClassInterface(); in isMethodContextSameForKindofLookup()
3315 MethodInList->getClassInterface(); in isMethodContextSameForKindofLookup()
3324 dyn_cast<ObjCCategoryDecl>(Method->getDeclContext())) in addMethodToGlobalList()
3325 if (!CD->IsClassExtension() && List->getBits() < 2) in addMethodToGlobalList()
3326 List->setBits(List->getBits() + 1); in addMethodToGlobalList()
3329 if (List->getMethod() == nullptr) { in addMethodToGlobalList()
3330 List->setMethod(Method); in addMethodToGlobalList()
3331 List->setNext(nullptr); in addMethodToGlobalList()
3339 for (; List; Previous = List, List = List->getNext()) { in addMethodToGlobalList()
3345 List->getMethod()); in addMethodToGlobalList()
3357 !isMethodContextSameForKindofLookup(Method, List->getMethod())) { in addMethodToGlobalList()
3361 if (!Method->isDefined()) in addMethodToGlobalList()
3362 List->setHasMoreThanOneDecl(true); in addMethodToGlobalList()
3366 if (Method->isDeprecated() && SameDeclaration && in addMethodToGlobalList()
3367 !ListWithSameDeclaration && !List->getMethod()->isDeprecated()) in addMethodToGlobalList()
3370 if (Method->isUnavailable() && SameDeclaration && in addMethodToGlobalList()
3372 List->getMethod()->getAvailability() < AR_Deprecated) in addMethodToGlobalList()
3377 ObjCMethodDecl *PrevObjCMethod = List->getMethod(); in addMethodToGlobalList()
3380 if (Method->isDefined()) in addMethodToGlobalList()
3381 PrevObjCMethod->setDefined(true); in addMethodToGlobalList()
3383 // Objective-C doesn't allow an @interface for a class after its in addMethodToGlobalList()
3387 List->setHasMoreThanOneDecl(true); in addMethodToGlobalList()
3392 if (Method->isDeprecated()) { in addMethodToGlobalList()
3393 if (!PrevObjCMethod->isDeprecated()) in addMethodToGlobalList()
3394 List->setMethod(Method); in addMethodToGlobalList()
3398 if (Method->isUnavailable()) { in addMethodToGlobalList()
3399 if (PrevObjCMethod->getAvailability() < AR_Deprecated) in addMethodToGlobalList()
3400 List->setMethod(Method); in addMethodToGlobalList()
3406 // We have a new signature for an existing method - add it. in addMethodToGlobalList()
3414 ListWithSameDeclaration->setMethod(Method); in addMethodToGlobalList()
3415 ListWithSameDeclaration->setNext(List); in addMethodToGlobalList()
3419 Previous->setNext(new (Mem) ObjCMethodList(Method)); in addMethodToGlobalList()
3426 SemaRef.ExternalSource->ReadMethodPool(Sel); in ReadMethodPool()
3432 SemaRef.ExternalSource->updateOutOfDateSelector(Sel); in updateOutOfDateSelector()
3438 if (cast<Decl>(Method->getDeclContext())->isInvalidDecl()) in AddMethodToGlobalPool()
3442 ReadMethodPool(Method->getSelector()); in AddMethodToGlobalPool()
3444 GlobalMethodPool::iterator Pos = MethodPool.find(Method->getSelector()); in AddMethodToGlobalPool()
3447 .insert(std::make_pair(Method->getSelector(), in AddMethodToGlobalPool()
3451 Method->setDefined(impl); in AddMethodToGlobalPool()
3453 ObjCMethodList &Entry = instance ? Pos->second.first : Pos->second.second; in AddMethodToGlobalPool()
3464 if (!chosen->isInstanceMethod()) in isAcceptableMethodMismatch()
3467 if (chosen->isDirectMethod() != other->isDirectMethod()) in isAcceptableMethodMismatch()
3470 Selector sel = chosen->getSelector(); in isAcceptableMethodMismatch()
3474 // Don't complain about mismatches for -length if the method we in isAcceptableMethodMismatch()
3476 return (chosen->getReturnType()->isIntegerType()); in isAcceptableMethodMismatch()
3485 if (TypeBound->isObjCId()) in FilterMethodsByTypeBound()
3489 auto *BoundInterface = TypeBound->getInterface(); in FilterMethodsByTypeBound()
3494 auto *MethodProtocol = dyn_cast<ObjCProtocolDecl>(Method->getDeclContext()); in FilterMethodsByTypeBound()
3501 if (ObjCInterfaceDecl *MethodInterface = Method->getClassInterface()) { in FilterMethodsByTypeBound()
3506 MethodInterface->isSuperClassOf(BoundInterface) || in FilterMethodsByTypeBound()
3507 BoundInterface->isSuperClassOf(MethodInterface); in FilterMethodsByTypeBound()
3524 // Gather the non-hidden methods. in CollectMultipleMethodsInGlobalPool()
3525 ObjCMethodList &MethList = InstanceFirst ? Pos->second.first : in CollectMultipleMethodsInGlobalPool()
3526 Pos->second.second; in CollectMultipleMethodsInGlobalPool()
3527 for (ObjCMethodList *M = &MethList; M; M = M->getNext()) in CollectMultipleMethodsInGlobalPool()
3528 if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) { in CollectMultipleMethodsInGlobalPool()
3529 if (FilterMethodsByTypeBound(M->getMethod(), TypeBound)) in CollectMultipleMethodsInGlobalPool()
3530 Methods.push_back(M->getMethod()); in CollectMultipleMethodsInGlobalPool()
3541 ObjCMethodList &MethList2 = InstanceFirst ? Pos->second.second : in CollectMultipleMethodsInGlobalPool()
3542 Pos->second.first; in CollectMultipleMethodsInGlobalPool()
3543 for (ObjCMethodList *M = &MethList2; M; M = M->getNext()) in CollectMultipleMethodsInGlobalPool()
3544 if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) { in CollectMultipleMethodsInGlobalPool()
3545 if (FilterMethodsByTypeBound(M->getMethod(), TypeBound)) in CollectMultipleMethodsInGlobalPool()
3546 Methods.push_back(M->getMethod()); in CollectMultipleMethodsInGlobalPool()
3560 if (M != BestMethod && !M->hasAttr<UnavailableAttr>()) in AreMultipleMethodsInGlobalPool()
3573 BestMethod->isInstanceMethod() ? Pos->second.first : Pos->second.second; in AreMultipleMethodsInGlobalPool()
3587 // Gather the non-hidden methods. in LookupMethodInGlobalPool()
3588 ObjCMethodList &MethList = instance ? Pos->second.first : Pos->second.second; in LookupMethodInGlobalPool()
3590 for (ObjCMethodList *M = &MethList; M; M = M->getNext()) { in LookupMethodInGlobalPool()
3591 if (M->getMethod() && M->getMethod()->isUnconditionallyVisible()) in LookupMethodInGlobalPool()
3592 return M->getMethod(); in LookupMethodInGlobalPool()
3642 Diag(Methods[0]->getBeginLoc(), in DiagnoseMultipleMethodInGlobalPool()
3644 << Methods[0]->getSourceRange(); in DiagnoseMultipleMethodInGlobalPool()
3646 Diag(Methods[I]->getBeginLoc(), diag::note_also_found) in DiagnoseMultipleMethodInGlobalPool()
3647 << Methods[I]->getSourceRange(); in DiagnoseMultipleMethodInGlobalPool()
3657 GlobalMethodPool::Lists &Methods = Pos->second; in LookupImplementedMethodInGlobalPool()
3659 Method = Method->getNext()) in LookupImplementedMethodInGlobalPool()
3660 if (Method->getMethod() && in LookupImplementedMethodInGlobalPool()
3661 (Method->getMethod()->isDefined() || in LookupImplementedMethodInGlobalPool()
3662 Method->getMethod()->isPropertyAccessor())) in LookupImplementedMethodInGlobalPool()
3663 return Method->getMethod(); in LookupImplementedMethodInGlobalPool()
3666 Method = Method->getNext()) in LookupImplementedMethodInGlobalPool()
3667 if (Method->getMethod() && in LookupImplementedMethodInGlobalPool()
3668 (Method->getMethod()->isDefined() || in LookupImplementedMethodInGlobalPool()
3669 Method->getMethod()->isPropertyAccessor())) in LookupImplementedMethodInGlobalPool()
3670 return Method->getMethod(); in LookupImplementedMethodInGlobalPool()
3680 std::string MethodName = Method->getSelector().getAsString(); in HelperSelectorsForTypoCorrection()
3682 unsigned MinPossibleEditDistance = abs((int)MethodName.size() - (int)Typo.size()); in HelperSelectorsForTypoCorrection()
3715 else if (!ObjectType->isObjCObjectPointerType()) in SelectorsForTypoCorrection()
3718 ObjectType->getAsObjCInterfacePointerType()) { in SelectorsForTypoCorrection()
3719 ObjectType = QualType(ObjCPtr->getInterfaceType(), 0); in SelectorsForTypoCorrection()
3722 else if (ObjectType->isObjCIdType() || ObjectType->isObjCQualifiedIdType()) in SelectorsForTypoCorrection()
3724 else if (ObjectType->isObjCClassType() || ObjectType->isObjCQualifiedClassType()) in SelectorsForTypoCorrection()
3732 for (ObjCMethodList *M = &b->second.first; M; M=M->getNext()) in SelectorsForTypoCorrection()
3733 if (M->getMethod() && in SelectorsForTypoCorrection()
3734 (M->getMethod()->getSelector().getNumArgs() == NumArgs) && in SelectorsForTypoCorrection()
3735 (M->getMethod()->getSelector() != Sel)) { in SelectorsForTypoCorrection()
3737 Methods.push_back(M->getMethod()); in SelectorsForTypoCorrection()
3740 SemaRef, M->getMethod()->getSelector(), ObjectType)) in SelectorsForTypoCorrection()
3741 Methods.push_back(M->getMethod()); in SelectorsForTypoCorrection()
3744 for (ObjCMethodList *M = &b->second.second; M; M=M->getNext()) in SelectorsForTypoCorrection()
3745 if (M->getMethod() && in SelectorsForTypoCorrection()
3746 (M->getMethod()->getSelector().getNumArgs() == NumArgs) && in SelectorsForTypoCorrection()
3747 (M->getMethod()->getSelector() != Sel)) { in SelectorsForTypoCorrection()
3749 Methods.push_back(M->getMethod()); in SelectorsForTypoCorrection()
3752 SemaRef, M->getMethod()->getSelector(), ObjectType)) in SelectorsForTypoCorrection()
3753 Methods.push_back(M->getMethod()); in SelectorsForTypoCorrection()
3765 /// DiagnoseDuplicateIvars -
3772 for (auto *Ivar : ID->ivars()) { in DiagnoseDuplicateIvars()
3773 if (Ivar->isInvalidDecl()) in DiagnoseDuplicateIvars()
3775 if (IdentifierInfo *II = Ivar->getIdentifier()) { in DiagnoseDuplicateIvars()
3776 ObjCIvarDecl* prevIvar = SID->lookupInstanceVariable(II); in DiagnoseDuplicateIvars()
3778 Diag(Ivar->getLocation(), diag::err_duplicate_member) << II; in DiagnoseDuplicateIvars()
3779 Diag(prevIvar->getLocation(), diag::note_previous_declaration); in DiagnoseDuplicateIvars()
3780 Ivar->setInvalidDecl(); in DiagnoseDuplicateIvars()
3786 /// Diagnose attempts to define ARC-__weak ivars when __weak is disabled.
3790 for (auto ivar = ID->getClassInterface()->all_declared_ivar_begin(); in DiagnoseWeakIvars()
3791 ivar; ivar = ivar->getNextIvar()) { in DiagnoseWeakIvars()
3792 if (ivar->isInvalidDecl()) continue; in DiagnoseWeakIvars()
3793 if (ivar->getType().getObjCLifetime() == Qualifiers::OCL_Weak) { in DiagnoseWeakIvars()
3795 S.Diag(ivar->getLocation(), diag::err_arc_weak_disabled); in DiagnoseWeakIvars()
3797 S.Diag(ivar->getLocation(), diag::err_arc_weak_no_runtime); in DiagnoseWeakIvars()
3809 for (auto ivar = ID->all_declared_ivar_begin(); ivar; in DiagnoseRetainableFlexibleArrayMember()
3810 ivar = ivar->getNextIvar()) { in DiagnoseRetainableFlexibleArrayMember()
3811 if (ivar->isInvalidDecl()) in DiagnoseRetainableFlexibleArrayMember()
3813 QualType IvarTy = ivar->getType(); in DiagnoseRetainableFlexibleArrayMember()
3814 if (IvarTy->isIncompleteArrayType() && in DiagnoseRetainableFlexibleArrayMember()
3816 IvarTy->isObjCLifetimeType()) { in DiagnoseRetainableFlexibleArrayMember()
3817 S.Diag(ivar->getLocation(), diag::err_flexible_array_arc_retainable); in DiagnoseRetainableFlexibleArrayMember()
3818 ivar->setInvalidDecl(); in DiagnoseRetainableFlexibleArrayMember()
3824 switch (SemaRef.CurContext->getDeclKind()) { in getObjCContainerKind()
3830 if (cast<ObjCCategoryDecl>(SemaRef.CurContext)->IsClassExtension()) in getObjCContainerKind()
3844 if (T->isIncompleteArrayType()) in IsVariableSizedType()
3846 const auto *RecordTy = T->getAs<RecordType>(); in IsVariableSizedType()
3847 return (RecordTy && RecordTy->getDecl()->hasFlexibleArrayMember()); in IsVariableSizedType()
3855 Ivars = IntfDecl->ivars(); in DiagnoseVariableSizedIvars()
3857 IntfDecl = ImplDecl->getClassInterface(); in DiagnoseVariableSizedIvars()
3858 Ivars = ImplDecl->ivars(); in DiagnoseVariableSizedIvars()
3860 if (CategoryDecl->IsClassExtension()) { in DiagnoseVariableSizedIvars()
3861 IntfDecl = CategoryDecl->getClassInterface(); in DiagnoseVariableSizedIvars()
3862 Ivars = CategoryDecl->ivars(); in DiagnoseVariableSizedIvars()
3869 if (!ivar->isInvalidDecl() && IsVariableSizedType(ivar->getType())) { in DiagnoseVariableSizedIvars()
3870 S.Diag(ivar->getLocation(), diag::warn_variable_sized_ivar_visibility) in DiagnoseVariableSizedIvars()
3871 << ivar->getDeclName() << ivar->getType(); in DiagnoseVariableSizedIvars()
3881 for (ObjCIvarDecl *ivar = IntfDecl->all_declared_ivar_begin(); ivar; in DiagnoseVariableSizedIvars()
3882 ivar = ivar->getNextIvar()) { in DiagnoseVariableSizedIvars()
3883 if (ivar->isInvalidDecl() || !ivar->getNextIvar()) in DiagnoseVariableSizedIvars()
3885 QualType IvarTy = ivar->getType(); in DiagnoseVariableSizedIvars()
3887 if (IvarTy->isIncompleteArrayType()) { in DiagnoseVariableSizedIvars()
3888 S.Diag(ivar->getLocation(), diag::err_flexible_array_not_at_end) in DiagnoseVariableSizedIvars()
3889 << ivar->getDeclName() << IvarTy in DiagnoseVariableSizedIvars()
3890 << llvm::to_underlying(TagTypeKind::Class); // Use "class" for Obj-C. in DiagnoseVariableSizedIvars()
3892 } else if (const RecordType *RecordTy = IvarTy->getAs<RecordType>()) { in DiagnoseVariableSizedIvars()
3893 if (RecordTy->getDecl()->hasFlexibleArrayMember()) { in DiagnoseVariableSizedIvars()
3894 S.Diag(ivar->getLocation(), in DiagnoseVariableSizedIvars()
3896 << ivar->getDeclName() << IvarTy; in DiagnoseVariableSizedIvars()
3901 S.Diag(ivar->getNextIvar()->getLocation(), in DiagnoseVariableSizedIvars()
3903 << ivar->getNextIvar()->getSynthesize(); in DiagnoseVariableSizedIvars()
3904 ivar->setInvalidDecl(); in DiagnoseVariableSizedIvars()
3913 if (FirstIvar && (FirstIvar == IntfDecl->all_declared_ivar_begin())) { in DiagnoseVariableSizedIvars()
3914 const ObjCInterfaceDecl *SuperClass = IntfDecl->getSuperClass(); in DiagnoseVariableSizedIvars()
3915 while (SuperClass && SuperClass->ivar_empty()) in DiagnoseVariableSizedIvars()
3916 SuperClass = SuperClass->getSuperClass(); in DiagnoseVariableSizedIvars()
3918 auto IvarIter = SuperClass->ivar_begin(); in DiagnoseVariableSizedIvars()
3919 std::advance(IvarIter, SuperClass->ivar_size() - 1); in DiagnoseVariableSizedIvars()
3921 if (IsVariableSizedType(LastIvar->getType())) { in DiagnoseVariableSizedIvars()
3922 S.Diag(FirstIvar->getLocation(), in DiagnoseVariableSizedIvars()
3924 << FirstIvar->getDeclName() << LastIvar->getDeclName() in DiagnoseVariableSizedIvars()
3925 << LastIvar->getType() << SuperClass->getDeclName(); in DiagnoseVariableSizedIvars()
3926 S.Diag(LastIvar->getLocation(), diag::note_entity_declared_at) in DiagnoseVariableSizedIvars()
3927 << LastIvar->getDeclName(); in DiagnoseVariableSizedIvars()
3945 if (!PDecl->isThisDeclarationADefinition() && PDecl->getDefinition()) in DiagnoseCategoryDirectMembersProtocolConformance()
3946 PDecl = PDecl->getDefinition(); in DiagnoseCategoryDirectMembersProtocolConformance()
3949 const auto *IDecl = CDecl->getClassInterface(); in DiagnoseCategoryDirectMembersProtocolConformance()
3950 for (auto *MD : PDecl->methods()) { in DiagnoseCategoryDirectMembersProtocolConformance()
3951 if (!MD->isPropertyAccessor()) { in DiagnoseCategoryDirectMembersProtocolConformance()
3953 IDecl->getMethod(MD->getSelector(), MD->isInstanceMethod())) { in DiagnoseCategoryDirectMembersProtocolConformance()
3954 if (CMD->isDirectMethod()) in DiagnoseCategoryDirectMembersProtocolConformance()
3959 for (auto *PD : PDecl->properties()) { in DiagnoseCategoryDirectMembersProtocolConformance()
3960 if (const auto *CPD = IDecl->FindPropertyVisibleInPrimaryClass( in DiagnoseCategoryDirectMembersProtocolConformance()
3961 PD->getIdentifier(), in DiagnoseCategoryDirectMembersProtocolConformance()
3962 PD->isClassProperty() in DiagnoseCategoryDirectMembersProtocolConformance()
3965 if (CPD->isDirectProperty()) in DiagnoseCategoryDirectMembersProtocolConformance()
3970 S.Diag(CDecl->getLocation(), diag::err_objc_direct_protocol_conformance) in DiagnoseCategoryDirectMembersProtocolConformance()
3971 << CDecl->IsClassExtension() << CDecl << PDecl << IDecl; in DiagnoseCategoryDirectMembersProtocolConformance()
3973 S.Diag(MD->getLocation(), diag::note_direct_member_here); in DiagnoseCategoryDirectMembersProtocolConformance()
3979 PDecl->protocols()); in DiagnoseCategoryDirectMembersProtocolConformance()
4005 for (auto *PropImpl : OID->property_impls()) { in ActOnAtEnd()
4006 if (auto *Getter = PropImpl->getGetterMethodDecl()) in ActOnAtEnd()
4007 if (Getter->isSynthesizedAccessorStub()) in ActOnAtEnd()
4008 OID->addDecl(Getter); in ActOnAtEnd()
4009 if (auto *Setter = PropImpl->getSetterMethodDecl()) in ActOnAtEnd()
4010 if (Setter->isSynthesizedAccessorStub()) in ActOnAtEnd()
4011 OID->addDecl(Setter); in ActOnAtEnd()
4024 if (Method->isInstanceMethod()) { in ActOnAtEnd()
4026 const ObjCMethodDecl *&PrevMethod = InsMap[Method->getSelector()]; in ActOnAtEnd()
4031 Diag(Method->getLocation(), diag::err_duplicate_method_decl) in ActOnAtEnd()
4032 << Method->getDeclName(); in ActOnAtEnd()
4033 Diag(PrevMethod->getLocation(), diag::note_previous_declaration); in ActOnAtEnd()
4034 Method->setInvalidDecl(); in ActOnAtEnd()
4037 Method->setAsRedeclaration(PrevMethod); in ActOnAtEnd()
4039 Method->getLocation())) in ActOnAtEnd()
4040 Diag(Method->getLocation(), diag::warn_duplicate_method_decl) in ActOnAtEnd()
4041 << Method->getDeclName(); in ActOnAtEnd()
4042 Diag(PrevMethod->getLocation(), diag::note_previous_declaration); in ActOnAtEnd()
4044 InsMap[Method->getSelector()] = Method; in ActOnAtEnd()
4050 const ObjCMethodDecl *&PrevMethod = ClsMap[Method->getSelector()]; in ActOnAtEnd()
4055 Diag(Method->getLocation(), diag::err_duplicate_method_decl) in ActOnAtEnd()
4056 << Method->getDeclName(); in ActOnAtEnd()
4057 Diag(PrevMethod->getLocation(), diag::note_previous_declaration); in ActOnAtEnd()
4058 Method->setInvalidDecl(); in ActOnAtEnd()
4061 Method->setAsRedeclaration(PrevMethod); in ActOnAtEnd()
4063 Method->getLocation())) in ActOnAtEnd()
4064 Diag(Method->getLocation(), diag::warn_duplicate_method_decl) in ActOnAtEnd()
4065 << Method->getDeclName(); in ActOnAtEnd()
4066 Diag(PrevMethod->getLocation(), diag::note_previous_declaration); in ActOnAtEnd()
4068 ClsMap[Method->getSelector()] = Method; in ActOnAtEnd()
4080 if (C->IsClassExtension()) { in ActOnAtEnd()
4081 ObjCInterfaceDecl *CCPrimary = C->getClassInterface(); in ActOnAtEnd()
4086 C->protocols()); in ActOnAtEnd()
4089 if (CDecl->getIdentifier()) in ActOnAtEnd()
4091 // user-defined setter/getter. It also synthesizes setter/getter methods in ActOnAtEnd()
4093 for (auto *I : CDecl->properties()) in ActOnAtEnd()
4095 CDecl->setAtEndRange(AtEnd); in ActOnAtEnd()
4098 IC->setAtEndRange(AtEnd); in ActOnAtEnd()
4099 if (ObjCInterfaceDecl* IDecl = IC->getClassInterface()) { in ActOnAtEnd()
4105 for (const auto *Ext : IDecl->visible_extensions()) { in ActOnAtEnd()
4106 for (const auto *Property : Ext->instance_properties()) { in ActOnAtEnd()
4109 = IC->FindPropertyImplDecl(Property->getIdentifier(), in ActOnAtEnd()
4110 Property->getQueryKind())) in ActOnAtEnd()
4111 if (PIDecl->getPropertyImplementation() in ActOnAtEnd()
4115 for (const auto *Ext : IDecl->visible_extensions()) { in ActOnAtEnd()
4117 Ext->getInstanceMethod(Property->getGetterName())) in ActOnAtEnd()
4118 GetterMethod->setPropertyAccessor(true); in ActOnAtEnd()
4119 if (!Property->isReadOnly()) in ActOnAtEnd()
4121 = Ext->getInstanceMethod(Property->getSetterName())) in ActOnAtEnd()
4122 SetterMethod->setPropertyAccessor(true); in ActOnAtEnd()
4130 if (IDecl->hasDesignatedInitializers()) in ActOnAtEnd()
4135 bool HasRootClassAttr = IDecl->hasAttr<ObjCRootClassAttr>(); in ActOnAtEnd()
4136 if (IDecl->getSuperClass() == nullptr) { in ActOnAtEnd()
4140 SourceLocation DeclLoc(IDecl->getLocation()); in ActOnAtEnd()
4143 << IDecl->getIdentifier(); in ActOnAtEnd()
4147 SemaRef.TUScope, NSAPIObj->getNSClassId(NSAPI::ClassId_NSObject), in ActOnAtEnd()
4150 if (NSObjectDecl && NSObjectDecl->getDefinition()) { in ActOnAtEnd()
4159 Diag(IDecl->getLocation(), diag::err_objc_root_class_subclass); in ActOnAtEnd()
4162 if (const ObjCInterfaceDecl *Super = IDecl->getSuperClass()) { in ActOnAtEnd()
4167 if (IDecl->hasAttr<ObjCSubclassingRestrictedAttr>() && in ActOnAtEnd()
4168 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) { in ActOnAtEnd()
4169 Diag(IC->getLocation(), diag::err_restricted_superclass_mismatch); in ActOnAtEnd()
4170 Diag(Super->getLocation(), diag::note_class_declared); in ActOnAtEnd()
4174 if (IDecl->hasAttr<ObjCClassStubAttr>()) in ActOnAtEnd()
4175 Diag(IC->getLocation(), diag::err_implementation_of_class_stub); in ActOnAtEnd()
4178 while (IDecl->getSuperClass()) { in ActOnAtEnd()
4179 DiagnoseDuplicateIvars(IDecl, IDecl->getSuperClass()); in ActOnAtEnd()
4180 IDecl = IDecl->getSuperClass(); in ActOnAtEnd()
4187 CatImplClass->setAtEndRange(AtEnd); in ActOnAtEnd()
4191 if (ObjCInterfaceDecl* IDecl = CatImplClass->getClassInterface()) { in ActOnAtEnd()
4193 = IDecl->FindCategoryDeclaration(CatImplClass->getIdentifier())) { in ActOnAtEnd()
4198 if (const ObjCInterfaceDecl *Super = IntfDecl->getSuperClass()) { in ActOnAtEnd()
4199 if (!IntfDecl->hasAttr<ObjCSubclassingRestrictedAttr>() && in ActOnAtEnd()
4200 Super->hasAttr<ObjCSubclassingRestrictedAttr>()) { in ActOnAtEnd()
4201 Diag(IntfDecl->getLocation(), diag::err_restricted_superclass_mismatch); in ActOnAtEnd()
4202 Diag(Super->getLocation(), diag::note_class_declared); in ActOnAtEnd()
4206 if (IntfDecl->hasAttr<ObjCClassStubAttr>() && in ActOnAtEnd()
4207 !IntfDecl->hasAttr<ObjCSubclassingRestrictedAttr>()) in ActOnAtEnd()
4208 Diag(IntfDecl->getLocation(), diag::err_class_stub_subclassing_mismatch); in ActOnAtEnd()
4217 if (!VDecl->hasExternalStorage()) in ActOnAtEnd()
4218 Diag(VDecl->getLocation(), diag::err_objc_var_decl_inclass); in ActOnAtEnd()
4227 (*I)->setTopLevelDeclInObjCContainer(); in ActOnAtEnd()
4235 /// CvtQTToAstBitMask - utility routine to produce an AST bitmask for
4236 /// objective-c's type qualifier from the parser version of the same info.
4242 /// Check whether the declared result type of the given Objective-C
4248 QualType ResultType = Method->getReturnType(); in CheckRelatedResultTypeCompatibility()
4250 // If an Objective-C method inherits its related result type, then its in CheckRelatedResultTypeCompatibility()
4254 = ResultType->getAs<ObjCObjectPointerType>()) { in CheckRelatedResultTypeCompatibility()
4255 // - it is id or qualified id, or in CheckRelatedResultTypeCompatibility()
4256 if (ResultObjectType->isObjCIdType() || in CheckRelatedResultTypeCompatibility()
4257 ResultObjectType->isObjCQualifiedIdType()) in CheckRelatedResultTypeCompatibility()
4262 = ResultObjectType->getInterfaceDecl()) { in CheckRelatedResultTypeCompatibility()
4263 // - it is the same as the method's class type, or in CheckRelatedResultTypeCompatibility()
4267 // - it is a superclass of the method's class type in CheckRelatedResultTypeCompatibility()
4268 if (ResultClass->isSuperClassOf(CurrentClass)) in CheckRelatedResultTypeCompatibility()
4272 // Any Objective-C pointer type might be acceptable for a protocol in CheckRelatedResultTypeCompatibility()
4292 Selector selector = method->getSelector(); in OverrideSearch()
4307 method->isInstanceMethod() ? it->second.first : it->second.second; in OverrideSearch()
4311 = cast<ObjCContainerDecl>(method->getDeclContext()); in OverrideSearch()
4319 if (const ObjCInterfaceDecl *Interface = Category->getClassInterface()) in OverrideSearch()
4332 if (container->isInvalidDecl()) return; in searchFromContainer()
4334 switch (container->getDeclKind()) { in searchFromContainer()
4348 if (!protocol->hasDefinition()) in searchFrom()
4353 search(protocol->getReferencedProtocols()); in searchFrom()
4360 search(category->getReferencedProtocols()); in searchFrom()
4367 if (ObjCCategoryDecl *category = impl->getCategoryDecl()) { in searchFrom()
4369 if (ObjCInterfaceDecl *Interface = category->getClassInterface()) in searchFrom()
4373 } else if (const auto *Interface = impl->getClassInterface()) { in searchFrom()
4380 if (!iface->hasDefinition()) in searchFrom()
4383 // - categories, in searchFrom()
4384 for (auto *Cat : iface->known_categories()) in searchFrom()
4387 // - the super class, and in searchFrom()
4388 if (ObjCInterfaceDecl *super = iface->getSuperClass()) in searchFrom()
4391 // - any referenced protocols. in searchFrom()
4392 search(iface->getReferencedProtocols()); in searchFrom()
4398 if (const auto *Interface = impl->getClassInterface()) in searchFrom()
4409 ObjCMethodDecl *meth = container->getMethod(Method->getSelector(), in search()
4410 Method->isInstanceMethod(), in search()
4432 if (overridden->isDirectMethod()) { in CheckObjCMethodDirectOverrides()
4433 const auto *attr = overridden->getAttr<ObjCDirectAttr>(); in CheckObjCMethodDirectOverrides()
4434 Diag(method->getLocation(), diag::err_objc_override_direct_method); in CheckObjCMethodDirectOverrides()
4435 Diag(attr->getLocation(), diag::note_previous_declaration); in CheckObjCMethodDirectOverrides()
4436 } else if (method->isDirectMethod()) { in CheckObjCMethodDirectOverrides()
4437 const auto *attr = method->getAttr<ObjCDirectAttr>(); in CheckObjCMethodDirectOverrides()
4438 Diag(attr->getLocation(), diag::err_objc_direct_on_override) in CheckObjCMethodDirectOverrides()
4439 << isa<ObjCProtocolDecl>(overridden->getDeclContext()); in CheckObjCMethodDirectOverrides()
4440 Diag(overridden->getLocation(), diag::note_previous_declaration); in CheckObjCMethodDirectOverrides()
4452 return M->getClassInterface()->getCanonicalDecl() == in CheckObjCMethodOverrides()
4453 CurrentClass->getCanonicalDecl(); in CheckObjCMethodOverrides()
4465 if (isa<ObjCProtocolDecl>(overridden->getDeclContext()) || in CheckObjCMethodOverrides()
4466 !IsMethodInCurrentClass(overridden) || overridden->isOverriding()) { in CheckObjCMethodOverrides()
4469 } else if (isa<ObjCImplDecl>(ObjCMethod->getDeclContext())) { in CheckObjCMethodOverrides()
4475 // extra info bits in GlobalMethodPool to check whether there were any in CheckObjCMethodOverrides()
4478 MethodPool.find(ObjCMethod->getSelector()); in CheckObjCMethodOverrides()
4481 ObjCMethod->isInstanceMethod()? It->second.first: It->second.second; in CheckObjCMethodOverrides()
4487 !isa<ObjCCategoryImplDecl>(overridden->getDeclContext())) { in CheckObjCMethodOverrides()
4490 if (isa<ObjCProtocolDecl>(SuperOverridden->getDeclContext()) || in CheckObjCMethodOverrides()
4494 overridden->setOverriding(true); in CheckObjCMethodOverrides()
4505 if (RTC != SemaObjC::RTC_Incompatible && overridden->hasRelatedResultType()) in CheckObjCMethodOverrides()
4506 ObjCMethod->setRelatedResultType(); in CheckObjCMethodOverrides()
4511 if (ObjCMethod->isImplicit() && overridden->isImplicit()) in CheckObjCMethodOverrides()
4515 if (isa<ObjCInterfaceDecl>(ObjCMethod->getDeclContext()) || in CheckObjCMethodOverrides()
4516 isa<ObjCImplementationDecl>(ObjCMethod->getDeclContext())) in CheckObjCMethodOverrides()
4518 isa<ObjCProtocolDecl>(overridden->getDeclContext())); in CheckObjCMethodOverrides()
4520 if (CurrentClass && overridden->getDeclContext() != CurrentClass && in CheckObjCMethodOverrides()
4521 isa<ObjCInterfaceDecl>(overridden->getDeclContext()) && in CheckObjCMethodOverrides()
4522 !overridden->isImplicit() /* not meant for properties */) { in CheckObjCMethodOverrides()
4523 ObjCMethodDecl::param_iterator ParamI = ObjCMethod->param_begin(), in CheckObjCMethodOverrides()
4524 E = ObjCMethod->param_end(); in CheckObjCMethodOverrides()
4525 ObjCMethodDecl::param_iterator PrevI = overridden->param_begin(), in CheckObjCMethodOverrides()
4526 PrevE = overridden->param_end(); in CheckObjCMethodOverrides()
4528 assert(PrevI != overridden->param_end() && "Param mismatch"); in CheckObjCMethodOverrides()
4529 QualType T1 = Context.getCanonicalType((*ParamI)->getType()); in CheckObjCMethodOverrides()
4530 QualType T2 = Context.getCanonicalType((*PrevI)->getType()); in CheckObjCMethodOverrides()
4534 Diag((*ParamI)->getLocation(), diag::ext_typecheck_base_super) in CheckObjCMethodOverrides()
4536 Diag(overridden->getLocation(), diag::note_previous_declaration); in CheckObjCMethodOverrides()
4543 ObjCMethod->setOverriding(hasOverriddenMethodsInBaseOrProtocol); in CheckObjCMethodOverrides()
4555 auto nullability = type->getNullability(); in mergeTypeNullabilityForRedecl()
4556 auto prevNullability = prevType->getNullability(); in mergeTypeNullabilityForRedecl()
4592 if (prevMethod->hasAttr<ObjCRequiresSuperAttr>() && in mergeInterfaceMethodToImpl()
4593 !method->hasAttr<ObjCRequiresSuperAttr>()) { in mergeInterfaceMethodToImpl()
4595 method->addAttr( in mergeInterfaceMethodToImpl()
4597 method->getLocation())); in mergeInterfaceMethodToImpl()
4603 S, method->getReturnTypeSourceRange().getBegin(), in mergeInterfaceMethodToImpl()
4604 method->getReturnType(), in mergeInterfaceMethodToImpl()
4605 method->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability, in mergeInterfaceMethodToImpl()
4606 prevMethod->getReturnTypeSourceRange().getBegin(), in mergeInterfaceMethodToImpl()
4607 prevMethod->getReturnType(), in mergeInterfaceMethodToImpl()
4608 prevMethod->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability); in mergeInterfaceMethodToImpl()
4609 method->setReturnType(newReturnType); in mergeInterfaceMethodToImpl()
4612 unsigned numParams = method->param_size(); in mergeInterfaceMethodToImpl()
4613 unsigned numPrevParams = prevMethod->param_size(); in mergeInterfaceMethodToImpl()
4615 ParmVarDecl *param = method->param_begin()[i]; in mergeInterfaceMethodToImpl()
4616 ParmVarDecl *prevParam = prevMethod->param_begin()[i]; in mergeInterfaceMethodToImpl()
4621 S, param->getLocation(), param->getType(), in mergeInterfaceMethodToImpl()
4622 param->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability, in mergeInterfaceMethodToImpl()
4623 prevParam->getLocation(), prevParam->getType(), in mergeInterfaceMethodToImpl()
4624 prevParam->getObjCDeclQualifier() & Decl::OBJC_TQ_CSNullability); in mergeInterfaceMethodToImpl()
4625 param->setType(newParamType); in mergeInterfaceMethodToImpl()
4635 "x86-specific check invoked for a different target"); in checkObjCMethodX86VectorTypes()
4638 for (const ParmVarDecl *P : Method->parameters()) { in checkObjCMethodX86VectorTypes()
4639 if (P->getType()->isVectorType()) { in checkObjCMethodX86VectorTypes()
4640 Loc = P->getBeginLoc(); in checkObjCMethodX86VectorTypes()
4641 T = P->getType(); in checkObjCMethodX86VectorTypes()
4646 if (Method->getReturnType()->isVectorType()) { in checkObjCMethodX86VectorTypes()
4647 Loc = Method->getReturnTypeSourceRange().getBegin(); in checkObjCMethodX86VectorTypes()
4648 T = Method->getReturnType(); in checkObjCMethodX86VectorTypes()
4667 << T << (Method->getReturnType()->isVectorType() ? /*return value*/ 1 in checkObjCMethodX86VectorTypes()
4673 if (!Method->isDirectMethod() && !Method->hasAttr<UnavailableAttr>() && in mergeObjCDirectMembers()
4674 CD->hasAttr<ObjCDirectMembersAttr>()) { in mergeObjCDirectMembers()
4675 Method->addAttr( in mergeObjCDirectMembers()
4676 ObjCDirectAttr::CreateImplicit(S.Context, Method->getLocation())); in mergeObjCDirectMembers()
4683 auto Sel = Method->getSelector(); in checkObjCDirectMethodClashes()
4684 bool isInstance = Method->isInstanceMethod(); in checkObjCDirectMethodClashes()
4688 if (diagnosed || IMD->isImplicit()) in checkObjCDirectMethodClashes()
4690 if (Method->isDirectMethod() || IMD->isDirectMethod()) { in checkObjCDirectMethodClashes()
4691 S.Diag(Method->getLocation(), diag::err_objc_direct_duplicate_decl) in checkObjCDirectMethodClashes()
4692 << Method->isDirectMethod() << /* method */ 0 << IMD->isDirectMethod() in checkObjCDirectMethodClashes()
4693 << Method->getDeclName(); in checkObjCDirectMethodClashes()
4694 S.Diag(IMD->getLocation(), diag::note_previous_declaration); in checkObjCDirectMethodClashes()
4702 // We do not use IDecl->lookupMethod() because we have specific needs: in checkObjCDirectMethodClashes()
4704 // - we absolutely do not need to walk protocols, because in checkObjCDirectMethodClashes()
4708 // - when we do not find a match in a given @interface container, in checkObjCDirectMethodClashes()
4712 if (auto *IMD = IDecl->getMethod(Sel, isInstance)) in checkObjCDirectMethodClashes()
4714 else if (auto *Impl = IDecl->getImplementation()) in checkObjCDirectMethodClashes()
4716 if (auto *IMD = IDecl->getImplementation()->getMethod(Sel, isInstance)) in checkObjCDirectMethodClashes()
4719 for (const auto *Cat : IDecl->visible_categories()) in checkObjCDirectMethodClashes()
4720 if (auto *IMD = Cat->getMethod(Sel, isInstance)) in checkObjCDirectMethodClashes()
4722 else if (auto CatImpl = Cat->getImplementation()) in checkObjCDirectMethodClashes()
4724 if (auto *IMD = Cat->getMethod(Sel, isInstance)) in checkObjCDirectMethodClashes()
4735 unsigned CNumArgs, // c-style args in ActOnMethodDeclaration()
4740 if (!SemaRef.CurContext->isObjCContainer()) { in ActOnMethodDeclaration()
4794 if (S->isDeclScope(PrevDecl)) { in ActOnMethodDeclaration()
4799 Diag(PrevDecl->getLocation(), in ActOnMethodDeclaration()
4805 ? DI->getTypeLoc().getBeginLoc() in ActOnMethodDeclaration()
4812 Param->setObjCMethodScopeInfo(i); in ActOnMethodDeclaration()
4814 Param->setObjCDeclQualifier( in ActOnMethodDeclaration()
4823 if (Param->hasAttr<BlocksAttr>()) { in ActOnMethodDeclaration()
4824 Diag(Param->getLocation(), diag::err_block_on_nonlocal); in ActOnMethodDeclaration()
4825 Param->setInvalidDecl(); in ActOnMethodDeclaration()
4827 S->AddDecl(Param); in ActOnMethodDeclaration()
4835 QualType ArgType = Param->getType(); in ActOnMethodDeclaration()
4842 Param->setDeclContext(ObjCMethod); in ActOnMethodDeclaration()
4846 ObjCMethod->setMethodParams(Context, Params, SelectorLocs); in ActOnMethodDeclaration()
4847 ObjCMethod->setObjCDeclQualifier( in ActOnMethodDeclaration()
4858 PrevMethod = ImpDecl->getInstanceMethod(Sel); in ActOnMethodDeclaration()
4859 ImpDecl->addInstanceMethod(ObjCMethod); in ActOnMethodDeclaration()
4861 PrevMethod = ImpDecl->getClassMethod(Sel); in ActOnMethodDeclaration()
4862 ImpDecl->addClassMethod(ObjCMethod); in ActOnMethodDeclaration()
4869 // user-specified implementation. in ActOnMethodDeclaration()
4870 for (ObjCPropertyImplDecl *PropertyImpl : ImpDecl->property_impls()) { in ActOnMethodDeclaration()
4871 if (auto *Setter = PropertyImpl->getSetterMethodDecl()) in ActOnMethodDeclaration()
4872 if (Setter->getSelector() == Sel && in ActOnMethodDeclaration()
4873 Setter->isInstanceMethod() == ObjCMethod->isInstanceMethod()) { in ActOnMethodDeclaration()
4874 assert(Setter->isSynthesizedAccessorStub() && "autosynth stub expected"); in ActOnMethodDeclaration()
4875 PropertyImpl->setSetterMethodDecl(ObjCMethod); in ActOnMethodDeclaration()
4877 if (auto *Getter = PropertyImpl->getGetterMethodDecl()) in ActOnMethodDeclaration()
4878 if (Getter->getSelector() == Sel && in ActOnMethodDeclaration()
4879 Getter->isInstanceMethod() == ObjCMethod->isInstanceMethod()) { in ActOnMethodDeclaration()
4880 assert(Getter->isSynthesizedAccessorStub() && "autosynth stub expected"); in ActOnMethodDeclaration()
4881 PropertyImpl->setGetterMethodDecl(ObjCMethod); in ActOnMethodDeclaration()
4890 // because IDecl->lookupMethod() returns more possible matches than just in ActOnMethodDeclaration()
4892 if (!ObjCMethod->isDirectMethod()) { in ActOnMethodDeclaration()
4893 const ObjCMethodDecl *CanonicalMD = ObjCMethod->getCanonicalDecl(); in ActOnMethodDeclaration()
4894 if (CanonicalMD->isDirectMethod()) { in ActOnMethodDeclaration()
4895 const auto *attr = CanonicalMD->getAttr<ObjCDirectAttr>(); in ActOnMethodDeclaration()
4896 ObjCMethod->addAttr( in ActOnMethodDeclaration()
4897 ObjCDirectAttr::CreateImplicit(Context, attr->getLocation())); in ActOnMethodDeclaration()
4903 if (ObjCInterfaceDecl *IDecl = ImpDecl->getClassInterface()) { in ActOnMethodDeclaration()
4904 if (auto *IMD = IDecl->lookupMethod(ObjCMethod->getSelector(), in ActOnMethodDeclaration()
4905 ObjCMethod->isInstanceMethod())) { in ActOnMethodDeclaration()
4908 // The Idecl->lookupMethod() above will find declarations for ObjCMethod in ActOnMethodDeclaration()
4923 // We deal with same-class container mismatches (Case 2) here. in ActOnMethodDeclaration()
4924 if (IDecl == IMD->getClassInterface()) { in ActOnMethodDeclaration()
4928 if (auto *Cat = dyn_cast<ObjCCategoryDecl>(IMD->getDeclContext())) in ActOnMethodDeclaration()
4929 decl = Cat->IsClassExtension() ? 1 : 2; in ActOnMethodDeclaration()
4934 Diag(ObjCMethod->getLocation(), in ActOnMethodDeclaration()
4937 Diag(IMD->getLocation(), diag::note_previous_declaration); in ActOnMethodDeclaration()
4940 if (ObjCMethod->isDirectMethod()) { in ActOnMethodDeclaration()
4941 const auto *attr = ObjCMethod->getAttr<ObjCDirectAttr>(); in ActOnMethodDeclaration()
4942 if (ObjCMethod->getCanonicalDecl() != IMD) { in ActOnMethodDeclaration()
4944 } else if (!IMD->isDirectMethod()) { in ActOnMethodDeclaration()
4945 Diag(attr->getLocation(), diag::err_objc_direct_missing_on_decl); in ActOnMethodDeclaration()
4946 Diag(IMD->getLocation(), diag::note_previous_declaration); in ActOnMethodDeclaration()
4948 } else if (IMD->isDirectMethod()) { in ActOnMethodDeclaration()
4949 const auto *attr = IMD->getAttr<ObjCDirectAttr>(); in ActOnMethodDeclaration()
4950 if (ObjCMethod->getCanonicalDecl() != IMD) { in ActOnMethodDeclaration()
4953 ObjCMethod->addAttr( in ActOnMethodDeclaration()
4954 ObjCDirectAttr::CreateImplicit(Context, attr->getLocation())); in ActOnMethodDeclaration()
4959 // Warn about defining -dealloc in a category. in ActOnMethodDeclaration()
4960 if (isa<ObjCCategoryImplDecl>(ImpDecl) && IMD->isOverriding() && in ActOnMethodDeclaration()
4961 ObjCMethod->getSelector().getMethodFamily() == OMF_dealloc) { in ActOnMethodDeclaration()
4962 Diag(ObjCMethod->getLocation(), diag::warn_dealloc_in_category) in ActOnMethodDeclaration()
4963 << ObjCMethod->getDeclName(); in ActOnMethodDeclaration()
4971 // extension conforms is non-escaping and the implementation's method is in ActOnMethodDeclaration()
4973 for (auto *C : IDecl->visible_categories()) in ActOnMethodDeclaration()
4974 for (auto &P : C->protocols()) in ActOnMethodDeclaration()
4975 if (auto *IMD = P->lookupMethod(ObjCMethod->getSelector(), in ActOnMethodDeclaration()
4976 ObjCMethod->isInstanceMethod())) { in ActOnMethodDeclaration()
4977 assert(ObjCMethod->parameters().size() == in ActOnMethodDeclaration()
4978 IMD->parameters().size() && in ActOnMethodDeclaration()
4980 auto OI = IMD->param_begin(), OE = IMD->param_end(); in ActOnMethodDeclaration() local
4981 auto NI = ObjCMethod->param_begin(); in ActOnMethodDeclaration()
4982 for (; OI != OE; ++OI, ++NI) in ActOnMethodDeclaration()
4992 IDecl = cast<ObjCCategoryDecl>(ClassDecl)->getClassInterface(); in ActOnMethodDeclaration()
5000 cast<DeclContext>(ClassDecl)->addDecl(ObjCMethod); in ActOnMethodDeclaration()
5005 Diag(ObjCMethod->getLocation(), diag::err_duplicate_method_decl) in ActOnMethodDeclaration()
5006 << ObjCMethod->getDeclName(); in ActOnMethodDeclaration()
5007 Diag(PrevMethod->getLocation(), diag::note_previous_declaration); in ActOnMethodDeclaration()
5008 ObjCMethod->setInvalidDecl(); in ActOnMethodDeclaration()
5012 // If this Objective-C method does not have a related result type, but we in ActOnMethodDeclaration()
5018 CurrentClass = Cat->getClassInterface(); in ActOnMethodDeclaration()
5020 CurrentClass = Impl->getClassInterface(); in ActOnMethodDeclaration()
5023 CurrentClass = CatImpl->getClassInterface(); in ActOnMethodDeclaration()
5037 !ObjCMethod->hasRelatedResultType() && in ActOnMethodDeclaration()
5040 switch (ObjCMethod->getMethodFamily()) { in ActOnMethodDeclaration()
5054 InferRelatedResultType = ObjCMethod->isClassMethod(); in ActOnMethodDeclaration()
5061 InferRelatedResultType = ObjCMethod->isInstanceMethod(); in ActOnMethodDeclaration()
5066 !ObjCMethod->getReturnType()->isObjCIndependentClassType()) in ActOnMethodDeclaration()
5067 ObjCMethod->setRelatedResultType(); in ActOnMethodDeclaration()
5076 if (const auto *attr = ObjCMethod->getAttr<AvailabilityAttr>()) { in ActOnMethodDeclaration()
5077 if (ObjCMethod->isClassMethod() && in ActOnMethodDeclaration()
5078 ObjCMethod->getSelector().getAsString() == "load") { in ActOnMethodDeclaration()
5079 Diag(attr->getLocation(), diag::warn_availability_on_static_initializer) in ActOnMethodDeclaration()
5081 ObjCMethod->dropAttr<AvailabilityAttr>(); in ActOnMethodDeclaration()
5086 ObjCMethod->createImplicitParams(Context, ObjCMethod->getClassInterface()); in ActOnMethodDeclaration()
5096 if (isa<ObjCContainerDecl>(SemaRef.CurContext->getRedeclContext())) in CheckObjCDeclScope()
5102 SemaRef.getCurLexicalContext()->getRedeclContext())) in CheckObjCDeclScope()
5105 Diag(D->getLocation(), diag::err_objc_decls_may_only_appear_in_global_scope); in CheckObjCDeclScope()
5106 D->setInvalidDecl(); in CheckObjCDeclScope()
5136 /*FIXME: StartL=*/ID->getLocation(), in ActOnDefs()
5137 ID->getLocation(), in ActOnDefs()
5138 ID->getIdentifier(), ID->getType(), in ActOnDefs()
5139 ID->getBitWidth()); in ActOnDefs()
5150 Record->addDecl(FD); in ActOnDefs()
5154 /// Build a type-check a new Objective-C exception variable declaration.
5162 // duration shall not be qualified by an address-space qualifier." in BuildObjCExceptionDecl()
5174 } else if (T->isDependentType()) { in BuildObjCExceptionDecl()
5176 } else if (T->isObjCQualifiedIdType()) { in BuildObjCExceptionDecl()
5179 } else if (T->isObjCIdType()) { in BuildObjCExceptionDecl()
5181 } else if (!T->isObjCObjectPointerType()) { in BuildObjCExceptionDecl()
5184 } else if (!T->castAs<ObjCObjectPointerType>()->getInterfaceType()) { in BuildObjCExceptionDecl()
5191 New->setExceptionVariable(true); in BuildObjCExceptionDecl()
5198 New->setInvalidDecl(); in BuildObjCExceptionDecl()
5231 QualType ExceptionType = TInfo->getType(); in ActOnObjCExceptionDecl()
5243 New->setInvalidDecl(); in ActOnObjCExceptionDecl()
5247 S->AddDecl(New); in ActOnObjCExceptionDecl()
5253 if (New->hasAttr<BlocksAttr>()) in ActOnObjCExceptionDecl()
5254 Diag(New->getLocation(), diag::err_block_on_nonlocal); in ActOnObjCExceptionDecl()
5258 /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
5263 for (ObjCIvarDecl *Iv = OI->all_declared_ivar_begin(); Iv; in CollectIvarsToConstructOrDestruct()
5264 Iv= Iv->getNextIvar()) { in CollectIvarsToConstructOrDestruct()
5265 QualType QT = Context.getBaseElementType(Iv->getType()); in CollectIvarsToConstructOrDestruct()
5266 if (QT->isRecordType()) in CollectIvarsToConstructOrDestruct()
5276 SemaRef.ExternalSource->ReadReferencedSelectors(Sels); in DiagnoseUseOfUnimplementedSelectors()
5298 if (Method->isClassMethod()) in GetIvarBackingPropertyAccessor()
5300 const ObjCInterfaceDecl *IDecl = Method->getClassInterface(); in GetIvarBackingPropertyAccessor()
5303 Method = IDecl->lookupMethod(Method->getSelector(), /*isInstance=*/true, in GetIvarBackingPropertyAccessor()
5306 if (!Method || !Method->isPropertyAccessor()) in GetIvarBackingPropertyAccessor()
5308 if ((PDecl = Method->findPropertyDecl())) in GetIvarBackingPropertyAccessor()
5309 if (ObjCIvarDecl *IV = PDecl->getPropertyIvarDecl()) { in GetIvarBackingPropertyAccessor()
5312 // FIXME. fix the const-ness issue. in GetIvarBackingPropertyAccessor()
5313 IV = const_cast<ObjCInterfaceDecl *>(IDecl)->lookupInstanceVariable( in GetIvarBackingPropertyAccessor()
5314 IV->getIdentifier()); in GetIvarBackingPropertyAccessor()
5340 if (E->getDecl() == IvarD) { in VisitObjCIvarRefExpr()
5348 if (E->getReceiverKind() == ObjCMessageExpr::Instance && in VisitObjCMessageExpr()
5349 S.ObjC().isSelfExpr(E->getInstanceReceiver(), Method)) { in VisitObjCMessageExpr()
5359 if (S->hasUnrecoverableErrorOccurred()) in DiagnoseUnusedBackingIvarInAccessor()
5362 for (const auto *CurMethod : ImplD->instance_methods()) { in DiagnoseUnusedBackingIvarInAccessor()
5364 SourceLocation Loc = CurMethod->getLocation(); in DiagnoseUnusedBackingIvarInAccessor()
5373 if (CurMethod->isSynthesizedAccessorStub()) in DiagnoseUnusedBackingIvarInAccessor()
5377 Checker.TraverseStmt(CurMethod->getBody()); in DiagnoseUnusedBackingIvarInAccessor()
5385 if (!IV->isReferenced() || !Checker.InvokedSelfMethod) { in DiagnoseUnusedBackingIvarInAccessor()
5387 Diag(PDecl->getLocation(), diag::note_property_declare); in DiagnoseUnusedBackingIvarInAccessor()
5397 T.getObjCLifetime() != Qualifiers::OCL_None || !T->isObjCLifetimeType()) in AdjustParameterTypeForObjCAutoRefCount()
5403 // - if it's const, use __unsafe_unretained in AdjustParameterTypeForObjCAutoRefCount()
5404 // - otherwise, it's an error in AdjustParameterTypeForObjCAutoRefCount()
5405 if (T->isArrayType()) { in AdjustParameterTypeForObjCAutoRefCount()
5413 << TSInfo->getTypeLoc().getSourceRange(); in AdjustParameterTypeForObjCAutoRefCount()
5417 Lifetime = T->getObjCARCImplicitLifetime(); in AdjustParameterTypeForObjCAutoRefCount()
5427 // The third "scope" argument is 0 since we aren't enabling lazy built-in in getObjCInterfaceDecl()
5434 // find an Objective-C class name. in getObjCInterfaceDecl()
5441 Id = IDecl->getIdentifier(); in getObjCInterfaceDecl()
5446 if (Def && Def->getDefinition()) in getObjCInterfaceDecl()
5447 Def = Def->getDefinition(); in getObjCInterfaceDecl()
5453 QualType type = decl->getType(); in inferObjCARCLifetime()
5457 unsigned kind = -1U; in inferObjCARCLifetime()
5459 if (var->hasAttr<BlocksAttr>()) in inferObjCARCLifetime()
5461 else if (!var->hasLocalStorage()) in inferObjCARCLifetime()
5469 if (kind != -1U) { in inferObjCARCLifetime()
5470 Diag(decl->getLocation(), diag::err_arc_autoreleasing_var) << kind; in inferObjCARCLifetime()
5474 if (!type->isObjCLifetimeType()) in inferObjCARCLifetime()
5477 lifetime = type->getObjCARCImplicitLifetime(); in inferObjCARCLifetime()
5479 decl->setType(type); in inferObjCARCLifetime()
5483 // Thread-local variables cannot have lifetime. in inferObjCARCLifetime()
5485 var->getTLSKind()) { in inferObjCARCLifetime()
5486 Diag(var->getLocation(), diag::err_arc_thread_ownership) in inferObjCARCLifetime()
5487 << var->getType(); in inferObjCARCLifetime()
5502 if (ObjCInterfaceDecl *OID = ObjCImplementation->getClassInterface()) { in SetIvarInitializers()
5511 if (Field->isInvalidDecl()) in SetIvarInitializers()
5517 InitializationKind::CreateDefault(ObjCImplementation->getLocation()); in SetIvarInitializers()
5536 Context.getBaseElementType(Field->getType()) in SetIvarInitializers()
5537 ->getAs<RecordType>()) { in SetIvarInitializers()
5538 CXXRecordDecl *RD = cast<CXXRecordDecl>(RecordTy->getDecl()); in SetIvarInitializers()
5540 SemaRef.MarkFunctionReferenced(Field->getLocation(), Destructor); in SetIvarInitializers()
5542 Field->getLocation(), Destructor, in SetIvarInitializers()
5544 << Context.getBaseElementType(Field->getType())); in SetIvarInitializers()
5548 ObjCImplementation->setIvarInitializers(Context, AllToInit.data(), in SetIvarInitializers()
5553 /// TranslateIvarVisibility - Translate visibility from a token ID to an
5571 /// ActOnIvar - Each ivar field of an objective-c class is passed into this
5585 QualType T = TInfo->getType(); in ActOnIvar()
5599 if (T->isReferenceType()) { in ActOnIvar()
5605 else if (T->isVariablyModifiedType()) { in ActOnIvar()
5618 if (!EnclosingDecl || EnclosingDecl->isInvalidDecl()) in ActOnIvar()
5626 EnclosingContext = IMPDecl->getClassInterface(); in ActOnIvar()
5632 if (getLangOpts().ObjCRuntime.isFragile() || !CDecl->IsClassExtension()) { in ActOnIvar()
5633 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension(); in ActOnIvar()
5645 if (T->containsErrors()) in ActOnIvar()
5646 NewID->setInvalidDecl(); in ActOnIvar()
5655 Diag(PrevDecl->getLocation(), diag::note_previous_declaration); in ActOnIvar()
5656 NewID->setInvalidDecl(); in ActOnIvar()
5664 NewID->setInvalidDecl(); in ActOnIvar()
5668 NewID->setInvalidDecl(); in ActOnIvar()
5671 NewID->setModulePrivate(); in ActOnIvar()
5676 S->AddDecl(NewID); in ActOnIvar()
5680 if (getLangOpts().ObjCRuntime.isNonFragile() && !NewID->isInvalidDecl() && in ActOnIvar()