From d608cdb7c044365cf4e8764ade1e11e99c176078 Mon Sep 17 00:00:00 2001 From: John McCall Date: Sun, 22 Aug 2010 10:59:02 +0000 Subject: Experiment with using first-class aggregates to represent member function pointers. I find the resulting code to be substantially cleaner, and it makes it very easy to use the same APIs for data member pointers (which I have conscientiously avoided here), and it avoids a plethora of potential inefficiencies due to excessive memory copying, but we'll have to see if it actually works. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111776 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprAgg.cpp | 55 ----------------------------------------------- 1 file changed, 55 deletions(-) (limited to 'lib/CodeGen/CGExprAgg.cpp') diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index b75aeb13b8..890a07f9fb 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -108,7 +108,6 @@ public: void VisitPointerToDataMemberBinaryOperator(const BinaryOperator *BO); void VisitBinAssign(const BinaryOperator *E); void VisitBinComma(const BinaryOperator *E); - void VisitUnaryAddrOf(const UnaryOperator *E); void VisitObjCMessageExpr(ObjCMessageExpr *E); void VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { @@ -287,46 +286,9 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) { Visit(E->getSubExpr()); break; - case CastExpr::CK_NullToMemberPointer: { - // If the subexpression's type is the C++0x nullptr_t, emit the - // subexpression, which may have side effects. - if (E->getSubExpr()->getType()->isNullPtrType()) - Visit(E->getSubExpr()); - - CGF.CGM.getCXXABI().EmitNullMemberFunctionPointer(CGF, - E->getType()->getAs(), - DestPtr, VolatileDest); - - break; - } - case CastExpr::CK_LValueBitCast: llvm_unreachable("there are no lvalue bit-casts on aggregates"); break; - - case CastExpr::CK_BitCast: { - // This must be a member function pointer cast. - Visit(E->getSubExpr()); - break; - } - - case CastExpr::CK_DerivedToBaseMemberPointer: - case CastExpr::CK_BaseToDerivedMemberPointer: { - QualType SrcType = E->getSubExpr()->getType(); - - llvm::Value *Src = CGF.CreateMemTemp(SrcType, "tmp"); - CGF.EmitAggExpr(E->getSubExpr(), Src, SrcType.isVolatileQualified()); - - // Note that the AST doesn't distinguish between checked and - // unchecked member pointer conversions, so we always have to - // implement checked conversions here. This is inefficient for - // ABIs where an actual null check is thus required; fortunately, - // the Itanium and ARM ABIs ignore the adjustment value when - // considering null-ness. - CGF.CGM.getCXXABI().EmitMemberFunctionPointerConversion(CGF, E, Src, - DestPtr, VolatileDest); - break; - } } } @@ -362,23 +324,6 @@ void AggExprEmitter::VisitBinComma(const BinaryOperator *E) { /*IgnoreResult=*/false, IsInitializer); } -void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) { - // We have a member function pointer. - assert(E->getType()->getAs() - ->getPointeeType()->isFunctionProtoType() && - "Unexpected member pointer type!"); - - // The creation of member function pointers has no side effects; if - // there is no destination pointer, we have nothing to do. - if (!DestPtr) - return; - - const DeclRefExpr *DRE = cast(E->getSubExpr()); - const CXXMethodDecl *MD = cast(DRE->getDecl()); - - CGF.CGM.getCXXABI().EmitMemberFunctionPointer(CGF, MD, DestPtr, VolatileDest); -} - void AggExprEmitter::VisitStmtExpr(const StmtExpr *E) { CGF.EmitCompoundStmt(*E->getSubStmt(), true, DestPtr, VolatileDest); } -- cgit v1.2.3