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

Aaron Ballman via lldb-commits lldb-commits at lists.llvm.org
Tue Jan 30 09:46:47 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:

Ah, thank you Eli! I missed that this was a params vs args issue.

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


More information about the lldb-commits mailing list