Probe overload resolution from a tool

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Probe overload resolution from a tool

David Blaikie via cfe-dev
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
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev