================
@@ -19108,8 +19118,23 @@ bool Sema::DefineUsedVTables() {
}
}
- if (IsExplicitInstantiationDeclaration)
+ if (IsExplicitInstantiationDeclaration) {
DefineVTable = false;
+
+ // Ensure the instance of a virtual member function which is declared
+ // with `__attribute__((exclude_from_explicit_instantiation))` is
+ // accessible from the VTable.
+ for (Decl *decl : Class->decls()) {
+ auto *Method = dyn_cast<CXXMethodDecl>(decl);
+ if (!Method || !Method->isVirtual())
+ continue;
+
+ if (Method->hasAttr<ExcludeFromExplicitInstantiationAttr>()) {
+ MarkFunctionReferenced(Loc, Method);
+ DefinedAnything = true;
+ }
+ }
----------------
kikairoya wrote:
I wasn't sure if `Consumer.HandleVTable(Class);` below should be called in this
case; that was not called previously. However, since the VTable is actually
emitted, it might need to be called.
Surprisingly, setting `DefineVTable = true` regardless
`IsExplicitInstantiationDeclaration` doesn't break any tests.
The current construction was introduced in 88d292ccb86c108, but the commit
doesn't mention MSVC ABI.
How do I check "correct" behavior?
https://github.com/llvm/llvm-project/pull/168171
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits