diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-19 00:48:05 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-02-19 00:48:05 +0000 |
commit | 83e3eea5fc8a14bae22a5b5a80fe96b7e6b91e55 (patch) | |
tree | 22f0e4dd28c08fa314b93ab236aa27bcf9b8fa10 /clang/lib | |
parent | 9c788c081cbda71d65a4fc32b339718cd9ade52e (diff) | |
download | bcm5719-llvm-83e3eea5fc8a14bae22a5b5a80fe96b7e6b91e55.tar.gz bcm5719-llvm-83e3eea5fc8a14bae22a5b5a80fe96b7e6b91e55.zip |
Some code simplification. ir gen for gc'able array
of objects in objc.
llvm-svn: 64992
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 20 | ||||
-rw-r--r-- | clang/lib/CodeGen/CGValue.h | 11 |
2 files changed, 17 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 69429e08e67..6e7d936c7e2 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -610,9 +610,7 @@ static void SetDeclObjCGCAttrInLvalue(ASTContext &Ctx, const QualType &Ty, LValue &LV) { QualType::GCAttrTypes attr = Ctx.getObjCGCAttrKind(Ty); - if (attr != QualType::GCNone) - LValue::SetObjCType(attr == QualType::Weak, - attr == QualType::Strong, LV); + LValue::SetObjCType(attr, LV); } LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) { @@ -767,11 +765,13 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) { BaseTypeSize)); } - QualType ExprTy = getContext().getCanonicalType(E->getBase()->getType()); + QualType T = E->getBase()->getType(); + QualType ExprTy = getContext().getCanonicalType(T); + T = T->getAsPointerType()->getPointeeType(); return LValue::MakeAddr(Builder.CreateGEP(Base, Idx, "arrayidx"), - ExprTy->getAsPointerType()->getPointeeType() - .getCVRQualifiers()); + ExprTy->getAsPointerType()->getPointeeType().getCVRQualifiers(), + getContext().getObjCGCAttrKind(T)); } static @@ -921,11 +921,13 @@ LValue CodeGenFunction::EmitLValueForField(llvm::Value* BaseValue, CGM.getLangOptions().getGCMode() != LangOptions::NonGC) { QualType Ty = Field->getType(); QualType::GCAttrTypes attr = Ty.getObjCGCAttr(); - if (attr != QualType::GCNone) + if (attr != QualType::GCNone) { // __weak attribute on a field is ignored. - LValue::SetObjCType(false, attr == QualType::Strong, LV); + if (attr == QualType::Strong) + LValue::SetObjCType(QualType::Strong, LV); + } else if (getContext().isObjCObjectPointerType(Ty)) - LValue::SetObjCType(false, true, LV); + LValue::SetObjCType(QualType::Strong, LV); } return LV; diff --git a/clang/lib/CodeGen/CGValue.h b/clang/lib/CodeGen/CGValue.h index 318ee55ac97..96e4224f614 100644 --- a/clang/lib/CodeGen/CGValue.h +++ b/clang/lib/CodeGen/CGValue.h @@ -182,11 +182,10 @@ public: R.Ivar = iValue; } - static void SetObjCType(bool isWeak, bool isStrong, LValue& R) { - assert(!(isWeak == true && isStrong == true)); - if (isWeak) + static void SetObjCType(QualType::GCAttrTypes GCAttrs, LValue& R) { + if (GCAttrs == QualType::Weak) R.ObjCType = Weak; - else if (isStrong) + else if (GCAttrs == QualType::Strong) R.ObjCType = Strong; } @@ -227,11 +226,13 @@ public: return KVCRefExpr; } - static LValue MakeAddr(llvm::Value *V, unsigned Qualifiers) { + static LValue MakeAddr(llvm::Value *V, unsigned Qualifiers, + QualType::GCAttrTypes GCAttrs = QualType::GCNone) { LValue R; R.LVType = Simple; R.V = V; SetQualifiers(Qualifiers,R); + SetObjCType(GCAttrs, R); return R; } |