fix logic for member expr codegen.

llvm-svn: 44520
This commit is contained in:
Chris Lattner 2007-12-02 18:52:07 +00:00
parent 828429fea9
commit 4e4186b2de
1 changed files with 8 additions and 12 deletions

View File

@ -389,19 +389,15 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
Expr *BaseExpr = E->getBase();
llvm::Value *BaseValue = NULL;
if (BaseExpr->isLvalue() == Expr::LV_Valid) {
LValue BaseLV = EmitLValue(BaseExpr);
BaseValue = BaseLV.getAddress();
if (E->isArrow()) {
QualType Ty = BaseExpr->getType();
Ty = cast<PointerType>(Ty.getCanonicalType())->getPointeeType();
BaseValue =
Builder.CreateBitCast(BaseValue,
llvm::PointerType::get(ConvertType(Ty)), "tmp");
}
} else
// If this is s.x, emit s as an lvalue. If it is s->x, emit s as a scalar.
if (E->isArrow())
BaseValue = EmitScalarExpr(BaseExpr);
else {
LValue BaseLV = EmitLValue(BaseExpr);
// FIXME: this isn't right for bitfields.
BaseValue = BaseLV.getAddress();
}
FieldDecl *Field = E->getMemberDecl();
unsigned idx = CGM.getTypes().getLLVMFieldNo(Field);