[clang] [Clang] [C++26] Implement P2573R2: `= delete("should have a reason");` (PR #86526)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 10 06:43:40 PDT 2024


================
@@ -14527,20 +14525,24 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
         UnaryOperator::getOpcodeStr(Opc), OpLoc);
     return ExprError();
 
-  case OR_Deleted:
+  case OR_Deleted: {
     // CreateOverloadedUnaryOp fills the first element of ArgsArray with the
     // object whose method was called. Later in NoteCandidates size of ArgsArray
     // is passed further and it eventually ends up compared to number of
     // function candidate parameters which never includes the object parameter,
     // so slice ArgsArray to make sure apples are compared to apples.
+    StringLiteral *Msg = Best->Function->getDeletedMessage();
     CandidateSet.NoteCandidates(
         PartialDiagnosticAt(OpLoc, PDiag(diag::err_ovl_deleted_oper)
                                        << UnaryOperator::getOpcodeStr(Opc)
+                                       << !!Msg
----------------
erichkeane wrote:

Same a few times here... this is a 'neat' trick, but it is something that we don't ever do, so it is a touch jarring/takes more thinking than something like this should.

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


More information about the cfe-commits mailing list