This is an archive of the discontinued LLVM Phabricator instance.

fix for clang-tidy modernize-pass-by-value on copy constructor
Needs RevisionPublic

Authored by Kessoufi on Apr 16 2016, 8:27 PM.

Details

Reviewers
hokein
alexfh
Summary

disabling the modernize-pass-by-value check on copy constructor as :

  • it outputs bad cpp code when combined with modernize-use-default
  • with only modernize-pass-by-value enabled it triggers a build error

See Bug comments for more details/ example code :
https://llvm.org/bugs/show_bug.cgi?id=27388

Diff Detail

Event Timeline

Kessoufi updated this revision to Diff 53996.Apr 16 2016, 8:27 PM
Kessoufi retitled this revision from to fix for clang-tidy modernize-pass-by-value on copy constructor.
Kessoufi updated this object.
Kessoufi added reviewers: djasper, klimek, alexfh.
alexfh edited reviewers, added: hokein; removed: alexfh, klimek, djasper.Apr 21 2016, 7:55 AM
alexfh added a subscriber: cfe-commits.
alexfh requested changes to this revision.Apr 21 2016, 7:58 AM
alexfh added a reviewer: alexfh.
alexfh added a subscriber: alexfh.
alexfh added inline comments.
clang-tidy/modernize/PassByValueCheck.cpp
166

You should use unless(isCopyConstructor) instead of creating a separate matcher.

This revision now requires changes to proceed.Apr 21 2016, 7:58 AM
Kessoufi updated this revision to Diff 54524.Apr 21 2016, 10:09 AM
Kessoufi edited edge metadata.

removed the redundant matcher

Kessoufi marked an inline comment as done.Apr 21 2016, 10:10 AM

Done

Now the problem is that the check changed behavior, but the tests are not updated. Do the tests still pass? If yes, we need to add tests for this behavior. If no, please fix the tests.

alexfh requested changes to this revision.Apr 21 2016, 10:17 AM
alexfh edited edge metadata.
This revision now requires changes to proceed.Apr 21 2016, 10:17 AM
Kessoufi updated this revision to Diff 54762.Apr 22 2016, 8:57 PM
Kessoufi edited edge metadata.
  • my previous fix was applied on the wrong location and accidentally worked.

now applied on the right location

  • previous tests still pass
  • added a specific test to highlight my issue
alexfh accepted this revision.Apr 25 2016, 10:49 AM
alexfh edited edge metadata.

This test doesn't fail without your fix.

clang-tidy/modernize/PassByValueCheck.cpp
155

This submatcher is much cheaper, so it should go first to make the whole matcher more efficient.

This revision is now accepted and ready to land.Apr 25 2016, 10:49 AM
alexfh requested changes to this revision.Apr 25 2016, 10:49 AM
alexfh edited edge metadata.
This revision now requires changes to proceed.Apr 25 2016, 10:49 AM