Patch for Bug 30413, including test case

Lobron, David via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 6 10:17:04 PST 2017


Hi Akira,

Pardon my slowness in addressing your question.

> This patch changes the encoding of an id conforming to a protocol, which I think was not intended: For example:
> 
> @encode(id<NSObject>)
> 
> Would passing IVD to the call to getObjCEncodingForType in CGObjCGNU::GenerateClass solve the problem?

Are you suggesting that passing IVD instead of just IVD->getType() will tell getObjCEncodingForType whether the code being compiled is a protocol, as opposed to an object?  I'm a little confused here, because IVD is an object of type ObjCIvarDecl, which is supposed to represent an instance variable, not a protocol.  Also, I don't see anything in the definition of ObjCIvarDecl (in AST/DeclObjC.h) that would tell us whether it represents an instance variable or a protocol.  Can you explain the case you are concerned about a little more?

If IVD can in fact tell us whether the code being compiled is an object, then we can make the EncodeClassNames argument of getObjCEncodingForTypeImpl true for ivars and false for protocols.

Thanks!

--David


More information about the cfe-commits mailing list