Context:
When setting a breakpoint by name, we invoke Module::FindFunctions to find the function(s) in question. However, we use a Module::LookupInfo to first process the user-provided name and figure out exactly what we're looking for. When we actually perform the function lookup, we search for the basename. After performing the search, we then filter out the results using Module::LookupInfo::Prune. For example, given a::b::foo we would first search for all instances of foo and then filter out the results to just names that have a::b::foo in them. As one can imagine, this involves a lot of debug info processing that we do not necessarily need to be doing.
Some numbers:
Debugging LLDB and placing a breakpoint on llvm::itanium_demangle::StringView::begin without this change takes approximately 70 seconds and resolves 31,920 DIEs. With this change, placing the breakpoint takes around 30 seconds and resolves 8 DIEs.
So this function can end up being called with an empty function_name when there is no mangled name (see comment in DWARFIndex.cpp). If there is no language then we return true, but what does a language plug-in do in DemangledNameContainsPath? The same thing?
I guess this means if you lookup "foo::erase" and you get a DIE that has "erase" as its DW_AT_name, but the DIE has no DW_AT_mangled (yes, some C++ debug info is emitted without a mangled name), that it will match any DIE that has a DW_AT_name that matches "erase" regardless of the actual decl context?