[PATCH] D147924: [clang-tidy] Exclude template instantiations in modernize-use-override
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 10 06:08:32 PDT 2023
njames93 added a comment.
In D147924#4255209 <https://reviews.llvm.org/D147924#4255209>, @PiotrZSL wrote:
> 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.
>
> 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.
My idea was to not check any template instantiations, instead look for template definitions with a template dependent base class that has potential override candidates.
I'd argue a (likely very rare) false positive that would prevent compilation is better than not diagnosing and then potentially(due to a later refactor) getting a near miss override candidate going undiagnosed and breaking the codebase.
It could also be nicer to just emit a warning with no fix, or a fix added to a note explaining the situation. (notes fixes aren't automatically applied when running clang tidy(and clang) for this reason.
Given the contention that is why i suggested this should just be user configurable.
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