Implemented code gen for sizeof(objc class interface).

llvm-svn: 62289
This commit is contained in:
Fariborz Jahanian 2009-01-16 00:57:08 +00:00
parent fa1b408b3b
commit c5ece68d16
1 changed files with 8 additions and 1 deletions

View File

@ -686,7 +686,14 @@ ScalarExprEmitter::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) {
Align /= 8; // Return alignment in bytes, not bits. Align /= 8; // Return alignment in bytes, not bits.
return llvm::ConstantInt::get(llvm::APInt(ResultWidth, Align)); 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<TagDecl*>(dyn_cast<TagDecl>(RD))).getTypePtr();
TypeToSize = Key->getDesugaredType();
}
std::pair<uint64_t, unsigned> Info = CGF.getContext().getTypeInfo(TypeToSize); std::pair<uint64_t, unsigned> Info = CGF.getContext().getTypeInfo(TypeToSize);
uint64_t Val = E->isSizeOf() ? Info.first : Info.second; uint64_t Val = E->isSizeOf() ? Info.first : Info.second;