/// \param[out] type_list
/// A type list gets populated with any matches.
///
- /// \return
- /// The number of matches added to \a type_list.
- size_t
+ void
FindTypes(ConstString type_name, bool exact_match, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeList &types);
/// This behaves like the other FindTypes method but allows to
/// specify a DeclContext and a language for the type being searched
/// for.
- size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, TypeMap &types);
+ void FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
+ TypeMap &types);
lldb::TypeSP FindFirstType(const SymbolContext &sc,
ConstString type_name, bool exact_match);
/// \param[out] type_list
/// A type list gets populated with any matches.
///
- /// \return
- /// The number of matches added to \a type_list.
- size_t FindTypesInNamespace(ConstString type_name,
- const CompilerDeclContext *parent_decl_ctx,
- size_t max_matches, TypeList &type_list);
+ void FindTypesInNamespace(ConstString type_name,
+ const CompilerDeclContext *parent_decl_ctx,
+ size_t max_matches, TypeList &type_list);
/// Get const accessor for the module architecture.
///
private:
Module(); // Only used internally by CreateJITModule ()
- size_t FindTypes_Impl(
+ void FindTypes_Impl(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
/// \param[out] type_list
/// A type list gets populated with any matches.
///
- /// \return
- /// The number of matches added to \a type_list.
- size_t FindTypes(Module *search_first, ConstString name,
- bool name_is_fully_qualified, size_t max_matches,
- llvm::DenseSet<SymbolFile *> &searched_symbol_files,
- TypeList &types) const;
+ void FindTypes(Module *search_first, ConstString name,
+ bool name_is_fully_qualified, size_t max_matches,
+ llvm::DenseSet<SymbolFile *> &searched_symbol_files,
+ TypeList &types) const;
bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const;
virtual uint32_t FindFunctions(const RegularExpression ®ex,
bool include_inlines, bool append,
SymbolContextList &sc_list);
- virtual uint32_t
+ virtual void
FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
/// Find types specified by a CompilerContextPattern.
/// \param languages Only return results in these languages.
- virtual size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
+ virtual void FindTypes(llvm::ArrayRef<CompilerContext> pattern,
LanguageSet languages, TypeMap &types);
virtual void
GetMangledNamesForFunction(const std::string &scope_qualified_name,
std::vector<ConstString> &mangled_names);
- virtual size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
- lldb::TypeClass type_mask,
- lldb_private::TypeList &type_list) = 0;
+ virtual void GetTypes(lldb_private::SymbolContextScope *sc_scope,
+ lldb::TypeClass type_mask,
+ lldb_private::TypeList &type_list) = 0;
virtual void PreloadSymbols();
void Dump(Stream *s, bool show_context);
- // lldb::TypeSP
- // FindType(lldb::user_id_t uid);
-
TypeList FindTypes(ConstString name);
void Insert(const lldb::TypeSP &type);
uint32_t GetSize() const;
+ bool Empty() const { return !GetSize(); }
+
lldb::TypeSP GetTypeAtIndex(uint32_t idx);
typedef std::vector<lldb::TypeSP> collection;
const bool exact_match = false;
ConstString name(type);
llvm::DenseSet<SymbolFile *> searched_symbol_files;
- const uint32_t num_matches = module_sp->FindTypes(
- name, exact_match, UINT32_MAX, searched_symbol_files, type_list);
+ module_sp->FindTypes(name, exact_match, UINT32_MAX, searched_symbol_files,
+ type_list);
- if (num_matches > 0) {
- for (size_t idx = 0; idx < num_matches; idx++) {
- TypeSP type_sp(type_list.GetTypeAtIndex(idx));
- if (type_sp)
- retval.Append(SBType(type_sp));
- }
- } else {
+ if (type_list.Empty()) {
auto type_system_or_err =
module_sp->GetTypeSystemForLanguage(eLanguageTypeC);
if (auto err = type_system_or_err.takeError()) {
if (compiler_type)
retval.Append(SBType(compiler_type));
}
+ } else {
+ for (size_t idx = 0; idx < type_list.GetSize(); idx++) {
+ TypeSP type_sp(type_list.GetTypeAtIndex(idx));
+ if (type_sp)
+ retval.Append(SBType(type_sp));
+ }
}
}
-
return LLDB_RECORD_RESULT(retval);
}
bool exact_match = false;
TypeList type_list;
llvm::DenseSet<SymbolFile *> searched_symbol_files;
- uint32_t num_matches =
- images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
- searched_symbol_files, type_list);
+ images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX,
+ searched_symbol_files, type_list);
- if (num_matches > 0) {
- for (size_t idx = 0; idx < num_matches; idx++) {
- TypeSP type_sp(type_list.GetTypeAtIndex(idx));
- if (type_sp)
- sb_type_list.Append(SBType(type_sp));
- }
+ for (size_t idx = 0; idx < type_list.GetSize(); idx++) {
+ TypeSP type_sp(type_list.GetTypeAtIndex(idx));
+ if (type_sp)
+ sb_type_list.Append(SBType(type_sp));
}
// Try the loaded language runtimes
static size_t LookupTypeInModule(CommandInterpreter &interpreter, Stream &strm,
Module *module, const char *name_cstr,
bool name_is_regex) {
+ TypeList type_list;
if (module && name_cstr && name_cstr[0]) {
- TypeList type_list;
const uint32_t max_num_matches = UINT32_MAX;
size_t num_matches = 0;
bool name_is_fully_qualified = false;
ConstString name(name_cstr);
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
- num_matches =
- module->FindTypes(name, name_is_fully_qualified, max_num_matches,
- searched_symbol_files, type_list);
-
- if (num_matches) {
- strm.Indent();
- strm.Printf("%" PRIu64 " match%s found in ", (uint64_t)num_matches,
- num_matches > 1 ? "es" : "");
- DumpFullpath(strm, &module->GetFileSpec(), 0);
- strm.PutCString(":\n");
- for (TypeSP type_sp : type_list.Types()) {
- if (type_sp) {
- // Resolve the clang type so that any forward references to types
- // that haven't yet been parsed will get parsed.
- type_sp->GetFullCompilerType();
- type_sp->GetDescription(&strm, eDescriptionLevelFull, true);
- // Print all typedef chains
- TypeSP typedef_type_sp(type_sp);
- TypeSP typedefed_type_sp(typedef_type_sp->GetTypedefType());
- while (typedefed_type_sp) {
- strm.EOL();
- strm.Printf(" typedef '%s': ",
- typedef_type_sp->GetName().GetCString());
- typedefed_type_sp->GetFullCompilerType();
- typedefed_type_sp->GetDescription(&strm, eDescriptionLevelFull,
- true);
- typedef_type_sp = typedefed_type_sp;
- typedefed_type_sp = typedef_type_sp->GetTypedefType();
- }
- }
- strm.EOL();
- }
- }
- return num_matches;
- }
- return 0;
-}
+ module->FindTypes(name, name_is_fully_qualified, max_num_matches,
+ searched_symbol_files, type_list);
-static size_t LookupTypeHere(CommandInterpreter &interpreter, Stream &strm,
- 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;
- bool name_is_fully_qualified = false;
+ if (type_list.Empty())
+ return 0;
- ConstString name(name_cstr);
- llvm::DenseSet<SymbolFile *> searched_symbol_files;
- 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, &module.GetFileSpec(), 0);
+ strm.Printf("%" PRIu64 " match%s found in ", (uint64_t)num_matches,
+ num_matches > 1 ? "es" : "");
+ DumpFullpath(strm, &module->GetFileSpec(), 0);
strm.PutCString(":\n");
-
- TypeSP type_sp(type_list.GetTypeAtIndex(0));
- if (type_sp) {
- // Resolve the clang type so that any forward references to types that
- // haven't yet been parsed will get parsed.
+ for (TypeSP type_sp : type_list.Types()) {
+ if (!type_sp)
+ continue;
+ // Resolve the clang type so that any forward references to types
+ // that haven't yet been parsed will get parsed.
type_sp->GetFullCompilerType();
type_sp->GetDescription(&strm, eDescriptionLevelFull, true);
// Print all typedef chains
}
strm.EOL();
}
- return num_matches;
+ return type_list.GetSize();
+}
+
+static size_t LookupTypeHere(CommandInterpreter &interpreter, Stream &strm,
+ Module &module, const char *name_cstr,
+ bool name_is_regex) {
+ TypeList type_list;
+ const uint32_t max_num_matches = UINT32_MAX;
+ bool name_is_fully_qualified = false;
+
+ ConstString name(name_cstr);
+ llvm::DenseSet<SymbolFile *> searched_symbol_files;
+ module.FindTypes(name, name_is_fully_qualified, max_num_matches,
+ searched_symbol_files, type_list);
+
+ if (type_list.Empty())
+ return 0;
+
+ strm.Indent();
+ strm.PutCString("Best match found in ");
+ DumpFullpath(strm, &module.GetFileSpec(), 0);
+ strm.PutCString(":\n");
+
+ TypeSP type_sp(type_list.GetTypeAtIndex(0));
+ if (type_sp) {
+ // Resolve the clang type so that any forward references to types that
+ // haven't yet been parsed will get parsed.
+ type_sp->GetFullCompilerType();
+ type_sp->GetDescription(&strm, eDescriptionLevelFull, true);
+ // Print all typedef chains
+ TypeSP typedef_type_sp(type_sp);
+ TypeSP typedefed_type_sp(typedef_type_sp->GetTypedefType());
+ while (typedefed_type_sp) {
+ strm.EOL();
+ strm.Printf(" typedef '%s': ",
+ typedef_type_sp->GetName().GetCString());
+ typedefed_type_sp->GetFullCompilerType();
+ typedefed_type_sp->GetDescription(&strm, eDescriptionLevelFull, true);
+ typedef_type_sp = typedefed_type_sp;
+ typedefed_type_sp = typedef_type_sp->GetTypedefType();
+ }
+ }
+ strm.EOL();
+ return type_list.GetSize();
}
static uint32_t LookupFileAndLineInModule(CommandInterpreter &interpreter,
}
}
-size_t Module::FindTypes_Impl(
+void Module::FindTypes_Impl(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
if (SymbolFile *symbols = GetSymbolFile())
- return symbols->FindTypes(name, parent_decl_ctx, max_matches,
- searched_symbol_files, types);
- return 0;
+ symbols->FindTypes(name, parent_decl_ctx, max_matches,
+ searched_symbol_files, types);
}
-size_t Module::FindTypesInNamespace(ConstString type_name,
- const CompilerDeclContext *parent_decl_ctx,
- size_t max_matches, TypeList &type_list) {
+void Module::FindTypesInNamespace(ConstString type_name,
+ const CompilerDeclContext *parent_decl_ctx,
+ size_t max_matches, TypeList &type_list) {
TypeMap types_map;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
- size_t num_types = FindTypes_Impl(type_name, parent_decl_ctx, max_matches,
- searched_symbol_files, types_map);
- if (num_types > 0) {
+ FindTypes_Impl(type_name, parent_decl_ctx, max_matches, searched_symbol_files,
+ types_map);
+ if (types_map.GetSize()) {
SymbolContext sc;
sc.module_sp = shared_from_this();
sc.SortTypeList(types_map, type_list);
}
- return num_types;
}
lldb::TypeSP Module::FindFirstType(const SymbolContext &sc,
ConstString name, bool exact_match) {
TypeList type_list;
llvm::DenseSet<lldb_private::SymbolFile *> searched_symbol_files;
- const size_t num_matches =
- FindTypes(name, exact_match, 1, searched_symbol_files, type_list);
- if (num_matches)
+ FindTypes(name, exact_match, 1, searched_symbol_files, type_list);
+ if (type_list.GetSize())
return type_list.GetTypeAtIndex(0);
return TypeSP();
}
-size_t Module::FindTypes(
+void Module::FindTypes(
ConstString name, bool exact_match, size_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeList &types) {
- size_t num_matches = 0;
const char *type_name_cstr = name.GetCString();
llvm::StringRef type_scope;
llvm::StringRef type_basename;
exact_match = type_scope.consume_front("::");
ConstString type_basename_const_str(type_basename);
- if (FindTypes_Impl(type_basename_const_str, nullptr, max_matches,
- searched_symbol_files, typesmap)) {
+ FindTypes_Impl(type_basename_const_str, nullptr, max_matches,
+ searched_symbol_files, typesmap);
+ if (typesmap.GetSize())
typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
- num_matches = typesmap.GetSize();
- }
} else {
// The type is not in a namespace/class scope, just search for it by
// basename
searched_symbol_files, typesmap);
typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
- num_matches = typesmap.GetSize();
} else {
- num_matches = FindTypes_Impl(name, nullptr, UINT_MAX,
- searched_symbol_files, typesmap);
+ FindTypes_Impl(name, nullptr, UINT_MAX, searched_symbol_files, typesmap);
if (exact_match) {
std::string name_str(name.AsCString(""));
typesmap.RemoveMismatchedTypes(type_scope, name_str, type_class,
exact_match);
- num_matches = typesmap.GetSize();
}
}
}
- if (num_matches > 0) {
+ if (typesmap.GetSize()) {
SymbolContext sc;
sc.module_sp = shared_from_this();
sc.SortTypeList(typesmap, types);
}
- return num_matches;
}
-size_t Module::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, TypeMap &types) {
+void Module::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
+ LanguageSet languages, TypeMap &types) {
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat, LLVM_PRETTY_FUNCTION);
if (SymbolFile *symbols = GetSymbolFile())
- return symbols->FindTypes(pattern, languages, types);
- return 0;
+ symbols->FindTypes(pattern, languages, types);
}
SymbolFile *Module::GetSymbolFile(bool can_create, Stream *feedback_strm) {
#include "lldb/Symbol/LocateSymbolFile.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/SymbolContext.h"
+#include "lldb/Symbol/TypeList.h"
#include "lldb/Symbol/VariableList.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/ConstString.h"
namespace lldb_private {
class Target;
}
-namespace lldb_private {
-class TypeList;
-}
using namespace lldb;
using namespace lldb_private;
return module_sp;
}
-size_t
-ModuleList::FindTypes(Module *search_first, ConstString name,
- bool name_is_fully_qualified, size_t max_matches,
- llvm::DenseSet<SymbolFile *> &searched_symbol_files,
- TypeList &types) const {
+void ModuleList::FindTypes(Module *search_first, ConstString name,
+ bool name_is_fully_qualified, size_t max_matches,
+ llvm::DenseSet<SymbolFile *> &searched_symbol_files,
+ TypeList &types) const {
std::lock_guard<std::recursive_mutex> guard(m_modules_mutex);
- size_t total_matches = 0;
collection::const_iterator pos, end = m_modules.end();
if (search_first) {
for (pos = m_modules.begin(); pos != end; ++pos) {
if (search_first == pos->get()) {
- total_matches +=
- search_first->FindTypes(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;
+ if (types.GetSize() >= max_matches)
+ return;
}
}
}
- if (total_matches < max_matches) {
- 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 (search_first != pos->get())
- total_matches +=
- (*pos)->FindTypes(name, name_is_fully_qualified, max_matches,
- searched_symbol_files, types);
-
- if (total_matches >= max_matches)
- break;
- }
+ 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 (search_first != pos->get())
+ (*pos)->FindTypes(name, name_is_fully_qualified, max_matches,
+ searched_symbol_files, types);
+
+ if (types.GetSize() >= max_matches)
+ return;
}
-
- return total_matches;
}
bool ModuleList::FindSourceFile(const FileSpec &orig_spec,
const bool exact_match = true;
TypeList class_types;
- uint32_t num_matches = 0;
// First look in the module that the vtable symbol came from and
// look for a single exact match.
llvm::DenseSet<SymbolFile *> searched_symbol_files;
- if (sc.module_sp) {
- num_matches = sc.module_sp->FindTypes(
- ConstString(lookup_name), exact_match, 1,
- searched_symbol_files, class_types);
- }
+ if (sc.module_sp)
+ sc.module_sp->FindTypes(ConstString(lookup_name), exact_match, 1,
+ searched_symbol_files, class_types);
// If we didn't find a symbol, then move on to the entire module
// list in the target and get as many unique matches as possible
- if (num_matches == 0) {
- num_matches = target.GetImages().FindTypes(
- nullptr, ConstString(lookup_name), exact_match, UINT32_MAX,
- searched_symbol_files, class_types);
- }
+ if (class_types.Empty())
+ target.GetImages().FindTypes(nullptr, ConstString(lookup_name),
+ exact_match, UINT32_MAX,
+ searched_symbol_files, class_types);
lldb::TypeSP type_sp;
- if (num_matches == 0) {
+ if (class_types.Empty()) {
LLDB_LOGF(log, "0x%16.16" PRIx64 ": is not dynamic\n",
original_ptr);
return TypeAndOrName();
}
- if (num_matches == 1) {
+ if (class_types.GetSize() == 1) {
type_sp = class_types.GetTypeAtIndex(0);
if (type_sp) {
if (ClangASTContext::IsCXXClassType(
type_info.SetTypeSP(type_sp);
}
}
- } else if (num_matches > 1) {
+ } else {
size_t i;
if (log) {
- for (i = 0; i < num_matches; i++) {
+ for (i = 0; i < class_types.GetSize(); i++) {
type_sp = class_types.GetTypeAtIndex(i);
if (type_sp) {
LLDB_LOGF(
}
}
- for (i = 0; i < num_matches; i++) {
+ for (i = 0; i < class_types.GetSize(); i++) {
type_sp = class_types.GetTypeAtIndex(i);
if (type_sp) {
if (ClangASTContext::IsCXXClassType(
}
}
- if (log && i == num_matches) {
+ if (log) {
LLDB_LOGF(log,
"0x%16.16" PRIx64
": static-type = '%s' has multiple matching dynamic "
TypeList types;
llvm::DenseSet<SymbolFile *> searched_symbol_files;
- const uint32_t num_types = module_sp->FindTypes(
- name, exact_match, max_matches, searched_symbol_files, types);
-
- if (num_types) {
- uint32_t i;
- for (i = 0; i < num_types; ++i) {
- TypeSP type_sp(types.GetTypeAtIndex(i));
-
- if (ClangASTContext::IsObjCObjectOrInterfaceType(
- type_sp->GetForwardCompilerType())) {
- if (type_sp->IsCompleteObjCClass()) {
- m_complete_class_cache[name] = type_sp;
- return type_sp;
- }
+ module_sp->FindTypes(name, exact_match, max_matches, searched_symbol_files,
+ types);
+
+ for (uint32_t i = 0; i < types.GetSize(); ++i) {
+ TypeSP type_sp(types.GetTypeAtIndex(i));
+
+ if (ClangASTContext::IsObjCObjectOrInterfaceType(
+ type_sp->GetForwardCompilerType())) {
+ if (type_sp->IsCompleteObjCClass()) {
+ m_complete_class_cache[name] = type_sp;
+ return type_sp;
}
}
}
return sc_list.GetSize();
}
-uint32_t SymbolFileBreakpad::FindTypes(
+void SymbolFileBreakpad::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
- TypeMap &types) {
- return 0;
-}
+ TypeMap &types) {}
-size_t SymbolFileBreakpad::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, TypeMap &types) {
- return 0;
-}
+void SymbolFileBreakpad::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
+ LanguageSet languages, TypeMap &types) {}
void SymbolFileBreakpad::AddSymbols(Symtab &symtab) {
Log *log = GetLogIfAllCategoriesSet(LIBLLDB_LOG_SYMBOLS);
lldb::SymbolContextItem resolve_scope,
SymbolContextList &sc_list) override;
- size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
- TypeList &type_list) override {
- return 0;
- }
+ void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
+ TypeList &type_list) override {}
uint32_t FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t FindFunctions(const RegularExpression ®ex, bool include_inlines,
bool append, SymbolContextList &sc_list) override;
- uint32_t FindTypes(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- uint32_t max_matches,
- llvm::DenseSet<SymbolFile *> &searched_symbol_files,
- TypeMap &types) override;
+ void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ uint32_t max_matches,
+ llvm::DenseSet<SymbolFile *> &searched_symbol_files,
+ TypeMap &types) override;
- size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, TypeMap &types) override;
+ void FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
+ TypeMap &types) override;
llvm::Expected<TypeSystem &>
GetTypeSystemForLanguage(lldb::LanguageType language) override {
// The type in the Clang module must have the same langage as the current CU.
LanguageSet languages;
languages.Insert(die.GetCU()->GetLanguageType());
- if (!dwo_module_sp->GetSymbolFile()->FindTypes(decl_context, languages,
- dwo_types)) {
+ dwo_module_sp->GetSymbolFile()->FindTypes(decl_context, languages, dwo_types);
+ if (dwo_types.GetSize()) {
if (!IsClangModuleFwdDecl(die))
return TypeSP();
for (const auto &name_module : sym_file.getExternalTypeModules()) {
if (!name_module.second)
continue;
- if (name_module.second->GetSymbolFile()->FindTypes(decl_context,
- languages, dwo_types))
+ name_module.second->GetSymbolFile()->FindTypes(decl_context,
+ languages, dwo_types);
+ if (dwo_types.GetSize())
break;
}
}
}
}
-size_t SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope,
- TypeClass type_mask, TypeList &type_list)
+void SymbolFileDWARF::GetTypes(SymbolContextScope *sc_scope,
+ TypeClass type_mask, TypeList &type_list)
{
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (comp_unit) {
dwarf_cu = GetDWARFCompileUnit(comp_unit);
- if (dwarf_cu == nullptr)
- return 0;
+ if (!dwarf_cu)
+ return;
GetTypes(dwarf_cu->DIE(), dwarf_cu->GetOffset(),
dwarf_cu->GetNextUnitOffset(), type_mask, type_set);
} else {
}
std::set<CompilerType> compiler_type_set;
- size_t num_types_added = 0;
for (Type *type : type_set) {
CompilerType compiler_type = type->GetForwardCompilerType();
if (compiler_type_set.find(compiler_type) == compiler_type_set.end()) {
compiler_type_set.insert(compiler_type);
type_list.Insert(type->shared_from_this());
- ++num_types_added;
}
}
- return num_types_added;
}
// Gets the first parent that is a lexical block, function or inlined
}
}
-uint32_t SymbolFileDWARF::FindTypes(
+void SymbolFileDWARF::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
// Make sure we haven't already searched this SymbolFile before...
if (searched_symbol_files.count(this))
- return 0;
- else
- searched_symbol_files.insert(this);
+ return;
+
+ searched_symbol_files.insert(this);
DWARFDebugInfo *info = DebugInfo();
- if (info == nullptr)
- return 0;
+ if (!info)
+ return;
Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
}
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
- return 0;
+ return;
DIEArray die_offsets;
m_index->GetTypes(name, die_offsets);
const size_t num_die_matches = die_offsets.size();
- const uint32_t initial_types_size = types.GetSize();
for (size_t i = 0; i < num_die_matches; ++i) {
const DIERef &die_ref = die_offsets[i];
searched_symbol_files, types);
}
- uint32_t num_matches = types.GetSize() - initial_types_size;
- if (log && num_matches) {
+ if (log && types.GetSize()) {
if (parent_decl_ctx) {
GetObjectFile()->GetModule()->LogMessage(
log,
"= %p (\"%s\"), max_matches=%u, type_list) => %u",
name.GetCString(), static_cast<const void *>(parent_decl_ctx),
parent_decl_ctx->GetName().AsCString("<NULL>"), max_matches,
- num_matches);
+ types.GetSize());
} else {
GetObjectFile()->GetModule()->LogMessage(
log,
"SymbolFileDWARF::FindTypes (sc, name=\"%s\", parent_decl_ctx "
"= NULL, max_matches=%u, type_list) => %u",
- name.GetCString(), max_matches, num_matches);
+ name.GetCString(), max_matches, types.GetSize());
}
}
-
- return num_matches;
}
-size_t SymbolFileDWARF::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
+void SymbolFileDWARF::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
LanguageSet languages, TypeMap &types) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (pattern.empty())
- return 0;
+ return;
ConstString name = pattern.back().name;
if (!name)
- return 0;
+ return;
DIEArray die_offsets;
m_index->GetTypes(name, die_offsets);
const size_t num_die_matches = die_offsets.size();
- size_t num_matches = 0;
for (size_t i = 0; i < num_die_matches; ++i) {
const DIERef &die_ref = die_offsets[i];
DWARFDIE die = GetDIE(die_ref);
- if (die) {
- if (!languages[die.GetCU()->GetLanguageType()])
- continue;
-
- llvm::SmallVector<CompilerContext, 4> die_context;
- die.GetDeclContext(die_context);
- if (!contextMatches(die_context, pattern))
- continue;
-
- Type *matching_type = ResolveType(die, true, true);
- if (matching_type) {
- // We found a type pointer, now find the shared pointer form our type
- // list
- types.InsertUnique(matching_type->shared_from_this());
- ++num_matches;
- }
- } else {
+ if (!die) {
m_index->ReportInvalidDIERef(die_ref, name.GetStringRef());
+ continue;
}
+ if (!languages[die.GetCU()->GetLanguageType()])
+ continue;
+
+ llvm::SmallVector<CompilerContext, 4> die_context;
+ die.GetDeclContext(die_context);
+ if (!contextMatches(die_context, pattern))
+ continue;
+
+ if (Type *matching_type = ResolveType(die, true, true))
+ // We found a type pointer, now find the shared pointer form our type
+ // list.
+ types.InsertUnique(matching_type->shared_from_this());
}
- return num_matches;
}
CompilerDeclContext
const std::string &scope_qualified_name,
std::vector<lldb_private::ConstString> &mangled_names) override;
- uint32_t
+ void
FindTypes(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) override;
- size_t FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern,
- lldb_private::LanguageSet languages,
- lldb_private::TypeMap &types) override;
+ void FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern,
+ lldb_private::LanguageSet languages,
+ lldb_private::TypeMap &types) override;
- size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
- lldb::TypeClass type_mask,
- lldb_private::TypeList &type_list) override;
+ void GetTypes(lldb_private::SymbolContextScope *sc_scope,
+ lldb::TypeClass type_mask,
+ lldb_private::TypeList &type_list) override;
llvm::Expected<lldb_private::TypeSystem &>
GetTypeSystemForLanguage(lldb::LanguageType language) override;
return sc_list.GetSize() - initial_size;
}
-size_t SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope,
- lldb::TypeClass type_mask,
- TypeList &type_list) {
+void SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope,
+ lldb::TypeClass type_mask,
+ TypeList &type_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
static Timer::Category func_cat(LLVM_PRETTY_FUNCTION);
Timer scoped_timer(func_cat,
"SymbolFileDWARFDebugMap::GetTypes (type_mask = 0x%8.8x)",
type_mask);
- uint32_t initial_size = type_list.GetSize();
SymbolFileDWARF *oso_dwarf = nullptr;
if (sc_scope) {
SymbolContext sc;
return false;
});
}
- return type_list.GetSize() - initial_size;
}
std::vector<lldb_private::CallEdge>
return TypeSP();
}
-uint32_t SymbolFileDWARFDebugMap::FindTypes(
+void SymbolFileDWARFDebugMap::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
TypeMap &types) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
- const uint32_t initial_types_size = types.GetSize();
-
ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
oso_dwarf->FindTypes(name, parent_decl_ctx, max_matches,
searched_symbol_files, types);
return types.GetSize() >= max_matches;
});
-
- return types.GetSize() - initial_types_size;
}
//
uint32_t FindFunctions(const lldb_private::RegularExpression ®ex,
bool include_inlines, bool append,
lldb_private::SymbolContextList &sc_list) override;
- uint32_t
+ void
FindTypes(lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
lldb_private::CompilerDeclContext FindNamespace(
lldb_private::ConstString name,
const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
- size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
- lldb::TypeClass type_mask,
- lldb_private::TypeList &type_list) override;
+ void GetTypes(lldb_private::SymbolContextScope *sc_scope,
+ lldb::TypeClass type_mask,
+ lldb_private::TypeList &type_list) override;
std::vector<lldb_private::CallEdge>
ParseCallEdgesInFunction(lldb_private::UserID func_id) override;
return 0;
}
-uint32_t SymbolFileNativePDB::FindTypes(
+void SymbolFileNativePDB::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
- uint32_t max_matches,
- llvm::DenseSet<SymbolFile *> &searched_symbol_files, TypeMap &types) {
+ uint32_t max_matches, llvm::DenseSet<SymbolFile *> &searched_symbol_files,
+ TypeMap &types) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!name)
- return 0;
+ return;
searched_symbol_files.clear();
searched_symbol_files.insert(this);
// There is an assumption 'name' is not a regex
- size_t match_count = FindTypesByName(name.GetStringRef(), max_matches, types);
-
- return match_count;
+ FindTypesByName(name.GetStringRef(), max_matches, types);
}
-size_t SymbolFileNativePDB::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, TypeMap &types) {
- return 0;
-}
+void SymbolFileNativePDB::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
+ LanguageSet languages, TypeMap &types) {}
-size_t SymbolFileNativePDB::FindTypesByName(llvm::StringRef name,
- uint32_t max_matches,
- TypeMap &types) {
+void SymbolFileNativePDB::FindTypesByName(llvm::StringRef name,
+ uint32_t max_matches,
+ TypeMap &types) {
- size_t match_count = 0;
std::vector<TypeIndex> matches = m_index->tpi().findRecordsByName(name);
if (max_matches > 0 && max_matches < matches.size())
matches.resize(max_matches);
continue;
types.Insert(type);
- ++match_count;
}
- return match_count;
}
size_t SymbolFileNativePDB::ParseTypes(CompileUnit &comp_unit) {
return m_ast->CompleteType(qt);
}
-size_t SymbolFileNativePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope,
- TypeClass type_mask,
- lldb_private::TypeList &type_list) {
- return 0;
-}
+void SymbolFileNativePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope,
+ TypeClass type_mask,
+ lldb_private::TypeList &type_list) {}
CompilerDeclContext
SymbolFileNativePDB::FindNamespace(ConstString name,
lldb::SymbolContextItem resolve_scope,
SymbolContextList &sc_list) override;
- size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
- TypeList &type_list) override;
+ void GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask,
+ TypeList &type_list) override;
uint32_t FindFunctions(ConstString name,
const CompilerDeclContext *parent_decl_ctx,
uint32_t FindFunctions(const RegularExpression ®ex, bool include_inlines,
bool append, SymbolContextList &sc_list) override;
- uint32_t FindTypes(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
- uint32_t max_matches,
- llvm::DenseSet<SymbolFile *> &searched_symbol_files,
- TypeMap &types) override;
+ void FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
+ uint32_t max_matches,
+ llvm::DenseSet<SymbolFile *> &searched_symbol_files,
+ TypeMap &types) override;
- size_t FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, TypeMap &types) override;
+ void FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
+ TypeMap &types) override;
llvm::Expected<TypeSystem &>
GetTypeSystemForLanguage(lldb::LanguageType language) override;
lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t index) override;
- size_t FindTypesByName(llvm::StringRef name, uint32_t max_matches,
- TypeMap &types);
+ void FindTypesByName(llvm::StringRef name, uint32_t max_matches,
+ TypeMap &types);
lldb::TypeSP CreateModifierType(PdbTypeSymId type_id,
const llvm::codeview::ModifierRecord &mr,
return new SymbolFileSymtab(std::move(objfile_sp));
}
-size_t SymbolFileSymtab::GetTypes(SymbolContextScope *sc_scope,
- TypeClass type_mask,
- lldb_private::TypeList &type_list) {
- return 0;
-}
+void SymbolFileSymtab::GetTypes(SymbolContextScope *sc_scope,
+ TypeClass type_mask,
+ lldb_private::TypeList &type_list) {}
SymbolFileSymtab::SymbolFileSymtab(ObjectFileSP objfile_sp)
: SymbolFile(std::move(objfile_sp)), m_source_indexes(), m_func_indexes(),
lldb::SymbolContextItem resolve_scope,
lldb_private::SymbolContext &sc) override;
- size_t GetTypes(lldb_private::SymbolContextScope *sc_scope,
- lldb::TypeClass type_mask,
- lldb_private::TypeList &type_list) override;
+ void GetTypes(lldb_private::SymbolContextScope *sc_scope,
+ lldb::TypeClass type_mask,
+ lldb_private::TypeList &type_list) override;
// PluginInterface protocol
lldb_private::ConstString GetPluginName() override;
return;
}
-uint32_t SymbolFile::FindTypes(
+void SymbolFile::FindTypes(
ConstString name, const CompilerDeclContext *parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
- TypeMap &types) {
- return 0;
-}
+ TypeMap &types) {}
-size_t SymbolFile::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
- LanguageSet languages, TypeMap &types) {
- return 0;
-}
+void SymbolFile::FindTypes(llvm::ArrayRef<CompilerContext> pattern,
+ LanguageSet languages, TypeMap &types) {}
void SymbolFile::AssertModuleLock() {
// The code below is too expensive to leave enabled in release builds. It's
llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
- symfile->FindTypes(ConstString("Class"), nullptr, false, 0, searched_files,
- results);
+ symfile->FindTypes(ConstString("Class"), nullptr, 0, searched_files, results);
EXPECT_EQ(1u, results.GetSize());
lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
EXPECT_EQ(ConstString("Class"), udt_type->GetName());
llvm::dyn_cast_or_null<ClangASTContext>(&clang_ast_ctx_or_err.get());
EXPECT_NE(nullptr, clang_ast_ctx);
- symfile->FindTypes(ConstString("Class"), nullptr, false, 0, searched_files,
- results);
+ symfile->FindTypes(ConstString("Class"), nullptr, 0, searched_files, results);
EXPECT_EQ(1u, results.GetSize());
auto Class = results.GetTypeAtIndex(0);
// 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);
- symfile->FindTypes(ConstString("NestedClass"), &ClassCompilerDeclCtx, false,
- 0, searched_files, results);
+ symfile->FindTypes(ConstString("NestedClass"), &ClassCompilerDeclCtx, 0,
+ searched_files, results);
EXPECT_LE(1u, results.GetSize());
lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
auto ns_namespace = symfile->FindNamespace(ConstString("NS"), nullptr);
EXPECT_TRUE(ns_namespace.IsValid());
- symfile->FindTypes(ConstString("NSClass"), &ns_namespace, false,
- 0, searched_files, results);
+ symfile->FindTypes(ConstString("NSClass"), &ns_namespace, 0, searched_files,
+ results);
EXPECT_EQ(1u, results.GetSize());
lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
const char *EnumsToCheck[] = {"Enum", "ShortEnum"};
for (auto Enum : EnumsToCheck) {
TypeMap results;
- symfile->FindTypes(ConstString(Enum), nullptr, false, 0,
- searched_files, results);
+ symfile->FindTypes(ConstString(Enum), nullptr, 0, searched_files, results);
EXPECT_EQ(1u, results.GetSize());
lldb::TypeSP enum_type = results.GetTypeAtIndex(0);
EXPECT_EQ(ConstString(Enum), enum_type->GetName());
"VariadicFuncPointerTypedef"};
for (auto Typedef : TypedefsToCheck) {
TypeMap results;
- symfile->FindTypes(ConstString(Typedef), nullptr, false, 0,
- searched_files, results);
+ symfile->FindTypes(ConstString(Typedef), nullptr, 0, searched_files,
+ results);
EXPECT_EQ(1u, results.GetSize());
lldb::TypeSP typedef_type = results.GetTypeAtIndex(0);
EXPECT_EQ(ConstString(Typedef), typedef_type->GetName());
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
const ConstString name("ClassTypedef");
- symfile->FindTypes(name, nullptr, false, 0, searched_files, results);
+ symfile->FindTypes(name, nullptr, 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
uint32_t iterations = std::min(results.GetSize(), 10u);
uint32_t num_results = results.GetSize();
for (uint32_t i = 1; i <= iterations; ++i) {
- symfile->FindTypes(name, nullptr, false, i, searched_files, results);
+ symfile->FindTypes(name, nullptr, i, searched_files, results);
uint32_t num_limited_results = results.GetSize() - num_results);
EXPECT_EQ(i, num_limited_results);
EXPECT_EQ(num_limited_results, results.GetSize());
static_cast<SymbolFilePDB *>(module->GetSymbolFile());
llvm::DenseSet<SymbolFile *> searched_files;
TypeMap results;
- symfile->FindTypes(ConstString(), nullptr, false, 0, searched_files, results);
+ symfile->FindTypes(ConstString(), nullptr, 0, searched_files, results);
EXPECT_EQ(0u, results.GetSize());
}