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

Aaron Puchert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 30 14:58:01 PDT 2021


aaronpuchert added a comment.

So I tried this in two code bases, both of which don't have `-Wweak-vtables` enabled though.

In the first (~500 TUs) there were a couple of interesting finds. But they are hard to fix, even where explicit instantiations were already there: the corresponding instantiation declarations would require additional includes in the headers because many of the templates are constrained, and concepts don't work well with forward declarations. That's also why we had to disable `-Wundefined-func-templates` there, which is otherwise a useful warning.

In the second code base (~30,000 TUs) it looks a lot more useful. There are many occurrences, but deduplicating and sorting by number of files they occur in finds a couple of templates where explicit instantiation could improve compile times and build sizes. To give some examples, its own standard library has instantiations `basic_ios<char, char_traits<char>>` plus the `wchar_t` equivalent or `basic_ostream<char, char_traits<char>>` and so on coming up in most TUs. Instantiating them explicitly would be natural and likely beneficial.

Overall it's not a warning that I would enable in regular builds, but rather like `-Wweak-vtables` collect the most common occurrences in special runs and do something about them. (The total number of warnings, not deduplicated, runs into the millions for both warnings on the second code base.)


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