[PATCH] D89332: [clang-tidy] performance-unnecessary-copy-initialization: Always allow std::function to be copied.
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 16 23:27:44 PDT 2020
njames93 added a comment.
How does this type alias and typedef, In theory that should also be handled.
using Functor = std::function<...>;
Functor Copy = Orig; // No warning.
================
Comment at: clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:39-44
+AST_MATCHER(NamedDecl, isStdFunction) {
+ // First use the fast getName() method to avoid unnecessary calls to the
+ // slow getQualifiedNameAsString().
+ return Node.getName() == "function" &&
+ Node.getQualifiedNameAsString() == "std::function";
+}
----------------
It's better to use `node.isInStdNamespace()` instead of checking the qualified name as its designed for that very purpose. Is should probably take a `CXXRecordDecl` instead of a `NamedDecl` aswell.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D89332/new/
https://reviews.llvm.org/D89332
More information about the cfe-commits
mailing list