[Openmp-commits] [libcxx] [libcxxabi] [lldb] [libunwind] [clang-tools-extra] [libc] [mlir] [compiler-rt] [clang] [lld] [llvm] [openmp] [flang] [clang] static operators should evaluate object argument (PR #68485)

Aaron Ballman via Openmp-commits openmp-commits at lists.llvm.org
Tue Jan 30 09:01:55 PST 2024


================
@@ -5865,10 +5867,24 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType, const CGCallee &OrigCallee
         break;
       }
     }
+
+    if (const auto *MD =
+            dyn_cast_if_present<CXXMethodDecl>(OCE->getCalleeDecl());
+        MD && MD->isStatic())
+      StaticOperator = true;
   }
 
-  EmitCallArgs(Args, dyn_cast<FunctionProtoType>(FnType), E->arguments(),
-               E->getDirectCallee(), /*ParamsToSkip*/ 0, Order);
+  if (StaticOperator) {
+    // If we're calling a static operator, we need to emit the object argument
+    // and ignore it.
+    EmitIgnoredExpr(E->getArg(0));
+
+    EmitCallArgs(Args, dyn_cast<FunctionProtoType>(FnType),
+                 drop_begin(E->arguments(), 1), E->getDirectCallee(),
+                 /*ParamsToSkip=*/0, Order);
+  } else
+    EmitCallArgs(Args, dyn_cast<FunctionProtoType>(FnType), E->arguments(),
+                 E->getDirectCallee(), /*ParamsToSkip=*/0, Order);
----------------
AaronBallman wrote:

I think that suggests there's still a problem; we should not have to manually drop the arguments when there's a parameter explicitly for that. I think what's happening is that there's a mismatch between static call operator prototypes and the checking logic in `EmitCallArgs`. CC @efriedma-quic @rjmccall 

https://github.com/llvm/llvm-project/pull/68485


More information about the Openmp-commits mailing list