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

Piotr Zegar via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 17 12:24:50 PST 2023


PiotrZSL added a comment.

You right swap case can also be invalid (rvalue not needed, there).
Anyway it it has too be script then this can be strict.

But message could be better, for example if we don't move all fields of class, then this could warn that its not fully moved, or that some members are accessed without move., or at least is not moved as whole.
Because not it could be confusing...

  void Class:set(Obj&& obj) // warning: rvalue reference parameter 'obj' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
  {
      this->a = std::move(obj.a);
      this->b = std::move(obj.b);
      this->c = std::move(obj.c);
  }

And then when you read "is never moved" you tap your forehead, about whats going on, you did move everything you wanted.


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