This is an archive of the discontinued LLVM Phabricator instance.

Use ExprMutationAnalyzer in performance-for-range-copy
ClosedPublic

Authored by shuaiwang on Jul 2 2018, 3:11 PM.

Details

Summary

This gives better coverage to the check as ExprMutationAnalyzer is more
accurate comparing to isOnlyUsedAsConst.

Majority of wins come from const usage of member field, e.g.:

for (auto widget : container) { // copy of loop variable
  if (widget.type == BUTTON) { // const usage only recognized by ExprMutationAnalyzer
    // ...
  }
}

Event Timeline

shuaiwang created this revision.Jul 2 2018, 3:11 PM
shuaiwang edited the summary of this revision. (Show Details)
JonasToth added inline comments.
test/clang-tidy/performance-for-range-copy.cpp
120

I feel that const methods should be added as a test as well.

hokein accepted this revision.Jul 3 2018, 8:29 AM

LGTM.

This revision is now accepted and ready to land.Jul 3 2018, 8:29 AM
shuaiwang marked an inline comment as done.Jul 10 2018, 2:20 PM
shuaiwang added inline comments.
test/clang-tidy/performance-for-range-copy.cpp
120

const methods are already tested with existing test cases.

This revision was automatically updated to reflect the committed changes.
shuaiwang marked an inline comment as done.