diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-14 20:13:28 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-14 20:13:28 +0000 |
commit | 99bed6fd21ca033074897160af1d971f6b5a9249 (patch) | |
tree | 88f6f47f84c04e77a0e7da8629db9db90f36b672 /clang/lib | |
parent | b6ba4682b501e3d6072a3839e11366da2549ff91 (diff) | |
download | bcm5719-llvm-99bed6fd21ca033074897160af1d971f6b5a9249.tar.gz bcm5719-llvm-99bed6fd21ca033074897160af1d971f6b5a9249.zip |
Fixed a problem caused by foreward @class use
which consequently caused a Seg fault. during meta-data
generation. It also addresses an issue related to
late binding of newly synthesize ivars (when we support it).
llvm-svn: 64563
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 12 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index d4fe26ed678..652fcdf8080 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/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/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 360eac0535a..4ec0e7c8883 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/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)); |