[all-commits] [llvm/llvm-project] e51f46: [clang-tidy] ignore NRVO const variables in perfor...

gnanabit via All-commits all-commits at lists.llvm.org
Mon Apr 3 10:03:09 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e51f46705e2876fbbdb59d4f1ba43fa6ecf78611
      https://github.com/llvm/llvm-project/commit/e51f46705e2876fbbdb59d4f1ba43fa6ecf78611
  Author: Logan Gnanapragasam <gnanabit at google.com>
  Date:   2023-04-03 (Mon, 03 Apr 2023)

  Changed paths:
    M clang-tools-extra/clang-tidy/performance/NoAutomaticMoveCheck.cpp
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/test/clang-tidy/checkers/performance/no-automatic-move.cpp

  Log Message:
  -----------
  [clang-tidy] ignore NRVO const variables in performance-no-automatic-move.

In the following code:

```cc
struct Obj {
  Obj();
  Obj(const Obj &);
  Obj(Obj &&);
  virtual ~Obj();
};

Obj ConstNrvo() {
  const Obj obj;
  return obj;
}
```

performance-no-automatic-move warns about the constness of `obj`. However, NRVO
is applied to `obj`, so the `const` should have no effect on performance.

This change modifies the matcher to exclude NRVO variables.

#clang-tidy

Reviewed By: courbet, PiotrZSL

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




More information about the All-commits mailing list