[PATCH] D20170: [clang-tidy] TypeTraits - Type is not expensive to copy when it has a deleted copy constructor.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed May 11 08:18:05 PDT 2016
aaron.ballman added a subscriber: aaron.ballman.
================
Comment at: clang-tidy/utils/TypeTraits.cpp:20
@@ -18,1 +19,3 @@
+using namespace ::clang::ast_matchers;
+
----------------
I would prefer this be used locally instead of at namespace scope to avoid potential name collisions.
================
Comment at: clang-tidy/utils/TypeTraits.cpp:32
@@ +31,3 @@
+ auto *Record = Type->getAsCXXRecordDecl();
+ if (Record == nullptr || !Record->hasDefinition())
+ return false;
----------------
`!Record` instead of explicit comparison.
================
Comment at: clang-tidy/utils/TypeTraits.cpp:34
@@ +33,3 @@
+ return false;
+ auto Matches = match(cxxRecordDecl(hasMethod(
+ cxxConstructorDecl(isCopyConstructor(), isDeleted())
----------------
Why use the matcher at all? You have the record decl, it can give you the copy constructor, and you can directly inspect whether that is deleted or not.
================
Comment at: test/clang-tidy/performance-unnecessary-value-param.cpp:27
@@ +26,3 @@
+struct MoveOnlyType {
+ MoveOnlyType(const MoveOnlyType&) = delete;
+ ~MoveOnlyType();
----------------
This is not a move-only type. Because you have a user-declared copy constructor (or destructor), the move constructor will not be implicitly declared. See [class.copy]p9 for details.
Repository:
rL LLVM
http://reviews.llvm.org/D20170
More information about the cfe-commits
mailing list