Skip to content
Snippets Groups Projects
Commit 3f92868b authored by Richard Smith's avatar Richard Smith
Browse files

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
parent d91ab1ce
No related branches found
No related tags found
No related merge requests found
...@@ -301,9 +301,6 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, ...@@ -301,9 +301,6 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
const CXXRecordDecl *RD = const CXXRecordDecl *RD =
cast<CXXRecordDecl>(MPT->getClass()->getAs<RecordType>()->getDecl()); cast<CXXRecordDecl>(MPT->getClass()->getAs<RecordType>()->getDecl());
// Get the member function pointer.
llvm::Value *MemFnPtr = EmitScalarExpr(MemFnExpr);
// Emit the 'this' pointer. // Emit the 'this' pointer.
Address This = Address::invalid(); Address This = Address::invalid();
if (BO->getOpcode() == BO_PtrMemI) if (BO->getOpcode() == BO_PtrMemI)
...@@ -314,6 +311,9 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E, ...@@ -314,6 +311,9 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
EmitTypeCheck(TCK_MemberCall, E->getExprLoc(), This.getPointer(), EmitTypeCheck(TCK_MemberCall, E->getExprLoc(), This.getPointer(),
QualType(MPT->getClass(), 0)); 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. // Ask the ABI to load the callee. Note that This is modified.
llvm::Value *ThisPtrForCall = nullptr; llvm::Value *ThisPtrForCall = nullptr;
llvm::Value *Callee = llvm::Value *Callee =
......
...@@ -125,35 +125,35 @@ void alloc_before_init() { ...@@ -125,35 +125,35 @@ void alloc_before_init() {
// CHECK: } // CHECK: }
} }
#if 0
// CHECKDISABLED-LABEL: define {{.*}}@{{.*}}dotstar_lhs_before_rhs{{.*}}( // CHECK-LABEL: define {{.*}}@{{.*}}dotstar_lhs_before_rhs{{.*}}(
int dotstar_lhs_before_rhs() { int dotstar_lhs_before_rhs() {
// CHECKDISABLED: call {{.*}}@{{.*}}make_a{{.*}}( // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
// CHECKDISABLED: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}( // CHECK: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}(
int a = make_a().*make_mem_ptr_a(); int a = make_a().*make_mem_ptr_a();
// CHECKDISABLED: call {{.*}}@{{.*}}make_a_ptr{{.*}}( // CHECK: call {{.*}}@{{.*}}make_a_ptr{{.*}}(
// CHECKDISABLED: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}( // CHECK: call {{.*}}@{{.*}}make_mem_ptr_a{{.*}}(
int b = make_a_ptr()->*make_mem_ptr_a(); int b = make_a_ptr()->*make_mem_ptr_a();
// CHECKDISABLED: call {{.*}}@{{.*}}make_c{{.*}}( // CHECK: call {{.*}}@{{.*}}make_c{{.*}}(
// CHECKDISABLED: call {{.*}}@{{.*}}make_b{{.*}}( // CHECK: call {{.*}}@{{.*}}make_b{{.*}}(
make_c()->*make_b(); make_c()->*make_b();
// CHECKDISABLED: call {{.*}}@{{.*}}make_a{{.*}}( // CHECK: call {{.*}}@{{.*}}make_a{{.*}}(
// CHECKDISABLED: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}( // CHECK: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}(
// CHECKDISABLED: call // CHECK: call
(make_a().*make_mem_fn_ptr_a())(); (make_a().*make_mem_fn_ptr_a())();
// CHECKDISABLED: call {{.*}}@{{.*}}make_a_ptr{{.*}}( // CHECK: call {{.*}}@{{.*}}make_a_ptr{{.*}}(
// CHECKDISABLED: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}( // CHECK: call {{.*}}@{{.*}}make_mem_fn_ptr_a{{.*}}(
// CHECKDISABLED: call // CHECK: call
(make_a_ptr()->*make_mem_fn_ptr_a())(); (make_a_ptr()->*make_mem_fn_ptr_a())();
return a + b; return a + b;
// CHECKDISABLED: } // CHECK: }
} }
#endif
#if 0 #if 0
// CHECKDISABLED-LABEL: define {{.*}}@{{.*}}assign_lhs_before_rhs{{.*}}( // CHECKDISABLED-LABEL: define {{.*}}@{{.*}}assign_lhs_before_rhs{{.*}}(
void assign_rhs_before_lhs() { void assign_rhs_before_lhs() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment