[PATCH] D32395: [clang-tidy] modernize-use-emplace: remove unnecessary make_pair calls
Jakub Kuderski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 24 04:28:51 PDT 2017
kuhar added inline comments.
================
Comment at: test/clang-tidy/modernize-use-emplace.cpp:284
+ // CHECK-FIXES: v.emplace_back(42LL, 13);
+
+ v.push_back(std::make_pair<char, char>(0, 3));
----------------
kuhar wrote:
> Prazek wrote:
> > I would add here test like:
> >
> > class X {
> > X(std:;pair<int, int> a) {}
> > };
> >
> > std::vector<X> v;
> > v.push_back(make_pair(42, 42));
> >
> > I guess as long as X ctor is not explicit this can happen, and we can't transform it to
> > emplace.back(42, 42)
> Nice idea for a test case, added.
A better test case would be to make X's ctor take a pair by const reference or rvalue reference. This way it wouldn't produce an extra CxxConstructExpr and will be currently (incorrectly) matched. This needs to be fixed.
https://reviews.llvm.org/D32395
More information about the cfe-commits
mailing list