[PATCH] D98034: [clang-tidy] Use-after-move: Ignore moves inside a try_emplace.
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 5 06:32:20 PST 2021
njames93 added a comment.
In D98034#2606535 <https://reviews.llvm.org/D98034#2606535>, @mboehme wrote:
> In D98034#2606488 <https://reviews.llvm.org/D98034#2606488>, @njames93 wrote:
>
>> While `try_emplace` is a special case, it's may not be the only special case in someone's codebase, this should be extended with options to let users handle their special containers.
>
> Sorry, I didn't see your comment before submitting.
>
> I agree that there may be other cases of "maybe move" functions, but try_emplace seems to be the most common case. Handling "maybe move" functions more general would require some way of annotating them; I felt it was useful to get the try_emplace case handled first.
The canonical way of doing this in clang-tidy is to add an option to the check which takes a semi-colon delimited list.
`clang::tidy::utils::options::parseStringList` can then turn that into a vector of string.
Annoyingly the hasAnyName matcher needs a vector of StringRef's so most checks do something like this
hasAnyName(SmallVector<StringRef, 4>(
StringLikeClasses.begin(), StringLikeClasses.end())
As you are reading options, you will need to override the storeOptions method in the check to then store the value read from config, `serializeStringList` is your friend here.
The documentation will also need updating to describe the option and what it does.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98034/new/
https://reviews.llvm.org/D98034
More information about the cfe-commits
mailing list