diff options
author | Sarah Spall <sarahspall@microsoft.com> | 2024-12-03 17:43:36 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-03 17:43:36 -0800 |
commit | 46de3a7064250bd2dfc7f8dc6e300474afa9fa97 (patch) | |
tree | 58f04eeddb0daa10a00c461dd9fd7cf86174b0e6 /clang/lib/Sema/Sema.cpp | |
parent | 6a0d6fc2e92bcfb7cb01a4c6cdd751a9b4b4c159 (diff) | |
download | llvm-46de3a7064250bd2dfc7f8dc6e300474afa9fa97.zip llvm-46de3a7064250bd2dfc7f8dc6e300474afa9fa97.tar.gz llvm-46de3a7064250bd2dfc7f8dc6e300474afa9fa97.tar.bz2 |
[HLSL] get inout/out ABI for array parameters working (#111047)
Get inout/out parameters working for HLSL Arrays.
Utilizes the fix from #109323, and corrects the assignment behavior
slightly to allow for Non-LValues on the RHS.
Closes #106917
---------
Co-authored-by: Chris B <beanz@abolishcrlf.org>
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r-- | clang/lib/Sema/Sema.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 942e7ec..d651751 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -723,6 +723,15 @@ ExprResult Sema::ImpCastExprToType(Expr *E, QualType Ty, QualType ExprTy = Context.getCanonicalType(E->getType()); QualType TypeTy = Context.getCanonicalType(Ty); + // This cast is used in place of a regular LValue to RValue cast for + // HLSL Array Parameter Types. It needs to be emitted even if + // ExprTy == TypeTy, except if E is an HLSLOutArgExpr + // Emitting a cast in that case will prevent HLSLOutArgExpr from + // being handled properly in EmitCallArg + if (Kind == CK_HLSLArrayRValue && !isa<HLSLOutArgExpr>(E)) + return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK, + CurFPFeatureOverrides()); + if (ExprTy == TypeTy) return E; |