From: Fariborz Jahanian Date: Fri, 16 Jan 2009 00:57:08 +0000 (+0000) Subject: Implemented code gen for sizeof(objc class interface). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=db751ebd3330bc9a64ce4d9d8f24e30669d91406;p=clang Implemented code gen for sizeof(objc class interface). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62289 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 4bb5fd1a4f..628bfb0788 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -686,7 +686,14 @@ ScalarExprEmitter::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) { Align /= 8; // Return alignment in bytes, not bits. return llvm::ConstantInt::get(llvm::APInt(ResultWidth, Align)); } - + if (TypeToSize->isObjCInterfaceType()) { + ObjCInterfaceDecl *OI = TypeToSize->getAsObjCInterfaceType()->getDecl(); + const RecordDecl *RD = CGF.getContext().addRecordToClass(OI); + const Type *Key = + CGF.getContext().getTagDeclType( + const_cast(dyn_cast(RD))).getTypePtr(); + TypeToSize = Key->getDesugaredType(); + } std::pair Info = CGF.getContext().getTypeInfo(TypeToSize); uint64_t Val = E->isSizeOf() ? Info.first : Info.second;