From 3f92868b7e1fb0b9e49e9407ff3f2c0e7f8d07ea Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 26 Sep 2016 23:56:57 +0000 Subject: [PATCH] P0145R3 (C++17 evaluation order tweaks): evaluate the base expression before the pointer-to-member expression in calls through .* and ->* expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282457 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGExprCXX.cpp | 6 +++--- test/CodeGenCXX/cxx1z-eval-order.cpp | 32 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/CodeGen/CGExprCXX.cpp b/lib/CodeGen/CGExprCXX.cpp index e607c3c153..1dfe437c33 100644 --- a/lib/CodeGen/CGExprCXX.cpp +++ b/lib/CodeGen/CGExprCXX.cpp @@ -301,9 +301,6 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, const CXXRecordDecl *RD = cast(MPT->getClass()->getAs()->getDecl()); - // Get the member function pointer. - llvm::Value *MemFnPtr = EmitScalarExpr(MemFnExpr); - // Emit the 'this' pointer. Address This = Address::invalid(); if (BO->getOpcode() == BO_PtrMemI) @@ -314,6 +311,9 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, EmitTypeCheck(TCK_MemberCall, E->getExprLoc(), This.getPointer(), QualType(MPT->getClass(), 0)); + // Get the member function pointer. + llvm::Value *MemFnPtr = EmitScalarExpr(MemFnExpr); + // Ask the ABI to load the callee. Note that This is modified. llvm::Value *ThisPtrForCall = nullptr; llvm::Value *Callee = diff --git a/test/CodeGenCXX/cxx1z-eval-order.cpp b/test/CodeGenCXX/cxx1z-eval-order.cpp index 3531891d38..655f9a5ee0 100644 --- a/test/CodeGenCXX/cxx1z-eval-order.cpp +++ b/test/CodeGenCXX/cxx1z-eval-order.cpp @@ -125,35 +125,35 @@ void alloc_before_init() { // CHECK: } } -#if 0 -// CHECKDISABLED-LABEL: define {{.*}}@{{.*}}dotstar_lhs_before_rhs{{.*}}( + +// CHECK-LABEL: define {{.*}}@{{.*}}dotstar_lhs_before_rhs{{.*}}( int dotstar_lhs_before_rhs() { - // CHECKDISABLED: call {{.*}}@{{.*}}make_a{{.*}}( - // CHECKDISABLED: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}( + // CHECK: call {{.*}}@{{.*}}make_a{{.*}}( + // CHECK: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}( int a = make_a().*make_mem_ptr_a(); - // CHECKDISABLED: call {{.*}}@{{.*}}make_a_ptr{{.*}}( - // CHECKDISABLED: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}( + // CHECK: call {{.*}}@{{.*}}make_a_ptr{{.*}}( + // CHECK: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}( int b = make_a_ptr()->*make_mem_ptr_a(); - // CHECKDISABLED: call {{.*}}@{{.*}}make_c{{.*}}( - // CHECKDISABLED: call {{.*}}@{{.*}}make_b{{.*}}( + // CHECK: call {{.*}}@{{.*}}make_c{{.*}}( + // CHECK: call {{.*}}@{{.*}}make_b{{.*}}( make_c()->*make_b(); - // CHECKDISABLED: call {{.*}}@{{.*}}make_a{{.*}}( - // CHECKDISABLED: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}( - // CHECKDISABLED: call + // CHECK: call {{.*}}@{{.*}}make_a{{.*}}( + // CHECK: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}( + // CHECK: call (make_a().*make_mem_fn_ptr_a())(); - // CHECKDISABLED: call {{.*}}@{{.*}}make_a_ptr{{.*}}( - // CHECKDISABLED: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}( - // CHECKDISABLED: call + // CHECK: call {{.*}}@{{.*}}make_a_ptr{{.*}}( + // CHECK: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}( + // CHECK: call (make_a_ptr()->*make_mem_fn_ptr_a())(); return a + b; -// CHECKDISABLED: } +// CHECK: } } -#endif + #if 0 // CHECKDISABLED-LABEL: define {{.*}}@{{.*}}assign_lhs_before_rhs{{.*}}( void assign_rhs_before_lhs() { -- 2.40.0