r196315 - [objc] Introduce ObjCInterfaceDecl::getDesignatedInitializers() to get the

Argyrios Kyrtzidis kyrtzidis at apple.com
Wed Dec 4 23:15:50 PST 2013


On Dec 3, 2013, at 1:21 PM, Jordan Rose <jordan_rose at apple.com> wrote:

> 
> On Dec 3, 2013, at 13:11, Argyrios Kyrtzidis <akyrtzi at gmail.com> wrote:
> 
>> +void ObjCInterfaceDecl::getDesignatedInitializers(
>> +    llvm::SmallVectorImpl<const ObjCMethodDecl *> &Methods) const {
>> +  assert(hasDefinition());
>> +  if (data().ExternallyCompleted)
>> +    LoadExternalDefinition();
>> +
>> +  const ObjCInterfaceDecl *IFace = this;
>> +  while (IFace) {
>> +    if (IFace->data().HasDesignatedInitializers)
>> +      break;
>> +    IFace = IFace->getSuperClass();
>> +  }
>> +
>> +  if (!IFace)
>> +    return;
>> +  for (instmeth_iterator I = IFace->instmeth_begin(),
>> +                         E = IFace->instmeth_end(); I != E; ++I) {
>> +    const ObjCMethodDecl *MD = *I;
>> +    if (MD->getMethodFamily() == OMF_init &&
>> +        MD->hasAttr<ObjCDesignatedInitializerAttr>())
>> +      Methods.push_back(MD);
>> +  }
>> +}
> 
> Is this correct? This says that even if I declare new init methods (and don't mark any as designated), the designated initializers are still my superclass's designated initializers. I think this is a backwards-compatibility problem for people shipping subclasses with new init methods.

Thanks for pointing out the issue!

With r196476, if an interface has no initializer marked as designated and introduces at least one new initializer, we don't assume that it inherits the designated initializers from the super class.
We assume that it inherits if it doesn't declare any initializer or if all the declared initializers are overrides from the superclass.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131204/23df955c/attachment.html>


More information about the cfe-commits mailing list