aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-05-03 13:55:09 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-05-03 13:55:09 +0000
commit5e563dd38d6ec9f367cfd4b55d3efaf88a97cc09 (patch)
tree37c0ed4238236779e235f12b71c7569020796ca6 /lib/CodeGen
parent8b2926c23645627d60d62667fc0e7a310e40815e (diff)
Lift out GetGCAttrTypeForType routine.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/CGObjCMac.cpp43
1 files changed, 23 insertions, 20 deletions
diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp
index 8517c87664..4d84c775d3 100644
--- a/lib/CodeGen/CGObjCMac.cpp
+++ b/lib/CodeGen/CGObjCMac.cpp
@@ -2907,6 +2907,22 @@ llvm::Constant *CGObjCCommonMac::GetIvarLayoutName(IdentifierInfo *Ident,
return llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy);
}
+static QualType::GCAttrTypes GetGCAttrTypeForType(QualType FQT) {
+ if (FQT.isObjCGCStrong())
+ return QualType::Strong;
+
+ if (FQT.isObjCGCWeak())
+ return QualType::Weak;
+
+ if (CGM.getContext().isObjCObjectPointerType(FQT))
+ return QualType::Strong;
+
+ if (const PointerType *PT = FQT->getAsPointerType())
+ return GetGCAttrTypeForType(PT->getPointeeType());
+
+ return QualType::GCNone;
+}
+
void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
const llvm::StructLayout *Layout,
const RecordDecl *RD,
@@ -2961,13 +2977,13 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
if (const ArrayType *Array = CGM.getContext().getAsArrayType(FQT)) {
const ConstantArrayType *CArray =
- dyn_cast_or_null<ConstantArrayType>(Array);
+ dyn_cast_or_null<ConstantArrayType>(Array);
uint64_t ElCount = CArray->getSize().getZExtValue();
- assert(CArray && "only array with know element size is supported");
+ assert(CArray && "only array with known element size is supported");
FQT = CArray->getElementType();
while (const ArrayType *Array = CGM.getContext().getAsArrayType(FQT)) {
const ConstantArrayType *CArray =
- dyn_cast_or_null<ConstantArrayType>(Array);
+ dyn_cast_or_null<ConstantArrayType>(Array);
ElCount *= CArray->getSize().getZExtValue();
FQT = CArray->getElementType();
}
@@ -2981,12 +2997,12 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
// FIXME - Use a common routine with the above!
const RecordType *RT = FQT->getAsRecordType();
const RecordDecl *RD = RT->getDecl();
- // FIXME - Find a more efficiant way of passing records down.
+ // FIXME - Find a more efficient way of passing records down.
TmpRecFields.append(RD->field_begin(CGM.getContext()),
RD->field_end(CGM.getContext()));
const llvm::Type *Ty = CGM.getTypes().ConvertType(FQT);
const llvm::StructLayout *RecLayout =
- CGM.getTargetData().getStructLayout(cast<llvm::StructType>(Ty));
+ CGM.getTargetData().getStructLayout(cast<llvm::StructType>(Ty));
BuildAggrIvarLayout(0, RecLayout, RD,
TmpRecFields,
@@ -3012,21 +3028,8 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCInterfaceDecl *OI,
}
// At this point, we are done with Record/Union and array there of.
// For other arrays we are down to its element type.
- QualType::GCAttrTypes GCAttr = QualType::GCNone;
- do {
- if (FQT.isObjCGCStrong() || FQT.isObjCGCWeak()) {
- GCAttr = FQT.isObjCGCStrong() ? QualType::Strong : QualType::Weak;
- break;
- } else if (CGM.getContext().isObjCObjectPointerType(FQT)) {
- GCAttr = QualType::Strong;
- break;
- } else if (const PointerType *PT = FQT->getAsPointerType()) {
- FQT = PT->getPointeeType();
- } else {
- break;
- }
- } while (true);
-
+ QualType::GCAttrTypes GCAttr = GetGCAttrTypeForType(FQT):
+
unsigned FieldSize = CGM.getContext().getTypeSize(Field->getType());
if ((ForStrongLayout && GCAttr == QualType::Strong)
|| (!ForStrongLayout && GCAttr == QualType::Weak)) {