objc2's ir-gen for nonfragile ivar access.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63578 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 2c16c19..4f8bd46 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -1020,7 +1020,8 @@
Offset);
}
-LValue CodeGenFunction::EmitLValueForIvar(llvm::Value *BaseValue,
+LValue CodeGenFunction::EmitLValueForIvar(QualType ObjectTy,
+ llvm::Value *BaseValue,
const ObjCIvarDecl *Ivar,
const FieldDecl *Field,
unsigned CVRQualifiers) {
@@ -1035,6 +1036,7 @@
CVRQualifiers, Index);
}
llvm::Value *V = CGM.getObjCRuntime().EmitObjCValueForIvar(*this,
+ ObjectTy,
BaseValue, Ivar, Field, CVRQualifiers);
LValue LV = LValue::MakeAddr(V, Ivar->getType().getCVRQualifiers()|CVRQualifiers);
SetVarDeclObjCAttribute(getContext(), Ivar, Ivar->getType(), LV);
@@ -1047,19 +1049,22 @@
llvm::Value *BaseValue = 0;
const Expr *BaseExpr = E->getBase();
unsigned CVRQualifiers = 0;
+ QualType ObjectTy;
if (E->isArrow()) {
BaseValue = EmitScalarExpr(BaseExpr);
const PointerType *PTy =
cast<PointerType>(getContext().getCanonicalType(BaseExpr->getType()));
- CVRQualifiers = PTy->getPointeeType().getCVRQualifiers();
+ ObjectTy = PTy->getPointeeType();
+ CVRQualifiers = ObjectTy.getCVRQualifiers();
} else {
LValue BaseLV = EmitLValue(BaseExpr);
// FIXME: this isn't right for bitfields.
BaseValue = BaseLV.getAddress();
- CVRQualifiers = BaseExpr->getType().getCVRQualifiers();
+ ObjectTy = BaseExpr->getType();
+ CVRQualifiers = ObjectTy.getCVRQualifiers();
}
- return EmitLValueForIvar(BaseValue, E->getDecl(),
+ return EmitLValueForIvar(ObjectTy, BaseValue, E->getDecl(),
getContext().getFieldDecl(E), CVRQualifiers);
}