[clang] [Clang] Apply exclude_from_explicit_instantiation to dllimport/dllexport (PR #168171)
Tomohiro Kashiwada via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 21 04:34:25 PST 2026
================
@@ -19109,7 +19119,17 @@ bool Sema::DefineUsedVTables() {
}
}
- if (IsExplicitInstantiationDeclaration)
+ if (IsExplicitInstantiationDeclaration &&
+ llvm::none_of(Class->decls(), [](Decl *decl) {
+ // If the class has a virtual member function declared with
+ // `__attribute__((exclude_from_explicit_instantiation))`, the
+ // explicit instantiation declaration shouldn't suppress emitting
+ // the vtable to ensure that the excluded member function is
+ // accessible through the vtable.
+ auto *Method = dyn_cast<CXXMethodDecl>(decl);
+ return Method && Method->isVirtual() &&
+ Method->hasAttr<ExcludeFromExplicitInstantiationAttr>();
+ }))
----------------
kikairoya wrote:
I think I understand now -- I was thinking only about explicit instantiation _declarations_, but I should also consider the interaction with explicit instantiation _definitions_.
Thank you for your detailed and patient guidance.
https://github.com/llvm/llvm-project/pull/168171
More information about the cfe-commits
mailing list