This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix false positive in modernize-pass-by-value
ClosedPublic

Authored by courbet on Jan 3 2022, 5:46 AM.

Details

Summary

The check should not trigger on lvalue/rvalue overload pairs:

struct S {
  S(const A& a) : a(a) {}
  S(A&& a) : a(std::move(a)) {}

  A a;
}

Diff Detail

Event Timeline

courbet created this revision.Jan 3 2022, 5:46 AM
courbet requested review of this revision.Jan 3 2022, 5:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2022, 5:46 AM
flx accepted this revision.Jan 4 2022, 7:01 AM
flx added inline comments.
clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
108

if

160

A comment why we have to have a different check for when the params are not at ParamIdx would be helpful.

This revision is now accepted and ready to land.Jan 4 2022, 7:01 AM
courbet marked 2 inline comments as done.Jan 5 2022, 5:25 AM

Thanks.

courbet updated this revision to Diff 397543.Jan 5 2022, 5:25 AM

Address review comments.

This revision was landed with ongoing or failed builds.Jan 5 2022, 5:34 AM
This revision was automatically updated to reflect the committed changes.