[PATCH] D20964: [clang-tidy] Add modernize-use-emplace
Vedant Kumar via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 9 18:21:12 PDT 2016
vsk added inline comments.
================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:41
@@ +40,3 @@
+ // (and destructed) as in push_back case.
+ auto isCtorOfSmartPtr = hasDeclaration(cxxConstructorDecl(
+ ofClass(hasAnyName("std::shared_ptr", "std::unique_ptr", "std::auto_ptr",
----------------
I agree that blacklisting some smart pointers is not a complete solution, and that we shouldn't introduce a check which emits false positives.
ISTM it's **only** safe to perform the "push(T(...)) -> emplace(...)" change if: it's safe to assume that if "emplace(...)" does not successfully call "T(...)", it's OK for the program to fail/leak/crash. Do we get to make this assumption ever? Perhaps just in no-exceptions mode?
http://reviews.llvm.org/D20964
More information about the cfe-commits
mailing list