diff options
author | Zinovy Nis <zinovy.nis@gmail.com> | 2018-04-06 20:02:50 +0000 |
---|---|---|
committer | Zinovy Nis <zinovy.nis@gmail.com> | 2018-04-06 20:02:50 +0000 |
commit | 95ea1b05fdacc4148e790dc1c30042818fe3638b (patch) | |
tree | 9ba529d296e295e637807b339510b827dd52d6fa /clang-tools-extra/docs | |
parent | c884b7187cd84bc0940487ebe320bc76a9902f4e (diff) | |
download | bcm5719-llvm-95ea1b05fdacc4148e790dc1c30042818fe3638b.tar.gz bcm5719-llvm-95ea1b05fdacc4148e790dc1c30042818fe3638b.zip |
[clang-tidy] Check if grand-..parent's virtual method was called instead of overridden parent's.
class A {...int virtual foo() {...}...};
class B: public A {...int foo() override {...}...};
class C: public B {...int foo() override {... A::foo()...}};
^^^^^^^^ warning: qualified name A::foo refers to a member overridden in subclass; did you mean 'B'? [bugprone-parent-virtual-call]
Differential Revision: https://reviews.llvm.org/D44295
llvm-svn: 329448
Diffstat (limited to 'clang-tools-extra/docs')
-rw-r--r-- | clang-tools-extra/docs/ReleaseNotes.rst | 6 | ||||
-rwxr-xr-x | clang-tools-extra/docs/clang-tidy/checks/bugprone-parent-virtual-call.rst | 23 | ||||
-rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/list.rst | 1 |
3 files changed, 30 insertions, 0 deletions
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 49ab862a7d9..82214ab66cc 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -64,6 +64,12 @@ Improvements to clang-tidy - New module ``zircon`` for checks related to Fuchsia's Zircon kernel. +- New :doc:`bugprone-parent-virtual-call + <clang-tidy/checks/bugprone-parent-virtual-call>` check + + Detects and fixes calls to grand-...parent virtual methods instead of calls + to overridden parent's virtual methods. + - New :doc:`bugprone-throw-keyword-missing <clang-tidy/checks/bugprone-throw-keyword-missing>` check diff --git a/clang-tools-extra/docs/clang-tidy/checks/bugprone-parent-virtual-call.rst b/clang-tools-extra/docs/clang-tidy/checks/bugprone-parent-virtual-call.rst new file mode 100755 index 00000000000..e1021b1888c --- /dev/null +++ b/clang-tools-extra/docs/clang-tidy/checks/bugprone-parent-virtual-call.rst @@ -0,0 +1,23 @@ +.. title:: clang-tidy - bugprone-parent-virtual-call + +bugprone-parent-virtual-call +============================ + +Detects and fixes calls to grand-...parent virtual methods instead of calls +to overridden parent's virtual methods. + +.. code-block:: c++ + + class A { + int virtual foo() {...} + }; + + class B: public A { + int foo() override {...} + }; + + class C: public B { + int foo() override { A::foo(); } + // ^^^^^^^^ + // warning: qualified name A::foo refers to a member overridden in subclass; did you mean 'B'? [bugprone-parent-virtual-call] + }; diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index 1551d36754f..f639618d9e8 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -36,6 +36,7 @@ Clang-Tidy Checks bugprone-misplaced-widening-cast bugprone-move-forwarding-reference bugprone-multiple-statement-macro + bugprone-parent-virtual-call bugprone-sizeof-container bugprone-sizeof-expression bugprone-string-constructor |