mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 20:10:50 +08:00
Create a new "lldb_private::CompilerDeclContext" class that will replace all direct uses of "clang::DeclContext" when used in compiler agnostic code, yet still allow for conversion to clang::DeclContext subclasses by clang specific code. This completes the abstraction of type parsing by removing all "clang::" references from the SymbolFileDWARF. The new "lldb_private::CompilerDeclContext" class abstracts decl contexts found in compiler type systems so they can be used in internal API calls. The TypeSystem is required to support CompilerDeclContexts with new pure virtual functions that start with "DeclContext" in the member function names. Converted all code that used lldb_private::ClangNamespaceDecl over to use the new CompilerDeclContext class and removed the ClangNamespaceDecl.cpp and ClangNamespaceDecl.h files.
Removed direct use of clang APIs from SBType and now use the abstract type systems to correctly explore types.
Bulk renames for things that used to return a ClangASTType which is now CompilerType:
"Type::GetClangFullType()" to "Type::GetFullCompilerType()"
"Type::GetClangLayoutType()" to "Type::GetLayoutCompilerType()"
"Type::GetClangForwardType()" to "Type::GetForwardCompilerType()"
"Value::GetClangType()" to "Value::GetCompilerType()"
"Value::SetClangType (const CompilerType &)" to "Value::SetCompilerType (const CompilerType &)"
"ValueObject::GetClangType ()" to "ValueObject::GetCompilerType()"
many more renames that are similar.
llvm-svn: 245905
148 lines
4.5 KiB
C++
148 lines
4.5 KiB
C++
//===-- SymbolFile.cpp ------------------------------------------*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "lldb/Symbol/SymbolFile.h"
|
|
|
|
#include "lldb/lldb-private.h"
|
|
#include "lldb/Core/Log.h"
|
|
#include "lldb/Core/Module.h"
|
|
#include "lldb/Core/PluginManager.h"
|
|
#include "lldb/Core/StreamString.h"
|
|
#include "lldb/Symbol/ObjectFile.h"
|
|
#include "lldb/Symbol/TypeList.h"
|
|
#include "lldb/Symbol/VariableList.h"
|
|
|
|
using namespace lldb_private;
|
|
|
|
SymbolFile*
|
|
SymbolFile::FindPlugin (ObjectFile* obj_file)
|
|
{
|
|
std::unique_ptr<SymbolFile> best_symfile_ap;
|
|
if (obj_file != nullptr)
|
|
{
|
|
|
|
// We need to test the abilities of this section list. So create what it would
|
|
// be with this new obj_file.
|
|
lldb::ModuleSP module_sp(obj_file->GetModule());
|
|
if (module_sp)
|
|
{
|
|
// Default to the main module section list.
|
|
ObjectFile *module_obj_file = module_sp->GetObjectFile();
|
|
if (module_obj_file != obj_file)
|
|
{
|
|
// Make sure the main object file's sections are created
|
|
module_obj_file->GetSectionList();
|
|
obj_file->CreateSections (*module_sp->GetUnifiedSectionList());
|
|
}
|
|
}
|
|
|
|
// TODO: Load any plug-ins in the appropriate plug-in search paths and
|
|
// iterate over all of them to find the best one for the job.
|
|
|
|
uint32_t best_symfile_abilities = 0;
|
|
|
|
SymbolFileCreateInstance create_callback;
|
|
for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(idx)) != nullptr; ++idx)
|
|
{
|
|
std::unique_ptr<SymbolFile> curr_symfile_ap(create_callback(obj_file));
|
|
|
|
if (curr_symfile_ap.get())
|
|
{
|
|
const uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities();
|
|
if (sym_file_abilities > best_symfile_abilities)
|
|
{
|
|
best_symfile_abilities = sym_file_abilities;
|
|
best_symfile_ap.reset (curr_symfile_ap.release());
|
|
// If any symbol file parser has all of the abilities, then
|
|
// we should just stop looking.
|
|
if ((kAllAbilities & sym_file_abilities) == kAllAbilities)
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (best_symfile_ap.get())
|
|
{
|
|
// Let the winning symbol file parser initialize itself more
|
|
// completely now that it has been chosen
|
|
best_symfile_ap->InitializeObject();
|
|
}
|
|
}
|
|
return best_symfile_ap.release();
|
|
}
|
|
|
|
TypeList *
|
|
SymbolFile::GetTypeList ()
|
|
{
|
|
if (m_obj_file)
|
|
return m_obj_file->GetModule()->GetTypeList();
|
|
return nullptr;
|
|
}
|
|
|
|
ClangASTContext &
|
|
SymbolFile::GetClangASTContext ()
|
|
{
|
|
return m_obj_file->GetModule()->GetClangASTContext();
|
|
}
|
|
|
|
TypeSystem *
|
|
SymbolFile::GetTypeSystemForLanguage (lldb::LanguageType language)
|
|
{
|
|
return m_obj_file->GetModule()->GetTypeSystemForLanguage (language);
|
|
}
|
|
|
|
uint32_t
|
|
SymbolFile::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
|
|
{
|
|
sc_list.Clear();
|
|
return 0;
|
|
}
|
|
|
|
|
|
uint32_t
|
|
SymbolFile::FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, VariableList& variables)
|
|
{
|
|
if (!append)
|
|
variables.Clear();
|
|
return 0;
|
|
}
|
|
|
|
|
|
uint32_t
|
|
SymbolFile::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
|
|
{
|
|
if (!append)
|
|
variables.Clear();
|
|
return 0;
|
|
}
|
|
|
|
uint32_t
|
|
SymbolFile::FindFunctions (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list)
|
|
{
|
|
if (!append)
|
|
sc_list.Clear();
|
|
return 0;
|
|
}
|
|
|
|
uint32_t
|
|
SymbolFile::FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list)
|
|
{
|
|
if (!append)
|
|
sc_list.Clear();
|
|
return 0;
|
|
}
|
|
|
|
uint32_t
|
|
SymbolFile::FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, TypeList& types)
|
|
{
|
|
if (!append)
|
|
types.Clear();
|
|
return 0;
|
|
}
|
|
|