[clang] Reland [C++20] [Modules] [Itanium ABI] Generate the vtable in the mod… (PR #102287)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 7 20:15:14 PDT 2024


================
@@ -5317,6 +5329,17 @@ void ASTWriter::WriteSpecialDeclRecords(Sema &SemaRef) {
   }
   if (!DeleteExprsToAnalyze.empty())
     Stream.EmitRecord(DELETE_EXPRS_TO_ANALYZE, DeleteExprsToAnalyze);
+
+  RecordData VTablesToEmit;
+  for (CXXRecordDecl *RD : PendingEmittingVTables) {
+    if (!wasDeclEmitted(RD))
+      continue;
----------------
ChuanqiXu9 wrote:

We may not be able to do that simply. The current workflow is:

> ParseAST -> WriteAST -> EmitVTables

The values of PendingEmittingVTables are inserted in `ParseAST` phase. And in `WriteAST` phase, we won't write every thing in the AST. The ASTWriter will only write the thing registered in `PrepareWritingSpecialDecls()` and the things reached during the writing process. This is the meaning of `wasDeclEmitted`.

So when we insert the values, we can't know what values are going to be wrote or not. We can only check this after writing the AST (now).

I didn't change the name to `MaybePendingEmittingVTables` since the pattern is pretty common to almost all the records in ASTWriter. I feel it is somewhat inconsistent to rename `PendingEmittingVTables` only.


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


More information about the cfe-commits mailing list