Given the following declarations for foo:
void foo(int a); void foo(int a) __attribute__((enable_if(a, "")));
...The only way to reinterpret_cast foo is to insert two casts:
auto fnptr = reinterpret_cast<void (*)(void *)>((void (*)(int))foo);
...Which isn't quite ideal. This patch teaches clang to check to see if an overload set has only one candidate that can have its address taken. If this is the case, then we'll use it automatically.
(As a side note: we use a custom loop rather than modifying AddressOfFunctionResolver because we don't need to do any kind of ranking, and there seem to be some cases where AddressOfFunctionResolver will disqualify candidates, which we don't really want here. I can fold this logic into AddressOfFunctionResolver if we want to potentially have less code duplication, but I feel this is straightforward enough that it can stand on its own, rather than adding complexity to AddressOfFunctionResolver).
Do we reach a DiagnoseUseOfDecl somewhere in here?