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

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 11:34:04 PDT 2024


================
@@ -761,6 +761,13 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
     }
   }
 
+  // FIXME: Hack: We're out of bits in FunctionDeclBits, so always
+  // add this even though it's 0 in the vast majority of cases. We
+  // might really want to consider storing this in the DefaultedFunctionInfo
+  // instead.
+  if (D->isDeletedAsWritten())
+    Record.AddStmt(D->getDeletedMessage());
----------------
Sirraide wrote:

> I didn't understand. Since the string literal is required to be `unevaluated string`, I feel it may be good to record the string value directly by `StringLiteral::getBytes`.

Hmm, from what I can tell, we don’t usually do that for string literals though. E.g. the string literal of a `FileScopeASMDecl` is also serialised as an expression:
https://github.com/llvm/llvm-project/blob/ff870aeeb7354fd3f681c17e248131e1065ac407/clang/lib/Serialization/ASTWriterDecl.cpp#L1272-L1274

Also, one issue that I see w/ only storing the string data is that we’d lose e.g. the source location of the string literal.

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


More information about the cfe-commits mailing list