aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGExprAgg.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-08-22 06:43:33 +0000
committerJohn McCall <rjmccall@apple.com>2010-08-22 06:43:33 +0000
commit875ab10245d3bf37252dd822aa1616bb0a391095 (patch)
treee0d71f880cfe63c0978c658fb5ef07d08a972679 /lib/CodeGen/CGExprAgg.cpp
parentcf2c85e76fdafe7e634810a292321a6c8322483d (diff)
Abstract out member-pointer creation. I'm really unhappy about the current
duplication between the constant and non-constant paths in all of this. Implement ARM ABI semantics for member pointer constants and conversion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111772 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprAgg.cpp')
-rw-r--r--lib/CodeGen/CGExprAgg.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp
index 1f8964d0b6..b75aeb13b8 100644
--- a/lib/CodeGen/CGExprAgg.cpp
+++ b/lib/CodeGen/CGExprAgg.cpp
@@ -364,9 +364,8 @@ void AggExprEmitter::VisitBinComma(const BinaryOperator *E) {
void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) {
// We have a member function pointer.
- const MemberPointerType *MPT = E->getType()->getAs<MemberPointerType>();
- (void) MPT;
- assert(MPT->getPointeeType()->isFunctionProtoType() &&
+ assert(E->getType()->getAs<MemberPointerType>()
+ ->getPointeeType()->isFunctionProtoType() &&
"Unexpected member pointer type!");
// The creation of member function pointers has no side effects; if
@@ -375,20 +374,9 @@ void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) {
return;
const DeclRefExpr *DRE = cast<DeclRefExpr>(E->getSubExpr());
- const CXXMethodDecl *MD =
- cast<CXXMethodDecl>(DRE->getDecl())->getCanonicalDecl();
+ const CXXMethodDecl *MD = cast<CXXMethodDecl>(DRE->getDecl());
- const llvm::Type *PtrDiffTy =
- CGF.ConvertType(CGF.getContext().getPointerDiffType());
-
- llvm::Value *DstPtr = Builder.CreateStructGEP(DestPtr, 0, "dst.ptr");
- llvm::Value *FuncPtr = CGF.CGM.GetCXXMemberFunctionPointerValue(MD);
- Builder.CreateStore(FuncPtr, DstPtr, VolatileDest);
-
- llvm::Value *AdjPtr = Builder.CreateStructGEP(DestPtr, 1, "dst.adj");
- // The adjustment will always be 0.
- Builder.CreateStore(llvm::ConstantInt::get(PtrDiffTy, 0), AdjPtr,
- VolatileDest);
+ CGF.CGM.getCXXABI().EmitMemberFunctionPointer(CGF, MD, DestPtr, VolatileDest);
}
void AggExprEmitter::VisitStmtExpr(const StmtExpr *E) {