[PATCH] D90392: [clang-tidy] Omit std::make_unique/make_shared for default initialization.

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 29 08:10:56 PDT 2020


njames93 requested changes to this revision.
njames93 added a comment.
This revision now requires changes to proceed.

IIUC, this is handling the case where `Ptr.reset(new int)` which is different to `Ptr.reset(new int())` because the former doesn't initialise the int while the latter default(zero) initialises it.
If that's correct I still think we should still warn about this case, but don't suggest an auto-fix as that will change behaviour.
Maybe put a note explaining why it can't be auto-fixed.



================
Comment at: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp:132
   // which maybe unexpected and cause performance regression.
-  if (New->isArray() && !New->hasInitializer())
+  const bool Initializes = New->hasInitializer() ||
+                           !utils::type_traits::isTriviallyDefaultConstructible(
----------------
Drop the const, we don't use const on local variables in the codebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D90392/new/

https://reviews.llvm.org/D90392



More information about the cfe-commits mailing list