Author: rsmith Date: Mon Sep 26 18:56:57 2016 New Revision: 282457 URL: http://llvm.org/viewvc/llvm-project?rev=282457&view=rev Log: P0145R3 (C++17 evaluation order tweaks): evaluate the base expression before the pointer-to-member expression in calls through .* and ->* expressions.
Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp cfe/trunk/test/CodeGenCXX/cxx1z-eval-order.cpp Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=282457&r1=282456&r2=282457&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Mon Sep 26 18:56:57 2016 @@ -301,9 +301,6 @@ CodeGenFunction::EmitCXXMemberPointerCal const CXXRecordDecl *RD = cast<CXXRecordDecl>(MPT->getClass()->getAs<RecordType>()->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::EmitCXXMemberPointerCal 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 = Modified: cfe/trunk/test/CodeGenCXX/cxx1z-eval-order.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx1z-eval-order.cpp?rev=282457&r1=282456&r2=282457&view=diff ============================================================================== --- cfe/trunk/test/CodeGenCXX/cxx1z-eval-order.cpp (original) +++ cfe/trunk/test/CodeGenCXX/cxx1z-eval-order.cpp Mon Sep 26 18:56:57 2016 @@ -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() { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits