================
@@ -676,6 +676,75 @@ 
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;
+
+  BuiltinTypeMethodBuilder Builder(*this, "", AST.VoidTy, false, true);
+  Builder.addParam("other", ConstRecordRefType);
+  Builder.ensureCompleteDecl();
+
+  ParmVarDecl *OtherParam = Builder.Method->getParamDecl(0);
+
+  Expr *OtherDeclRef = DeclRefExpr::Create(
+      AST, NestedNameSpecifierLoc(), SourceLocation(), OtherParam, false,
+      DeclarationNameInfo(OtherParam->getDeclName(), SourceLocation()),
+      ConstRecordType, VK_LValue);
+
+  FieldDecl *HandleField = getResourceHandleField();
+  Expr *OtherHandleMemberExpr = MemberExpr::CreateImplicit(
+      AST, OtherDeclRef, false, HandleField, HandleField->getType(), VK_LValue,
+      OK_Ordinary);
+
+  return Builder.assign(PH::Handle, OtherHandleMemberExpr).finalize();
----------------
hekota wrote:

Whenever possible, could you please try to use the same builder pattern as the 
other constructors and methods?

```suggestion
 return BuiltinTypeMethodBuilder(*this, "", AST.VoidTy, false, true)
    .addParam("other", ConstRecordRefType)
    .getResourceHandle(PH::_0)
    .assign(PH::Handle, PH::LastStmt)
    .finalize();
```

https://github.com/llvm/llvm-project/pull/156075
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to