[clang] [HLSL] Remove support for constructors for user defined structs (PR #190089)
Helena Kotas via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 8 12:42:20 PDT 2026
================
@@ -15522,6 +15501,31 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
switch (Opc) {
case BO_Assign:
+ // If this is HLSL and the LHS is a record try to perform aggregate
+ // initialization.
+ if (getLangOpts().HLSL && LHSExpr->getType()->isRecordType()) {
+ ResultTy = LHSExpr->getType();
+ InitListExpr *ILE =
+ new (Context) InitListExpr(getASTContext(), RHSExpr->getBeginLoc(),
+ {RHSExpr}, RHSExpr->getEndLoc());
+ ILE->setType(getASTContext().VoidTy);
+ InitializationKind Kind = InitializationKind::CreateDirectList(
+ RHSExpr->getBeginLoc(), RHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
+ InitializedEntity Entity =
+ InitializedEntity::InitializeTemporary(ResultTy);
+ RHSExpr = ILE;
+ InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
+ if (!HLSL().transformInitList(Entity, ILE))
+ InitSeq.SetFailed(
+ InitializationSequence::FK_HLSLInitListFlatteningFailed);
+
+ ExprResult Init = InitSeq.Perform(*this, Entity, Kind, RHSExpr);
+ if (Init.isInvalid())
+ return Init;
+ RHS = Init.get();
----------------
hekota wrote:
Consider moving this code to SemaHLSL.cpp/.h
```suggestion
RHS = HLSL().convertToAggregateInit(LHSExpr->getType(), RHS);
```
https://github.com/llvm/llvm-project/pull/190089
More information about the cfe-commits
mailing list