[clang-tools-extra] [clang-tidy] Add check performance-lost-std-move (PR #139525)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 11 06:25:39 PST 2025


vbvictor wrote:

Did you try running this check on some codebases? The easiest way is to run it on `clang-tidy` itself. E.g.
```
python3 clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -p build/ -checks="-*,performance-lost-std-move" -clang-tidy-binary build/bin/clang-tidy -quiet -hide-progress clang-tools-extra/clang-tidy/
```

I found such case:
```
/home/victor/llvm2/llvm-project/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp:32:25: warning: could be std::move() [performance-lost-std-move]
   32 |               std::move(CallArgs)](const MatchFinder::MatchResult &Result)
      |                         ^~~~~~~~
      |                         std::move(CallArgs)
/home/victor/llvm2/llvm-project/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:82:21: warning: could be std::move() [performance-lost-std-move]
   82 |   setRule(std::move(R));
      |                     ^
      |                     std::move(R)
```

The check doesn't consider already `std::move` variables?

Also, there are many "false positives" where the check suggest to use `std::move` when passing variable as function parameter, but function only accept `const&` and https://clang.llvm.org/extra/clang-tidy/checks/performance/move-const-arg.html start giving warning. I think we should avoid these false positive also. 

https://github.com/llvm/llvm-project/pull/139525


More information about the cfe-commits mailing list