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

Malcolm Parsons via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 9 10:56:46 PST 2018

malcolm.parsons added inline comments.

Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:152
+        Member->getQualifierLoc().getSourceRange(),
+        GetNameAsString(*(Parents.front())) + "::");
+  }
zinovy.nis wrote:
> malcolm.parsons wrote:
> > What does this do for templated parent classes?
> Please see my last test case in updated revision.
Also, a templated parent class of a templated class.
template <class T>
class DF : public BF<T> {
  int virt_1() override { return A::virt_1(); }
  // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: 'A::virt_1' is a grand-parent's method, not parent's. Did you mean 'BF<T>'?
  // CHECK-FIXES:  int virt_1() override { return BF<T>::virt_1(); }

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list