This patch fixes compiler crash described in the following thread: http://lists.cs.uiuc.edu/pipermail/cfe-dev/2015-July/thread.html#43852. It also fixes incorrect behavior described in PR17829.
In essence, I inserted a check in GetAddrOfFunction that verifies that no two different declarations correspond to the same mangled name. Given that clang defers everything, this is the best suitable place I managed to find for the check. Also, the check makes sense only if one of declarations is a C++ method, as there are some kinds of non-C++ declarations that can correctly have the same mangled name (inline assembly inserts is an example).
Yours,
Andrey Bokhanko
Software Engineer
Intel Compiler Team
Intel
This is a pretty expensive extra check, and I think it only kicks in on invalid code where we've got multiple definitions of a function. Can we just eliminate it? It's not really a problem to emit the second function definition as long as we're not trying to emit it into the same llvm::Function.