[PATCH] D18961: Add a readability-deleted-default clang-tidy check.
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 11 16:46:54 PDT 2016
alexfh added inline comments.
================
Comment at: clang-tidy/readability/DeletedDefaultCheck.cpp:28
@@ +27,3 @@
+ // - actually deleted
+ // - not in template instantiation.
+ const auto isBadlyDefaulted =
----------------
For decls there is `isInstantiated()`, which is defined as:
auto IsInstantiation = decl(anyOf(cxxRecordDecl(isTemplateInstantiation()),
functionDecl(isTemplateInstantiation())));
return decl(anyOf(IsInstantiation, hasAncestor(IsInstantiation)));
and should be just what you need.
================
Comment at: clang-tidy/readability/DeletedDefaultCheck.cpp:35
@@ +34,3 @@
+ this);
+ Finder->addMatcher(cxxMethodDecl(anyOf(isCopyAssignmentOperator(),
+ isMoveAssignmentOperator()),
----------------
It's not overly important, but you can further reduce the code by folding the first matcher into the second one (move `cxxConstructorDecl()` inside `anyOf` here, since `CXXConstructorDecl` is a `CXXMethodDecl`). You can also use just a single id to bind the node and distinguish the constructor using `dyn_cast`. Then you'll be able to use a single `diag()` call below and remove the unneeded variables `Message` and `isBadlyDefaulted`.
http://reviews.llvm.org/D18961
More information about the cfe-commits
mailing list