summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/SymbolFile/PDB
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
commitcfca06d7963fa0909f90483b42a6d7d194d01e08 (patch)
tree209fb2a2d68f8f277793fc8df46c753d31bc853b /lldb/source/Plugins/SymbolFile/PDB
parent706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff)
Notes
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/PDB')
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp156
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h14
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h4
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp95
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h18
6 files changed, 169 insertions, 120 deletions
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index 6b2dbd9e1e5a..d87926a6588f 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -1,4 +1,4 @@
-//===-- PDBASTParser.cpp ----------------------------------------*- C++ -*-===//
+//===-- PDBASTParser.cpp --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,10 +14,10 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTMetadata.h"
+#include "Plugins/ExpressionParser/Clang/ClangUtil.h"
+#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
#include "lldb/Core/Module.h"
-#include "lldb/Symbol/ClangASTContext.h"
-#include "lldb/Symbol/ClangASTMetadata.h"
-#include "lldb/Symbol/ClangUtil.h"
#include "lldb/Symbol/Declaration.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/TypeMap.h"
@@ -100,7 +100,7 @@ static lldb::Encoding TranslateEnumEncoding(PDB_VariantType type) {
}
static CompilerType
-GetBuiltinTypeForPDBEncodingAndBitSize(ClangASTContext &clang_ast,
+GetBuiltinTypeForPDBEncodingAndBitSize(TypeSystemClang &clang_ast,
const PDBSymbolTypeBuiltin &pdb_type,
Encoding encoding, uint32_t width) {
clang::ASTContext &ast = clang_ast.getASTContext();
@@ -353,7 +353,7 @@ static clang::CallingConv TranslateCallingConvention(PDB_CallingConv pdb_cc) {
}
}
-PDBASTParser::PDBASTParser(lldb_private::ClangASTContext &ast) : m_ast(ast) {}
+PDBASTParser::PDBASTParser(lldb_private::TypeSystemClang &ast) : m_ast(ast) {}
PDBASTParser::~PDBASTParser() {}
@@ -386,7 +386,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
return nullptr;
// Ignore unnamed-tag UDTs.
- std::string name = MSVCUndecoratedNameParser::DropScope(udt->getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(udt->getName()));
if (name.empty())
return nullptr;
@@ -408,9 +409,9 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
metadata.SetUserID(type.getSymIndexId());
metadata.SetIsDynamicCXXType(false);
- clang_type =
- m_ast.CreateRecordType(decl_context, access, name, tag_type_kind,
- lldb::eLanguageTypeC_plus_plus, &metadata);
+ clang_type = m_ast.CreateRecordType(
+ decl_context, OptionalClangModuleID(), access, name, tag_type_kind,
+ lldb::eLanguageTypeC_plus_plus, &metadata);
assert(clang_type.IsValid());
auto record_decl =
@@ -422,15 +423,15 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
m_ast.getASTContext(), GetMSInheritance(*udt));
record_decl->addAttr(inheritance_attr);
- ClangASTContext::StartTagDeclarationDefinition(clang_type);
+ TypeSystemClang::StartTagDeclarationDefinition(clang_type);
auto children = udt->findAllChildren();
if (!children || children->getChildCount() == 0) {
// PDB does not have symbol of forwarder. We assume we get an udt w/o
// any fields. Just complete it at this point.
- ClangASTContext::CompleteTagDeclarationDefinition(clang_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(clang_type);
- ClangASTContext::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
+ TypeSystemClang::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
false);
type_resolve_state = Type::ResolveState::Full;
@@ -439,7 +440,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
// an endless recursion in CompleteTypeFromUdt function.
m_forward_decl_to_uid[record_decl] = type.getSymIndexId();
- ClangASTContext::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
+ TypeSystemClang::SetHasExternalStorage(clang_type.GetOpaqueQualType(),
true);
type_resolve_state = Type::ResolveState::Forward;
@@ -465,7 +466,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
assert(enum_type);
std::string name =
- MSVCUndecoratedNameParser::DropScope(enum_type->getName());
+ std::string(MSVCUndecoratedNameParser::DropScope(enum_type->getName()));
auto decl_context = GetDeclContextContainingSymbol(type);
uint64_t bytes = enum_type->getLength();
@@ -496,10 +497,11 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
// Class). Set it false for now.
bool isScoped = false;
- ast_enum = m_ast.CreateEnumerationType(name.c_str(), decl_context, decl,
+ ast_enum = m_ast.CreateEnumerationType(name.c_str(), decl_context,
+ OptionalClangModuleID(), decl,
builtin_type, isScoped);
- auto enum_decl = ClangASTContext::GetAsEnumDecl(ast_enum);
+ auto enum_decl = TypeSystemClang::GetAsEnumDecl(ast_enum);
assert(enum_decl);
m_uid_to_decl[type.getSymIndexId()] = enum_decl;
@@ -512,8 +514,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
}
}
- if (ClangASTContext::StartTagDeclarationDefinition(ast_enum))
- ClangASTContext::CompleteTagDeclarationDefinition(ast_enum);
+ if (TypeSystemClang::StartTagDeclarationDefinition(ast_enum))
+ TypeSystemClang::CompleteTagDeclarationDefinition(ast_enum);
}
if (enum_type->isConstType())
@@ -538,7 +540,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
return nullptr;
std::string name =
- MSVCUndecoratedNameParser::DropScope(type_def->getName());
+ std::string(MSVCUndecoratedNameParser::DropScope(type_def->getName()));
auto decl_ctx = GetDeclContextContainingSymbol(type);
// Check if such a typedef already exists in the current context
@@ -549,11 +551,11 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
CompilerType target_ast_type = target_type->GetFullCompilerType();
ast_typedef = m_ast.CreateTypedefType(
- target_ast_type, name.c_str(), m_ast.CreateDeclContext(decl_ctx));
+ target_ast_type, name.c_str(), m_ast.CreateDeclContext(decl_ctx), 0);
if (!ast_typedef)
return nullptr;
- auto typedef_decl = ClangASTContext::GetAsTypedefDecl(ast_typedef);
+ auto typedef_decl = TypeSystemClang::GetAsTypedefDecl(ast_typedef);
assert(typedef_decl);
m_uid_to_decl[type.getSymIndexId()] = typedef_decl;
}
@@ -587,7 +589,8 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
return nullptr;
func_sig = sig.release();
// Function type is named.
- name = MSVCUndecoratedNameParser::DropScope(pdb_func->getName());
+ name = std::string(
+ MSVCUndecoratedNameParser::DropScope(pdb_func->getName()));
} else if (auto pdb_func_sig =
llvm::dyn_cast<PDBSymbolTypeFunctionSig>(&type)) {
func_sig = const_cast<PDBSymbolTypeFunctionSig *>(pdb_func_sig);
@@ -660,10 +663,10 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
CompilerType element_ast_type = element_type->GetForwardCompilerType();
// If element type is UDT, it needs to be complete.
- if (ClangASTContext::IsCXXClassType(element_ast_type) &&
+ if (TypeSystemClang::IsCXXClassType(element_ast_type) &&
!element_ast_type.GetCompleteType()) {
- if (ClangASTContext::StartTagDeclarationDefinition(element_ast_type)) {
- ClangASTContext::CompleteTagDeclarationDefinition(element_ast_type);
+ if (TypeSystemClang::StartTagDeclarationDefinition(element_ast_type)) {
+ TypeSystemClang::CompleteTagDeclarationDefinition(element_ast_type);
} else {
// We are not able to start defintion.
return nullptr;
@@ -721,7 +724,7 @@ lldb::TypeSP PDBASTParser::CreateLLDBTypeFromPDBType(const PDBSymbol &type) {
assert(class_parent_type);
CompilerType pointer_ast_type;
- pointer_ast_type = ClangASTContext::CreateMemberPointerType(
+ pointer_ast_type = TypeSystemClang::CreateMemberPointerType(
class_parent_type->GetLayoutCompilerType(),
pointee_type->GetForwardCompilerType());
assert(pointer_ast_type);
@@ -787,7 +790,7 @@ bool PDBASTParser::CompleteTypeFromPDB(
m_forward_decl_to_uid.erase(uid_it);
- ClangASTContext::SetHasExternalStorage(compiler_type.GetOpaqueQualType(),
+ TypeSystemClang::SetHasExternalStorage(compiler_type.GetOpaqueQualType(),
false);
switch (symbol->getSymTag()) {
@@ -887,7 +890,8 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
if (auto parent_decl = llvm::dyn_cast_or_null<clang::TagDecl>(decl_context))
m_ast.GetCompleteDecl(parent_decl);
- std::string name = MSVCUndecoratedNameParser::DropScope(data->getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(data->getName()));
// Check if the current context already contains the symbol with the name.
clang::Decl *decl =
@@ -898,7 +902,7 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
return nullptr;
decl = m_ast.CreateVariableDeclaration(
- decl_context, name.c_str(),
+ decl_context, OptionalClangModuleID(), name.c_str(),
ClangUtil::GetQualType(type->GetLayoutCompilerType()));
}
@@ -913,7 +917,8 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
auto decl_context = GetDeclContextContainingSymbol(symbol);
assert(decl_context);
- std::string name = MSVCUndecoratedNameParser::DropScope(func->getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(func->getName()));
Type *type = symbol_file->ResolveTypeUID(sym_id);
if (!type)
@@ -923,8 +928,8 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
: clang::StorageClass::SC_None;
auto decl = m_ast.CreateFunctionDeclaration(
- decl_context, name.c_str(), type->GetForwardCompilerType(), storage,
- func->hasInlineAttribute());
+ decl_context, OptionalClangModuleID(), name.c_str(),
+ type->GetForwardCompilerType(), storage, func->hasInlineAttribute());
std::vector<clang::ParmVarDecl *> params;
if (std::unique_ptr<PDBSymbolTypeFunctionSig> sig = func->getSignature()) {
@@ -937,8 +942,8 @@ PDBASTParser::GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol) {
continue;
clang::ParmVarDecl *param = m_ast.CreateParameterDeclaration(
- decl, nullptr, arg_type->GetForwardCompilerType(),
- clang::SC_None, true);
+ decl, OptionalClangModuleID(), nullptr,
+ arg_type->GetForwardCompilerType(), clang::SC_None, true);
if (param)
params.push_back(param);
}
@@ -1047,13 +1052,13 @@ clang::DeclContext *PDBASTParser::GetDeclContextContainingSymbol(
// or a type. We check it to avoid fake namespaces such as `__l2':
// `N0::N1::CClass::PrivateFunc::__l2::InnerFuncStruct'
if (!has_type_or_function_parent) {
- std::string namespace_name = specs[i].GetBaseName();
+ std::string namespace_name = std::string(specs[i].GetBaseName());
const char *namespace_name_c_str =
IsAnonymousNamespaceName(namespace_name) ? nullptr
: namespace_name.data();
clang::NamespaceDecl *namespace_decl =
- m_ast.GetUniqueNamespaceDeclaration(namespace_name_c_str,
- curr_context);
+ m_ast.GetUniqueNamespaceDeclaration(
+ namespace_name_c_str, curr_context, OptionalClangModuleID());
m_parent_to_namespaces[curr_context].insert(namespace_decl);
m_namespaces.insert(namespace_decl);
@@ -1119,7 +1124,8 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type,
const PDBSymbolData &enum_value) {
Declaration decl;
Variant v = enum_value.getValue();
- std::string name = MSVCUndecoratedNameParser::DropScope(enum_value.getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(enum_value.getName()));
int64_t raw_value;
switch (v.Type) {
case PDB_VariantType::Int8:
@@ -1149,8 +1155,7 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type,
default:
return false;
}
- CompilerType underlying_type =
- m_ast.GetEnumerationIntegerType(enum_type.GetOpaqueQualType());
+ CompilerType underlying_type = m_ast.GetEnumerationIntegerType(enum_type);
uint32_t byte_size = m_ast.getASTContext().getTypeSize(
ClangUtil::GetQualType(underlying_type));
auto enum_constant_decl = m_ast.AddEnumerationValueToEnumerationType(
@@ -1190,8 +1195,8 @@ bool PDBASTParser::CompleteTypeFromUDT(
AddRecordMethods(symbol_file, compiler_type, *methods_enum);
m_ast.AddMethodOverridesForCXXRecordType(compiler_type.GetOpaqueQualType());
- ClangASTContext::BuildIndirectFields(compiler_type);
- ClangASTContext::CompleteTagDeclarationDefinition(compiler_type);
+ TypeSystemClang::BuildIndirectFields(compiler_type);
+ TypeSystemClang::CompleteTagDeclarationDefinition(compiler_type);
clang::CXXRecordDecl *record_decl =
m_ast.GetAsCXXRecordDecl(compiler_type.GetOpaqueQualType());
@@ -1225,8 +1230,8 @@ void PDBASTParser::AddRecordMembers(
"which does not have a complete definition.",
record_type.GetTypeName().GetCString(), member_name.c_str(),
member_comp_type.GetTypeName().GetCString());
- if (ClangASTContext::StartTagDeclarationDefinition(member_comp_type))
- ClangASTContext::CompleteTagDeclarationDefinition(member_comp_type);
+ if (TypeSystemClang::StartTagDeclarationDefinition(member_comp_type))
+ TypeSystemClang::CompleteTagDeclarationDefinition(member_comp_type);
}
auto access = TranslateMemberAccess(member->getAccess());
@@ -1239,7 +1244,7 @@ void PDBASTParser::AddRecordMembers(
if (location_type == PDB_LocType::ThisRel)
bit_size *= 8;
- auto decl = ClangASTContext::AddFieldToRecordType(
+ auto decl = TypeSystemClang::AddFieldToRecordType(
record_type, member_name.c_str(), member_comp_type, access, bit_size);
if (!decl)
continue;
@@ -1255,11 +1260,57 @@ void PDBASTParser::AddRecordMembers(
break;
}
case PDB_DataKind::StaticMember: {
- auto decl = ClangASTContext::AddVariableToRecordType(
+ auto decl = TypeSystemClang::AddVariableToRecordType(
record_type, member_name.c_str(), member_comp_type, access);
if (!decl)
continue;
+ // Static constant members may be a const[expr] declaration.
+ // Query the symbol's value as the variable initializer if valid.
+ if (member_comp_type.IsConst()) {
+ auto value = member->getValue();
+ clang::QualType qual_type = decl->getType();
+ unsigned type_width = m_ast.getASTContext().getIntWidth(qual_type);
+ unsigned constant_width = value.getBitWidth();
+
+ if (qual_type->isIntegralOrEnumerationType()) {
+ if (type_width >= constant_width) {
+ TypeSystemClang::SetIntegerInitializerForVariable(
+ decl, value.toAPSInt().extOrTrunc(type_width));
+ } else {
+ LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST),
+ "Class '{0}' has a member '{1}' of type '{2}' ({3} bits) "
+ "which resolves to a wider constant value ({4} bits). "
+ "Ignoring constant.",
+ record_type.GetTypeName(), member_name,
+ member_comp_type.GetTypeName(), type_width,
+ constant_width);
+ }
+ } else {
+ switch (member_comp_type.GetBasicTypeEnumeration()) {
+ case lldb::eBasicTypeFloat:
+ case lldb::eBasicTypeDouble:
+ case lldb::eBasicTypeLongDouble:
+ if (type_width == constant_width) {
+ TypeSystemClang::SetFloatingInitializerForVariable(
+ decl, value.toAPFloat());
+ decl->setConstexpr(true);
+ } else {
+ LLDB_LOG(GetLogIfAllCategoriesSet(LIBLLDB_LOG_AST),
+ "Class '{0}' has a member '{1}' of type '{2}' ({3} "
+ "bits) which resolves to a constant value of mismatched "
+ "width ({4} bits). Ignoring constant.",
+ record_type.GetTypeName(), member_name,
+ member_comp_type.GetTypeName(), type_width,
+ constant_width);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
m_uid_to_decl[member->getSymIndexId()] = decl;
break;
@@ -1289,8 +1340,8 @@ void PDBASTParser::AddRecordBases(
"which does not have a complete definition.",
record_type.GetTypeName().GetCString(),
base_comp_type.GetTypeName().GetCString());
- if (ClangASTContext::StartTagDeclarationDefinition(base_comp_type))
- ClangASTContext::CompleteTagDeclarationDefinition(base_comp_type);
+ if (TypeSystemClang::StartTagDeclarationDefinition(base_comp_type))
+ TypeSystemClang::CompleteTagDeclarationDefinition(base_comp_type);
}
auto access = TranslateMemberAccess(base->getAccess());
@@ -1333,7 +1384,8 @@ clang::CXXMethodDecl *
PDBASTParser::AddRecordMethod(lldb_private::SymbolFile &symbol_file,
lldb_private::CompilerType &record_type,
const llvm::pdb::PDBSymbolFunc &method) const {
- std::string name = MSVCUndecoratedNameParser::DropScope(method.getName());
+ std::string name =
+ std::string(MSVCUndecoratedNameParser::DropScope(method.getName()));
Type *method_type = symbol_file.ResolveTypeUID(method.getSymIndexId());
// MSVC specific __vecDelDtor.
@@ -1346,8 +1398,8 @@ PDBASTParser::AddRecordMethod(lldb_private::SymbolFile &symbol_file,
":: Class '%s' has a method '%s' whose type cannot be completed.",
record_type.GetTypeName().GetCString(),
method_comp_type.GetTypeName().GetCString());
- if (ClangASTContext::StartTagDeclarationDefinition(method_comp_type))
- ClangASTContext::CompleteTagDeclarationDefinition(method_comp_type);
+ if (TypeSystemClang::StartTagDeclarationDefinition(method_comp_type))
+ TypeSystemClang::CompleteTagDeclarationDefinition(method_comp_type);
}
AccessType access = TranslateMemberAccess(method.getAccess());
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
index 9221d42b2020..06f317f4c4d9 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.h
@@ -6,12 +6,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLDB_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
-#define LLDB_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
#include "lldb/lldb-forward.h"
-#include "lldb/Symbol/ClangASTImporter.h"
+#include "Plugins/ExpressionParser/Clang/ClangASTImporter.h"
class SymbolFilePDB;
@@ -23,7 +23,7 @@ class RecordDecl;
} // namespace clang
namespace lldb_private {
-class ClangASTContext;
+class TypeSystemClang;
class CompilerType;
} // namespace lldb_private
@@ -42,7 +42,7 @@ class PDBSymbolTypeUDT;
class PDBASTParser {
public:
- PDBASTParser(lldb_private::ClangASTContext &ast);
+ PDBASTParser(lldb_private::TypeSystemClang &ast);
~PDBASTParser();
lldb::TypeSP CreateLLDBTypeFromPDBType(const llvm::pdb::PDBSymbol &type);
@@ -103,7 +103,7 @@ private:
lldb_private::CompilerType &record_type,
const llvm::pdb::PDBSymbolFunc &method) const;
- lldb_private::ClangASTContext &m_ast;
+ lldb_private::TypeSystemClang &m_ast;
lldb_private::ClangASTImporter m_ast_importer;
CXXRecordDeclToUidMap m_forward_decl_to_uid;
@@ -113,4 +113,4 @@ private:
DeclContextToUidMap m_decl_context_to_uid;
};
-#endif // LLDB_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBASTPARSER_H
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp b/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
index 42bf1b34c956..330188e29f00 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
@@ -1,4 +1,4 @@
-//===-- PDBLocationToDWARFExpression.cpp ------------------------*- C++ -*-===//
+//===-- PDBLocationToDWARFExpression.cpp ----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h b/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h
index 2e9d1386d537..fd0fef03e2c8 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Plugins_SymbolFile_PDB_PDBLocationToDWARFExpression_h_
-#define lldb_Plugins_SymbolFile_PDB_PDBLocationToDWARFExpression_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBLOCATIONTODWARFEXPRESSION_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_PDBLOCATIONTODWARFEXPRESSION_H
#include "lldb/Core/Module.h"
#include "lldb/Symbol/Variable.h"
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 917ab68af418..1001514edede 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(
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
index 7a4eee48771a..928cbffc5f63 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_
-#define lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_
+#ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H
+#define LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H
#include "lldb/Core/UniqueCStringMap.h"
#include "lldb/Symbol/SymbolFile.h"
@@ -112,7 +112,7 @@ public:
void
FindGlobalVariables(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
lldb_private::VariableList &variables) override;
@@ -121,7 +121,7 @@ public:
lldb_private::VariableList &variables) override;
void FindFunctions(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
lldb::FunctionNameType name_type_mask,
bool include_inlines,
lldb_private::SymbolContextList &sc_list) override;
@@ -138,7 +138,7 @@ public:
void
FindTypes(lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx,
+ const lldb_private::CompilerDeclContext &parent_decl_ctx,
uint32_t max_matches,
llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
lldb_private::TypeMap &types) override;
@@ -160,7 +160,7 @@ public:
lldb_private::CompilerDeclContext FindNamespace(
lldb_private::ConstString name,
- const lldb_private::CompilerDeclContext *parent_decl_ctx) override;
+ const lldb_private::CompilerDeclContext &parent_decl_ctx) override;
lldb_private::ConstString GetPluginName() override;
@@ -195,7 +195,7 @@ private:
llvm::DenseMap<uint32_t, uint32_t> &index_map) const;
void 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::string GetMangledForPDBData(const llvm::pdb::PDBSymbolData &pdb_data);
@@ -242,7 +242,7 @@ private:
void CacheFunctionNames();
bool DeclContextMatchesThisSymbolFile(
- const lldb_private::CompilerDeclContext *decl_ctx);
+ const lldb_private::CompilerDeclContext &decl_ctx);
uint32_t GetCompilandId(const llvm::pdb::PDBSymbolData &data);
@@ -262,4 +262,4 @@ private:
lldb_private::UniqueCStringMap<uint32_t> m_func_method_names;
};
-#endif // lldb_Plugins_SymbolFile_PDB_SymbolFilePDB_h_
+#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_PDB_SYMBOLFILEPDB_H