diff options
author | Chris Lattner <sabre@nondot.org> | 2008-03-30 23:25:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-03-30 23:25:33 +0000 |
commit | ce5605ecf76d8cde6372138f830bb144d174ced9 (patch) | |
tree | f3aa9a95602ec48d6fa560d2c4c1599d543a9ed6 /lib/CodeGen/CGExpr.cpp | |
parent | 391d77a26382dddf25da73e29fc1fa5aaaea4c6f (diff) |
some cleanups on top of David's patch. There are still two
remaining open issues I've communicated to him:
1) self can be assigned to, and his patch didn't handle it correctly.
2) CollectObjCIvarTypes is N^2 (because each subclass reprocesses
all parent class ivars) and flattens classes. If A derives from B,
and both have an int, I'd expect to get { {i32}, i32}, not { i32, i32}.
David, please review.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48970 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 12900e8b9d..66aeea3540 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -82,7 +82,7 @@ RValue CodeGenFunction::EmitAnyExpr(const Expr *E, llvm::Value *AggLoc, LValue CodeGenFunction::EmitLValue(const Expr *E) { switch (E->getStmtClass()) { default: { - printf("Statement class: %d\n", E->getStmtClass()); + printf("Statement class: %d\n", E->getStmtClass()); WarnUnsupported(E, "l-value expression"); llvm::Type *Ty = llvm::PointerType::getUnqual(ConvertType(E->getType())); return LValue::MakeAddr(llvm::UndefValue::get(Ty)); @@ -566,32 +566,27 @@ LValue CodeGenFunction::EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E) { // a class without recompiling all of the subclasses. If this is the case // then the CGObjCRuntime subclass must return true to LateBoundIvars and // implement the lookup itself. - if(CGM.getObjCRuntime()->LateBoundIVars()) { + if (CGM.getObjCRuntime()->LateBoundIVars()) { assert(0 && "FIXME: Implement support for late-bound instance variables"); return LValue(); // Not reached. } - else { - // Get a structure type for the object - QualType ExprTy = E->getBase()->getType(); - const llvm::Type *ObjectType = ConvertType(ExprTy); - //TODO: Add a special case for isa (index 0) - // Work out which index the ivar is - const ObjCIvarDecl *Decl = E->getDecl(); - unsigned Index = CGM.getTypes().getLLVMFieldNo(Decl); + + // Get a structure type for the object + QualType ExprTy = E->getBase()->getType(); + const llvm::Type *ObjectType = ConvertType(ExprTy); + // TODO: Add a special case for isa (index 0) + // Work out which index the ivar is + const ObjCIvarDecl *Decl = E->getDecl(); + unsigned Index = CGM.getTypes().getLLVMFieldNo(Decl); - // Get object pointer - llvm::Value * Object = EmitLValue(E->getBase()).getAddress(); - // Coerce object pointer to correct type. - if (Object->getType() != ObjectType) { - Object = Builder.CreateBitCast(Object, ObjectType); - } - // Get the correct element - llvm::Value * Element = Builder.CreateStructGEP(Object, - Index, - Decl->getName()); - // Element = Builder.CreateLoad(Element); - return LValue::MakeAddr(Element); - } + // Get object pointer and coerce object pointer to correct type. + llvm::Value *Object = EmitLValue(E->getBase()).getAddress(); + if (Object->getType() != ObjectType) + Object = Builder.CreateBitCast(Object, ObjectType); + + // Return a pointer to the right element. + return LValue::MakeAddr(Builder.CreateStructGEP(Object, Index, + Decl->getName())); } RValue CodeGenFunction::EmitCallExpr(llvm::Value *Callee, QualType FnType, |