ckennelly added a comment.

njames93: Ping



================
Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize-make-shared.cpp:51
   // CHECK-FIXES: std::shared_ptr<int> P1 = std::make_shared<int>();
+  std::shared_ptr<int> P2 = std::shared_ptr<int>(new int);
 
----------------
steveire wrote:
> ckennelly wrote:
> > steveire wrote:
> > > I'm a bit confused. Why don't we want to transform this?
> > `std::make_shared<int>()` is equivalent to `std::shared_ptr<int>(new 
> > int())`.  This value initializes (read: zeroes out the value).
> > 
> > The statement here is only default initializing (read: leaves the value 
> > uninitialized).  For this use case, we should use 
> > `std::make_shared_for_overwrite` when it is available.
> I see. Did you consider an option to transform these anyway? It seems at 
> least as likely that for real-world code bases they are not initialized 
> accidentally (as opposed to being a deliberate choice as assumed here).
The default initialization case for arrays was added because it caused several 
performance regressions.  I want to get the complete initialization check 
implemented, which will then make the `make_unique_for_overwrite` rewrite 
straight forward (just `!initializating`).

An option could then be added in a subsequent commit.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90392

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to