}
CompilerType GetBuiltinTypeForPDBEncodingAndBitSize(
- ClangASTContext *clang_ast, const PDBSymbolTypeBuiltin *pdb_type,
+ ClangASTContext &clang_ast, const PDBSymbolTypeBuiltin &pdb_type,
Encoding encoding, uint32_t width) {
- if (!pdb_type)
- return CompilerType();
- if (!clang_ast)
- return CompilerType();
- auto *ast = clang_ast->getASTContext();
+ auto *ast = clang_ast.getASTContext();
if (!ast)
return CompilerType();
- switch (pdb_type->getBuiltinType()) {
+ switch (pdb_type.getBuiltinType()) {
default: break;
case PDB_BuiltinType::None:
return CompilerType();
case PDB_BuiltinType::Void:
- return clang_ast->GetBasicType(eBasicTypeVoid);
+ return clang_ast.GetBasicType(eBasicTypeVoid);
case PDB_BuiltinType::Bool:
- return clang_ast->GetBasicType(eBasicTypeBool);
+ return clang_ast.GetBasicType(eBasicTypeBool);
case PDB_BuiltinType::Long:
if (width == ast->getTypeSize(ast->LongTy))
return CompilerType(ast, ast->LongTy);
}
// If there is no match on PDB_BuiltinType, fall back to default search
// by encoding and width only
- return clang_ast->GetBuiltinTypeForEncodingAndBitSize(encoding, width);
+ return clang_ast.GetBuiltinTypeForEncodingAndBitSize(encoding, width);
}
-ConstString GetPDBBuiltinTypeName(const PDBSymbolTypeBuiltin *pdb_type,
+ConstString GetPDBBuiltinTypeName(const PDBSymbolTypeBuiltin &pdb_type,
CompilerType &compiler_type) {
- if (!pdb_type)
- return compiler_type.GetTypeName();
-
- PDB_BuiltinType kind = pdb_type->getBuiltinType();
+ PDB_BuiltinType kind = pdb_type.getBuiltinType();
switch (kind) {
default: break;
case PDB_BuiltinType::Currency:
CompilerType builtin_type;
if (bytes > 0)
builtin_type = GetBuiltinTypeForPDBEncodingAndBitSize(
- &m_ast, underlying_type_up.get(), encoding, bytes * 8);
+ m_ast, *underlying_type_up, encoding, bytes * 8);
else
builtin_type = m_ast.GetBasicType(eBasicTypeInt);
// FIXME: PDB does not have information about scoped enumeration (Enum Class).
uint64_t bytes = builtin_type->getLength();
Encoding encoding = TranslateBuiltinEncoding(builtin_kind);
CompilerType builtin_ast_type = GetBuiltinTypeForPDBEncodingAndBitSize(
- &m_ast, builtin_type, encoding, bytes * 8);
+ m_ast, *builtin_type, encoding, bytes * 8);
if (builtin_type->isConstType())
builtin_ast_type = builtin_ast_type.AddConstModifier();
if (builtin_type->isVolatileType())
builtin_ast_type = builtin_ast_type.AddVolatileModifier();
- auto type_name = GetPDBBuiltinTypeName(builtin_type, builtin_ast_type);
+ auto type_name = GetPDBBuiltinTypeName(*builtin_type, builtin_ast_type);
return std::make_shared<lldb_private::Type>(
builtin_type->getSymIndexId(), m_ast.GetSymbolFile(), type_name,
}
void SymbolFilePDB::GetCompileUnitIndex(
- const llvm::pdb::PDBSymbolCompiland *pdb_compiland,
+ const llvm::pdb::PDBSymbolCompiland &pdb_compiland,
uint32_t &index) {
- if (!pdb_compiland)
- return;
-
auto results_up = m_global_scope_up->findAllChildren<PDBSymbolCompiland>();
if (!results_up)
return;
- auto uid = pdb_compiland->getSymIndexId();
+ auto uid = pdb_compiland.getSymIndexId();
for (uint32_t cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) {
auto compiland_up = results_up->getChildAtIndex(cu_idx);
if (!compiland_up)
lldb_private::Function *
SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(
- const PDBSymbolFunc *pdb_func,
+ const PDBSymbolFunc &pdb_func,
const lldb_private::SymbolContext &sc) {
- assert(pdb_func != nullptr);
lldbassert(sc.comp_unit && sc.module_sp.get());
- auto file_vm_addr = pdb_func->getVirtualAddress();
+ auto file_vm_addr = pdb_func.getVirtualAddress();
if (file_vm_addr == LLDB_INVALID_ADDRESS)
return nullptr;
- auto func_length = pdb_func->getLength();
+ auto func_length = pdb_func.getLength();
AddressRange func_range = AddressRange(file_vm_addr,
func_length,
sc.module_sp->GetSectionList());
if (!func_range.GetBaseAddress().IsValid())
return nullptr;
- lldb_private::Type* func_type = ResolveTypeUID(pdb_func->getSymIndexId());
+ lldb_private::Type* func_type = ResolveTypeUID(pdb_func.getSymIndexId());
if (!func_type)
return nullptr;
- user_id_t func_type_uid = pdb_func->getSignatureId();
+ user_id_t func_type_uid = pdb_func.getSignatureId();
Mangled mangled = GetMangledForPDBFunc(pdb_func);
FunctionSP func_sp = std::make_shared<Function>(sc.comp_unit,
- pdb_func->getSymIndexId(),
+ pdb_func.getSymIndexId(),
func_type_uid,
mangled,
func_type,
auto func_sp =
sc.comp_unit->FindFunctionByUID(pdb_func_up->getSymIndexId());
if (!func_sp) {
- if (ParseCompileUnitFunctionForPDBFunc(pdb_func_up.get(), sc))
+ if (ParseCompileUnitFunctionForPDBFunc(*pdb_func_up, sc))
++func_added;
}
}
auto func_uid = pdb_func->getSymIndexId();
sc.function = sc.comp_unit->FindFunctionByUID(func_uid).get();
if (sc.function == nullptr)
- sc.function = ParseCompileUnitFunctionForPDBFunc(pdb_func, sc);
+ sc.function = ParseCompileUnitFunctionForPDBFunc(*pdb_func, sc);
if (sc.function) {
resolved_flags |= eSymbolContextFunction;
if (resolve_scope & eSymbolContextBlock) {
if (sc.function == nullptr) {
auto pdb_func = llvm::dyn_cast<PDBSymbolFunc>(symbol_up.get());
assert(pdb_func);
- sc.function = ParseCompileUnitFunctionForPDBFunc(pdb_func, sc);
+ sc.function = ParseCompileUnitFunctionForPDBFunc(*pdb_func, sc);
}
if (sc.function && (resolve_scope & eSymbolContextBlock)) {
Block &block = sc.function->GetBlock(true);
return uint32_t();
}
-bool SymbolFilePDB::ResolveFunction(llvm::pdb::PDBSymbolFunc *pdb_func,
+bool SymbolFilePDB::ResolveFunction(const llvm::pdb::PDBSymbolFunc &pdb_func,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) {
- if (!pdb_func)
- return false;
lldb_private::SymbolContext sc;
- auto file_vm_addr = pdb_func->getVirtualAddress();
+ auto file_vm_addr = pdb_func.getVirtualAddress();
if (file_vm_addr == LLDB_INVALID_ADDRESS)
return false;
auto *func = llvm::dyn_cast<PDBSymbolFunc>(symbol_up.get());
assert(func);
- sc.function = ParseCompileUnitFunctionForPDBFunc(func, sc);
+ sc.function = ParseCompileUnitFunctionForPDBFunc(*func, sc);
if (!sc.function)
return false;
m_session_up->getConcreteSymbolById<PDBSymbolFunc>(uid);
if (!pdb_func_up && !(include_inlines && pdb_func_up->hasInlineAttribute()))
return false;
- return ResolveFunction(pdb_func_up.get(), include_inlines, sc_list);
+ return ResolveFunction(*pdb_func_up, include_inlines, sc_list);
}
void SymbolFilePDB::CacheFunctionNames() {
}
void
-SymbolFilePDB::GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol *pdb_symbol,
+SymbolFilePDB::GetTypesForPDBSymbol(const llvm::pdb::PDBSymbol &pdb_symbol,
uint32_t type_mask,
TypeCollection &type_collection) {
- if (!pdb_symbol)
- return;
-
bool can_parse = false;
- switch (pdb_symbol->getSymTag()) {
+ switch (pdb_symbol.getSymTag()) {
case PDB_SymType::ArrayType:
can_parse = ((type_mask & eTypeClassArray) != 0);
break;
can_parse = ((type_mask & eTypeClassTypedef) != 0);
break;
case PDB_SymType::UDT: {
- auto *udt = llvm::dyn_cast<PDBSymbolTypeUDT>(pdb_symbol);
+ auto *udt = llvm::dyn_cast<PDBSymbolTypeUDT>(&pdb_symbol);
assert(udt);
can_parse = (udt->getUdtKind() != PDB_UdtType::Interface &&
((type_mask & (eTypeClassClass | eTypeClassStruct |
}
if (can_parse) {
- if (auto *type = ResolveTypeUID(pdb_symbol->getSymIndexId())) {
+ if (auto *type = ResolveTypeUID(pdb_symbol.getSymIndexId())) {
auto result =
std::find(type_collection.begin(), type_collection.end(), type);
if (result == type_collection.end())
}
}
- auto results_up = pdb_symbol->findAllChildren();
+ auto results_up = pdb_symbol.findAllChildren();
while (auto symbol_up = results_up->getNext())
- GetTypesForPDBSymbol(symbol_up.get(), type_mask, type_collection);
+ GetTypesForPDBSymbol(*symbol_up, type_mask, type_collection);
}
size_t SymbolFilePDB::GetTypes(lldb_private::SymbolContextScope *sc_scope,
sc_scope->CalculateSymbolContextCompileUnit() : nullptr;
if (cu) {
auto compiland_up = GetPDBCompilandByUID(cu->GetID());
- GetTypesForPDBSymbol(compiland_up.get(), type_mask, type_collection);
+ if (!compiland_up)
+ return 0;
+ GetTypesForPDBSymbol(*compiland_up, type_mask, type_collection);
} else {
for (uint32_t cu_idx = 0; cu_idx < GetNumCompileUnits(); ++cu_idx) {
auto cu_sp = ParseCompileUnitAtIndex(cu_idx);
if (cu_sp.get()) {
- auto compiland_up = GetPDBCompilandByUID(cu_sp->GetID());
- GetTypesForPDBSymbol(compiland_up.get(), type_mask, type_collection);
+ if (auto compiland_up = GetPDBCompilandByUID(cu_sp->GetID()))
+ GetTypesForPDBSymbol(*compiland_up, type_mask, type_collection);
}
}
}
m_comp_units.insert(std::make_pair(id, cu_sp));
if (index == UINT32_MAX)
- GetCompileUnitIndex(compiland_up.get(), index);
+ GetCompileUnitIndex(*compiland_up, index);
lldbassert(index != UINT32_MAX);
m_obj_file->GetModule()->GetSymbolVendor()->SetCompileUnitAtIndex(
index, cu_sp);
}
Mangled
-SymbolFilePDB::GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc *pdb_func) {
+SymbolFilePDB::GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func) {
Mangled mangled;
- if (!pdb_func)
- return mangled;
-
- auto func_name = pdb_func->getName();
- auto func_undecorated_name = pdb_func->getUndecoratedName();
+ auto func_name = pdb_func.getName();
+ auto func_undecorated_name = pdb_func.getUndecoratedName();
std::string func_decorated_name;
// Seek from public symbols for non-static function's decorated name if any.