Use mangled and demangled names when checking for a function in a namespace and a function in an anonymous namespace, respectively.
Add an additional testcase for PR15882.