diff options
Diffstat (limited to 'lib/CodeGen/CGExprScalar.cpp')
-rw-r--r-- | lib/CodeGen/CGExprScalar.cpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index 9ac8b4d8b3..1ce4c5aef4 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -168,21 +168,8 @@ public: } Value *VisitObjCIsaExpr(ObjCIsaExpr *E) { - Value *V; - // object->isa or (*object).isa - // Generate code as for: *(Class*)object - Expr *BaseExpr = E->getBase(); - if (E->isArrow()) - V = 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, CGF.MakeQualifiers(E->getType())); - V = CGF.EmitLoadOfLValue(LV, E->getType()).getScalarVal(); + LValue LV = CGF.EmitObjCIsaExpr(E); + Value *V = CGF.EmitLoadOfLValue(LV, E->getType()).getScalarVal(); return V; } @@ -1997,3 +1984,22 @@ llvm::Value *CodeGenFunction::EmitVector(llvm::Value * const *Vals, return Vec; } + +LValue CodeGenFunction::EmitObjCIsaExpr(const ObjCIsaExpr *E) { + llvm::Value *V; + // object->isa or (*object).isa + // Generate code as for: *(Class*)object + Expr *BaseExpr = E->getBase(); + 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())); + return LV; +} + |