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

Stanisław Barzowski via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 3 08:39:15 PDT 2016


sbarzowski added inline comments.

================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:30
@@ +29,3 @@
+      cxxMemberCallExpr(hasDeclaration(functionDecl(hasName(PushBackName))),
+                        on(hasType(cxxRecordDecl(hasName(VectorName)))))
+          .bind("call");
----------------
Maybe it can work with some more types, with minimal changes... Like maybe std::list.

================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:38
@@ +37,3 @@
+  auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(
+      ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",
+                         "std::weak_ptr"))));
----------------
This argument really holds for _any_ class taking ownership of the created object.

Maybe it would be better to check if we pass a non-const pointer as an argument to the constructor, as a pretty good indicator of taking ownership.

Or maybe just look for `new` operator in the expression.


http://reviews.llvm.org/D20964





More information about the cfe-commits mailing list