[clang] [HLSL] Implement array temporary support (PR #79382)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 24 17:35:12 PST 2024


================
@@ -10524,6 +10524,11 @@ Sema::PerformCopyInitialization(const InitializedEntity &Entity,
   Expr *InitE = Init.get();
   assert(InitE && "No initialization expression?");
 
+  if (LangOpts.HLSL)
+    if (auto AdjTy = dyn_cast<DecayedType>(Entity.getType()))
+      if (AdjTy->getOriginalType()->isConstantArrayType())
+        InitE = HLSLArrayTemporaryExpr::Create(getASTContext(), InitE);
----------------
llvm-beanz wrote:

Ooo. I like this idea a lot. Let me go give that a try. I was trying to avoid completely breaking array decay completely because at some point we’re going to align the language more with C/C++.

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


More information about the cfe-commits mailing list