[PATCH] D107450: [clang-tidy] Fix wrong and missing warnings in performance-move-const-arg

Whisperity via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 5 06:44:42 PDT 2021


whisperity added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp:51
+          hasReturnValue(anyOf(
+              ignoringImplicit(ignoringParenCasts(MoveCallMatcher)),
+              cxxConstructExpr(hasDeclaration(cxxConstructorDecl(allOf(
----------------
I am not sure if `ignoringImplicit(ignoringParenCasts(_))` is the same as `ignoringParenImpCasts(_)`, but I've seen the latter one appear many times in other matchers.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:261
+  showInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: std::move of the variable 'a' of the trivially-copyable type 'int' has no effect; remove std::move()
+  return std::move(a);
----------------
MTC wrote:
> Quuxplusone wrote:
> > This warning is incorrect, as indicated in your PR summary. Isn't the point of this PR mainly to remove this incorrect warning?
> I guess what @Sockke wants to express is that applying `std::move` on the integer type makes no sense.
Yes, but there is no //FixIt// for this warning, but even if the user fixes this //manually// according to the warning, it'll result in

> error: cannot bind rvalue reference of type `int&&` to lvalue of type `int`

because `showInt` takes `int&&`!

So this is not just unfixable automatically (hence no `CHECK-FIXES` line), it isn't fixable at all.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107450/new/

https://reviews.llvm.org/D107450



More information about the cfe-commits mailing list