================
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to