From aee1f514854c59f3890a97f23dccbf2be21d06e1 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 3 May 2010 20:00:27 +0000 Subject: If we're generating code to create a pointer-to-member function aggregate and the result of the aggregate is unused, bail out early. Fixes PR7027. llvm-svn: 102942 --- clang/lib/CodeGen/CGExprAgg.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'clang/lib/CodeGen/CGExprAgg.cpp') diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index d2f75bd3552b..d1b0dff11e5a 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -321,6 +321,11 @@ void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) { (void) MPT; assert(MPT->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 = @@ -329,6 +334,7 @@ void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) { const llvm::Type *PtrDiffTy = CGF.ConvertType(CGF.getContext().getPointerDiffType()); + llvm::Value *DstPtr = Builder.CreateStructGEP(DestPtr, 0, "dst.ptr"); llvm::Value *FuncPtr; -- cgit v1.2.3