[PATCH] D147924: [clang-tidy] Exclude template instantiations in modernize-use-override

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 10 05:23:39 PDT 2023


PiotrZSL added a comment.

Problem is that you may have specialization of Bar class wihtout bar base, and that specialization can be local to some compilation unit.
Like:

  template<>
  struct Bar<int> {
      void bar(); // function wihout virtual or no function at all.
  };

And now your fix (override) won't compile.

In D147924#4255151 <https://reviews.llvm.org/D147924#4255151>, @njames93 wrote:

> template<typename T>
> struct Bar {
>
>   virtual void bar();
>
> };
>
> template <typename T>
> struct TemplateBase : Bar<T> {
>
>   virtual void bar();
>
> };
>
> TemplateBase<int> Y; // This instantiation should warn about the above declaration.
>
>   // Or potentially configurable to either warn or ignore this case.
>
>   

Only configuration option possible to be done, is to check template instantiations or not, but this going to produce false-positives.
And probably we don't want false-positives in this check.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147924



More information about the cfe-commits mailing list