[PATCH] D20964: [clang-tidy] Add modernize-use-emplace
Vedant Kumar via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 9 13:12:14 PDT 2016
vsk added a subscriber: vsk.
vsk added a comment.
@Eugene.Zelenko thanks for pointing this out, I had totally missed this patch! Once we get this reviewed I'm willing to abandon my version. Some comments inline --
================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:26
@@ +25,3 @@
+ // + add handling of `push` for std::stack, std::queue, std::priority_queue
+ // + add handling of `insert` for stl associative container, but be cerfull
+ // because this requires special treatment (it could cause performance
----------------
cerfull -> careful
================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:37
@@ +36,3 @@
+
+ // We can't replace push_backs of smart pointer becase
+ // if emplacement will fail (f.e. bad_alloc in vector) we will have leak of
----------------
becase -> because
================
Comment at: test/clang-tidy/modernize-use-emplace.cpp:147
@@ +146,3 @@
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back {{..}}
+ // CHECK-FIXES: v.emplace_back(1, 2);
+ v.push_back( S {1, 2} );
----------------
I don't think this is correct. Comments immediately before/after `S` or immediately before/after the second right parenthesis should be preserved. C.f the implementation in D21185.
http://reviews.llvm.org/D20964
More information about the cfe-commits
mailing list