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

Chris Cotter via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 13 04:51:22 PST 2023


ccotter added a comment.

> What happens with code like this
>
>   void foo(bar&& B) {
>     std::move(B);
>   }

My new check does not flag this function, although it looks like another check flagged the move expression: `ignoring return value of function declared with const attribute [clang-diagnostic-unused-value]`. Guideline F.18 only says to flag functions where "the function body uses them without std::move." I think this could be improved with something like "the function body does not move construct or move assign the parameter, and does not pass the result of move() to another function which accepts rvalue references". I can open an issue on the CppCoreGuidelines repo to discuss this. On a related note, I believe there's another clang-tidy check that flags `move` on const values, so I could see clang-tidy similarly checking other "nonsense" move expressions such as this one (separate check).


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