[clang] [HLSL] get inout/out ABI for array parameters working (PR #111047)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 22 13:42:41 PDT 2024


================
@@ -5811,9 +5811,12 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) {
 // This function implements trivial copy assignment for HLSL's
 // assignable constant arrays.
 LValue CodeGenFunction::EmitHLSLArrayAssignLValue(const BinaryOperator *E) {
-  LValue TrivialAssignmentRHS = EmitLValue(E->getRHS());
+  // Don't emit an LValue for the RHS because it might not be an LValue
   LValue LHS = EmitLValue(E->getLHS());
-  EmitAggregateAssign(LHS, TrivialAssignmentRHS, E->getLHS()->getType());
+  // In C assignment operator RHS is often an RValue.
+  // EmitAggregateAssign expects an LValue for the RHS so call the below
+  // function instead.
----------------
efriedma-quic wrote:

In C++, "assignment" is mostly just syntax sugar for calling operator=.  EmitAggregateAssign is designed for that kind of usage, where the RHS is actually an lvalue.

If HLSL works differently here, using a different API is fine, I guess.

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


More information about the cfe-commits mailing list