diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2009-03-11 21:42:00 +0000 | 
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-03-11 21:42:00 +0000 | 
| commit | 99bee42be2dcdd28a5ffc96fb8adc32392f915e9 (patch) | |
| tree | a2a3616cebb8b6df6dee8ec4a78df5b064e37e74 /clang/lib/CodeGen | |
| parent | f61c8e81bd5ef3974873ecb48b514f04cec0930f (diff) | |
| download | bcm5719-llvm-99bee42be2dcdd28a5ffc96fb8adc32392f915e9.tar.gz bcm5719-llvm-99bee42be2dcdd28a5ffc96fb8adc32392f915e9.zip  | |
Code refactoring. No change in functionality.
llvm-svn: 66710
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 46 | 
1 files changed, 25 insertions, 21 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 48ea99ef7d8..045cde248c2 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -416,11 +416,15 @@ protected:    /// name. The return value has type char *.    llvm::Constant *GetClassName(IdentifierInfo *Ident); +  /// GetInterfaceDeclStructLayout - Get layout for ivars of given +  /// interface declaration. +  const llvm::StructLayout *GetInterfaceDeclStructLayout( +                                          const ObjCInterfaceDecl *ID) const; +      /// BuildIvarLayout - Builds ivar layout bitmap for the class    /// implementation for the __strong or __weak case.    /// -  llvm::Constant *BuildIvarLayout(const llvm::StructLayout *Layout, -                                  ObjCImplementationDecl *OI, +  llvm::Constant *BuildIvarLayout(ObjCImplementationDecl *OI,                                    bool ForStrongLayout,                                    const ObjCCommonTypesHelper &ObjCTypes); @@ -1706,10 +1710,7 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID,    ObjCInterfaceDecl *OID =       const_cast<ObjCInterfaceDecl*>(ID->getClassInterface()); -  const llvm::Type *InterfaceTy =  -    CGM.getTypes().ConvertType(CGM.getContext().getObjCInterfaceType(OID)); -  const llvm::StructLayout *Layout = -    CGM.getTargetData().getStructLayout(cast<llvm::StructType>(InterfaceTy)); +  const llvm::StructLayout *Layout = GetInterfaceDeclStructLayout(OID);    RecordDecl::field_iterator ifield, pfield;    const RecordDecl *RD = GetFirstIvarInRecord(OID, ifield, pfield); @@ -2292,10 +2293,7 @@ LValue CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF,  llvm::Value *CGObjCMac::EmitIvarOffset(CodeGen::CodeGenFunction &CGF,                                         ObjCInterfaceDecl *Interface,                                         const ObjCIvarDecl *Ivar) { -  const llvm::Type *InterfaceLTy = -  CGM.getTypes().ConvertType(CGM.getContext().getObjCInterfaceType(Interface)); -  const llvm::StructLayout *Layout = -  CGM.getTargetData().getStructLayout(cast<llvm::StructType>(InterfaceLTy)); +  const llvm::StructLayout *Layout = GetInterfaceDeclStructLayout(Interface);    FieldDecl *Field = Interface->lookupFieldDeclForIvar(CGM.getContext(), Ivar);    uint64_t Offset = GetIvarBaseOffset(Layout, Field);    return llvm::ConstantInt::get( @@ -2462,6 +2460,19 @@ llvm::Constant *CGObjCCommonMac::GetClassName(IdentifierInfo *Ident) {    return getConstantGEP(Entry, 0, 0);  } +/// GetInterfaceDeclStructLayout - Get layout for ivars of given +/// interface declaration. +const llvm::StructLayout *CGObjCCommonMac::GetInterfaceDeclStructLayout( +                                        const ObjCInterfaceDecl *OID) const { +  const llvm::Type *InterfaceTy = +    CGM.getTypes().ConvertType( +      CGM.getContext().getObjCInterfaceType( +                                        const_cast<ObjCInterfaceDecl*>(OID))); +  const llvm::StructLayout *Layout = +    CGM.getTargetData().getStructLayout(cast<llvm::StructType>(InterfaceTy)); +  return Layout; +} +  /// GetIvarLayoutName - Returns a unique constant for the given  /// ivar layout bitmap.  llvm::Constant *CGObjCCommonMac::GetIvarLayoutName(IdentifierInfo *Ident, @@ -2666,7 +2677,6 @@ IvarBytePosCompare (const void *a, const void *b)  /// - __weak anything  ///  llvm::Constant *CGObjCCommonMac::BuildIvarLayout( -                                      const llvm::StructLayout *Layout,                                        ObjCImplementationDecl *OMD,                                        bool ForStrongLayout,                                        const ObjCCommonTypesHelper &ObjCTypes) { @@ -2681,7 +2691,8 @@ llvm::Constant *CGObjCCommonMac::BuildIvarLayout(    CGM.getContext().CollectObjCIvars(OI, RecFields);    if (RecFields.empty())      return llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy); -     +   +  const llvm::StructLayout *Layout = GetInterfaceDeclStructLayout(OI);    BuildAggrIvarLayout (Layout, 0, RecFields, 0, ForStrongLayout,                          Index, SkIndex, hasUnion);    if (Index == -1) @@ -4129,10 +4140,7 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {    if (ObjCInterfaceDecl *OID =         const_cast<ObjCInterfaceDecl*>(ID->getClassInterface())) {      // FIXME. Share this with the one in EmitIvarList. -    const llvm::Type *InterfaceTy =  -    CGM.getTypes().ConvertType(CGM.getContext().buildObjCInterfaceType(OID)); -    const llvm::StructLayout *Layout = -    CGM.getTargetData().getStructLayout(cast<llvm::StructType>(InterfaceTy)); +    const llvm::StructLayout *Layout = GetInterfaceDeclStructLayout(OID);      RecordDecl::field_iterator firstField, lastField;      const RecordDecl *RD = GetFirstIvarInRecord(OID, firstField, lastField); @@ -4442,11 +4450,7 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList(    assert(OID && "CGObjCNonFragileABIMac::EmitIvarList - null interface");    // FIXME. Consolidate this with similar code in GenerateClass. -  const llvm::Type *InterfaceTy = -    CGM.getTypes().ConvertType(CGM.getContext().getObjCInterfaceType( -                                        const_cast<ObjCInterfaceDecl*>(OID))); -  const llvm::StructLayout *Layout = -    CGM.getTargetData().getStructLayout(cast<llvm::StructType>(InterfaceTy)); +  const llvm::StructLayout *Layout = GetInterfaceDeclStructLayout(OID);    RecordDecl::field_iterator i,p;    const RecordDecl *RD = GetFirstIvarInRecord(OID, i,p);  | 

