================
@@ -1180,6 +1185,21 @@ bool CodeGenVTables::isVTableExternal(const 
CXXRecordDecl *RD) {
       TSK == TSK_ExplicitInstantiationDefinition)
     return false;
 
+  // Itanium C++ ABI [5.2.3]:
+  // Virtual tables for dynamic classes are emitted as follows:
+  //
+  // - If the class is templated, the tables are emitted in every object that
+  // references any of them.
+  // - Otherwise, if the class is attached to a module, the tables are uniquely
+  // emitted in the object for the module unit in which it is defined.
+  // - Otherwise, if the class has a key function (see below), the tables are
+  // emitted in the object for the translation unit containing the definition 
of
+  // the key function. This is unique if the key function is not inline.
+  // - Otherwise, the tables are emitted in every object that references any of
+  // them.
+  if (Module *M = RD->getOwningModule(); M && M->isNamedModule())
----------------
ChuanqiXu9 wrote:

> hasExternalDefinitions isn't "is this AST from some other AST file" but "did 
> the AST file say it'd handle the object-file definition of this thing" - the 
> pcm file specifies which things it'll handle.
> So if the intent is not to home anything in the GMF, then pcms could be 
> written out that don't set "hasExternalDefinitions" to true for those 
> entities.

No, it is not the intent. The intent is to keep GMF as legacy code instead of 
named modules.

For example,

```
// header.h
void func() { } // ! Non inline

// x.cppm
module;
#include "header.h"
export module x;
...
```

Then in the object file of `x.cppm`, (if `func()` is not discarded out), we 
should be able to see the definition of `func()`. Although it is rare since the 
definitions in the headers are generally inline, but we as the compiler can't 
assume that.

I think the current implementation is more straight forward and clear.

https://github.com/llvm/llvm-project/pull/75912
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to