https://github.com/ojhunt created 
https://github.com/llvm/llvm-project/pull/137102

When serializing and deserializing a FunctionDecl we don't recover whether or 
not the decl was a type aware allocator or destroying delete, because in the 
final PR that information was placed in a side table in ASTContext.

In principle it should be possible to re-do the semantic checks to determine 
what these flags should be when deserializing, but it seems like the most 
robust path is simply recording the flags directly in the serialized AST.

>From fdb5037f8cbcc6f2e1e967f6cac0a1bbb46abb51 Mon Sep 17 00:00:00 2001
From: Oliver Hunt <oli...@apple.com>
Date: Wed, 23 Apr 2025 18:09:22 -0700
Subject: [PATCH] [clang][p2719] Module deserialization does not restore
 allocator flags

When serializing and deserializing a FunctionDecl we don't recover
whether or not the decl was a type aware allocator or destroying
delete, because in the final PR that information was placed in a
side table in ASTContext.

In principle it should be possible to re-do the semantic checks to
determine what these flags should be when deserializing, but it
seems like the most robust path is simply recording the flags
directly in the serialized AST.
---
 clang/lib/Serialization/ASTReaderDecl.cpp | 3 +++
 clang/lib/Serialization/ASTWriterDecl.cpp | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 5545cbc8d608c..bc6f745a5c514 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1076,6 +1076,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
   FD->setFriendConstraintRefersToEnclosingTemplate(
       FunctionDeclBits.getNextBit());
   FD->setUsesSEHTry(FunctionDeclBits.getNextBit());
+  FD->setIsDestroyingOperatorDelete(FunctionDeclBits.getNextBit());
+  FD->setIsTypeAwareOperatorNewOrDelete(FunctionDeclBits.getNextBit());
 
   FD->EndRangeLoc = readSourceLocation();
   if (FD->isExplicitlyDefaulted())
@@ -1160,6 +1162,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
       C.registerSYCLEntryPointFunction(FD);
     }
   }
+
 }
 
 void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index 3a7a23481ea98..d1f92cea4dfea 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -847,6 +847,8 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
   FunctionDeclBits.addBit(D->isInstantiatedFromMemberTemplate());
   FunctionDeclBits.addBit(D->FriendConstraintRefersToEnclosingTemplate());
   FunctionDeclBits.addBit(D->usesSEHTry());
+  FunctionDeclBits.addBit(D->isDestroyingOperatorDelete());
+  FunctionDeclBits.addBit(D->isTypeAwareOperatorNewOrDelete());
   Record.push_back(FunctionDeclBits);
 
   Record.AddSourceLocation(D->getEndLoc());

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to