[lldb-dev] Type lookup by basename vs. qualified name

Zachary Turner via lldb-dev lldb-dev at lists.llvm.org
Tue Oct 23 16:02:22 PDT 2018

I was trying to implemented type lookup for qualified names (e.g. in
namespaces), and I noticed we have this code in Module.cpp:

  if (Type::GetTypeScopeAndBasename(type_name_cstr, type_scope,
                                    type_class)) {
    // Check if "name" starts with "::" which means the qualified type
    // from the root namespace and implies and exact match. The typenames we
    // get back from clang do not start with "::" so we need to strip this
    // in order to get the qualified names to match
    exact_match = type_scope.consume_front("::");

    ConstString type_basename_const_str(type_basename);
    if (FindTypes_Impl(sc, type_basename_const_str, nullptr, append,
                       max_matches, searched_symbol_files, typesmap)) {
      typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
      num_matches = typesmap.GetSize();
  } else {

Basically we are stripping the namespace and scope, and only passing the
basename to the SymbolVendor.  I guess then the SymbolFile will find any
types which match the basename, which could be anything, and the
RemoveMismatchedTypes will filter this down to only the ones that are in
the namespace.

I don't know what this is like in DWARF-land, but for PDB this is
*precisely* what we do not want to do.  Types are indexed in an internal
hash table by fully qualified name, so we need the fully scoped name in the
SymbolFile plugin otherwise we basically have to do the equivalent of a
full table scan for what could be an O(1) operation.

If I change this to pass the fully scoped name, is this going to break
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20181023/65c99c46/attachment.html>

More information about the lldb-dev mailing list