[PATCH] D22208: [clang-tidy] Fixes to modernize-use-emplace

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 21 17:55:58 PDT 2016


alexfh requested changes to this revision.
This revision now requires changes to proceed.

================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:45
@@ -33,3 +44,3 @@
       hasDeclaration(functionDecl(hasName("push_back"))),
-      on(hasType(cxxRecordDecl(hasAnyName("std::vector", "llvm::SmallVector",
-                                          "std::list", "std::deque")))));
+      on(hasType(cxxRecordDecl(hasAnyName(SmallVector<StringRef, 5>(
+          ContainersWithPushBack.begin(), ContainersWithPushBack.end()))))));
----------------
What's the reason for explicitly creating a `SmallVector`? `VariadicFunction::operator()` takes an `ArrayRef`, which `std::vector<>` should be implicitly convertible to. Am I missing something?

================
Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:12
@@ +11,3 @@
+uses it. It also doesn't support ``insert`` functions for associative containers
+because chaning ``insert`` to ``emplace`` may result in
+`speed regression <http://htmlpreview.github.io/?https://github.com/HowardHinnant/papers/blob/master/insert_vs_emplace.html>`_.
----------------
s/chaning/changing/

================
Comment at: docs/clang-tidy/checks/modernize-use-emplace.rst:12
@@ +11,3 @@
+uses it. It also doesn't support ``insert`` functions for associative containers
+because chaning ``insert`` to ``emplace`` may result in
+`speed regression <http://htmlpreview.github.io/?https://github.com/HowardHinnant/papers/blob/master/insert_vs_emplace.html>`_.
----------------
alexfh wrote:
> s/chaning/changing/
How about the `insert` method of `std::vector<>`?


Repository:
  rL LLVM

https://reviews.llvm.org/D22208





More information about the cfe-commits mailing list