13#include "clang/AST/CharUnits.h"
14#include "clang/AST/Decl.h"
15#include "clang/AST/DeclCXX.h"
26#include "llvm/DebugInfo/PDB/ConcreteSymbolEnumerator.h"
27#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
28#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
29#include "llvm/DebugInfo/PDB/PDBSymbol.h"
30#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
31#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
32#include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
33#include "llvm/DebugInfo/PDB/PDBSymbolTypeBaseClass.h"
34#include "llvm/DebugInfo/PDB/PDBSymbolTypeBuiltin.h"
35#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
36#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionArg.h"
37#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
38#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
39#include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
40#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
51 case PDB_UdtType::Class:
52 return clang::TTK_Class;
53 case PDB_UdtType::Struct:
54 return clang::TTK_Struct;
55 case PDB_UdtType::Union:
56 return clang::TTK_Union;
57 case PDB_UdtType::Interface:
58 return clang::TTK_Interface;
60 llvm_unreachable(
"unsuported PDB UDT type");
65 case PDB_BuiltinType::Float:
67 case PDB_BuiltinType::Int:
68 case PDB_BuiltinType::Long:
69 case PDB_BuiltinType::Char:
71 case PDB_BuiltinType::Bool:
72 case PDB_BuiltinType::Char16:
73 case PDB_BuiltinType::Char32:
74 case PDB_BuiltinType::UInt:
75 case PDB_BuiltinType::ULong:
76 case PDB_BuiltinType::HResult:
77 case PDB_BuiltinType::WCharT:
86 case PDB_VariantType::Int8:
87 case PDB_VariantType::Int16:
88 case PDB_VariantType::Int32:
89 case PDB_VariantType::Int64:
92 case PDB_VariantType::UInt8:
93 case PDB_VariantType::UInt16:
94 case PDB_VariantType::UInt32:
95 case PDB_VariantType::UInt64:
107 const PDBSymbolTypeBuiltin &pdb_type,
111 switch (pdb_type.getBuiltinType()) {
114 case PDB_BuiltinType::None:
116 case PDB_BuiltinType::Void:
118 case PDB_BuiltinType::Char:
120 case PDB_BuiltinType::Bool:
122 case PDB_BuiltinType::Long:
123 if (width == ast.getTypeSize(ast.LongTy))
125 ast.LongTy.getAsOpaquePtr());
126 if (width == ast.getTypeSize(ast.LongLongTy))
128 ast.LongLongTy.getAsOpaquePtr());
130 case PDB_BuiltinType::ULong:
131 if (width == ast.getTypeSize(ast.UnsignedLongTy))
133 ast.UnsignedLongTy.getAsOpaquePtr());
134 if (width == ast.getTypeSize(ast.UnsignedLongLongTy))
136 ast.UnsignedLongLongTy.getAsOpaquePtr());
138 case PDB_BuiltinType::WCharT:
139 if (width == ast.getTypeSize(ast.WCharTy))
141 ast.WCharTy.getAsOpaquePtr());
143 case PDB_BuiltinType::Char16:
145 ast.Char16Ty.getAsOpaquePtr());
146 case PDB_BuiltinType::Char32:
148 ast.Char32Ty.getAsOpaquePtr());
149 case PDB_BuiltinType::Float:
163 PDB_BuiltinType kind = pdb_type.getBuiltinType();
167 case PDB_BuiltinType::Currency:
169 case PDB_BuiltinType::Date:
171 case PDB_BuiltinType::Variant:
173 case PDB_BuiltinType::Complex:
175 case PDB_BuiltinType::Bitfield:
177 case PDB_BuiltinType::BSTR:
179 case PDB_BuiltinType::HResult:
181 case PDB_BuiltinType::BCD:
183 case PDB_BuiltinType::Char16:
185 case PDB_BuiltinType::Char32:
187 case PDB_BuiltinType::None:
194 auto &raw_sym = symbol.getRawSymbol();
195 auto first_line_up = raw_sym.getSrcLineOnTypeDefn();
197 if (!first_line_up) {
198 auto lines_up = symbol.getSession().findLineNumbersByAddress(
199 raw_sym.getVirtualAddress(), raw_sym.getLength());
202 first_line_up = lines_up->getNext();
206 uint32_t src_file_id = first_line_up->getSourceFileId();
207 auto src_file_up = symbol.getSession().getSourceFileById(src_file_id);
211 FileSpec spec(src_file_up->getFileName());
213 decl.
SetColumn(first_line_up->getColumnNumber());
214 decl.
SetLine(first_line_up->getLineNumber());
220 case PDB_MemberAccess::Private:
222 case PDB_MemberAccess::Protected:
224 case PDB_MemberAccess::Public:
232 case PDB_UdtType::Struct:
233 case PDB_UdtType::Union:
235 case PDB_UdtType::Class:
236 case PDB_UdtType::Interface:
239 llvm_unreachable(
"unsupported PDB UDT type");
247 auto parent = udt.getClassParent();
251 auto parent_udt = llvm::dyn_cast<PDBSymbolTypeUDT>(parent.get());
258static clang::MSInheritanceAttr::Spelling
261 bool has_virtual =
false;
263 auto bases_enum = udt.findAllChildren<PDBSymbolTypeBaseClass>();
265 while (
auto base = bases_enum->getNext()) {
267 has_virtual |= base->isVirtualBaseClass();
272 return clang::MSInheritanceAttr::Keyword_virtual_inheritance;
274 return clang::MSInheritanceAttr::Keyword_multiple_inheritance;
275 return clang::MSInheritanceAttr::Keyword_single_inheritance;
278static std::unique_ptr<llvm::pdb::PDBSymbol>
280 const IPDBSession &session = symbol.getSession();
281 const IPDBRawSymbol &raw = symbol.getRawSymbol();
282 auto tag = symbol.getSymTag();
288 case PDB_SymType::Function:
289 case PDB_SymType::Data:
290 case PDB_SymType::UDT:
291 case PDB_SymType::Enum:
292 case PDB_SymType::FunctionSig:
293 case PDB_SymType::Typedef:
294 case PDB_SymType::BaseClass:
295 case PDB_SymType::VTable: {
296 auto class_parent_id = raw.getClassParentId();
297 if (
auto class_parent = session.getSymbolById(class_parent_id))
308 case PDB_SymType::Block:
309 case PDB_SymType::Data: {
310 auto lexical_parent_id = raw.getLexicalParentId();
311 auto lexical_parent = session.getSymbolById(lexical_parent_id);
315 auto lexical_parent_tag = lexical_parent->getSymTag();
316 if (lexical_parent_tag == PDB_SymType::Function)
317 return lexical_parent;
318 if (lexical_parent_tag == PDB_SymType::Exe)
328static clang::NamedDecl *
330 const clang::DeclContext &decl_context,
331 llvm::StringRef name) {
332 clang::IdentifierInfo &ident = ast.Idents.get(name);
333 clang::DeclarationName decl_name = ast.DeclarationNames.getIdentifier(&ident);
334 clang::DeclContext::lookup_result result = decl_context.lookup(decl_name);
338 return *result.begin();
342 return name ==
"`anonymous namespace'" || name ==
"`anonymous-namespace'";
347 case llvm::codeview::CallingConvention::NearC:
349 case llvm::codeview::CallingConvention::NearStdCall:
350 return clang::CC_X86StdCall;
351 case llvm::codeview::CallingConvention::NearFast:
352 return clang::CC_X86FastCall;
353 case llvm::codeview::CallingConvention::ThisCall:
354 return clang::CC_X86ThisCall;
355 case llvm::codeview::CallingConvention::NearVector:
356 return clang::CC_X86VectorCall;
357 case llvm::codeview::CallingConvention::NearPascal:
358 return clang::CC_X86Pascal;
360 assert(
false &&
"Unknown calling convention");
373 switch (type.getSymTag()) {
374 case PDB_SymType::BaseClass: {
379 auto ty = symbol_file->
ResolveTypeUID(type.getRawSymbol().getTypeId());
380 return ty ? ty->shared_from_this() :
nullptr;
382 case PDB_SymType::UDT: {
383 auto udt = llvm::dyn_cast<PDBSymbolTypeUDT>(&type);
394 if (udt->getLength() == 0)
418 metadata.
SetUserID(type.getSymIndexId());
431 auto inheritance_attr = clang::MSInheritanceAttr::CreateImplicit(
433 record_decl->addAttr(inheritance_attr);
437 auto children = udt->findAllChildren();
438 if (!children || children->getChildCount() == 0) {
446 type_resolve_state = Type::ResolveState::Full;
455 type_resolve_state = Type::ResolveState::Forward;
458 type_resolve_state = Type::ResolveState::Forward;
460 if (udt->isConstType())
463 if (udt->isVolatileType())
468 type.getSymIndexId(),
ConstString(name), udt->getLength(),
nullptr,
472 case PDB_SymType::Enum: {
473 auto enum_type = llvm::dyn_cast<PDBSymbolTypeEnum>(&type);
479 uint64_t bytes = enum_type->getLength();
485 auto underlying_type_up = enum_type->getUnderlyingType();
486 if (!underlying_type_up)
493 auto first_child = enum_type->findOneChild<PDBSymbolData>();
500 m_ast, *underlying_type_up, encoding, bytes * 8);
506 bool isScoped =
false;
510 builtin_type, isScoped);
516 auto enum_values = enum_type->findAllChildren<PDBSymbolData>();
518 while (
auto enum_value = enum_values->getNext()) {
519 if (enum_value->getDataKind() != PDB_DataKind::Constant)
529 if (enum_type->isConstType())
532 if (enum_type->isVolatileType())
537 type.getSymIndexId(),
ConstString(name), bytes,
nullptr,
541 case PDB_SymType::Typedef: {
542 auto type_def = llvm::dyn_cast<PDBSymbolTypeTypedef>(&type);
571 assert(typedef_decl);
575 if (type_def->isConstType())
578 if (type_def->isVolatileType())
582 std::optional<uint64_t> size;
583 if (type_def->getLength())
584 size = type_def->getLength();
586 type_def->getSymIndexId(),
ConstString(name), size,
nullptr,
590 case PDB_SymType::Function:
591 case PDB_SymType::FunctionSig: {
593 PDBSymbolTypeFunctionSig *func_sig =
nullptr;
594 if (
auto pdb_func = llvm::dyn_cast<PDBSymbolFunc>(&type)) {
595 if (pdb_func->isCompilerGenerated())
598 auto sig = pdb_func->getSignature();
601 func_sig = sig.release();
605 }
else if (
auto pdb_func_sig =
606 llvm::dyn_cast<PDBSymbolTypeFunctionSig>(&type)) {
607 func_sig =
const_cast<PDBSymbolTypeFunctionSig *
>(pdb_func_sig);
609 llvm_unreachable(
"Unexpected PDB symbol!");
611 auto arg_enum = func_sig->getArguments();
612 uint32_t num_args = arg_enum->getChildCount();
613 std::vector<CompilerType> arg_list;
615 bool is_variadic = func_sig->isCVarArgs();
619 for (
uint32_t arg_idx = 0; arg_idx < num_args; arg_idx++) {
620 auto arg = arg_enum->getChildAtIndex(arg_idx);
635 arg_list.push_back(arg_ast_type);
639 auto pdb_return_type = func_sig->getReturnType();
652 if (func_sig->isConstType())
653 type_quals |= clang::Qualifiers::Const;
654 if (func_sig->isVolatileType())
655 type_quals |= clang::Qualifiers::Volatile;
659 arg_list.size(), is_variadic, type_quals, cc);
663 type.getSymIndexId(),
ConstString(name), std::nullopt,
nullptr,
667 case PDB_SymType::ArrayType: {
668 auto array_type = llvm::dyn_cast<PDBSymbolTypeArray>(&type);
670 uint32_t num_elements = array_type->getCount();
671 uint32_t element_uid = array_type->getElementTypeId();
672 std::optional<uint64_t> bytes;
673 if (uint64_t size = array_type->getLength())
698 element_ast_type, num_elements,
false);
700 array_type->getSymIndexId(),
ConstString(), bytes,
nullptr,
703 type_sp->SetEncodingType(element_type);
706 case PDB_SymType::BuiltinType: {
707 auto *builtin_type = llvm::dyn_cast<PDBSymbolTypeBuiltin>(&type);
708 assert(builtin_type);
709 PDB_BuiltinType builtin_kind = builtin_type->getBuiltinType();
710 if (builtin_kind == PDB_BuiltinType::None)
713 std::optional<uint64_t> bytes;
714 if (uint64_t size = builtin_type->getLength())
718 m_ast, *builtin_type, encoding, bytes.value_or(0) * 8);
720 if (builtin_type->isConstType())
723 if (builtin_type->isVolatileType())
729 builtin_type->getSymIndexId(), type_name, bytes,
nullptr,
733 case PDB_SymType::PointerType: {
734 auto *pointer_type = llvm::dyn_cast<PDBSymbolTypePointer>(&type);
735 assert(pointer_type);
742 pointer_type->getPointeeType()->getSymIndexId());
746 if (pointer_type->isPointerToDataMember() ||
747 pointer_type->isPointerToMemberFunction()) {
748 auto class_parent_uid = pointer_type->getRawSymbol().getClassParentId();
749 auto class_parent_type = symbol_file->
ResolveTypeUID(class_parent_uid);
750 assert(class_parent_type);
754 class_parent_type->GetLayoutCompilerType(),
756 assert(pointer_ast_type);
767 if (pointer_type->isReference())
769 else if (pointer_type->isRValueReference())
774 if (pointer_type->isConstType())
777 if (pointer_type->isVolatileType())
780 if (pointer_type->isRestrictedType())
784 pointer_type->getSymIndexId(),
ConstString(), pointer_type->getLength(),
801 clang::CXXRecordDecl *record_decl =
812 std::unique_ptr<PDBSymbol> symbol =
813 symbol_file->
GetPDBSession().getSymbolById(uid_it->getSecond());
822 switch (symbol->getSymTag()) {
823 case PDB_SymType::UDT: {
824 auto udt = llvm::dyn_cast<PDBSymbolTypeUDT>(symbol.get());
831 llvm_unreachable(
"not a forward clang type decl!");
837 uint32_t sym_id = symbol.getSymIndexId();
849 auto tag = symbol.getSymTag();
850 if (tag == PDB_SymType::Data || tag == PDB_SymType::Function) {
851 const IPDBSession &session = symbol.getSession();
852 const IPDBRawSymbol &raw = symbol.getRawSymbol();
854 auto class_parent_id = raw.getClassParentId();
855 if (std::unique_ptr<PDBSymbol> class_parent =
856 session.getSymbolById(class_parent_id)) {
857 auto class_parent_type = symbol_file->
ResolveTypeUID(class_parent_id);
858 if (!class_parent_type)
861 CompilerType class_parent_ct = class_parent_type->GetFullCompilerType();
871 if (
auto func = llvm::dyn_cast_or_null<PDBSymbolFunc>(&symbol)) {
874 if (
uint32_t rva = func->getRelativeVirtualAddress()) {
877 class_parent->findAllChildren<PDBSymbolFunc>()) {
878 while (std::unique_ptr<PDBSymbolFunc> method =
879 methods_enum->getNext()) {
880 if (method->getRelativeVirtualAddress() == rva) {
904 switch (symbol.getSymTag()) {
905 case PDB_SymType::Data: {
906 auto data = llvm::dyn_cast<PDBSymbolData>(&symbol);
910 assert(decl_context);
917 if (
auto parent_decl = llvm::dyn_cast_or_null<clang::TagDecl>(decl_context))
927 auto type = symbol_file->ResolveTypeUID(data->getTypeId());
940 case PDB_SymType::Function: {
941 auto func = llvm::dyn_cast<PDBSymbolFunc>(&symbol);
945 assert(decl_context);
950 Type *type = symbol_file->ResolveTypeUID(sym_id);
954 auto storage = func->isStatic() ? clang::StorageClass::SC_Static
955 : clang::StorageClass::SC_None;
961 std::vector<clang::ParmVarDecl *> params;
962 if (std::unique_ptr<PDBSymbolTypeFunctionSig> sig = func->getSignature()) {
964 arg_enum = sig->findAllChildren<PDBSymbolTypeFunctionArg>()) {
965 while (std::unique_ptr<PDBSymbolTypeFunctionArg> arg =
966 arg_enum->getNext()) {
967 Type *arg_type = symbol_file->ResolveTypeUID(arg->getTypeId());
975 params.push_back(param);
988 Type *type = symbol_file->ResolveTypeUID(sym_id);
999 if (symbol.getSymTag() == PDB_SymType::Function) {
1000 clang::DeclContext *result =
1018 clang::DeclContext *result =
1028 const llvm::pdb::PDBSymbol &symbol) {
1032 return parent_context;
1044 std::string name(symbol.getRawSymbol().getName());
1046 llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.
GetSpecifiers();
1055 auto global = symbol_file->GetPDBSession().getGlobalScope();
1059 bool has_type_or_function_parent =
false;
1061 for (std::size_t i = 0; i < specs.size() - 1; i++) {
1063 if (std::unique_ptr<IPDBEnumSymbols> children_enum = global->findChildren(
1064 PDB_SymType::None, specs[i].GetFullName(), NS_CaseSensitive)) {
1065 while (IPDBEnumChildren<PDBSymbol>::ChildTypePtr child =
1066 children_enum->getNext()) {
1067 if (clang::DeclContext *child_context =
1073 has_type_or_function_parent =
true;
1074 curr_context = child_context;
1083 if (!has_type_or_function_parent) {
1084 std::string namespace_name = std::string(specs[i].GetBaseName());
1085 const char *namespace_name_c_str =
1087 : namespace_name.data();
1088 clang::NamespaceDecl *namespace_decl =
1095 curr_context = namespace_decl;
1099 return curr_context;
1103 const clang::DeclContext *decl_context) {
1112 auto global_up = session.getGlobalScope();
1116 symbol = symbol_up.get();
1118 symbol = global_up.get();
1122 if (
auto children = symbol->findAllChildren())
1123 while (
auto child = children->getNext())
1127clang::NamespaceDecl *
1129 llvm::StringRef name) {
1142 for (clang::NamespaceDecl *namespace_decl : *set)
1143 if (namespace_decl->getName().equals(name))
1144 return namespace_decl;
1146 for (clang::NamespaceDecl *namespace_decl : *set)
1147 if (namespace_decl->isAnonymousNamespace())
1154 const PDBSymbolData &enum_value) {
1156 Variant v = enum_value.getValue();
1161 case PDB_VariantType::Int8:
1162 raw_value = v.Value.Int8;
1164 case PDB_VariantType::Int16:
1165 raw_value = v.Value.Int16;
1167 case PDB_VariantType::Int32:
1168 raw_value = v.Value.Int32;
1170 case PDB_VariantType::Int64:
1171 raw_value = v.Value.Int64;
1173 case PDB_VariantType::UInt8:
1174 raw_value = v.Value.UInt8;
1176 case PDB_VariantType::UInt16:
1177 raw_value = v.Value.UInt16;
1179 case PDB_VariantType::UInt32:
1180 raw_value = v.Value.UInt32;
1182 case PDB_VariantType::UInt64:
1183 raw_value = v.Value.UInt64;
1192 enum_type, decl, name.c_str(), raw_value, byte_size * 8);
1193 if (!enum_constant_decl)
1196 m_uid_to_decl[enum_value.getSymIndexId()] = enum_constant_decl;
1204 llvm::pdb::PDBSymbolTypeUDT &udt) {
1206 layout_info.
bit_size = udt.getLength() * 8;
1208 auto nested_enums = udt.findAllChildren<PDBSymbolTypeUDT>();
1210 while (
auto nested = nested_enums->getNext())
1213 auto bases_enum = udt.findAllChildren<PDBSymbolTypeBaseClass>();
1219 auto members_enum = udt.findAllChildren<PDBSymbolData>();
1223 auto methods_enum = udt.findAllChildren<PDBSymbolFunc>();
1231 clang::CXXRecordDecl *record_decl =
1234 return static_cast<bool>(compiler_type);
1238 return static_cast<bool>(compiler_type);
1246 while (
auto member = members_enum.getNext()) {
1247 if (member->isCompilerGenerated())
1250 auto member_name = member->getName();
1252 auto member_type = symbol_file.
ResolveTypeUID(member->getTypeId());
1257 if (!member_comp_type.GetCompleteType()) {
1259 ":: Class '{0}' has a member '{1}' of type '{2}' "
1260 "which does not have a complete definition.",
1262 member_comp_type.GetTypeName().GetCString());
1269 switch (member->getDataKind()) {
1270 case PDB_DataKind::Member: {
1271 auto location_type = member->getLocationType();
1273 auto bit_size = member->getLength();
1274 if (location_type == PDB_LocType::ThisRel)
1278 record_type, member_name.c_str(), member_comp_type, access, bit_size);
1284 auto offset = member->getOffset() * 8;
1285 if (location_type == PDB_LocType::BitField)
1286 offset += member->getBitPosition();
1288 layout_info.
field_offsets.insert(std::make_pair(decl, offset));
1292 case PDB_DataKind::StaticMember: {
1294 record_type, member_name.c_str(), member_comp_type, access);
1300 if (member_comp_type.IsConst()) {
1301 auto value = member->getValue();
1302 if (value.Type == llvm::pdb::Empty) {
1304 "Class '{0}' has member '{1}' of type '{2}' with an unknown "
1307 member_comp_type.GetTypeName());
1311 clang::QualType qual_type = decl->getType();
1313 unsigned constant_width = value.getBitWidth();
1315 if (qual_type->isIntegralOrEnumerationType()) {
1316 if (type_width >= constant_width) {
1318 decl, value.toAPSInt().extOrTrunc(type_width));
1321 "Class '{0}' has a member '{1}' of type '{2}' ({3} bits) "
1322 "which resolves to a wider constant value ({4} bits). "
1323 "Ignoring constant.",
1325 member_comp_type.GetTypeName(), type_width,
1329 switch (member_comp_type.GetBasicTypeEnumeration()) {
1333 if (type_width == constant_width) {
1335 decl, value.toAPFloat());
1336 decl->setConstexpr(
true);
1339 "Class '{0}' has a member '{1}' of type '{2}' ({3} "
1340 "bits) which resolves to a constant value of mismatched "
1341 "width ({4} bits). Ignoring constant.",
1343 member_comp_type.GetTypeName(), type_width,
1358 llvm_unreachable(
"unsupported PDB data kind");
1368 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> base_classes;
1370 while (
auto base = bases_enum.getNext()) {
1376 if (!base_comp_type.GetCompleteType()) {
1378 ":: Class '{0}' has a base class '{1}' "
1379 "which does not have a complete definition.",
1381 base_comp_type.GetTypeName().GetCString());
1388 auto is_virtual = base->isVirtualBaseClass();
1390 std::unique_ptr<clang::CXXBaseSpecifier> base_spec =
1393 record_kind == clang::TTK_Class);
1396 base_classes.push_back(std::move(base_spec));
1405 auto offset = clang::CharUnits::fromQuantity(base->getOffset());
1406 layout_info.
base_offsets.insert(std::make_pair(decl, offset));
1410 std::move(base_classes));
1416 while (std::unique_ptr<PDBSymbolFunc> method = methods_enum.getNext())
1417 if (clang::CXXMethodDecl *decl =
1422clang::CXXMethodDecl *
1425 const llvm::pdb::PDBSymbolFunc &method)
const {
1437 ":: Class '{0}' has a method '{1}' whose type cannot be completed.",
1451 nullptr, method_comp_type, access, method.isVirtual(),
1452 method.isStatic(), method.hasInlineAttribute(),
1455 method.isCompilerGenerated());
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
static clang::CallingConv TranslateCallingConvention(PDB_CallingConv pdb_cc)
static int TranslateUdtKind(PDB_UdtType pdb_kind)
static clang::NamedDecl * GetDeclFromContextByName(const clang::ASTContext &ast, const clang::DeclContext &decl_context, llvm::StringRef name)
static ConstString GetPDBBuiltinTypeName(const PDBSymbolTypeBuiltin &pdb_type, CompilerType &compiler_type)
static std::unique_ptr< llvm::pdb::PDBSymbol > GetClassOrFunctionParent(const llvm::pdb::PDBSymbol &symbol)
static lldb::Encoding TranslateEnumEncoding(PDB_VariantType type)
static AccessType TranslateMemberAccess(PDB_MemberAccess access)
static CompilerType GetBuiltinTypeForPDBEncodingAndBitSize(TypeSystemClang &clang_ast, const PDBSymbolTypeBuiltin &pdb_type, Encoding encoding, uint32_t width)
static lldb::Encoding TranslateBuiltinEncoding(PDB_BuiltinType type)
static AccessType GetAccessibilityForUdt(const PDBSymbolTypeUDT &udt)
static AccessType GetDefaultAccessibilityForUdtKind(PDB_UdtType udt_kind)
static bool AddSourceInfoToDecl(const PDBSymbol &symbol, Declaration &decl)
static clang::MSInheritanceAttr::Spelling GetMSInheritance(const PDBSymbolTypeUDT &udt)
static bool IsAnonymousNamespaceName(llvm::StringRef name)
static std::optional< clang::CallingConv > TranslateCallingConvention(llvm::codeview::CallingConvention conv)
static bool IsAnonymousNamespaceName(llvm::StringRef name)
static clang::TagTypeKind TranslateUdtKind(const TagRecord &cr)
llvm::ArrayRef< MSVCUndecoratedNameSpecifier > GetSpecifiers() const
static llvm::StringRef DropScope(llvm::StringRef name)
lldb_private::TypeSystemClang & m_ast
clang::NamespaceDecl * FindNamespaceDecl(const clang::DeclContext *parent, llvm::StringRef name)
bool CompleteTypeFromUDT(lldb_private::SymbolFile &symbol_file, lldb_private::CompilerType &compiler_type, llvm::pdb::PDBSymbolTypeUDT &udt)
void AddRecordMethods(lldb_private::SymbolFile &symbol_file, lldb_private::CompilerType &record_type, PDBFuncSymbolEnumerator &methods_enum)
NamespacesSet m_namespaces
lldb::TypeSP CreateLLDBTypeFromPDBType(const llvm::pdb::PDBSymbol &type)
DeclContextToUidMap m_decl_context_to_uid
clang::DeclContext * GetDeclContextForSymbol(const llvm::pdb::PDBSymbol &symbol)
lldb_private::ClangASTImporter & GetClangASTImporter()
void ParseDeclsForDeclContext(const clang::DeclContext *decl_context)
void AddRecordBases(lldb_private::SymbolFile &symbol_file, lldb_private::CompilerType &record_type, int record_kind, PDBBaseClassSymbolEnumerator &bases_enum, lldb_private::ClangASTImporter::LayoutInfo &layout_info) const
void AddRecordMembers(lldb_private::SymbolFile &symbol_file, lldb_private::CompilerType &record_type, PDBDataSymbolEnumerator &members_enum, lldb_private::ClangASTImporter::LayoutInfo &layout_info)
std::set< clang::NamespaceDecl * > NamespacesSet
UidToDeclMap m_uid_to_decl
bool CompleteTypeFromPDB(lldb_private::CompilerType &compiler_type)
bool AddEnumValue(lldb_private::CompilerType enum_type, const llvm::pdb::PDBSymbolData &data)
PDBASTParser(lldb_private::TypeSystemClang &ast)
ParentToNamespacesMap m_parent_to_namespaces
clang::Decl * GetDeclForSymbol(const llvm::pdb::PDBSymbol &symbol)
clang::DeclContext * GetDeclContextContainingSymbol(const llvm::pdb::PDBSymbol &symbol)
clang::CXXMethodDecl * AddRecordMethod(lldb_private::SymbolFile &symbol_file, lldb_private::CompilerType &record_type, const llvm::pdb::PDBSymbolFunc &method) const
CXXRecordDeclToUidMap m_forward_decl_to_uid
llvm::pdb::IPDBSession & GetPDBSession()
lldb_private::Type * ResolveTypeUID(lldb::user_id_t type_uid) override
bool CompleteType(const CompilerType &compiler_type)
void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo &layout)
Sets the layout for the given RecordDecl.
Generic representation of a type in a programming language.
CompilerType AddConstModifier() const
Return a new CompilerType adds a const modifier to this type if this type is valid and the type syste...
CompilerType GetRValueReferenceType() const
Return a new CompilerType that is a R value reference to this type if this type is valid and the type...
CompilerType GetPointerType() const
Return a new CompilerType that is a pointer to this type.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
CompilerType AddVolatileModifier() const
Return a new CompilerType adds a volatile modifier to this type if this type is valid and the type sy...
CompilerType AddRestrictModifier() const
Return a new CompilerType adds a restrict modifier to this type if this type is valid and the type sy...
CompilerType GetLValueReferenceType() const
Return a new CompilerType that is a L value reference to this type if this type is valid and the type...
ConstString GetTypeName(bool BaseOnly=false) const
bool GetCompleteType() const
Type Completion.
CompilerType CreateTypedef(const char *name, const CompilerDeclContext &decl_ctx, uint32_t payload) const
Create a typedef to this type using "name" as the name of the typedef this type is valid and the type...
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
A class that describes the declaration location of a lldb object.
void SetLine(uint32_t line)
Set accessor for the declaration line number.
void SetColumn(uint16_t column)
Set accessor for the declaration column number.
void SetFile(const FileSpec &file_spec)
Set accessor for the declaration file specification.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Provides public interface for all SymbolFiles.
virtual Type * ResolveTypeUID(lldb::user_id_t type_uid)=0
virtual SymbolFile * GetBackingSymbolFile()
SymbolFileOnDemand class overrides this to return the underlying backing SymbolFile implementation th...
virtual lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name, std::optional< uint64_t > byte_size, SymbolContextScope *context, lldb::user_id_t encoding_uid, Type::EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_qual_type, Type::ResolveState compiler_type_resolve_state, uint32_t opaque_payload=0)=0
virtual ObjectFile * GetObjectFile()=0
A TypeSystem implementation based on Clang.
clang::TranslationUnitDecl * GetTranslationUnitDecl()
static clang::TypedefNameDecl * GetAsTypedefDecl(const CompilerType &type)
CompilerType GetBasicType(lldb::BasicType type)
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size)
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
static bool IsCXXClassType(const CompilerType &type)
static void SetFloatingInitializerForVariable(clang::VarDecl *var, const llvm::APFloat &init_value)
Initializes a variable with a floating point value.
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > bases)
static void SetIntegerInitializerForVariable(clang::VarDecl *var, const llvm::APInt &init_value)
Initializes a variable with an integer value.
std::unique_ptr< clang::CXXBaseSpecifier > CreateBaseClassSpecifier(lldb::opaque_compiler_type_t type, lldb::AccessType access, bool is_virtual, bool base_of_class)
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
CompilerType GetTypeForIdentifier(ConstString type_name, clang::DeclContext *decl_context=nullptr)
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline)
static void BuildIndirectFields(const CompilerType &type)
void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type)
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, const char *mangled_name, const CompilerType &method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, int64_t enum_value, uint32_t enum_value_bit_size)
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
clang::ASTContext & getASTContext()
Returns the clang::ASTContext instance managed by this TypeSystemClang.
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped)
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType ¶m_type, int storage, bool add_decl=false)
CompilerType CreateArrayType(const CompilerType &element_type, size_t element_count, bool is_vector)
bool GetCompleteDecl(clang::Decl *decl)
static bool StartTagDeclarationDefinition(const CompilerType &type)
static clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type, lldb::AccessType access)
CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
static clang::EnumDecl * GetAsEnumDecl(const CompilerType &type)
void SetFunctionParameters(clang::FunctionDecl *function_decl, llvm::ArrayRef< clang::ParmVarDecl * > params)
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, ClangASTMetadata *metadata=nullptr, bool exports_symbols=false)
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
virtual SymbolFile * GetSymbolFile() const
CompilerType GetForwardCompilerType()
@ eEncodingIsTypedefUID
This type is alias to a type whose UID is m_encoding_uid.
@ eEncodingIsUID
This type is the type whose UID is m_encoding_uid.
CompilerType GetLayoutCompilerType()
CompilerType GetFullCompilerType()
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
Encoding
Register encoding definitions.
@ eEncodingUint
unsigned integer
@ eEncodingSint
signed integer
llvm::DenseMap< const clang::FieldDecl *, uint64_t > field_offsets
static clang::QualType GetQualType(const CompilerType &ct)
lldb::user_id_t GetID() const
Get accessor for the user ID.