[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 19:45:09 PDT 2024


================
@@ -1483,10 +1483,15 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
   if (D->isThisDeclarationADefinition())
     Record.AddCXXDefinitionData(D);
 
-  // Store (what we currently believe to be) the key function to avoid
-  // deserializing every method so we can compute it.
-  if (D->isCompleteDefinition())
-    Record.AddDeclRef(Context.getCurrentKeyFunction(D));
+  if (D->isCompleteDefinition()) {
+    if (D->getOwningModule() && D->getOwningModule()->isInterfaceOrPartition())
+      Writer.ModularCodegenDecls.push_back(Writer.GetDeclRef(D));
+    else {
+      // Store (what we currently believe to be) the key function to avoid
----------------
ChuanqiXu9 wrote:

```suggestion
if (D->isCompleteDefinition() && D->getOwningModule() &&
    D->getOwningModule()->isInterfaceOrPartition())
  Writer.ModularCodegenDecls.push_back(Writer.GetDeclRef(D));

  // Store (what we currently believe to be) the key function to avoid
  // deserializing every method so we can compute it.
  if (D->isCompleteDefinition())
    Record.AddDeclRef(Context.getCurrentKeyFunction(D));
```

Do you mean such changes? I feel it is somewhat overkill since it looks pretty straight forward due to the code is pretty near and the patch itself is about we don't need more key functions in modules.

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


More information about the cfe-commits mailing list