================
@@ -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>();
+ }))
----------------
zmodem wrote:
As a style issue, I think it would be easier to read if we put this in a
variable, like:
```
bool HasExcludeFromExplicitInstantiation = llvm::any_of(...
hasAttr<ExcludeFromExlicitInstantiationAttr>() ...
```
Also, I'm not sure that it matters whether the method with the attribute is
virtual or not. I think it would be enough to check that *any* method has the
attribute -- because then the motivation about "suppress the vtable; it will
live with the explicit instantiation definition" may not hold.
https://github.com/llvm/llvm-project/pull/168171
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits