[all-commits] [llvm/llvm-project] a7f8ae: [clang-tidy] Fix wrong FixIt in performance-move-c...

Liu Ke via All-commits all-commits at lists.llvm.org
Thu Jan 20 22:31:11 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a7f8aea71485c00db2ffb6288ae58475869048b1
      https://github.com/llvm/llvm-project/commit/a7f8aea71485c00db2ffb6288ae58475869048b1
  Author: Sockke <liuke.gehry at bytedance.com>
  Date:   2022-01-21 (Fri, 21 Jan 2022)

  Changed paths:
    M clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
    M clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp

  Log Message:
  -----------
  [clang-tidy] Fix wrong FixIt in performance-move-const-arg

There are incorrect Fixit and missing warnings:
case :
A trivially-copyable object wrapped by std::move is passed to the function with rvalue reference parameters. Removing std::move will cause compilation errors.
```
void showInt(int&&) {}
void testInt() {
    int a = 10;
    // expect: warning + nofix
    showInt(std::move(a));  // showInt(a) <--- wrong fix
}

struct Tmp {};
void showTmp(Tmp&&) {}
void testTmp() {
    Tmp t;
    // expect: warning + nofix
    showTmp(std::move(t));  // showTmp(t) <--- wrong fix
}
```

Reviewed By: aaron.ballman, Quuxplusone

Differential Revision: https://reviews.llvm.org/D107450




More information about the All-commits mailing list