[PATCH] D70390: [clang-tidy] new performance-no-automatic-move check.
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 20 16:07:17 PST 2019
JonasToth added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/performance/NoAutomaticMoveCheck.cpp:28
+void NoAutomaticMoveCheck::registerMatchers(MatchFinder *finder) {
+ const auto const_local_variable =
+ varDecl(hasLocalStorage(), unless(hasType(lValueReferenceType())),
----------------
the matchers need only to be registered for c++ and and c++11 and later. See `getLangOpts()` in other checks.
================
Comment at: clang-tools-extra/clang-tidy/performance/NoAutomaticMoveCheck.cpp:59
+ const QualType var_type = vardecl->getType();
+ if (var_type.isConstQualified()) {
+ diag(ctor_call->getExprLoc(), "constness of '%0' prevents automatic move")
----------------
i think `isConstQualified` could move into the matcher with `Matcher<QualType> isConstQualified`.
================
Comment at: clang-tools-extra/docs/clang-tidy/checks/performance-no-automatic-move.rst:11
+local values are automatically moved out when returning from a function. A
+common mistake is to declared local ``lvalue`` variables ``const``, which
+prevents the move.
----------------
s/declared/declare
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70390/new/
https://reviews.llvm.org/D70390
More information about the cfe-commits
mailing list