================
@@ -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;
+ }
+ }
----------------
zmodem wrote:
Hmm. I guess I'm confused by the contradiction of setting "DefineVTable =
false" and then "ensure ... is accessible from the vtable".
The problem seems to be that some parts of the code tries to suppress vtable
emission, while a different part emits it.
Would it work if we don't do the `DefineVTable = false` part, i.e. just changed
the the `if (IsExplicitInstantiationDeclaration)` to something like `if
(IsExplicitInstantiationDeclaration &&
!HasExcludeFromExplicitInstantiationAttr)`?
https://github.com/llvm/llvm-project/pull/168171
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits