[clang] [HLSL] Implement output parameter (PR #101083)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 28 18:09:16 PDT 2024
================
@@ -11427,6 +11427,19 @@ static void AnalyzeImplicitConversions(
return;
}
+ if (auto *OutArgE = dyn_cast<HLSLOutArgExpr>(E)) {
+ // The base expression is only used to initialize the parameter for
+ // arguments to `inout` parameters, so we only traverse down the base
+ // expression for `inout` cases.
----------------
llvm-beanz wrote:
Gotcha! I think I misunderstood your comment since I didn't have the original lvalue preserved initially. I'll update this.
These are pretty wonky when we start looking at C++isms. My team reacted with disgust when I posed this potential (but currently invalid) code:
```hlsl
RWBuffer<int> Val;
struct A {
int Idx;
A &operator ++() {
Val[Idx] = Val[Idx] + 1;
return *this;
}
};
void init(out A Obj) {
Obj.Idx = 2;
};
[numthreads(1,1,1)]
void main() {
A a;
a.Idx = 0;
init(++a);
++a;
}
```
We certainly need to evaluate the argument expression (so that it can side-effect). Constructors would make this more complicated, but it probably should default initialize. Are you okay with that being a follow-up? If so I'll file an issue to track doing that work.
https://github.com/llvm/llvm-project/pull/101083
More information about the cfe-commits
mailing list