]> granicus.if.org Git - clang/commitdiff
P0145R3 (C++17 evaluation order tweaks): evaluate the base expression before
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 26 Sep 2016 23:56:57 +0000 (23:56 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 26 Sep 2016 23:56:57 +0000 (23:56 +0000)
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
test/CodeGenCXX/cxx1z-eval-order.cpp

index e607c3c153e0543ebb4ac4d4ec5204847f359a24..1dfe437c339283e96329a9ab2e3a6e3a808ec9e9 100644 (file)
@@ -301,9 +301,6 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
   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::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 =
index 3531891d383cbbb54947e8b7be191d2702d239fe..655f9a5ee0afa3c89c41f8757370ee5d039394ea 100644 (file)
@@ -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() {