[PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 10 05:03:28 PDT 2016


aaron.ballman added a comment.

Good catch! Some small nits.


================
Comment at: clang-tidy/modernize/MakeSmartPtrCheck.cpp:32-33
@@ -31,1 +31,4 @@
 
+  // It is possible to make smart ptr calling private ctor inside of a member
+  // function. Change to make_smart_ptr will be invalid.
+  auto CallsPrivateCtor = has(
----------------
Nit: this reads a bit strangely, how about: `Calling make_smart_ptr from within a member function of a type with a private constructor would be ill-formed.`

================
Comment at: test/clang-tidy/modernize-make-shared.cpp:109
@@ +108,3 @@
+  void create() {
+    auto ptr = std::shared_ptr<Private>(new Private(42));
+  }
----------------
Add comments explaining why make_shared is not correct. Also, please add a case showing that protected constructors still get the proper fix applied.

================
Comment at: test/clang-tidy/modernize-make-unique.cpp:112
@@ +111,3 @@
+  void create() {
+    auto ptr = std::unique_ptr<Private>(new Private(42));
+  }
----------------
Add comments as above.


https://reviews.llvm.org/D23343





More information about the cfe-commits mailing list