[clang] [HLSL] Remove support for constructors for user defined structs (PR #190089)

Steven Perron via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 14 07:57:18 PDT 2026


================
@@ -15522,6 +15533,18 @@ 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();
+      ExprResult Init =
+          HLSL().tryAggregateInitialization(*this, ResultTy, RHSExpr);
+      if (Init.isInvalid())
+        return Init;
+      RHS = Init.get();
+      break;
+    }
+
----------------
s-perron wrote:

Cool. While you get this cleaned up, please take the constantbuffer cases into consideration: https://godbolt.org/z/z39rTq1Pq.

Assignments and initialization of structs from a ConstantBuffer<S> will require HLSL specific handling. I'll probably want to make this another case in whatever code you add.

https://github.com/llvm/llvm-project/pull/190089


More information about the cfe-commits mailing list