[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace
Nicolas van Kempen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 28 09:54:08 PDT 2021
nicovank added a comment.
As you can see, this will fail some tests as there is one corner case which is tricky to handle:
std::vector<std::tuple<std::tuple<int, int>>> vec;
// This is valid and should not be changed.
vec.emplace_back(std::make_tuple(13, 31));
Does anyone have a suggestion for a good way to handle this?
Ideally, it would be nice to just check that the type of the temporary matches the type of the `value_type`, but I've tried that with a simple `==`, and it then becomes a problem with strings, where for example
std::vector<std::pair<std::string, std::string>> vec;
vec.emplace_back(std::make_pair("foo", "bar"));
would not be changed as it would list the pair as a `std::pair<const char*, const char*>`, and not match with `std::pair<std::string, std::string>`.
Is there some way that I couldn't find to check if two `clang::Types` are "compatible"?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101471/new/
https://reviews.llvm.org/D101471
More information about the llvm-commits
mailing list