Summary
In a program such as:
namespace A { namespace B { struct Bar {}; } } namespace B { struct Foo {}; }
...LLDB would run into issues such as:
(lldb) expr ::B::Foo f error: expression failed to parse: error: <user expression 0>:1:6: no type named 'Foo' in namespace 'A::B' ::B::Foo f ~~~~~^
This is because the SymbolFileDWARF::FindNamespace implementation
will return *any* namespace it finds if the parent_decl_ctx provided
is empty. In FindExternalVisibleDecls we use this API to find the
namespace that symbol B refers to. If A::B happened to be the one
that SymbolFileDWARF::FindNamespace looked at first, we would try
to find struct Foo in A::B. Hence the error.
This patch proposes a new flag to SymbolFileDWARF::FindNamespace
allows us to only consider top-level namespaces in our search, which is what
FindExternalVisibleDecls is attempting anyway; it just never
accounted for multiple namespaces of the same name.
Testing
- Added API test-case
This looks like a great opportunity to add a Doxygen comment in the base class!