diff options
-rw-r--r-- | include/clang/AST/ASTContext.h | 1 | ||||
-rw-r--r-- | lib/AST/ASTContext.cpp | 12 | ||||
-rw-r--r-- | lib/CodeGen/CGObjCMac.cpp | 4 | ||||
-rw-r--r-- | test/CodeGenObjC/class-type.m | 24 |
4 files changed, 39 insertions, 2 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 3f9e6bf213..c09c2573bd 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -263,6 +263,7 @@ public: /// specified typename decl. QualType getTypedefType(TypedefDecl *Decl); QualType getObjCInterfaceType(ObjCInterfaceDecl *Decl); + QualType buildObjCInterfaceType(ObjCInterfaceDecl *Decl); QualType getTemplateTypeParmType(unsigned Depth, unsigned Index, IdentifierInfo *Name = 0); diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index d4fe26ed67..652fcdf808 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1210,6 +1210,18 @@ QualType ASTContext::getObjCInterfaceType(ObjCInterfaceDecl *Decl) { return QualType(Decl->TypeForDecl, 0); } +/// buildObjCInterfaceType - Returns a new type for the interface +/// declaration, regardless. It also removes any previously built +/// record declaration so caller can rebuild it. +QualType ASTContext::buildObjCInterfaceType(ObjCInterfaceDecl *Decl) { + const RecordDecl *&RD = ASTRecordForInterface[Decl]; + if (RD) + RD = 0; + Decl->TypeForDecl = new(*this,8) ObjCInterfaceType(Type::ObjCInterface, Decl); + Types.push_back(Decl->TypeForDecl); + return QualType(Decl->TypeForDecl, 0); +} + /// \brief Retrieve the template type parameter type for a template /// parameter with the given depth, index, and (optionally) name. QualType ASTContext::getTemplateTypeParmType(unsigned Depth, unsigned Index, diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index 360eac0535..4ec0e7c888 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -1370,7 +1370,7 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) { Interface->protocol_begin(), Interface->protocol_end()); const llvm::Type *InterfaceTy = - CGM.getTypes().ConvertType(CGM.getContext().getObjCInterfaceType(Interface)); + CGM.getTypes().ConvertType(CGM.getContext().buildObjCInterfaceType(Interface)); unsigned Flags = eClassFlags_Factory; unsigned Size = CGM.getTargetData().getTypePaddedSize(InterfaceTy); @@ -3717,7 +3717,7 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { const_cast<ObjCInterfaceDecl*>(ID->getClassInterface())) { // FIXME. Share this with the one in EmitIvarList. const llvm::Type *InterfaceTy = - CGM.getTypes().ConvertType(CGM.getContext().getObjCInterfaceType(OID)); + CGM.getTypes().ConvertType(CGM.getContext().buildObjCInterfaceType(OID)); const llvm::StructLayout *Layout = CGM.getTargetData().getStructLayout(cast<llvm::StructType>(InterfaceTy)); diff --git a/test/CodeGenObjC/class-type.m b/test/CodeGenObjC/class-type.m new file mode 100644 index 0000000000..12a8a31b9d --- /dev/null +++ b/test/CodeGenObjC/class-type.m @@ -0,0 +1,24 @@ +// RUN: clang -triple x86_64-unknown-unknown -emit-llvm -o %t %s + +@interface I0 { + struct { int a; } a; +} +@end + +@class I2; + +@interface I1 { + I2 *_imageBrowser; +} +@end + +@implementation I1 +@end + +@interface I2 : I0 +@end + +@implementation I2 +@end + + |