brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · cd953e7 Raw
57 lines · plain
1.. title:: clang-tidy - modernize-make-shared2 3modernize-make-shared4=====================5 6This check finds the creation of ``std::shared_ptr`` objects by explicitly7calling the constructor and a ``new`` expression, and replaces it with a call8to ``std::make_shared``.9 10.. code-block:: c++11 12  auto my_ptr = std::shared_ptr<MyPair>(new MyPair(1, 2));13 14  // becomes15 16  auto my_ptr = std::make_shared<MyPair>(1, 2);17 18This check also finds calls to ``std::shared_ptr::reset()`` with a ``new``19expression, and replaces it with a call to ``std::make_shared``.20 21.. code-block:: c++22 23  my_ptr.reset(new MyPair(1, 2));24 25  // becomes26 27  my_ptr = std::make_shared<MyPair>(1, 2);28 29Options30-------31 32.. option:: MakeSmartPtrFunction33 34   A string specifying the name of make-shared-ptr function. Default is35   `std::make_shared`.36 37.. option:: MakeSmartPtrFunctionHeader38 39   A string specifying the corresponding header of make-shared-ptr function.40   Default is `<memory>`.41 42.. option:: IncludeStyle43 44   A string specifying which include-style is used, `llvm` or `google`. Default45   is `llvm`.46 47.. option:: IgnoreMacros48 49   If set to `true`, the check will not give warnings inside macros. Default50   is `true`.51 52.. option:: IgnoreDefaultInitialization53 54   If set to `false`, the check does not suggest edits that will transform55   default initialization into value initialization, as this can cause56   performance regressions. Default is `true`.57