[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

Oliver Stöneberg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 10 12:15:02 PST 2022


firewave added a comment.

Another false positive:

  #include <unordered_map>
  
  void evaluateLibraryFunction()
  {
  	std::unordered_map<int, const void*> m;
  
  	auto f = [m]() {};
  }



  input.cpp:7:12: warning: Parameter 'm' is copied on last use, consider moving it instead. [performance-unnecessary-copy-on-last-use]
          auto f = [m]() {};
                    ^
                    std::move( )

This is suggested regardless of the C++ standard defined (unfortunately I didn't get a `-Wc++14-extensions` warning out of clang-tidy).

Also the fix-it will result in invalid code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205



More information about the cfe-commits mailing list