From: David Chisnall Date: Mon, 21 Feb 2011 23:47:40 +0000 (+0000) Subject: The instance size of a metaclass should be the size of a class. This is not, in... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=05f3a507bb53ed2bd5573d551a26654a604187eb;p=clang The instance size of a metaclass should be the size of a class. This is not, in fact, 0, even for very small classes. (GNU runtime) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126161 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index d481e77926..8950f2131f 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -949,7 +949,12 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure( Elements.push_back(MakeConstantString(Name, ".class_name")); Elements.push_back(Zero); Elements.push_back(llvm::ConstantInt::get(LongTy, info)); - Elements.push_back(InstanceSize); + if (isMeta) { + llvm::TargetData td(&TheModule); + Elements.push_back(llvm::ConstantInt::get(LongTy, + td.getTypeSizeInBits(ClassTy)/8)); + } else + Elements.push_back(InstanceSize); Elements.push_back(IVars); Elements.push_back(Methods); Elements.push_back(NULLPtr);