aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenTypes.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-12-15 20:35:07 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-12-15 20:35:07 +0000
commitfd64bb635dc221baa19f81d5d2a084f7eb269f7f (patch)
treecc7de8b7ad8802f40468ace0b831c274ca97109e /lib/CodeGen/CodeGenTypes.cpp
parent0ea76727ae91bca918a8414ed85b530eddcfedeb (diff)
Code gen. for ivar references; including bitfield
ivars. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61043 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenTypes.cpp')
-rw-r--r--lib/CodeGen/CodeGenTypes.cpp41
1 files changed, 10 insertions, 31 deletions
diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp
index ff89341ddc..3470cca4d1 100644
--- a/lib/CodeGen/CodeGenTypes.cpp
+++ b/lib/CodeGen/CodeGenTypes.cpp
@@ -155,21 +155,6 @@ void CodeGenTypes::UpdateCompletedType(const TagDecl *TD) {
cast<llvm::OpaqueType>(OpaqueHolder.get())->refineAbstractTypeTo(NT);
}
-/// Produces a vector containing the all of the instance variables in an
-/// Objective-C object, in the order that they appear. Used to create LLVM
-/// structures corresponding to Objective-C objects.
-void CodeGenTypes::CollectObjCIvarTypes(ObjCInterfaceDecl *ObjCClass,
- std::vector<const llvm::Type*> &IvarTypes) {
- ObjCInterfaceDecl *SuperClass = ObjCClass->getSuperClass();
- if (SuperClass)
- CollectObjCIvarTypes(SuperClass, IvarTypes);
- for (ObjCInterfaceDecl::ivar_iterator I = ObjCClass->ivar_begin(),
- E = ObjCClass->ivar_end(); I != E; ++I) {
- IvarTypes.push_back(ConvertType((*I)->getType()));
- ObjCIvarInfo[*I] = IvarTypes.size() - 1;
- }
-}
-
static const llvm::Type* getTypeForFormat(const llvm::fltSemantics &format) {
if (&format == &llvm::APFloat::IEEEsingle)
return llvm::Type::FloatTy;
@@ -280,21 +265,22 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) {
ConvertTypeRecursive(QualType(cast<ASQualType>(Ty).getBaseType(), 0));
case Type::ObjCInterface: {
- // FIXME: This comment is broken. Either the code should check for
- // the flag it is referring to or it should do the right thing in
- // the presence of it.
-
// Warning: Use of this is strongly discouraged. Late binding of instance
// variables is supported on some runtimes and so using static binding can
// break code when libraries are updated. Only use this if you have
// previously checked that the ObjCRuntime subclass in use does not support
// late-bound ivars.
+ // We are issuing warnings elsewhere!
ObjCInterfaceType OIT = cast<ObjCInterfaceType>(Ty);
- std::vector<const llvm::Type*> IvarTypes;
- CollectObjCIvarTypes(OIT.getDecl(), IvarTypes);
- llvm::Type *T = llvm::StructType::get(IvarTypes);
- TheModule.addTypeName("struct." + OIT.getDecl()->getNameAsString(), T);
- return T;
+ ObjCInterfaceDecl *ID = OIT.getDecl();
+ RecordDecl *RD = ID->getRecordForDecl();
+ if(!RD) {
+ // Sometimes, class type is being directly generated in code gen for
+ // built-in class types.
+ ID->addLayoutToClass(Context);
+ RD = ID->getRecordForDecl();
+ }
+ return ConvertTagDeclType(cast<TagDecl>(RD));
}
case Type::ObjCQualifiedInterface: {
@@ -427,13 +413,6 @@ unsigned CodeGenTypes::getLLVMFieldNo(const FieldDecl *FD) {
return I->second;
}
-unsigned CodeGenTypes::getLLVMFieldNo(const ObjCIvarDecl *OID) {
- llvm::DenseMap<const ObjCIvarDecl*, unsigned>::iterator
- I = ObjCIvarInfo.find(OID);
- assert(I != ObjCIvarInfo.end() && "Unable to find field info");
- return I->second;
-}
-
/// addFieldInfo - Assign field number to field FD.
void CodeGenTypes::addFieldInfo(const FieldDecl *FD, unsigned No) {
FieldInfo[FD] = No;