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

Eugene Zelenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 9 10:15:16 PST 2018


Eugene.Zelenko added inline comments.


================
Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:26
+
+bool IsParentOf(const CXXRecordDecl *Parent, const CXXRecordDecl *ThisClass) {
+  assert(Parent);
----------------
Please make this function static and remove anonymous namespace.


================
Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:40
+
+bool IsRecursiveParentOf(const CXXRecordDecl *Parent,
+                         const CXXRecordDecl *ThisClass) {
----------------
Please make this function static and remove anonymous namespace.


================
Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:48
+std::list<const CXXRecordDecl *>
+GetParentsByGrandParent(const CXXRecordDecl *GrandParent,
+                        const CXXRecordDecl *ThisClass) {
----------------
Please make this function static and remove anonymous namespace.


================
Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:66
+// PrintingPolicy for anonymous namespaces.
+std::string GetNameAsString(const NamedDecl &Decl) {
+  PrintingPolicy PP(Decl.getASTContext().getPrintingPolicy());
----------------
Please make this function static and remove anonymous namespace.


================
Comment at: clang-tidy/bugprone/ParentVirtualCallCheck.cpp:91
+void ParentVirtualCallCheck::check(const MatchFinder::MatchResult &Result) {
+
+  const auto *MatchedDecl = Result.Nodes.getNodeAs<CXXMemberCallExpr>("call");
----------------
Please remove this line.


================
Comment at: docs/ReleaseNotes.rst:76
+
+  Warns if one calls grand-..parent's virtual method in child's virtual
+  method instead of parent's. Can automatically fix such cases by retargeting
----------------
Please make description here and first statement in documentation same.


================
Comment at: docs/clang-tidy/checks/bugprone-parent-virtual-call.rst:9
+
+class A {
+...
----------------
Please add .. code-block:: c++


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295





More information about the cfe-commits mailing list