[clang] [HLSL] Implement HLSL intialization list support (PR #123141)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 14 13:03:32 PST 2025
================
@@ -3173,9 +3173,18 @@ bool SemaHLSL::TransformInitList(const InitializedEntity &Entity,
BuildFlattenedTypeList(InitTy, DestTypes);
llvm::SmallVector<Expr *, 16> ArgExprs;
- for (Expr *Arg : Init->inits())
- if (!BuildInitializerList(SemaRef, Ctx, Arg, ArgExprs, DestTypes))
+ for (unsigned I = 0; I < Init->getNumInits(); ++I) {
+ Expr *E = Init->getInit(I);
+ if (E->HasSideEffects(Ctx)) {
+ QualType Ty = E->getType();
+ if (auto *RTy = Ty->getAs<RecordType>())
+ E = new (Ctx) MaterializeTemporaryExpr(Ty, E, E->isLValue());
----------------
llvm-beanz wrote:
All AST node memory is owned by the ASTContext (hence the placement new-style syntax).
`E` is always owned by the ASTContext, I'm just shifting where in the AST it appears from being the top-level expression in the argument list to being a child of the MaterializeTemporary or OpaqueValue expression, which (at the end of the function) all gets rewritten over the original InitListExpr's Init expressions.
https://github.com/llvm/llvm-project/pull/123141
More information about the cfe-commits
mailing list