[cfe-dev] Probe overload resolution from a tool
Kim Gräsman via cfe-dev
cfe-dev at lists.llvm.org
Tue Dec 17 12:23:35 PST 2019
It's been almost a year since I thought about this. Any pointers
before 2019 closes?
Thanks,
- Kim
On Sun, Feb 10, 2019 at 1:24 PM Kim Gräsman <kim.grasman at gmail.com> wrote:
>
> Hi all,
>
> We had a bug report in IWYU recently, that `std::move` is not
> recognized in a templated context:
>
> #include <ostream>
>
> template <typename> struct A {};
>
> struct B {
> template <typename T>
> B(A<T>&& a) {}
> };
>
> template <typename T>
> void f(A<T>&& a) {
> B(std::move(a));
> }
>
> (full report: https://github.com/include-what-you-use/include-what-you-use/issues/636)
>
> We currently handle this by RAV-visiting OverloadExprs and basically
> picking the first decl in the candidate set.
>
> To make this more rigorous, I guess we would have to use the arguments
> from the originating CallExpr to find the best match. Is there library
> support in e.g. Sema to do this? Since IWYU assumes working code, we
> know there's exactly one candidate that will be selected, we just need
> to be able to resolve which one. I'm looking for something like:
>
> Decl* bestMatch(const llvm::iterator_range<decls_iterator>& Decls,
> ArrayRef<Expr *> Args);
>
> Given that this is C++, I'm expecting this to be much more complicated
> in practice :)
>
> Ideas? Does any of the Clang tools already do something like this?
> I've been grepping around the code base, but haven't found anything
> obvious.
>
> Thanks,
> - Kim
More information about the cfe-dev
mailing list