summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp')
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp95
1 files changed, 46 insertions, 49 deletions
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 917ab68af4180..1001514edede1 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -1,4 +1,4 @@
-//===-- SymbolFilePDB.cpp ---------------------------------------*- C++ -*-===//
+//===-- SymbolFilePDB.cpp -------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -13,9 +13,9 @@
#include "clang/Lex/Lexer.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/PluginManager.h"
-#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineTable.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -58,6 +58,8 @@ using namespace lldb;
using namespace lldb_private;
using namespace llvm::pdb;
+LLDB_PLUGIN_DEFINE(SymbolFilePDB)
+
char SymbolFilePDB::ID;
namespace {
@@ -310,8 +312,8 @@ SymbolFilePDB::ParseCompileUnitFunctionForPDBFunc(const PDBSymbolFunc &pdb_func,
return nullptr;
}
- ClangASTContext *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_type_system =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_type_system)
return nullptr;
clang_type_system->GetPDBParser()->GetDeclForSymbol(pdb_func);
@@ -560,8 +562,8 @@ lldb_private::Type *SymbolFilePDB::ResolveTypeUID(lldb::user_id_t type_uid) {
return nullptr;
}
- ClangASTContext *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_type_system =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_type_system)
return nullptr;
PDBASTParser *pdb = clang_type_system->GetPDBParser();
@@ -597,8 +599,8 @@ bool SymbolFilePDB::CompleteType(lldb_private::CompilerType &compiler_type) {
return false;
}
- ClangASTContext *clang_ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_ctx)
return false;
@@ -619,8 +621,8 @@ lldb_private::CompilerDecl SymbolFilePDB::GetDeclForUID(lldb::user_id_t uid) {
return CompilerDecl();
}
- ClangASTContext *clang_ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_ctx)
return CompilerDecl();
@@ -636,7 +638,7 @@ lldb_private::CompilerDecl SymbolFilePDB::GetDeclForUID(lldb::user_id_t uid) {
if (!decl)
return CompilerDecl();
- return CompilerDecl(clang_ast_ctx, decl);
+ return clang_ast_ctx->GetCompilerDecl(decl);
}
lldb_private::CompilerDeclContext
@@ -649,8 +651,8 @@ SymbolFilePDB::GetDeclContextForUID(lldb::user_id_t uid) {
return CompilerDeclContext();
}
- ClangASTContext *clang_ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_ctx)
return CompilerDeclContext();
@@ -679,8 +681,8 @@ SymbolFilePDB::GetDeclContextContainingUID(lldb::user_id_t uid) {
return CompilerDeclContext();
}
- ClangASTContext *clang_ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_ctx)
return CompilerDeclContext();
@@ -708,8 +710,8 @@ void SymbolFilePDB::ParseDeclsForContext(
return;
}
- ClangASTContext *clang_ast_ctx =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ TypeSystemClang *clang_ast_ctx =
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_ast_ctx)
return;
@@ -1096,8 +1098,7 @@ SymbolFilePDB::ParseVariables(const lldb_private::SymbolContext &sc,
}
void SymbolFilePDB::FindGlobalVariables(
- lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ lldb_private::ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, lldb_private::VariableList &variables) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
if (!DeclContextMatchesThisSymbolFile(parent_decl_ctx))
@@ -1129,8 +1130,8 @@ void SymbolFilePDB::FindGlobalVariables(
if (sc.comp_unit == nullptr)
continue;
- if (parent_decl_ctx && GetDeclContextContainingUID(
- result->getSymIndexId()) != *parent_decl_ctx)
+ if (parent_decl_ctx.IsValid() &&
+ GetDeclContextContainingUID(result->getSymIndexId()) != parent_decl_ctx)
continue;
ParseVariables(sc, *pdb_data, &variables);
@@ -1225,7 +1226,7 @@ void SymbolFilePDB::CacheFunctionNames() {
// To search a method name, like NS::Class:MemberFunc, LLDB searches
// its base name, i.e. MemberFunc by default. Since PDBSymbolFunc does
- // not have inforamtion of this, we extract base names and cache them
+ // not have information of this, we extract base names and cache them
// by our own effort.
llvm::StringRef basename = MSVCUndecoratedNameParser::DropScope(name);
if (!basename.empty())
@@ -1294,7 +1295,7 @@ void SymbolFilePDB::CacheFunctionNames() {
void SymbolFilePDB::FindFunctions(
lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
FunctionNameType name_type_mask, bool include_inlines,
lldb_private::SymbolContextList &sc_list) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
@@ -1323,8 +1324,8 @@ void SymbolFilePDB::FindFunctions(
if (resolved_ids.find(id) != resolved_ids.end())
continue;
- if (parent_decl_ctx &&
- GetDeclContextContainingUID(id) != *parent_decl_ctx)
+ if (parent_decl_ctx.IsValid() &&
+ GetDeclContextContainingUID(id) != parent_decl_ctx)
continue;
if (ResolveFunction(id, include_inlines, sc_list))
@@ -1422,8 +1423,7 @@ void SymbolFilePDB::AddSymbols(lldb_private::Symtab &symtab) {
}
void SymbolFilePDB::FindTypes(
- lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ lldb_private::ConstString name, const CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) {
@@ -1450,7 +1450,7 @@ void SymbolFilePDB::DumpClangAST(Stream &s) {
}
auto *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_type_system)
return;
clang_type_system->Dump(s);
@@ -1513,7 +1513,7 @@ void SymbolFilePDB::FindTypesByRegex(
void SymbolFilePDB::FindTypesByName(
llvm::StringRef name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches, lldb_private::TypeMap &types) {
std::unique_ptr<IPDBEnumSymbols> results;
if (name.empty())
@@ -1548,8 +1548,8 @@ void SymbolFilePDB::FindTypesByName(
if (!ResolveTypeUID(result->getSymIndexId()))
continue;
- if (parent_decl_ctx && GetDeclContextContainingUID(
- result->getSymIndexId()) != *parent_decl_ctx)
+ if (parent_decl_ctx.IsValid() &&
+ GetDeclContextContainingUID(result->getSymIndexId()) != parent_decl_ctx)
continue;
auto iter = m_types.find(result->getSymIndexId());
@@ -1663,17 +1663,16 @@ PDBASTParser *SymbolFilePDB::GetPDBAstParser() {
}
auto *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_type_system)
return nullptr;
return clang_type_system->GetPDBParser();
}
-
-lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
- lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx) {
+lldb_private::CompilerDeclContext
+SymbolFilePDB::FindNamespace(lldb_private::ConstString name,
+ const CompilerDeclContext &parent_decl_ctx) {
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
auto type_system_or_err =
GetTypeSystemForLanguage(lldb::eLanguageTypeC_plus_plus);
@@ -1685,7 +1684,7 @@ lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
}
auto *clang_type_system =
- llvm::dyn_cast_or_null<ClangASTContext>(&type_system_or_err.get());
+ llvm::dyn_cast_or_null<TypeSystemClang>(&type_system_or_err.get());
if (!clang_type_system)
return CompilerDeclContext();
@@ -1696,7 +1695,7 @@ lldb_private::CompilerDeclContext SymbolFilePDB::FindNamespace(
clang::DeclContext *decl_context = nullptr;
if (parent_decl_ctx)
decl_context = static_cast<clang::DeclContext *>(
- parent_decl_ctx->GetOpaqueDeclContext());
+ parent_decl_ctx.GetOpaqueDeclContext());
auto namespace_decl =
pdb->FindNamespaceDecl(decl_context, name.GetStringRef());
@@ -1817,7 +1816,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit &comp_unit,
prev_source_idx, false, false, false, false, true);
line_table->InsertSequence(sequence.release());
- sequence.reset(line_table->CreateLineSequenceContainer());
+ sequence = line_table->CreateLineSequenceContainer();
}
if (ShouldAddLine(match_line, lno, length)) {
@@ -1854,7 +1853,7 @@ bool SymbolFilePDB::ParseCompileUnitLineTable(CompileUnit &comp_unit,
prev_source_idx, false, false, false, false, true);
}
- line_table->InsertSequence(sequence.release());
+ line_table->InsertSequence(sequence.get());
}
if (line_table->GetSize()) {
@@ -1940,18 +1939,17 @@ SymbolFilePDB::GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func) {
mangled.SetMangledName(ConstString(func_decorated_name));
// For MSVC, format of C funciton's decorated name depends on calling
- // conventon. Unfortunately none of the format is recognized by current
+ // convention. Unfortunately none of the format is recognized by current
// LLDB. For example, `_purecall` is a __cdecl C function. From PDB,
// `__purecall` is retrieved as both its decorated and undecorated name
// (using PDBSymbolFunc::getUndecoratedName method). However `__purecall`
// string is not treated as mangled in LLDB (neither `?` nor `_Z` prefix).
// Mangled::GetDemangledName method will fail internally and caches an
- // empty string as its undecorated name. So we will face a contradition
+ // empty string as its undecorated name. So we will face a contradiction
// here for the same symbol:
// non-empty undecorated name from PDB
// empty undecorated name from LLDB
- if (!func_undecorated_name.empty() &&
- mangled.GetDemangledName(mangled.GuessLanguage()).IsEmpty())
+ if (!func_undecorated_name.empty() && mangled.GetDemangledName().IsEmpty())
mangled.SetDemangledName(ConstString(func_undecorated_name));
// LLDB uses several flags to control how a C++ decorated name is
@@ -1960,8 +1958,7 @@ SymbolFilePDB::GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func) {
// PDB source unless we also apply same flags in getting undecorated
// name through PDBSymbolFunc::getUndecoratedNameEx method.
if (!func_undecorated_name.empty() &&
- mangled.GetDemangledName(mangled.GuessLanguage()) !=
- ConstString(func_undecorated_name))
+ mangled.GetDemangledName() != ConstString(func_undecorated_name))
mangled.SetDemangledName(ConstString(func_undecorated_name));
} else if (!func_undecorated_name.empty()) {
mangled.SetDemangledName(ConstString(func_undecorated_name));
@@ -1972,11 +1969,11 @@ SymbolFilePDB::GetMangledForPDBFunc(const llvm::pdb::PDBSymbolFunc &pdb_func) {
}
bool SymbolFilePDB::DeclContextMatchesThisSymbolFile(
- const lldb_private::CompilerDeclContext *decl_ctx) {
- if (decl_ctx == nullptr || !decl_ctx->IsValid())
+ const lldb_private::CompilerDeclContext &decl_ctx) {
+ if (!decl_ctx.IsValid())
return true;
- TypeSystem *decl_ctx_type_system = decl_ctx->GetTypeSystem();
+ TypeSystem *decl_ctx_type_system = decl_ctx.GetTypeSystem();
if (!decl_ctx_type_system)
return false;
auto type_system_or_err = GetTypeSystemForLanguage(