[SymbolFile] Remove SymbolContext parameter from FindTypes.

This parameter was only ever used with the Module set, and
since a SymbolFile is tied to a module, the parameter turns
out to be entirely unnecessary.  Furthermore, it doesn't make
a lot of sense to ask a caller to ask SymbolFile which is tied
to Module X to find types for Module Y, but that possibility
was open with the previous interface.  By removing this
parameter from the API, it makes it harder to use incorrectly
as well as easier for an implementor to understand what it
needs to do.

llvm-svn: 351133
This commit is contained in:
Zachary Turner 2019-01-14 22:41:21 +00:00
parent c0a246afbe
commit 576495e67b
30 changed files with 111 additions and 169 deletions

View File

@ -499,10 +499,6 @@ public:
/// have to specify complete scoping on all expressions, but it also allows
/// for exact matching when required.
///
/// @param[in] sc
/// A symbol context that scopes where to extract a type list
/// from.
///
/// @param[in] type_name
/// The name of the type we are looking for that is a fully
/// or partially qualified type name.
@ -521,8 +517,7 @@ public:
/// The number of matches added to \a type_list.
//------------------------------------------------------------------
size_t
FindTypes(const SymbolContext &sc, const ConstString &type_name,
bool exact_match, size_t max_matches,
FindTypes(const ConstString &type_name, bool exact_match, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeList &types);
@ -534,10 +529,6 @@ public:
/// expression parser when searches need to happen in an exact namespace
/// scope.
///
/// @param[in] sc
/// A symbol context that scopes where to extract a type list
/// from.
///
/// @param[in] type_name
/// The name of a type within a namespace that should not include
/// any qualifying namespaces (just a type basename).
@ -551,8 +542,7 @@ public:
/// @return
/// The number of matches added to \a type_list.
//------------------------------------------------------------------
size_t FindTypesInNamespace(const SymbolContext &sc,
const ConstString &type_name,
size_t FindTypesInNamespace(const ConstString &type_name,
const CompilerDeclContext *parent_decl_ctx,
size_t max_matches, TypeList &type_list);
@ -1182,9 +1172,8 @@ private:
Module(); // Only used internally by CreateJITModule ()
size_t FindTypes_Impl(
const SymbolContext &sc, const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append,
size_t max_matches,
const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);

View File

@ -417,9 +417,9 @@ public:
//------------------------------------------------------------------
/// Find types by name.
///
/// @param[in] sc
/// A symbol context that scopes where to extract a type list
/// from.
/// @param[in] search_first
/// If non-null, this module will be searched before any other
/// modules.
///
/// @param[in] name
/// The name of the type we are looking for.
@ -447,7 +447,7 @@ public:
/// @return
/// The number of matches added to \a type_list.
//------------------------------------------------------------------
size_t FindTypes(const SymbolContext &sc, const ConstString &name,
size_t FindTypes(Module *search_first, const ConstString &name,
bool name_is_fully_qualified, size_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeList &types) const;

View File

@ -193,9 +193,8 @@ public:
bool include_inlines, bool append,
SymbolContextList &sc_list);
virtual uint32_t
FindTypes(const SymbolContext &sc, const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,
FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);
virtual size_t FindTypes(const std::vector<CompilerContext> &context,

View File

@ -99,9 +99,8 @@ public:
SymbolContextList &sc_list);
virtual size_t
FindTypes(const SymbolContext &sc, const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append,
size_t max_matches,
FindTypes(const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types);

View File

@ -440,13 +440,12 @@ lldb::SBTypeList SBModule::FindTypes(const char *type) {
ModuleSP module_sp(GetSP());
if (type && module_sp) {
SymbolContext sc;
TypeList type_list;
const bool exact_match = false;
ConstString name(type);
llvm::DenseSet<SymbolFile *> searched_symbol_files;
const uint32_t num_matches = module_sp->FindTypes(
sc, name, exact_match, UINT32_MAX, searched_symbol_files, type_list);
name, exact_match, UINT32_MAX, searched_symbol_files, type_list);
if (num_matches > 0) {
for (size_t idx = 0; idx < num_matches; idx++) {

View File

@ -1850,11 +1850,10 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) {
ModuleList &images = target_sp->GetImages();
ConstString const_typename(typename_cstr);
bool exact_match = false;
SymbolContext sc;
TypeList type_list;
llvm::DenseSet<SymbolFile *> searched_symbol_files;
uint32_t num_matches =
images.FindTypes(sc, const_typename, exact_match, UINT32_MAX,
images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
searched_symbol_files, type_list);
if (num_matches > 0) {

View File

@ -382,7 +382,6 @@ protected:
if (view_as_type_cstr && view_as_type_cstr[0]) {
// We are viewing memory as a type
SymbolContext sc;
const bool exact_match = false;
TypeList type_list;
uint32_t reference_count = 0;
@ -467,17 +466,13 @@ protected:
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
ConstString lookup_type_name(type_str.c_str());
StackFrame *frame = m_exe_ctx.GetFramePtr();
ModuleSP search_first;
if (frame) {
sc = frame->GetSymbolContext(eSymbolContextModule);
if (sc.module_sp) {
sc.module_sp->FindTypes(sc, lookup_type_name, exact_match, 1,
searched_symbol_files, type_list);
}
}
if (type_list.GetSize() == 0) {
target->GetImages().FindTypes(sc, lookup_type_name, exact_match, 1,
searched_symbol_files, type_list);
search_first = frame->GetSymbolContext(eSymbolContextModule).module_sp;
}
target->GetImages().FindTypes(search_first.get(), lookup_type_name,
exact_match, 1, searched_symbol_files,
type_list);
if (type_list.GetSize() == 0 && lookup_type_name.GetCString() &&
*lookup_type_name.GetCString() == '$') {

View File

@ -1672,12 +1672,11 @@ static size_t LookupTypeInModule(CommandInterpreter &interpreter, Stream &strm,
const uint32_t max_num_matches = UINT32_MAX;
size_t num_matches = 0;
bool name_is_fully_qualified = false;
SymbolContext sc;
ConstString name(name_cstr);
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
num_matches =
module->FindTypes(sc, name, name_is_fully_qualified, max_num_matches,
module->FindTypes(name, name_is_fully_qualified, max_num_matches,
searched_symbol_files, type_list);
if (num_matches) {
@ -1715,11 +1714,8 @@ static size_t LookupTypeInModule(CommandInterpreter &interpreter, Stream &strm,
}
static size_t LookupTypeHere(CommandInterpreter &interpreter, Stream &strm,
const SymbolContext &sym_ctx,
const char *name_cstr, bool name_is_regex) {
if (!sym_ctx.module_sp)
return 0;
Module &module, const char *name_cstr,
bool name_is_regex) {
TypeList type_list;
const uint32_t max_num_matches = UINT32_MAX;
size_t num_matches = 1;
@ -1727,14 +1723,13 @@ static size_t LookupTypeHere(CommandInterpreter &interpreter, Stream &strm,
ConstString name(name_cstr);
llvm::DenseSet<SymbolFile *> searched_symbol_files;
num_matches = sym_ctx.module_sp->FindTypes(
sym_ctx, name, name_is_fully_qualified, max_num_matches,
searched_symbol_files, type_list);
num_matches = module.FindTypes(name, name_is_fully_qualified, max_num_matches,
searched_symbol_files, type_list);
if (num_matches) {
strm.Indent();
strm.PutCString("Best match found in ");
DumpFullpath(strm, &sym_ctx.module_sp->GetFileSpec(), 0);
DumpFullpath(strm, &module.GetFileSpec(), 0);
strm.PutCString(":\n");
TypeSP type_sp(type_list.GetTypeAtIndex(0));
@ -3832,8 +3827,9 @@ public:
return false;
case eLookupTypeType:
if (!m_options.m_str.empty()) {
if (LookupTypeHere(m_interpreter, result.GetOutputStream(), sym_ctx,
m_options.m_str.c_str(), m_options.m_use_regex)) {
if (LookupTypeHere(m_interpreter, result.GetOutputStream(),
*sym_ctx.module_sp, m_options.m_str.c_str(),
m_options.m_use_regex)) {
result.SetStatus(eReturnStatusSuccessFinishResult);
return true;
}

View File

@ -943,33 +943,33 @@ void Module::FindAddressesForLine(const lldb::TargetSP target_sp,
}
size_t Module::FindTypes_Impl(
const SymbolContext &sc, const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches,
const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
if (!sc.module_sp || sc.module_sp.get() == this) {
SymbolVendor *symbols = GetSymbolVendor();
if (symbols)
return symbols->FindTypes(sc, name, parent_decl_ctx, append, max_matches,
searched_symbol_files, types);
}
SymbolVendor *symbols = GetSymbolVendor();
if (symbols)
return symbols->FindTypes(name, parent_decl_ctx, append, max_matches,
searched_symbol_files, types);
return 0;
}
size_t Module::FindTypesInNamespace(const SymbolContext &sc,
const ConstString &type_name,
size_t Module::FindTypesInNamespace(const ConstString &type_name,
const CompilerDeclContext *parent_decl_ctx,
size_t max_matches, TypeList &type_list) {
const bool append = true;
TypeMap types_map;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
size_t num_types =
FindTypes_Impl(sc, type_name, parent_decl_ctx, append, max_matches,
FindTypes_Impl(type_name, parent_decl_ctx, append, max_matches,
searched_symbol_files, types_map);
if (num_types > 0)
if (num_types > 0) {
SymbolContext sc;
sc.module_sp = shared_from_this();
sc.SortTypeList(types_map, type_list);
}
return num_types;
}
@ -978,15 +978,14 @@ lldb::TypeSP Module::FindFirstType(const SymbolContext &sc,
TypeList type_list;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
const size_t num_matches =
FindTypes(sc, name, exact_match, 1, searched_symbol_files, type_list);
FindTypes(name, exact_match, 1, searched_symbol_files, type_list);
if (num_matches)
return type_list.GetTypeAtIndex(0);
return TypeSP();
}
size_t Module::FindTypes(
const SymbolContext &sc, const ConstString &name, bool exact_match,
size_t max_matches,
const ConstString &name, bool exact_match, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeList &types) {
size_t num_matches = 0;
@ -1006,8 +1005,8 @@ size_t Module::FindTypes(
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)) {
if (FindTypes_Impl(type_basename_const_str, nullptr, append, max_matches,
searched_symbol_files, typesmap)) {
typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
num_matches = typesmap.GetSize();
@ -1018,13 +1017,13 @@ size_t Module::FindTypes(
if (type_class != eTypeClassAny && !type_basename.empty()) {
// The "type_name_cstr" will have been modified if we have a valid type
// class prefix (like "struct", "class", "union", "typedef" etc).
FindTypes_Impl(sc, ConstString(type_basename), nullptr, append,
UINT_MAX, searched_symbol_files, typesmap);
FindTypes_Impl(ConstString(type_basename), nullptr, append, UINT_MAX,
searched_symbol_files, typesmap);
typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
num_matches = typesmap.GetSize();
} else {
num_matches = FindTypes_Impl(sc, name, nullptr, append, UINT_MAX,
num_matches = FindTypes_Impl(name, nullptr, append, UINT_MAX,
searched_symbol_files, typesmap);
if (exact_match) {
std::string name_str(name.AsCString(""));
@ -1034,8 +1033,11 @@ size_t Module::FindTypes(
}
}
}
if (num_matches > 0)
if (num_matches > 0) {
SymbolContext sc;
sc.module_sp = shared_from_this();
sc.SortTypeList(typesmap, types);
}
return num_matches;
}

View File

@ -542,7 +542,7 @@ ModuleSP ModuleList::FindModule(const UUID &uuid) const {
}
size_t
ModuleList::FindTypes(const SymbolContext &sc, const ConstString &name,
ModuleList::FindTypes(Module *search_first, const ConstString &name,
bool name_is_fully_qualified, size_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeList &types) const {
@ -550,14 +550,12 @@ ModuleList::FindTypes(const SymbolContext &sc, const ConstString &name,
size_t total_matches = 0;
collection::const_iterator pos, end = m_modules.end();
if (sc.module_sp) {
// The symbol context "sc" contains a module so we want to search that one
// first if it is in our list...
if (search_first) {
for (pos = m_modules.begin(); pos != end; ++pos) {
if (sc.module_sp.get() == (*pos).get()) {
if (search_first == pos->get()) {
total_matches +=
(*pos)->FindTypes(sc, name, name_is_fully_qualified, max_matches,
searched_symbol_files, types);
search_first->FindTypes(name, name_is_fully_qualified, max_matches,
searched_symbol_files, types);
if (total_matches >= max_matches)
break;
@ -566,15 +564,14 @@ ModuleList::FindTypes(const SymbolContext &sc, const ConstString &name,
}
if (total_matches < max_matches) {
SymbolContext world_sc;
for (pos = m_modules.begin(); pos != end; ++pos) {
// Search the module if the module is not equal to the one in the symbol
// context "sc". If "sc" contains a empty module shared pointer, then the
// comparison will always be true (valid_module_ptr != nullptr).
if (sc.module_sp.get() != (*pos).get())
if (search_first != pos->get())
total_matches +=
(*pos)->FindTypes(world_sc, name, name_is_fully_qualified,
max_matches, searched_symbol_files, types);
(*pos)->FindTypes(name, name_is_fully_qualified, max_matches,
searched_symbol_files, types);
if (total_matches >= max_matches)
break;

View File

@ -159,11 +159,10 @@ bool TypeFormatImpl_EnumType::FormatObject(ValueObject *valobj,
if (!target_sp)
return false;
const ModuleList &images(target_sp->GetImages());
SymbolContext sc;
TypeList types;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
images.FindTypes(sc, m_enum_type, false, UINT32_MAX, searched_symbol_files,
types);
images.FindTypes(nullptr, m_enum_type, false, UINT32_MAX,
searched_symbol_files, types);
if (types.GetSize() == 0)
return false;
for (lldb::TypeSP type_sp : types.Types()) {

View File

@ -332,11 +332,9 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
TypeList types;
SymbolContext null_sc;
ConstString name(tag_decl->getName().str().c_str());
i->first->FindTypesInNamespace(null_sc, name, &i->second, UINT32_MAX,
types);
i->first->FindTypesInNamespace(name, &i->second, UINT32_MAX, types);
for (uint32_t ti = 0, te = types.GetSize(); ti != te && !found; ++ti) {
lldb::TypeSP type = types.GetTypeAtIndex(ti);
@ -366,7 +364,6 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
} else {
TypeList types;
SymbolContext null_sc;
ConstString name(tag_decl->getName().str().c_str());
CompilerDeclContext namespace_decl;
@ -374,7 +371,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
bool exact_match = false;
llvm::DenseSet<SymbolFile *> searched_symbol_files;
module_list.FindTypes(null_sc, name, exact_match, UINT32_MAX,
module_list.FindTypes(nullptr, name, exact_match, UINT32_MAX,
searched_symbol_files, types);
for (uint32_t ti = 0, te = types.GetSize(); ti != te && !found; ++ti) {
@ -854,15 +851,12 @@ void ClangASTSource::FindExternalVisibleDecls(
break;
TypeList types;
SymbolContext null_sc;
const bool exact_match = true;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
if (module_sp && namespace_decl)
module_sp->FindTypesInNamespace(null_sc, name, &namespace_decl, 1, types);
module_sp->FindTypesInNamespace(name, &namespace_decl, 1, types);
else {
SymbolContext sc;
sc.module_sp = module_sp;
m_target->GetImages().FindTypes(sc, name, exact_match, 1,
m_target->GetImages().FindTypes(module_sp.get(), name, exact_match, 1,
searched_symbol_files, types);
}

View File

@ -101,7 +101,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress(
llvm::DenseSet<SymbolFile *> searched_symbol_files;
if (sc.module_sp) {
num_matches = sc.module_sp->FindTypes(
sc, ConstString(lookup_name), exact_match, 1,
ConstString(lookup_name), exact_match, 1,
searched_symbol_files, class_types);
}
@ -109,7 +109,7 @@ TypeAndOrName ItaniumABILanguageRuntime::GetTypeInfoFromVTableAddress(
// list in the target and get as many unique matches as possible
if (num_matches == 0) {
num_matches = target.GetImages().FindTypes(
sc, ConstString(lookup_name), exact_match, UINT32_MAX,
nullptr, ConstString(lookup_name), exact_match, UINT32_MAX,
searched_symbol_files, class_types);
}

View File

@ -558,7 +558,7 @@ AppleObjCDeclVendor::FindDecls(const ConstString &name, bool append,
LIBLLDB_LOG_EXPRESSIONS)); // FIXME - a more appropriate log channel?
if (log)
log->Printf("AppleObjCDeclVendor::FindTypes [%u] ('%s', %s, %u, )",
log->Printf("AppleObjCDeclVendor::FindDecls [%u] ('%s', %s, %u, )",
current_id, (const char *)name.AsCString(),
append ? "true" : "false", max_matches);

View File

@ -153,10 +153,9 @@ uint32_t SymbolFileBreakpad::FindFunctions(const RegularExpression &regex,
}
uint32_t SymbolFileBreakpad::FindTypes(
const SymbolContext &sc, const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) {
const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) {
if (!append)
types.Clear();
return types.GetSize();

View File

@ -113,7 +113,7 @@ public:
uint32_t FindFunctions(const RegularExpression &regex, bool include_inlines,
bool append, SymbolContextList &sc_list) override;
uint32_t FindTypes(const SymbolContext &sc, const ConstString &name,
uint32_t FindTypes(const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,

View File

@ -2437,9 +2437,8 @@ void SymbolFileDWARF::GetMangledNamesForFunction(
}
uint32_t SymbolFileDWARF::FindTypes(
const SymbolContext &sc, const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,
const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
// If we aren't appending the results to this list, then clear the list
@ -2528,8 +2527,8 @@ uint32_t SymbolFileDWARF::FindTypes(
SymbolVendor *sym_vendor = external_module_sp->GetSymbolVendor();
if (sym_vendor) {
const uint32_t num_external_matches =
sym_vendor->FindTypes(sc, name, parent_decl_ctx, append,
max_matches, searched_symbol_files, types);
sym_vendor->FindTypes(name, parent_decl_ctx, append, max_matches,
searched_symbol_files, types);
if (num_external_matches)
return num_external_matches;
}

View File

@ -193,8 +193,7 @@ public:
std::vector<lldb_private::ConstString> &mangled_names) override;
uint32_t
FindTypes(const lldb_private::SymbolContext &sc,
const lldb_private::ConstString &name,
FindTypes(const lldb_private::ConstString &name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,

View File

@ -1180,9 +1180,8 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
}
uint32_t SymbolFileDWARFDebugMap::FindTypes(
const SymbolContext &sc, const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,
const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
if (!append)
@ -1191,18 +1190,11 @@ uint32_t SymbolFileDWARFDebugMap::FindTypes(
const uint32_t initial_types_size = types.GetSize();
SymbolFileDWARF *oso_dwarf;
if (sc.comp_unit) {
oso_dwarf = GetSymbolFile(sc);
if (oso_dwarf)
return oso_dwarf->FindTypes(sc, name, parent_decl_ctx, append,
max_matches, searched_symbol_files, types);
} else {
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
oso_dwarf->FindTypes(sc, name, parent_decl_ctx, append, max_matches,
searched_symbol_files, types);
return types.GetSize() >= max_matches;
});
}
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
oso_dwarf->FindTypes(name, parent_decl_ctx, append, max_matches,
searched_symbol_files, types);
return types.GetSize() >= max_matches;
});
return types.GetSize() - initial_types_size;
}

View File

@ -116,8 +116,7 @@ public:
bool include_inlines, bool append,
lldb_private::SymbolContextList &sc_list) override;
uint32_t
FindTypes(const lldb_private::SymbolContext &sc,
const lldb_private::ConstString &name,
FindTypes(const lldb_private::ConstString &name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,

View File

@ -1219,10 +1219,9 @@ uint32_t SymbolFileNativePDB::FindFunctions(const RegularExpression &regex,
}
uint32_t SymbolFileNativePDB::FindTypes(
const SymbolContext &sc, const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
TypeMap &types) {
const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) {
if (!append)
types.Clear();
if (!name)

View File

@ -139,7 +139,7 @@ public:
uint32_t FindFunctions(const RegularExpression &regex, bool include_inlines,
bool append, SymbolContextList &sc_list) override;
uint32_t FindTypes(const SymbolContext &sc, const ConstString &name,
uint32_t FindTypes(const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,
llvm::DenseSet<SymbolFile *> &searched_symbol_files,

View File

@ -1376,7 +1376,6 @@ void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) {
}
uint32_t SymbolFilePDB::FindTypes(
const lldb_private::SymbolContext &sc,
const lldb_private::ConstString &name,
const lldb_private::CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,

View File

@ -137,8 +137,7 @@ public:
void AddSymbols(lldb_private::Symtab &symtab) override;
uint32_t
FindTypes(const lldb_private::SymbolContext &sc,
const lldb_private::ConstString &name,
FindTypes(const lldb_private::ConstString &name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,

View File

@ -140,9 +140,8 @@ void SymbolFile::GetMangledNamesForFunction(
}
uint32_t SymbolFile::FindTypes(
const SymbolContext &sc, const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append,
uint32_t max_matches,
const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
if (!append)

View File

@ -310,15 +310,15 @@ size_t SymbolVendor::FindFunctions(const RegularExpression &regex,
}
size_t SymbolVendor::FindTypes(
const SymbolContext &sc, const ConstString &name,
const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches,
const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
bool append, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
if (m_sym_file_ap.get())
return m_sym_file_ap->FindTypes(sc, name, parent_decl_ctx, append,
return m_sym_file_ap->FindTypes(name, parent_decl_ctx, append,
max_matches, searched_symbol_files,
types);
}

View File

@ -385,11 +385,10 @@ bool Language::ImageListTypeScavenger::Find_Impl(
Target *target = exe_scope->CalculateTarget().get();
if (target) {
const auto &images(target->GetImages());
SymbolContext null_sc;
ConstString cs_key(key);
llvm::DenseSet<SymbolFile *> searched_sym_files;
TypeList matches;
images.FindTypes(null_sc, cs_key, false, UINT32_MAX, searched_sym_files,
images.FindTypes(nullptr, cs_key, false, UINT32_MAX, searched_sym_files,
matches);
for (const auto &match : matches.Types()) {
if (match.get()) {

View File

@ -108,14 +108,13 @@ ObjCLanguageRuntime::LookupInCompleteClassCache(ConstString &name) {
if (!module_sp)
return TypeSP();
const SymbolContext null_sc;
const bool exact_match = true;
const uint32_t max_matches = UINT32_MAX;
TypeList types;
llvm::DenseSet<SymbolFile *> searched_symbol_files;
const uint32_t num_types = module_sp->FindTypes(
null_sc, name, exact_match, max_matches, searched_symbol_files, types);
name, exact_match, max_matches, searched_symbol_files, types);
if (num_types) {
uint32_t i;

View File

@ -459,10 +459,9 @@ Error opts::symbols::findTypes(lldb_private::Module &Module) {
CompilerDeclContext *ContextPtr =
ContextOr->IsValid() ? &*ContextOr : nullptr;
SymbolContext SC;
DenseSet<SymbolFile *> SearchedFiles;
TypeMap Map;
Vendor.FindTypes(SC, ConstString(Name), ContextPtr, true, UINT32_MAX,
Vendor.FindTypes(ConstString(Name), ContextPtr, true, UINT32_MAX,
SearchedFiles, Map);
outs() << formatv("Found {0} types:\n", Map.GetSize());

View File

@ -366,10 +366,9 @@ TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) {
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("Class"), nullptr, false, 0,
EXPECT_EQ(1u, symfile->FindTypes(ConstString("Class"), nullptr, false, 0,
searched_files, results));
EXPECT_EQ(1u, results.GetSize());
lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
@ -389,7 +388,6 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
@ -397,7 +395,7 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
symfile->GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus));
EXPECT_NE(nullptr, clang_ast_ctx);
EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("Class"), nullptr, false, 0,
EXPECT_EQ(1u, symfile->FindTypes(ConstString("Class"), nullptr, false, 0,
searched_files, results));
EXPECT_EQ(1u, results.GetSize());
@ -416,7 +414,7 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
// compiler type for both, but `FindTypes` may return more than one type
// (with the same compiler type) because the symbols have different IDs.
auto ClassCompilerDeclCtx = CompilerDeclContext(clang_ast_ctx, ClassDeclCtx);
EXPECT_LE(1u, symfile->FindTypes(sc, ConstString("NestedClass"),
EXPECT_LE(1u, symfile->FindTypes(ConstString("NestedClass"),
&ClassCompilerDeclCtx, false, 0,
searched_files, results));
EXPECT_LE(1u, results.GetSize());
@ -459,9 +457,8 @@ TEST_F(SymbolFilePDBTests, TestClassInNamespace) {
auto ns_namespace = symfile->FindNamespace(ConstString("NS"), nullptr);
EXPECT_TRUE(ns_namespace.IsValid());
SymbolContext sc;
EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString("NSClass"), &ns_namespace,
false, 0, searched_files, results));
EXPECT_EQ(1u, symfile->FindTypes(ConstString("NSClass"), &ns_namespace, false,
0, searched_files, results));
EXPECT_EQ(1u, results.GetSize());
lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
@ -483,12 +480,11 @@ TEST_F(SymbolFilePDBTests, TestEnumTypes) {
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
const char *EnumsToCheck[] = {"Enum", "ShortEnum"};
for (auto Enum : EnumsToCheck) {
TypeMap results;
EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Enum), nullptr, false, 0,
EXPECT_EQ(1u, symfile->FindTypes(ConstString(Enum), nullptr, false, 0,
searched_files, results));
EXPECT_EQ(1u, results.GetSize());
lldb::TypeSP enum_type = results.GetTypeAtIndex(0);
@ -530,7 +526,6 @@ TEST_F(SymbolFilePDBTests, TestTypedefs) {
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
@ -539,8 +534,8 @@ TEST_F(SymbolFilePDBTests, TestTypedefs) {
"VariadicFuncPointerTypedef"};
for (auto Typedef : TypedefsToCheck) {
TypeMap results;
EXPECT_EQ(1u, symfile->FindTypes(sc, ConstString(Typedef), nullptr, false,
0, searched_files, results));
EXPECT_EQ(1u, symfile->FindTypes(ConstString(Typedef), nullptr, false, 0,
searched_files, results));
EXPECT_EQ(1u, results.GetSize());
lldb::TypeSP typedef_type = results.GetTypeAtIndex(0);
EXPECT_EQ(ConstString(Typedef), typedef_type->GetName());
@ -584,12 +579,11 @@ TEST_F(SymbolFilePDBTests, TestMaxMatches) {
SymbolVendor *plugin = module->GetSymbolVendor();
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
const ConstString name("ClassTypedef");
uint32_t num_results =
symfile->FindTypes(sc, name, nullptr, false, 0, searched_files, results);
symfile->FindTypes(name, nullptr, false, 0, searched_files, results);
// Try to limit ourselves from 1 to 10 results, otherwise we could be doing
// this thousands of times.
// The idea is just to make sure that for a variety of values, the number of
@ -597,8 +591,8 @@ TEST_F(SymbolFilePDBTests, TestMaxMatches) {
// comes out to the number we are expecting.
uint32_t iterations = std::min(num_results, 10u);
for (uint32_t i = 1; i <= iterations; ++i) {
uint32_t num_limited_results = symfile->FindTypes(
sc, name, nullptr, false, i, searched_files, results);
uint32_t num_limited_results =
symfile->FindTypes(name, nullptr, false, i, searched_files, results);
EXPECT_EQ(i, num_limited_results);
EXPECT_EQ(num_limited_results, results.GetSize());
}
@ -612,11 +606,10 @@ TEST_F(SymbolFilePDBTests, TestNullName) {
SymbolVendor *plugin = module->GetSymbolVendor();
SymbolFilePDB *symfile =
static_cast<SymbolFilePDB *>(plugin->GetSymbolFile());
SymbolContext sc;
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
uint32_t num_results = symfile->FindTypes(sc, ConstString(), nullptr, false,
0, searched_files, results);
uint32_t num_results = symfile->FindTypes(ConstString(), nullptr, false, 0,
searched_files, results);
EXPECT_EQ(0u, num_results);
EXPECT_EQ(0u, results.GetSize());
}