[PATCH] D101566: Let -Wweak-template-vtables warn on implicit instantiations

Aaron Puchert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 29 15:44:57 PDT 2021


aaronpuchert added a comment.

In D101566#2726820 <https://reviews.llvm.org/D101566#2726820>, @dblaikie wrote:

> Along time ago Clang had a fairly strong aversion to implementing "off by default" warnings ([...]) because they would tend to go unused and unmaintained.

That was a valid reason, but now there are code bases that work with `-Weverything` and disable the warnings they are not interested in.

> I'm sort of inclined towards this subset of the warning (either the poorly implemented one originally, or this version) being that sort of category, and that it'd be better to delete it.

We have other warnings that are basically just about "cleaner" object files, like `-Wmissing-prototypes` or `-Wmissing-variable-declarations`. (These enforce adding `static` on functions/variables not previously declared. Though together with `-Wunused-{function,variable}` one could find more unused functions/variables, which could be seen as improving code quality.)

> The warning was originally written to ignore implicit template instantiations - and should've ignored explicit instantiations too, I think.

Looking at the warning name I think you're right. There is no way to make the vtables strong. But I don't think anybody cares about this technicality, the warning is there to reduce compile time and object file sizes.

In fact it's probably not so much about emitting the vtable, but about emitting all virtual functions, even if they end up unused. In the template case this also implies instantiation.

> @aaronpuchert - do you have plans to use this warning, if it's implemented/changed in this way?

Let's say that I'm considering it. I'll need to see how often this fires and whether the explicit instantiations make sense to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101566/new/

https://reviews.llvm.org/D101566



More information about the cfe-commits mailing list