[PATCH] D20964: [clang-tidy] Add modernize-use-emplace

Piotr Padlewski via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 3 08:51:10 PDT 2016


Prazek added inline comments.

================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:31
@@ +30,3 @@
+                        on(hasType(cxxRecordDecl(hasName(VectorName)))))
+          .bind("call");
+
----------------
ok, std::list works for me. I just don't want to spend much time on it right now, and I want to be sure it works.

================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:39
@@ +38,3 @@
+      ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",
+                         "std::weak_ptr"))));
+
----------------
Look at tests - the same thing happens when

std::vector<std::unique_ptr<int>> v;

const auto *p = new int;
v.push_back(p);

Not many custom classes take pointer in constructor. 
If I will look for const pointers, then I will not be able to pass "abc" into vector<string>.

So I guess this solution seems to be the best idea. 


http://reviews.llvm.org/D20964





More information about the cfe-commits mailing list