This patch ensures built-in functions are rewritten using the proper
parent declaration. Tests are added to ensure the functionality works
also with C++ for OpenCL.
I would say in the interest of saving testing time running one of those test in C++ mode should be enough.
I think these builtins were added before we could specify address spaces in tablegen file. So I think we should actually change these builtins to add the address spaces on pointers such that this code wouldn't be called at all. But your fix is still needed for general cases.
If you either write FIXME next to the OpenCL builtins in Builtins.td to add the address spaces or create a bugzilla bug describing this problem I am happy to go ahead with this patch.