[clang] [HLSL] Implement output parameter (PR #101083)
John McCall via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 28 11:23:48 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.
----------------
rjmccall wrote:
I specifically said the original l-value expression. I'm trying to make sure we get warnings in sub-expressions of the l-value that have nothing to do with the final conversion to produce the argument.
With that said:
> If SemaChecking traverses down both sides we get warnings for the conversion that would "initialize" the out parameter, but those warnings aren't accurate because no initialization occurs.
Isn't this an argument that you either (1) shouldn't visit the initialization specifically for `out`, but should still do it for `inout`, or (2) shouldn't generate the initialization expression for `out`?
Apropos, I know this is a future direction, but what semantics do you want for C++ class types and `out`? Skipping the initialization entirely is definitely incorrect — the callee will get passed a reference to an uninitialized object and (presumably) start calling methods on it. Probably this should default-initialize?
https://github.com/llvm/llvm-project/pull/101083
More information about the cfe-commits
mailing list