[cfe-commits] r62289 - /cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Fariborz Jahanian fjahanian at apple.com
Thu Jan 15 16:57:08 PST 2009


Author: fjahanian
Date: Thu Jan 15 18:57:08 2009
New Revision: 62289

URL: http://llvm.org/viewvc/llvm-project?rev=62289&view=rev
Log:
Implemented code gen for sizeof(objc class interface).

Modified:
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=62289&r1=62288&r2=62289&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Thu Jan 15 18:57:08 2009
@@ -686,7 +686,14 @@
     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<TagDecl*>(dyn_cast<TagDecl>(RD))).getTypePtr();
+    TypeToSize = Key->getDesugaredType();
+  }  
   std::pair<uint64_t, unsigned> Info = CGF.getContext().getTypeInfo(TypeToSize);
   
   uint64_t Val = E->isSizeOf() ? Info.first : Info.second;





More information about the cfe-commits mailing list