This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const "this" object argument if it is not modified
ClosedPublic

Authored by flx on May 5 2016, 7:22 PM.

Details

Summary

Also trigger the check in the following case:

void foo() {

ExpensiveToCopy Obj;
const auto UnnecessaryCopy = Obj.constReference();
Obj.onlyUsedAsConst();

}

i.e. when the object the method is called on is not const but is never modified.

Diff Detail

Repository
rL LLVM

Event Timeline

flx updated this revision to Diff 56379.May 5 2016, 7:22 PM
flx retitled this revision from to [clang-tidy] UnnecessaryCopyInitialization - Extend to trigger on non-const "this" object argument if it is not modified .
flx updated this object.
flx set the repository for this revision to rL LLVM.
flx added reviewers: alexfh, fowles.
flx added a subscriber: cfe-commits.
alexfh requested changes to this revision.May 11 2016, 10:43 AM
alexfh edited edge metadata.

How many more (in relative numbers) results does this check generate now?

clang-tidy/performance/UnnecessaryCopyInitialization.cpp
45 ↗(On Diff #56379)

Please enclose inline code snippets in backquotes (this, check(), etc.).

test/clang-tidy/performance-unnecessary-copy-initialization.cpp
133 ↗(On Diff #56379)

Please include dynamic parts of the message to the CHECK lines (in this case - the variable name).

This revision now requires changes to proceed.May 11 2016, 10:43 AM
flx updated this revision to Diff 58181.May 23 2016, 6:49 PM
flx edited edge metadata.
flx removed rL LLVM as the repository for this revision.
flx marked an inline comment as done.

How many more (in relative numbers) results does this check generate now?

147% more :)

fowles edited edge metadata.May 24 2016, 6:48 AM

LGTM, but I will wait for people who know this stuff better to sign off

flx added a comment.May 26 2016, 7:38 AM

Friendly ping.

alexfh accepted this revision.May 27 2016, 7:04 AM
alexfh edited edge metadata.

LG

This revision is now accepted and ready to land.May 27 2016, 7:04 AM
This revision was automatically updated to reflect the committed changes.