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

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 14 09:30:34 PDT 2018


alexfh requested changes to this revision.
alexfh added inline comments.
This revision now requires changes to proceed.


================
Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:24-25
+                       const CXXRecordDecl *ThisClass) {
+  assert(Parent);
+  assert(ThisClass);
+  if (Parent->getCanonicalDecl() == ThisClass->getCanonicalDecl())
----------------
aaron.ballman wrote:
> You can drop these asserts.
... and make arguments const references ;)


================
Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:44
+
+static std::list<const CXXRecordDecl *>
+GetParentsByGrandParent(const CXXRecordDecl *GrandParent,
----------------
std::list is almost never a good choice due to large overhead, poor locality of the data, etc. Use std::vector instead.


================
Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:53
+            GrandParent,
+            Base.getType()->getAsCXXRecordDecl()->getCanonicalDecl()))
+      result.push_back(
----------------
Pull this to a variable to avoid repetition.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295





More information about the cfe-commits mailing list