[cfe-commits] r44520 - /cfe/trunk/CodeGen/CGExpr.cpp

Chris Lattner sabre at nondot.org
Sun Dec 2 10:52:08 PST 2007


Author: lattner
Date: Sun Dec  2 12:52:07 2007
New Revision: 44520

URL: http://llvm.org/viewvc/llvm-project?rev=44520&view=rev
Log:
fix logic for member expr codegen.

Modified:
    cfe/trunk/CodeGen/CGExpr.cpp

Modified: cfe/trunk/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExpr.cpp?rev=44520&r1=44519&r2=44520&view=diff

==============================================================================
--- cfe/trunk/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/CodeGen/CGExpr.cpp Sun Dec  2 12:52:07 2007
@@ -389,19 +389,15 @@
 
   Expr *BaseExpr = E->getBase();
   llvm::Value *BaseValue = NULL;
-  if (BaseExpr->isLvalue() == Expr::LV_Valid) {
+  
+  // 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();
-    
-    if (E->isArrow()) {
-      QualType Ty = BaseExpr->getType();
-      Ty = cast<PointerType>(Ty.getCanonicalType())->getPointeeType();
-      BaseValue =  
-        Builder.CreateBitCast(BaseValue, 
-                              llvm::PointerType::get(ConvertType(Ty)), "tmp");
-    }
-  } else
-    BaseValue = EmitScalarExpr(BaseExpr);
+  }
 
   FieldDecl *Field = E->getMemberDecl();
   unsigned idx = CGM.getTypes().getLLVMFieldNo(Field);





More information about the cfe-commits mailing list