[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

Chris Cotter via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 20 09:02:25 PST 2023


ccotter added inline comments.


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp:301
+  }
+  void never_moves(T&& t) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: rvalue reference parameter 't' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
----------------
PiotrZSL wrote:
> that's not always rvalue, if T would be for example int&, then this going to be lvalue...
Looking at the rule enforcement, I might have overlooked one thing:

 > Flag all X&& parameters (where X is not a template type parameter name) where the function body uses them without std::move.

I think this means this code should not be flagged, even if `T` is an object which is cheap to move but expensive to copy (and not a reference to that type). I would like for `AClassTemplate<LargeObject>` to be flagged, but not `AClassTemplate<LargeObject&>`, so let me look into this to see if I can limit this to instantiations of the type, rather than looking at the template definition itself.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569



More information about the cfe-commits mailing list