[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
Sun Apr 23 15:51:39 PDT 2017


kuhar marked 2 inline comments as done.
kuhar added inline comments.


================
Comment at: clang-tidy/modernize/UseEmplaceCheck.cpp:93
+                      to(functionDecl(hasName("::std::make_pair"))))
+      ))))
+          .bind("make_pair"));
----------------
Prazek wrote:
> JonasToth wrote:
> > is the new line here necessary? i think it looks better if the `.bind` is on this line.
> Better question is "is it clang formated?"
It was clang-formatted, but I do agree that it looked a bit weird. I removed the extra newline.


================
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));
----------------
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.


https://reviews.llvm.org/D32395





More information about the cfe-commits mailing list