This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Better custom class support for performance-inefficient-vector-operation
Needs ReviewPublic

Authored by njames93 on Feb 16 2020, 3:49 AM.

Details

Summary

Adds options to the check for customising the vector like classes the check will work on and the range-for types supported. Enables you to specify classes with methods that aren't named `push_back, emplace_back, reserve and size`

Diff Detail

Event Timeline

njames93 created this revision.Feb 16 2020, 3:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 16 2020, 3:49 AM
njames93 edited the summary of this revision. (Show Details)Feb 16 2020, 3:52 AM
njames93 added a project: Restricted Project.
njames93 updated this revision to Diff 244867.Feb 16 2020, 4:14 AM
  • New line and undo clang format artefact
njames93 updated this revision to Diff 244939.Feb 17 2020, 4:08 AM
  • Added check if size() method is const for range loops
  • Optimised FixItHint creation
njames93 updated this revision to Diff 244952.Feb 17 2020, 5:42 AM
  • Moved const size method check to matcher

Thanks for the patch. May I know the motivation of this patch? Personally, I'd be conservative of exposing too many options.

Thanks for the patch. May I know the motivation of this patch? Personally, I'd be conservative of exposing too many options.

I was using custom classes with a different naming convention which was not being picked up by this check. Right now this check is only good for classes that mimick the stl conventions.

njames93 updated this revision to Diff 245115.Feb 18 2020, 2:46 AM
  • Added support for converting loops over c style arrays
njames93 updated this revision to Diff 245116.Feb 18 2020, 2:55 AM
  • Small nit
njames93 updated this revision to Diff 245240.Feb 18 2020, 1:02 PM
  • Better template support
  • Removed excess code
  • Refactor alot of the check