[clang] [llvm] [HLSL] Use static create methods to initialize individual resources (PR #156544)
Farzon Lotfi via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 15 12:10:21 PDT 2025
================
@@ -580,6 +589,20 @@ BuiltinTypeMethodBuilder &BuiltinTypeMethodBuilder::returnValue(T ReturnValue) {
Expr *ReturnValueExpr = convertPlaceholder(ReturnValue);
ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
+
+ QualType Ty = ReturnValueExpr->getType();
+ if (Ty->isRecordType()) {
+ // For record types, create a call to copy constructor to ensure proper copy
+ // semantics.
+ auto *ICE =
+ ImplicitCastExpr::Create(AST, Ty.withConst(), CK_NoOp, ReturnValueExpr,
+ nullptr, VK_XValue, FPOptionsOverride());
+ CXXConstructorDecl *CD = lookupCopyConstructor(Ty);
+ assert(CD && "no copy constructor found");
+ ReturnValueExpr = CXXConstructExpr::Create(
+ AST, Ty, SourceLocation(), CD, false, {ICE}, false, false, false, false,
----------------
farzonl wrote:
could we comment these false cases with the param names so its clear what we are setting to false.
example `/*param*/ false`
https://github.com/llvm/llvm-project/pull/156544
More information about the llvm-commits
mailing list