Page MenuHomePhabricator

[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

Unit TestsFailed

TimeTest
80 msx64 windows > LLVM.CodeGen/XCore::threads.ll
Script: -- : 'RUN: at line 1'; c:\ws\w1\llvm-project\premerge-checks\build\bin\llc.exe -march=xcore < C:\ws\w1\llvm-project\premerge-checks\llvm\test\CodeGen\XCore\threads.ll | c:\ws\w1\llvm-project\premerge-checks\build\bin\filecheck.exe C:\ws\w1\llvm-project\premerge-checks\llvm\test\CodeGen\XCore\threads.ll

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