[SERVER-73860] Add performance-unnecessary-copy-initialization clang-tidy check Created: 09/Feb/23  Updated: 02/Feb/24

Status: Backlog
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Matt Kneiser Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-73635 Coverity analysis defect 135021: AUTO... Blocked
is depended on by SERVER-73637 Coverity analysis defect 135034: AUTO... Blocked
Assigned Teams:
Build
Sprint: Execution Team 2023-02-20, Execution Team 2023-04-17
Participants:

 Description   

I've noticed several unnecessary copies of objects occurring in our codebase, often from a misunderstanding/misuse of the auto specifier. There's an existing clang-tidy check that we can leverage to cut down on extraneous copies being made.



 Comments   
Comment by Matt Kneiser [ 16/Feb/23 ]

The current version of clang-tidy in the v4 toolchain, v12, is older than the tip of the llvm project, v17.

The tip has many useful and relevant improvements to this checker. Namely:

  • An additional option: ExcludedContainerTypes
  • A fixer

While some copies I found after running this tool made sense, I know that it wasn't perfect and required exclusions like in some tests where the copy constructor was explicitly being invoked.

 

It might make sense to import the latest version of this tool into our custom checkers suite and modify as necessary. I began this path and found that we need better support from SDP to get all the llvm/clang headers lied up correctly so checks can be imported easily.

Generated at Thu Feb 08 06:25:50 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.