[PATCH] D70390: [clang-tidy] new performance-no-automatic-move check.

Clement Courbet via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 19 00:22:19 PST 2019


courbet reclaimed this revision.
courbet added a comment.

Actually, thinking more about this, adding this to the existing warning might not be a very consensual change. In the case of the warning:

  S<T> f() {
    T&& t = ...;
    ...
    return t;
  }

there is no argument against doing the std::move(): the code is just as clear and has better performance:

  S<T> f() {
    T&& t = ...;
    ...
    return std::move(t);
  }

In the case of a const variable, some people might value the safety from the const above the performance:

  S<T> f() {
    const T t = ...;
    ...  // here be dragons
    return t;
  }

And they would be unhappy if the -Wreturn-std-move started warning about this.

So I think there are two options here:

- Add a new warning, or
- Add it as a clang-tidy as in this change.

What do you think ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70390





More information about the cfe-commits mailing list