aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/FileCheck/FileCheck.cpp
diff options
context:
space:
mode:
authorDevon Loehr <DKLoehr@users.noreply.github.com>2025-03-17 10:07:31 -0400
committerGitHub <noreply@github.com>2025-03-17 15:07:31 +0100
commit2ff370f45266b14c2a86e6395042a4574701f2d2 (patch)
tree2920134238745627b6e18d34479d510bffedc33e /llvm/lib/FileCheck/FileCheck.cpp
parent1c3a9a853ce68c3c539e7cab21380b9d8b18f426 (diff)
downloadllvm-2ff370f45266b14c2a86e6395042a4574701f2d2.zip
llvm-2ff370f45266b14c2a86e6395042a4574701f2d2.tar.gz
llvm-2ff370f45266b14c2a86e6395042a4574701f2d2.tar.bz2
Warn about virtual methods in `final` classes (#131188)
There's never any point to adding a `virtual` specifier to methods in a `final` class, since the class can't be subclassed. This adds a warning when we notice this happening, as suggested in #131108. We don't currently implement the second part of the suggestion, to warn on `virtual` methods which are never overridden anywhere. Although it's feasible to do this for things with internal linkage (so we can check at the end of the TU), it's more complicated to implement and it's not clear it's worth the effort. I tested the warning by compiling chromium and clang itself. Chromium resulted in [277 warnings across 109 files](https://github.com/user-attachments/files/19234889/warnings-chromium.txt), while clang had [38 warnings across 29 files](https://github.com/user-attachments/files/19234888/warnings-clang.txt). I inspected a subset of the warning sites manually, and they all seemed legitimate. This warning is very easy to fix (just remove the `virtual` specifier) and I haven't seen any false positives, so it's suitable for on-by-default. However, I've currently made it off-by-default because it fires at several places in the repo. I plan to submit a followup PR fixing those places and enabling the warning by default.
Diffstat (limited to 'llvm/lib/FileCheck/FileCheck.cpp')
0 files changed, 0 insertions, 0 deletions