[Lldb-commits] [lldb] [lldb] Add SBType::FindNestedType() function (PR #68705)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 12 01:29:52 PDT 2023


Michael137 wrote:

> It's not clear to me whether `TypeSystem::DeclContextIsContainedInLookup` provides such a guarantee. Implementation suggests that it's only interested in direct `DeclContext`, maybe ignoring transparent decl contexts like inline namespace it already handles. I hope reviewers can clarify this.

We use `DeclContextIsContainedInLookup` to make sure that if, e.g., a user ran `expr A::B::C`, then the type we find for `C` is in fact a child of `B` which is a child of `A`. So it really is just a way to walk up a context hierarchy directly and check that the hierarchy in DWARF matches the hierarchy in `clang::DeclContext`. As you say, it also supports inline namespaces, but that only came later as we needed it to make namespaces work during expression evaluation. It seems to me that this function developed organically with the needs of the expression evaluator/type lookup, and its purpose was always really to just do a directed is-contained check. While I don't think this will be change (since lookup is already fragile things probably rely on it being this way), it would make sense to document this in the `DeclContextIsContainedInLookup` contract and add tests for it so it's future proof. But that could be done outside of this PR in my opinion.

https://github.com/llvm/llvm-project/pull/68705


More information about the lldb-commits mailing list