Due to the way the lldb override for clang::ExternalASTSource::FindExternalGlobalVisibleDeclsByName callback was searching for functions, it was possible for invalid declarations to end up in the list of function declarations passed back to the clang AST, which subsequently caused clang to complain about ambiguous lookups. The logic used to prune duplicate function declarations based on lexical distance was ignoring the error status returned for invalid declarations which meant that they ended up in the list of resolved declarations passed back to clang.
Shouldn't it be the job of the subsequent filtering loop to sort this out? The debugger should be able to call functions from a given frame, even if that function is not actually visible from the current frame. So I don't think you want to reject such functions from the candidate list. You just want to make sure that if there IS one visible, it should override the ones that aren't visible.