diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-05 19:18:30 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-02-05 19:18:30 +0000 |
commit | 5ed676c90c839c89093b605d76c7e581ab69ebb8 (patch) | |
tree | 781c3e9163ea5857a352ee2831f645a5783c288b /lib/CodeGen/CGExprScalar.cpp | |
parent | ae4c77dc8a77ee89e5b2de8003283249e38075c3 (diff) |
Fix a code gen bug accessing 'isa' field via a message call
(Fixes radar 7609722).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95406 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index f58d6e871b..cb3fb61cf3 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -1880,14 +1880,23 @@ LValue CodeGenFunction::EmitObjCIsaExpr(const ObjCIsaExpr *E) { llvm::Value *V; // object->isa or (*object).isa // Generate code as for: *(Class*)object + // build Class* type + const llvm::Type *ClassPtrTy = ConvertType(E->getType()); + Expr *BaseExpr = E->getBase(); - if (E->isArrow()) - V = ScalarExprEmitter(*this).EmitLoadOfLValue(BaseExpr); - else - V = EmitLValue(BaseExpr).getAddress(); + if (BaseExpr->isLvalue(getContext()) != Expr::LV_Valid) { + V = CreateTempAlloca(ClassPtrTy, "resval"); + llvm::Value *Src = EmitScalarExpr(BaseExpr); + Builder.CreateStore(Src, V); + } + else { + if (E->isArrow()) + V = ScalarExprEmitter(*this).EmitLoadOfLValue(BaseExpr); + else + V = EmitLValue(BaseExpr).getAddress(); + } // build Class* type - const llvm::Type *ClassPtrTy = ConvertType(E->getType()); ClassPtrTy = ClassPtrTy->getPointerTo(); V = Builder.CreateBitCast(V, ClassPtrTy); LValue LV = LValue::MakeAddr(V, MakeQualifiers(E->getType())); |