This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Add make_unique_for_overwrite/make_shared_for_overwrite check.
Needs ReviewPublic

Authored by ckennelly on Dec 9 2020, 7:12 PM.

Details

Summary

std::make_unique_for_overwrite and std::make_shared_for_overwrite were
introduced in C++20.

These default initialize the values, unlike std::make_unique /
std::make_shared, which value initialize. The latter can cause
unexpected performance regressions when trivial types (such as int) are
subsequently value initialized.

Diff Detail

Event Timeline

ckennelly created this revision.Dec 9 2020, 7:12 PM
ckennelly requested review of this revision.Dec 9 2020, 7:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2020, 7:12 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Eugene.Zelenko added inline comments.
clang-tools-extra/docs/ReleaseNotes.rst
143

Please keep alphabetical order.

146

Please use double back-ticks to highlight language constructs. Same below.

clang-tools-extra/docs/clang-tidy/checks/modernize-make-shared-for-overwrite.rst
6

Please make same as entry in Release Notes.

clang-tools-extra/docs/clang-tidy/checks/modernize-make-unique-for-overwrite.rst
6

Please make same as entry in Release Notes.

Eugene.Zelenko added a project: Restricted Project.Dec 9 2020, 9:48 PM

I'm definitely of the opinion this should be an option in the modernize-make-(shared|unique) check