[PATCH] D54704: [clang-tidy] Don't generate incorrect fixes for class constructed from list-initialized arguments

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 20 07:46:45 PST 2018


hokein added a comment.

In https://reviews.llvm.org/D54704#1304176, @aaron.ballman wrote:

> > Currently the smart_ptr check (modernize-make-unique) generates the fixes that cannot compile for cases like below -- because brace list can not be deduced in make_unique.
> > 
> >   class Bar { int a, b; };
> >   class Foo { Foo(Bar); };
> >   auto foo = std::unique_ptr<Foo>(new Foo({1, 2}));
>
> This code isn't legal in the first place. ;-)


Thanks for the review. Fixed :)



================
Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:287
+  //   Foo(Bar{1, 2}) => true
+  //   Foo(1) => false
+  auto HasListIntializedArgument = [](const CXXConstructExpr *CE) {
----------------
aaron.ballman wrote:
> I assume this is expected to be false? `Foo{1}`
Yes, added this sample to the comment.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54704





More information about the cfe-commits mailing list