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

via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 10 01:17:10 PDT 2024


================
@@ -2484,6 +2498,9 @@ class FunctionDecl : public DeclaratorDecl,
 
   void setDeletedAsWritten(bool D = true) { FunctionDeclBits.IsDeleted = D; }
 
+  /// Only valid if isDeletedAsWritten() returns true.
+  void setDeletedMessage(StringLiteral *Message);
+
----------------
Sirraide wrote:

So the main reasons I haven’t done that are:
1. `setDeletedAsWritten()` is called in many different places, but only in one of them do we also set the message;
2. `setDeletedMessage()` does a lot more than `setDeletedAsWritten()`, because whereas the latter just sets a bit to true, the former may also have to allocate a `DefaultedOrDeletedInfo` first and also has a couple asserts to make sure calling it is well-formed.

That said, `setDeletedMessage()` is currently only called in one place, directly after `setDeletedAsWritten()` (because all the other places where we need to set the message, e.g. serialisation, just directly create the `DefaultedOrDeletedInfo` instead), so if you still think we should just fold that into `setDeletedMessage()` then I’ll do that instead.

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


More information about the cfe-commits mailing list