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
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 12900e8..66aeea3 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -82,7 +82,7 @@
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 @@
// 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,