fix logic for member expr codegen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44520 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp
index e7bd712..5d563e1 100644
--- a/CodeGen/CGExpr.cpp
+++ b/CodeGen/CGExpr.cpp
@@ -389,19 +389,15 @@
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);