return 0;
}
Value *VisitExpr(Expr *S);
+ Value *VisitPointerToDataMemberBinaryExpr(const BinaryOperator *BExpr);
+
Value *VisitParenExpr(ParenExpr *PE) { return Visit(PE->getSubExpr()); }
// Leaves.
//===----------------------------------------------------------------------===//
Value *ScalarExprEmitter::VisitExpr(Expr *E) {
+ if (const BinaryOperator *BExpr = dyn_cast<BinaryOperator>(E))
+ if (BExpr->getOpcode() == BinaryOperator::PtrMemD)
+ return VisitPointerToDataMemberBinaryExpr(BExpr);
+
CGF.ErrorUnsupported(E, "scalar expression");
if (E->getType()->isVoidType())
return 0;
return llvm::UndefValue::get(CGF.ConvertType(E->getType()));
}
+Value *ScalarExprEmitter::VisitPointerToDataMemberBinaryExpr(
+ const BinaryOperator *E) {
+ Value *BaseV = EmitLValue(E->getLHS()).getAddress();
+ const llvm::Type *i8Ty = llvm::Type::getInt8PtrTy(CGF.getLLVMContext());
+ BaseV = Builder.CreateBitCast(BaseV, i8Ty);
+ Value *OffsetV = EmitLoadOfLValue(E->getRHS());
+ const llvm::Type* ResultType = ConvertType(
+ CGF.getContext().getPointerDiffType());
+ OffsetV = Builder.CreateBitCast(OffsetV, ResultType);
+ Value *AddV = Builder.CreateInBoundsGEP(BaseV, OffsetV, "add.ptr");
+ QualType Ty = E->getRHS()->getType();
+ const MemberPointerType *MemPtrType = Ty->getAs<MemberPointerType>();
+ Ty = MemPtrType->getPointeeType();
+ const llvm::Type* PType =
+ ConvertType(CGF.getContext().getPointerType(Ty));
+ AddV = Builder.CreateBitCast(AddV, PType);
+ LValue LV = LValue::MakeAddr(AddV, CGF.MakeQualifiers(Ty));
+ Value *InVal = CGF.EmitLoadOfLValue(LV, Ty).getScalarVal();
+ return InVal;
+}
+
Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
llvm::SmallVector<llvm::Constant*, 32> indices;
for (unsigned i = 2; i < E->getNumSubExprs(); i++) {
class A : public B, public B1 {
public:
+ A() : f(1.0), d(2.0), Ai(3) {}
float f;
double d;
int Ai;
printf("%d\n", &A::B1::iV);
printf("%d\n", &A::B::V::iV);
printf("%d\n", &A::B1::V::iV);
- // FIXME. NYI
- // printf(" %d, %f, %f \n", a1.*pa, a1.f, a1.d);
+ printf("%d, %f, %f \n", a1.*pa, a1.*pf, a1.*pd);
}