[clang] [clang] static operators should evaluate object argument (PR #68485)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 10 16:41:22 PDT 2023


================
@@ -5536,10 +5538,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);
----------------
shafik wrote:

nit
```suggestion
                 /*ParamsToSkip=*/0, Order);
```

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


More information about the cfe-commits mailing list