[clang] [clang-repl] fix vtable symbol duplication error (closes #141039) (PR #185648)

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 31 06:29:39 PDT 2026


================
@@ -1300,11 +1301,18 @@ void CodeGenModule::EmitDeferredVTables() {
   size_t savedSize = DeferredVTables.size();
 #endif
 
-  for (const CXXRecordDecl *RD : DeferredVTables)
+  for (const CXXRecordDecl *RD : DeferredVTables) {
+    // if a table has been emitted in an earlier PTU, but was also marked
+    // deferred, we should skip if the linkage is external
+    if (EmittedVTables.count(RD) &&
+        getVTableLinkage(RD) == llvm::GlobalValue::ExternalLinkage)
----------------
vgvassilev wrote:

This is exactly what I was after. Thank you for the explanation.

We have two options:
  * Perhaps the most minimal change would be to remove from the list of DeferredVTables the strong symbols
  * Keep a the current patch.

@efriedma-quic, can you help me with deciding on this part?

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


More information about the cfe-commits mailing list