[clang] [HLSL] Add copy assignment and construtor to resource types (PR #156075)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 4 13:51:50 PDT 2025
================
@@ -676,6 +704,44 @@ BuiltinTypeDeclBuilder::addHandleConstructorFromImplicitBinding() {
.finalize();
}
+BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addCopyConstructor() {
+ if (Record->isCompleteDefinition())
+ return *this;
+
+ ASTContext &AST = SemaRef.getASTContext();
+ QualType RecordType = AST.getCanonicalTagType(Record);
+ QualType ConstRecordType = RecordType.withConst();
+ QualType ConstRecordRefType = AST.getLValueReferenceType(ConstRecordType);
+
+ using PH = BuiltinTypeMethodBuilder::PlaceHolder;
+
+ return BuiltinTypeMethodBuilder(*this, "", AST.VoidTy, false, true)
+ .addParam("other", ConstRecordRefType)
+ .getResourceHandle(PH::_0)
+ .assign(PH::Handle, PH::LastStmt)
+ .finalize();
+}
+
+BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addCopyAssignmentOperator() {
+ if (Record->isCompleteDefinition())
+ return *this;
+
+ ASTContext &AST = SemaRef.getASTContext();
+ QualType RecordType = AST.getCanonicalTagType(Record);
+ QualType ConstRecordType = RecordType.withConst();
+ QualType ConstRecordRefType = AST.getLValueReferenceType(ConstRecordType);
+ QualType RecordRefType = AST.getLValueReferenceType(RecordType);
+
+ using PH = BuiltinTypeMethodBuilder::PlaceHolder;
+ DeclarationName Name = AST.DeclarationNames.getCXXOperatorName(OO_Equal);
+ return BuiltinTypeMethodBuilder(*this, Name, RecordRefType, false, false)
----------------
shafik wrote:
The default arguments are `false` so we can leave off the last two.
https://github.com/llvm/llvm-project/pull/156075
More information about the cfe-commits
mailing list