[PATCH] D44295: [clang-tidy] Detects and fixes calls to grand-...parent virtual methods instead of calls to parent's virtual methods

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 16 05:43:12 PDT 2018

aaron.ballman added inline comments.

Comment at: test/clang-tidy/bugprone-parent-virtual-call.cpp:105
+// Test virtual method is diagnosted although not overridden in parent.
+class BI : public A {
Typo: diagnosted -> diagnosed

Comment at: test/clang-tidy/bugprone-parent-virtual-call.cpp:113
+  int virt_1() override { return A::virt_1(); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: qualified function name A::virt_1 refers to a function not from a direct base class; did you mean 'BI'? [bugprone-parent-virtual-call]
+  // CHECK-FIXES:  int virt_1() override { return BI::virt_1(); }
This seems like a false positive to me. Yes, the virtual function is technically exposed in `BI`, but why is the programmer obligated to call that one rather than the one from `A`, which is written in the source?

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list