[cfe-commits] r64992 - in /cfe/trunk/lib/CodeGen: CGExpr.cpp CGValue.h
Fariborz Jahanian
fjahanian at apple.com
Wed Feb 18 16:48:06 PST 2009
Author: fjahanian
Date: Wed Feb 18 18:48:05 2009
New Revision: 64992
URL: http://llvm.org/viewvc/llvm-project?rev=64992&view=rev
Log:
Some code simplification. ir gen for gc'able array
of objects in objc.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGValue.h
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=64992&r1=64991&r2=64992&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Feb 18 18:48:05 2009
@@ -610,9 +610,7 @@
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 @@
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 @@
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;
Modified: cfe/trunk/lib/CodeGen/CGValue.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGValue.h?rev=64992&r1=64991&r2=64992&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGValue.h (original)
+++ cfe/trunk/lib/CodeGen/CGValue.h Wed Feb 18 18:48:05 2009
@@ -182,11 +182,10 @@
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 @@
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;
}
More information about the cfe-commits
mailing list