[PATCH] D25898: [clang-tidy] Enhance modernize-make-unique to handle unique_ptr.reset()
Piotr Padlewski via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 23 02:33:57 PDT 2016
Prazek added a comment.
Besides this looks good
Comment at: test/clang-tidy/modernize-make-shared.cpp:122
+ Pderived = std::shared_ptr<Derived>(new Derived());
+ // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use std::make_shared instead
+ // CHECK-FIXES: Pderived = std::make_shared<Derived>();
I think the warning here could be better. The user is using make_shared here.
Maybe ' warning: use std::make_shared with zero arguments ...', but only in this case
Comment at: test/clang-tidy/modernize-make-shared.cpp:129
+ // FIXME: OK to replace when auto is not used
+ std::shared_ptr<Base> PBase = std::shared_ptr<Base>(new Derived());
I think it is good to replace it even with auto, like
auto PBase = std::make_shared<Base>(new Derived());
For shared_ptr we can even do better, that we can't do for unique_ptr - we
coud change it to
auto PBase = std::make_shared<Derived>();
because all conversions works.
Of course not in this patch, but it would be good to leave a comment about this here.
More information about the cfe-commits