================ @@ -7061,6 +7061,67 @@ class ArraySectionExpr : public Expr { void setRBracketLoc(SourceLocation L) { RBracketLoc = L; } }; +/// This class represents temporary values used to represent inout and out +/// arguments in HLSL. From the callee perspective these parameters are more or +/// less __restrict__ T&. They are guaranteed to not alias any memory. inout +/// parameters are initialized by the caller, and out parameters are references +/// to uninitialized memory. +/// +/// In the caller, the argument expression creates a temporary in local memory +/// and the address of the temporary is passed into the callee. There may be +/// implicit conversion sequences to initialize the temporary, and on expiration +/// of the temporary an inverse conversion sequence is applied as a write-back +/// conversion to the source l-value. +class HLSLOutArgExpr : public Expr { + friend class ASTStmtReader; + + Expr *Base; + Expr *Writeback; + OpaqueValueExpr *OpaqueVal; + bool IsInOut; + + HLSLOutArgExpr(QualType Ty, Expr *B, Expr *WB, OpaqueValueExpr *OpV, + bool IsInOut) + : Expr(HLSLOutArgExprClass, Ty, VK_LValue, OK_Ordinary), Base(B), + Writeback(WB), OpaqueVal(OpV), IsInOut(IsInOut) { + assert(!Ty->isDependentType() && "HLSLOutArgExpr given a dependent type!"); + } + + explicit HLSLOutArgExpr(EmptyShell Shell) + : Expr(HLSLOutArgExprClass, Shell) {} + +public: + static HLSLOutArgExpr *Create(const ASTContext &C, QualType Ty, Expr *Base, + bool IsInOut, Expr *WB, OpaqueValueExpr *OpV); + static HLSLOutArgExpr *CreateEmpty(const ASTContext &Ctx); + + const Expr *getBase() const { return Base; } ---------------- rjmccall wrote:
You need to document what the expressions are here, because it's pretty subtle. So the way you've written it, this a conversion of the base l-value to the type of the parameter, the writeback is an assignment of the temporary result back to the base l-value, and the OVE represents the temporary result. I think this is problematic, though; see the comment in Sema. https://github.com/llvm/llvm-project/pull/101083 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits