[all-commits] [llvm/llvm-project] 8d2c09: [clang-tidy] Omit std::make_unique/make_shared for...

Chris Kennelly via All-commits all-commits at lists.llvm.org
Tue Dec 8 07:38:44 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 8d2c095e5a6bd34f8bb5cffd5c57c8deea5b8647
      https://github.com/llvm/llvm-project/commit/8d2c095e5a6bd34f8bb5cffd5c57c8deea5b8647
  Author: Chris Kennelly <ckennelly at ckennelly.com>
  Date:   2020-12-08 (Tue, 08 Dec 2020)

  Changed paths:
    M clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
    M clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
    M clang-tools-extra/docs/clang-tidy/checks/modernize-make-shared.rst
    M clang-tools-extra/docs/clang-tidy/checks/modernize-make-unique.rst
    M clang-tools-extra/test/clang-tidy/checkers/modernize-make-shared.cpp
    A clang-tools-extra/test/clang-tidy/checkers/modernize-make-unique-default-init.cpp
    M clang-tools-extra/test/clang-tidy/checkers/modernize-make-unique.cpp

  Log Message:
  -----------
  [clang-tidy] Omit std::make_unique/make_shared for default initialization.

This extends the check for default initialization in arrays added in
547f89d6070 to include scalar types and exclude them from the suggested fix for
make_unique/make_shared.

Rewriting std::unique_ptr<int>(new int) as std::make_unique<int>() (or for
other, similar trivial T) switches from default initialization to value
initialization, a performance regression for trivial T.  For these use cases,
std::make_unique_for_overwrite is more suitable alternative.

Reviewed By: hokein

Differential Revision: https://reviews.llvm.org/D90392




More information about the All-commits mailing list