3#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
4#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
5#include "llvm/DebugInfo/CodeView/RecordName.h"
6#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
7#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
8#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
9#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
10#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
11#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
12#include "llvm/DebugInfo/PDB/Native/PublicsStream.h"
13#include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
14#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
15#include "llvm/Demangle/MicrosoftDemangle.h"
37 CreateMethodDecl(PdbIndex &m_index, TypeSystemClang &m_clang,
38 TypeIndex func_type_index,
39 clang::FunctionDecl *&function_decl,
41 llvm::StringRef proc_name, ConstString mangled_name,
43 : m_index(m_index), m_clang(m_clang), func_type_index(func_type_index),
44 function_decl(function_decl), parent_ty(parent_ty),
45 proc_name(proc_name), mangled_name(mangled_name), func_ct(func_ct) {}
47 TypeSystemClang &m_clang;
48 TypeIndex func_type_index;
49 clang::FunctionDecl *&function_decl;
51 llvm::StringRef proc_name;
52 ConstString mangled_name;
55 llvm::Error visitKnownMember(CVMemberRecord &cvr,
56 OverloadedMethodRecord &overloaded)
override {
57 TypeIndex method_list_idx = overloaded.MethodList;
59 CVType method_list_type = m_index.tpi().getType(method_list_idx);
60 assert(method_list_type.kind() == LF_METHODLIST);
62 MethodOverloadListRecord method_list;
63 llvm::cantFail(TypeDeserializer::deserializeAs<MethodOverloadListRecord>(
64 method_list_type, method_list));
66 for (
const OneMethodRecord &method : method_list.Methods) {
67 if (method.getType().getIndex() == func_type_index.getIndex())
68 AddMethod(overloaded.Name, method.getAccess(), method.getOptions(),
72 return llvm::Error::success();
75 llvm::Error visitKnownMember(CVMemberRecord &cvr,
76 OneMethodRecord &record)
override {
77 AddMethod(record.getName(), record.getAccess(), record.getOptions(),
79 return llvm::Error::success();
82 void AddMethod(llvm::StringRef name, MemberAccess access,
83 MethodOptions options, MemberAttributes attrs) {
84 if (name != proc_name || function_decl)
87 bool is_virtual = attrs.isVirtual();
88 bool is_static = attrs.isStatic();
89 bool is_artificial = (options & MethodOptions::CompilerGenerated) ==
90 MethodOptions::CompilerGenerated;
91 function_decl = m_clang.AddMethodToCXXRecordType(
92 parent_ty, proc_name, mangled_name, func_ct, access_type,
93 is_virtual, is_static,
95 false, is_artificial);
102 case TypeRecordKind::Class:
103 return clang::TagTypeKind::Class;
104 case TypeRecordKind::Struct:
105 return clang::TagTypeKind::Struct;
106 case TypeRecordKind::Union:
107 return clang::TagTypeKind::Union;
108 case TypeRecordKind::Interface:
109 return clang::TagTypeKind::Interface;
110 case TypeRecordKind::Enum:
111 return clang::TagTypeKind::Enum;
113 lldbassert(
false &&
"Invalid tag record kind!");
114 return clang::TagTypeKind::Struct;
121 return args.back() == TypeIndex::None();
126 for (llvm::ms_demangle::Node *n : scopes) {
127 auto *idn =
static_cast<llvm::ms_demangle::IdentifierNode *
>(n);
128 if (idn->TemplateParams)
134static std::optional<clang::CallingConv>
136 using CC = llvm::codeview::CallingConvention;
141 return clang::CallingConv::CC_C;
144 return clang::CallingConv::CC_X86Pascal;
147 return clang::CallingConv::CC_X86FastCall;
148 case CC::NearStdCall:
150 return clang::CallingConv::CC_X86StdCall;
152 return clang::CallingConv::CC_X86ThisCall;
154 return clang::CallingConv::CC_X86VectorCall;
161 return name ==
"`anonymous namespace'" || name ==
"`anonymous-namespace'";
170std::pair<clang::DeclContext *, std::string>
173 m_clang.GetSymbolFile()->GetBackingSymbolFile());
175 if (!record.hasUniqueName())
178 llvm::ms_demangle::Demangler demangler;
179 std::string_view sv(record.UniqueName.begin(), record.UniqueName.size());
180 llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
184 llvm::ms_demangle::IdentifierNode *idn =
185 ttn->QualifiedName->getUnqualifiedIdentifier();
186 std::string uname = idn->toString(llvm::ms_demangle::OF_NoTagSpecifier);
188 llvm::ms_demangle::NodeArrayNode *name_components =
189 ttn->QualifiedName->Components;
190 llvm::ArrayRef<llvm::ms_demangle::Node *> scopes(name_components->Nodes,
191 name_components->Count - 1);
193 clang::DeclContext *context =
m_clang.GetTranslationUnitDecl();
198 std::optional<TypeIndex> parent_index =
pdb->GetParentType(ti);
201 return {context, uname};
209 return {context, std::string(record.Name)};
211 for (llvm::ms_demangle::Node *scope : scopes) {
212 auto *nii =
static_cast<llvm::ms_demangle::NamedIdentifierNode *
>(scope);
213 std::string str = nii->toString();
216 return {context, uname};
224 if (parent_qt.isNull())
225 return {
nullptr,
""};
227 context = clang::TagDecl::castToDeclContext(parent_qt->getAsTagDecl());
228 return {context, uname};
245 m_clang.GetSymbolFile()->GetBackingSymbolFile());
253 clang::Decl *scope_decl = clang::Decl::castFromDeclContext(scope);
259 switch (cvs.kind()) {
278std::optional<CompilerDecl>
283 clang::Decl *result =
nullptr;
284 switch (uid.
kind()) {
292 if (
auto *tag = qt->getAsTagDecl()) {
320 return clang::Decl::castToDeclContext(decl);
323std::pair<clang::DeclContext *, std::string>
326 m_clang.GetSymbolFile()->GetBackingSymbolFile());
329 llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.
GetSpecifiers();
333 llvm::StringRef uname = specs.back().GetBaseName();
334 specs = specs.drop_back();
336 return {context, std::string(name)};
338 llvm::StringRef scope_name = specs.back().GetFullName();
341 std::vector<TypeIndex> types = index.
tpi().findRecordsByName(scope_name);
342 while (!types.empty()) {
346 clang::TagDecl *tag = qt->getAsTagDecl();
348 return {clang::TagDecl::castToDeclContext(tag), std::string(uname)};
354 std::string ns_name = spec.GetBaseName().str();
357 return {context, std::string(uname)};
364 m_clang.GetSymbolFile()->GetBackingSymbolFile());
366 switch (uid.
kind()) {
368 std::optional<PdbCompilandSymId> scope =
380 std::optional<TypeIndex> parent_index =
pdb->GetParentType(type_id.
index);
397 switch (global.kind()) {
398 case SymbolKind::S_GDATA32:
399 case SymbolKind::S_LDATA32:
401 case SymbolKind::S_PROCREF:
402 case SymbolKind::S_LPROCREF: {
403 ProcRefSym ref{global.kind()};
405 SymbolDeserializer::deserializeAs<ProcRefSym>(global, ref));
409 case SymbolKind::S_CONSTANT:
410 case SymbolKind::S_UDT:
426 clang::TagDecl *tag = qt->getAsTagDecl();
427 if (qt->isArrayType()) {
428 const clang::Type *element_type = qt->getArrayElementTypeNoTypeQual();
429 tag = element_type->getAsTagDecl();
449 m_clang.GetSymbolFile()->GetBackingSymbolFile())
453 clang::QualType tag_qt =
m_clang.getASTContext().getCanonicalTagType(&tag);
457 CVType cvt = index.
tpi().getType(tag_ti);
458 if (cvt.kind() == LF_MODIFIER)
462 cvt = index.
tpi().getType(best_ti.
index);
472 CVType field_list_cvt = index.
tpi().getType(field_list_ti);
473 if (field_list_cvt.kind() != LF_FIELDLIST)
475 FieldListRecord field_list;
476 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
477 field_list_cvt, field_list))
478 llvm::consumeError(std::move(
error));
486 llvm::codeview::visitMemberRecordStream(field_list.Data, completer);
491 llvm::consumeError(std::move(
error));
498 if (ti == TypeIndex::NullptrT())
501 if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
503 if (direct_type.isNull())
505 return m_clang.getASTContext().getPointerType(direct_type);
508 if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
523 if (pointee_type.isNull())
526 if (pointer.isPointerToMember()) {
527 MemberPointerInfo mpi = pointer.getMemberInfo();
529 if (class_type.isNull())
531 if (clang::TagDecl *tag = class_type->getAsTagDecl()) {
532 clang::MSInheritanceAttr::Spelling spelling;
533 switch (mpi.Representation) {
534 case llvm::codeview::PointerToMemberRepresentation::SingleInheritanceData:
535 case llvm::codeview::PointerToMemberRepresentation::
536 SingleInheritanceFunction:
538 clang::MSInheritanceAttr::Spelling::Keyword_single_inheritance;
540 case llvm::codeview::PointerToMemberRepresentation::
541 MultipleInheritanceData:
542 case llvm::codeview::PointerToMemberRepresentation::
543 MultipleInheritanceFunction:
545 clang::MSInheritanceAttr::Spelling::Keyword_multiple_inheritance;
547 case llvm::codeview::PointerToMemberRepresentation::
548 VirtualInheritanceData:
549 case llvm::codeview::PointerToMemberRepresentation::
550 VirtualInheritanceFunction:
552 clang::MSInheritanceAttr::Spelling::Keyword_virtual_inheritance;
554 case llvm::codeview::PointerToMemberRepresentation::Unknown:
556 clang::MSInheritanceAttr::Spelling::Keyword_unspecified_inheritance;
559 spelling = clang::MSInheritanceAttr::Spelling::SpellingNotCalculated;
562 tag->addAttr(clang::MSInheritanceAttr::CreateImplicit(
563 m_clang.getASTContext(), spelling));
565 return m_clang.getASTContext().getMemberPointerType(
566 pointee_type, std::nullopt,
567 class_type->getAsCXXRecordDecl());
570 clang::QualType pointer_type;
571 if (pointer.getMode() == PointerMode::LValueReference)
572 pointer_type =
m_clang.getASTContext().getLValueReferenceType(pointee_type);
573 else if (pointer.getMode() == PointerMode::RValueReference)
574 pointer_type =
m_clang.getASTContext().getRValueReferenceType(pointee_type);
576 pointer_type =
m_clang.getASTContext().getPointerType(pointee_type);
578 if ((pointer.getOptions() & PointerOptions::Const) != PointerOptions::None)
579 pointer_type.addConst();
581 if ((pointer.getOptions() & PointerOptions::Volatile) != PointerOptions::None)
582 pointer_type.addVolatile();
584 if ((pointer.getOptions() & PointerOptions::Restrict) != PointerOptions::None)
585 pointer_type.addRestrict();
592 clang::QualType unmodified_type =
GetOrCreateType(modifier.ModifiedType);
593 if (unmodified_type.isNull())
596 if ((modifier.Modifiers & ModifierOptions::Const) != ModifierOptions::None)
597 unmodified_type.addConst();
598 if ((modifier.Modifiers & ModifierOptions::Volatile) != ModifierOptions::None)
599 unmodified_type.addVolatile();
601 return unmodified_type;
605 const TagRecord &record) {
606 clang::DeclContext *context =
nullptr;
632 clang::QualType result =
646clang::NamespaceDecl *
648 clang::DeclContext &context) {
649 clang::NamespaceDecl *ns =
m_clang.GetUniqueNamespaceDeclaration(
660 return llvm::dyn_cast<clang::BlockDecl>(decl);
664 clang::BlockDecl *block_decl =
677 clang::DeclContext &scope) {
683 clang::VarDecl *var_decl =
m_clang.CreateVariableDeclaration(
698 return llvm::dyn_cast<clang::VarDecl>(decl);
705 m_clang.GetSymbolFile()->GetBackingSymbolFile());
713 return llvm::dyn_cast<clang::VarDecl>(decl);
716 m_clang.GetSymbolFile()->GetBackingSymbolFile());
723clang::TypedefNameDecl *
726 return llvm::dyn_cast<clang::TypedefNameDecl>(decl);
729 m_clang.GetSymbolFile()->GetBackingSymbolFile());
733 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
739 if (qt.isNull() || !scope)
746 clang::TypedefNameDecl *tnd =
m_clang.GetAsTypedefDecl(ct);
760 if (type.
index.isSimple())
764 m_clang.GetSymbolFile()->GetBackingSymbolFile());
766 CVType cvt = index.
tpi().getType(type.
index);
768 if (cvt.kind() == LF_MODIFIER) {
769 ModifierRecord modifier;
771 TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier));
775 if (cvt.kind() == LF_POINTER) {
776 PointerRecord pointer;
778 TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer));
791 if (cvt.kind() == LF_ARRAY) {
793 llvm::cantFail(TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar));
797 if (cvt.kind() == LF_PROCEDURE) {
799 llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr));
803 if (cvt.kind() == LF_MFUNCTION) {
804 MemberFunctionRecord mfr;
806 TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr));
814 if (type.
index.isNoneType())
823 m_clang.GetSymbolFile()->GetBackingSymbolFile());
846 clang::TagDecl *tag = qt->getAsTagDecl();
858 llvm::StringRef func_name,
TypeIndex func_ti,
860 clang::StorageClass func_storage,
861 bool is_inline, clang::DeclContext *parent) {
862 clang::FunctionDecl *function_decl =
nullptr;
863 if (parent->isRecord()) {
865 m_clang.GetSymbolFile()->GetBackingSymbolFile());
867 clang::CanQualType parent_qt =
868 m_clang.getASTContext().getCanonicalTypeDeclType(
869 llvm::cast<clang::TypeDecl>(parent));
875 if (iter->getSecond().contains({func_name, func_ct})) {
880 CVType cvt = index.
tpi().getType(func_ti);
881 MemberFunctionRecord func_record(
static_cast<TypeRecordKind
>(cvt.kind()));
882 llvm::cantFail(TypeDeserializer::deserializeAs<MemberFunctionRecord>(
884 TypeIndex class_index = func_record.getClassType();
886 CVType parent_cvt = index.
tpi().getType(class_index);
889 if (tag_record.isForwardRef()) {
890 llvm::Expected<TypeIndex> eti =
891 index.
tpi().findFullDeclForForwardRef(class_index);
898 pdb->FindMangledFunctionName(func_id).value_or(llvm::StringRef()));
900 if (!tag_record.FieldList.isSimple()) {
901 CVType field_list_cvt = index.
tpi().getType(tag_record.FieldList);
902 FieldListRecord field_list;
903 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
904 field_list_cvt, field_list))
905 llvm::consumeError(std::move(
error));
906 CreateMethodDecl process(index,
m_clang, func_ti, function_decl,
907 parent_opaque_ty, func_name, mangled_name,
909 if (llvm::Error err = visitMemberRecordStream(field_list.Data, process))
910 llvm::consumeError(std::move(err));
913 if (!function_decl) {
914 function_decl =
m_clang.AddMethodToCXXRecordType(
915 parent_opaque_ty, func_name, mangled_name, func_ct,
923 function_decl =
m_clang.CreateFunctionDeclaration(
928 return function_decl;
934 m_clang.GetSymbolFile()->GetBackingSymbolFile());
939 InlineSiteSym inline_site(
static_cast<SymbolRecordKind
>(sym.kind()));
940 cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site));
947 return llvm::dyn_cast<clang::FunctionDecl>(decl);
948 clang::FunctionDecl *function_decl =
950 if (function_decl ==
nullptr)
955 uint64_t inlinesite_uid =
toOpaqueUid(inlinesite_id);
958 status.
uid = inlinesite_uid;
967 return function_decl;
975 m_clang.GetSymbolFile()->GetBackingSymbolFile());
977 CVType func_cvt = index.
ipi().getType(func_tid.
index);
978 llvm::StringRef func_name;
980 clang::DeclContext *parent =
nullptr;
981 switch (func_cvt.kind()) {
983 MemberFuncIdRecord mfr;
985 TypeDeserializer::deserializeAs<MemberFuncIdRecord>(func_cvt, mfr));
986 func_name = mfr.getName();
987 func_ti = mfr.getFunctionType();
994 cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(func_cvt, fir));
995 func_name = fir.getName();
996 func_ti = fir.getFunctionType();
998 if (!fir.ParentScope.isNoneType()) {
999 CVType parent_cvt = index.
ipi().getType(fir.ParentScope);
1000 if (parent_cvt.kind() == LF_STRING_ID) {
1003 TypeDeserializer::deserializeAs<StringIdRecord>(parent_cvt, sir));
1010 lldbassert(
false &&
"Invalid function id type!");
1013 if (func_qt.isNull() || !parent)
1016 uint32_t param_count =
1017 llvm::cast<clang::FunctionProtoType>(func_qt)->getNumParams();
1019 clang::SC_None,
true, parent);
1022clang::FunctionDecl *
1025 return llvm::dyn_cast<clang::FunctionDecl>(decl);
1030 std::string context_name;
1031 if (clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(parent)) {
1032 context_name = ns->getQualifiedNameAsString();
1033 }
else if (clang::TagDecl *tag = llvm::dyn_cast<clang::TagDecl>(parent)) {
1034 context_name = tag->getQualifiedNameAsString();
1038 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1041 ProcSym proc(
static_cast<SymbolRecordKind
>(cvs.kind()));
1042 llvm::cantFail(SymbolDeserializer::deserializeAs<ProcSym>(cvs, proc));
1049 clang::StorageClass storage = clang::SC_None;
1050 if (proc.Kind == SymbolRecordKind::ProcSym)
1051 storage = clang::SC_Static;
1053 const clang::FunctionProtoType *func_type =
1054 llvm::dyn_cast<clang::FunctionProtoType>(qt);
1058 llvm::StringRef proc_name = proc.Name;
1059 proc_name.consume_front(context_name);
1060 proc_name.consume_front(
"::");
1061 clang::FunctionDecl *function_decl =
1063 func_type->getNumParams(), storage,
false, parent);
1064 if (function_decl ==
nullptr)
1074 return function_decl;
1078 clang::FunctionDecl &function_decl,
1079 uint32_t param_count) {
1081 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1084 CVSymbolArray scope =
1088 auto begin = scope.begin();
1089 auto end = scope.end();
1090 std::vector<clang::ParmVarDecl *> params;
1091 for (uint32_t i = 0; i < param_count && begin != end;) {
1092 uint32_t record_offset = begin.offset();
1093 CVSymbol sym = *begin++;
1096 llvm::StringRef param_name;
1097 switch (sym.kind()) {
1099 RegRelativeSym reg(SymbolRecordKind::RegRelativeSym);
1100 cantFail(SymbolDeserializer::deserializeAs<RegRelativeSym>(sym, reg));
1101 param_type = reg.Type;
1102 param_name = reg.Name;
1106 RegisterSym reg(SymbolRecordKind::RegisterSym);
1107 cantFail(SymbolDeserializer::deserializeAs<RegisterSym>(sym, reg));
1108 param_type = reg.Index;
1109 param_name = reg.Name;
1113 LocalSym local(SymbolRecordKind::LocalSym);
1114 cantFail(SymbolDeserializer::deserializeAs<LocalSym>(sym, local));
1115 if ((local.Flags & LocalSymFlags::IsParameter) == LocalSymFlags::None)
1117 param_type = local.Type;
1118 param_name = local.Name;
1138 clang::ParmVarDecl *param =
m_clang.CreateParameterDeclaration(
1140 param_type_ct, clang::SC_None,
true);
1144 params.push_back(param);
1148 if (!params.empty() && params.size() == param_count)
1149 function_decl.setParams(params);
1153 const EnumRecord &er) {
1154 clang::DeclContext *decl_context =
nullptr;
1161 if (underlying_type.isNull())
1180 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1183 if (element_type.isNull() || element_size == 0)
1185 uint64_t element_count = ar.Size / element_size;
1188 element_count,
false);
1194 llvm::codeview::CallingConvention calling_convention) {
1196 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1198 TpiStream &stream = index.
tpi();
1199 CVType args_cvt = stream.getType(args_type_idx);
1202 TypeDeserializer::deserializeAs<ArgListRecord>(args_cvt, args));
1204 llvm::ArrayRef<TypeIndex> arg_indices = llvm::ArrayRef(args.ArgIndices);
1207 arg_indices = arg_indices.drop_back();
1209 std::vector<CompilerType> arg_types;
1210 arg_types.reserve(arg_indices.size());
1212 for (
TypeIndex arg_index : arg_indices) {
1214 if (arg_type.isNull())
1220 if (return_type.isNull())
1223 std::optional<clang::CallingConv> cc =
1230 m_clang.CreateFunctionType(return_ct, arg_types, is_variadic, 0, *cc);
1232 return clang::QualType::getFromOpaquePtr(
1237 return llvm::isa<clang::TagDecl>(&context);
1241 return llvm::isa<clang::FunctionDecl>(&context);
1245 return llvm::isa<clang::BlockDecl>(&context);
1249 clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(&context);
1252 std::string qname = ns->getQualifiedNameAsString();
1254 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1257 for (
const CVType &cvt : index.
tpi().typeArray()) {
1269 clang::DeclContext *context =
nullptr;
1272 if (!context || !context->isNamespace())
1275 clang::NamespaceDecl *ns = llvm::cast<clang::NamespaceDecl>(context);
1276 llvm::StringRef ns_name = ns->getName();
1277 if (ns_name.starts_with(qname)) {
1278 ns_name = ns_name.drop_front(qname.size());
1279 if (ns_name.starts_with(
"::"))
1290 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1293 for (
const CVType &cvt : index.
tpi().typeArray()) {
1308 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1310 uint32_t module_count = index.
dbi().modules().getModuleCount();
1311 for (uint16_t modi = 0; modi < module_count; ++modi) {
1313 const CVSymbolArray &symbols = cii.
m_debug_stream.getSymbolArray();
1314 auto iter = symbols.begin();
1315 while (iter != symbols.end()) {
1318 switch (iter->kind()) {
1322 iter = symbols.at(getScopeEndOffset(*iter));
1341 const CVSymbolArray &symbols) {
1342 clang::FunctionDecl *func_decl = llvm::dyn_cast<clang::FunctionDecl>(&decl);
1345 unsigned int params = func_decl->getNumParams();
1349 CVSymbolArray result = symbols;
1351 while (!result.empty()) {
1355 CVSymbol sym = *result.begin();
1356 result.drop_front();
1368 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1371 lldbassert(sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32 ||
1372 sym.kind() == S_BLOCK32 || sym.kind() == S_INLINESITE);
1375 CVSymbolArray symbols =
1380 if (sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32)
1384 symbols.drop_front();
1385 auto begin = symbols.begin();
1386 while (begin != symbols.end()) {
1389 if (begin->kind() == S_BLOCK32 || begin->kind() == S_INLINESITE) {
1391 begin = symbols.at(getScopeEndOffset(*begin));
1399 clang::Decl *decl = clang::Decl::castFromDeclContext(&context);
1405 if (
auto *tag = llvm::dyn_cast<clang::TagDecl>(&context)) {
1423 if (context.isTranslationUnit()) {
1429 if (context.isNamespace()) {
1441 return m_clang.GetCompilerDecl(&decl);
1445 return {
m_clang.weak_from_this(), qt.getAsOpaquePtr()};
1450 return m_clang.CreateDeclContext(&context);
1467clang::NamespaceDecl *
1469 llvm::StringRef name) {
1483 for (clang::NamespaceDecl *namespace_decl : *set)
1484 if (namespace_decl->getName() == name)
1485 return namespace_decl;
1487 for (clang::NamespaceDecl *namespace_decl : *set)
1488 if (namespace_decl->isAnonymousNamespace())
static llvm::raw_ostream & error(Stream &strm)
static bool isFunctionDecl(clang::DeclContext &context)
static bool isBlockDecl(clang::DeclContext &context)
static CVSymbolArray skipFunctionParameters(clang::Decl &decl, const CVSymbolArray &symbols)
static std::optional< clang::CallingConv > TranslateCallingConvention(llvm::codeview::CallingConvention conv)
static bool isTagDecl(clang::DeclContext &context)
static bool isLocalVariableType(SymbolKind K)
static bool IsAnonymousNamespaceName(llvm::StringRef name)
static clang::TagTypeKind TranslateUdtKind(const TagRecord &cr)
static bool IsCVarArgsFunction(llvm::ArrayRef< TypeIndex > args)
static bool AnyScopesHaveTemplateParams(llvm::ArrayRef< llvm::ms_demangle::Node * > scopes)
llvm::ArrayRef< MSVCUndecoratedNameSpecifier > GetSpecifiers() const
Represents a generic declaration context in a program.
void * GetOpaqueDeclContext() const
Represents a generic declaration such as a function declaration.
Generic representation of a type in a programming language.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
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.
A class that describes the declaration location of a lldb object.
A stream class that can stream formatted output to a file.
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
A TypeSystem implementation based on Clang.
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
static bool StartTagDeclarationDefinition(const CompilerType &type)
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
CompilandIndexItem & GetOrCreateCompiland(uint16_t modi)
const CompilandIndexItem * GetCompiland(uint16_t modi) const
clang::QualType CreatePointerType(const llvm::codeview::PointerRecord &pointer)
bool CompleteTagDecl(clang::TagDecl &tag)
void ParseBlockChildren(PdbCompilandSymId block_id)
llvm::DenseMap< lldb::opaque_compiler_type_t, llvm::SmallSet< std::pair< llvm::StringRef, CompilerType >, 8 > > m_cxx_record_map
clang::FunctionDecl * CreateFunctionDecl(PdbCompilandSymId func_id, llvm::StringRef func_name, TypeIndex func_ti, CompilerType func_ct, uint32_t param_count, clang::StorageClass func_storage, bool is_inline, clang::DeclContext *parent)
lldb_private::CompilerDeclContext GetTranslationUnitDecl()
clang::QualType CreateModifierType(const llvm::codeview::ModifierRecord &modifier)
void ParseDeclsForSimpleContext(clang::DeclContext &context)
CompilerDecl ToCompilerDecl(clang::Decl &decl)
llvm::DenseMap< lldb::user_id_t, clang::QualType > m_uid_to_type
clang::QualType CreateFunctionType(TypeIndex args_type_idx, TypeIndex return_type_idx, llvm::codeview::CallingConvention calling_convention)
clang::DeclContext * GetParentDeclContext(PdbSymUid uid)
void Dump(Stream &stream, llvm::StringRef filter, bool show_color)
TypeSystemClang & m_clang
void ParseNamespace(clang::DeclContext &parent)
llvm::codeview::TypeIndex TypeIndex
CompilerDeclContext ToCompilerDeclContext(clang::DeclContext &context)
std::pair< clang::DeclContext *, std::string > CreateDeclInfoForUndecoratedName(llvm::StringRef uname)
clang::Decl * TryGetDecl(PdbSymUid uid) const
clang::DeclContext * FromCompilerDeclContext(CompilerDeclContext context)
clang::VarDecl * GetOrCreateVariableDecl(PdbCompilandSymId scope_id, PdbCompilandSymId var_id)
clang::Decl * GetOrCreateSymbolForId(PdbCompilandSymId id)
CompilerType ToCompilerType(clang::QualType qt)
NamespaceSet m_parsed_namespaces
clang::NamespaceDecl * FindNamespaceDecl(const clang::DeclContext *parent, llvm::StringRef name)
clang::NamespaceDecl * GetOrCreateNamespaceDecl(const char *name, clang::DeclContext &context)
PdbAstBuilder(TypeSystemClang &clang)
std::pair< clang::DeclContext *, std::string > CreateDeclInfoForType(const llvm::codeview::TagRecord &record, TypeIndex ti)
clang::QualType GetBasicType(lldb::BasicType type)
bool CompleteType(clang::QualType qt)
llvm::DenseMap< clang::Decl *, DeclStatus > m_decl_to_status
clang::DeclContext * GetOrCreateDeclContextForUid(PdbSymUid uid)
NamespaceSet m_known_namespaces
void ParseDeclsForContext(clang::DeclContext &context)
llvm::DenseMap< lldb::user_id_t, clang::Decl * > m_uid_to_decl
clang::BlockDecl * GetOrCreateBlockDecl(PdbCompilandSymId block_id)
clang::Decl * FromCompilerDecl(CompilerDecl decl)
clang::QualType CreateSimpleType(TypeIndex ti)
void CreateFunctionParameters(PdbCompilandSymId func_id, clang::FunctionDecl &function_decl, uint32_t param_count)
clang::FunctionDecl * GetOrCreateFunctionDecl(PdbCompilandSymId func_id)
llvm::once_flag m_parse_all_types
clang::QualType CreateArrayType(const llvm::codeview::ArrayRecord &array)
clang::QualType CreateRecordType(PdbTypeSymId id, const llvm::codeview::TagRecord &record)
clang::FunctionDecl * CreateFunctionDeclFromId(PdbTypeSymId func_tid, PdbCompilandSymId func_sid)
llvm::once_flag m_parse_functions_and_non_local_vars
clang::VarDecl * CreateVariableDecl(PdbSymUid uid, llvm::codeview::CVSymbol sym, clang::DeclContext &scope)
clang::QualType GetOrCreateType(PdbTypeSymId type)
clang::QualType CreateEnumType(PdbTypeSymId id, const llvm::codeview::EnumRecord &record)
clang::FunctionDecl * GetOrCreateInlinedFunctionDecl(PdbCompilandSymId inlinesite_id)
void ParseAllFunctionsAndNonLocalVars()
std::optional< lldb_private::CompilerDecl > GetOrCreateDeclForUid(PdbSymUid uid)
llvm::DenseSet< clang::NamespaceDecl * > NamespaceSet
clang::QualType CreateType(PdbTypeSymId type)
clang::TypedefNameDecl * GetOrCreateTypedefDecl(PdbGlobalSymId id)
llvm::DenseMap< clang::DeclContext *, NamespaceSet > m_parent_to_namespaces
PdbIndex - Lazy access to the important parts of a PDB file.
llvm::pdb::TpiStream & ipi()
CompileUnitIndex & compilands()
llvm::pdb::DbiStream & dbi()
llvm::codeview::CVSymbol ReadSymbolRecord(PdbCompilandSymId cu_sym) const
llvm::pdb::TpiStream & tpi()
PdbGlobalSymId asGlobalSym() const
PdbCompilandSymId asCompilandSym() const
PdbTypeSymId asTypeSym() const
PdbSymUidKind kind() const
llvm::StringRef DropNameScope(llvm::StringRef name)
uint64_t toOpaqueUid(const T &cid)
lldb::BasicType GetCompilerTypeForSimpleKind(llvm::codeview::SimpleTypeKind kind)
VariableInfo GetVariableNameInfo(llvm::codeview::CVSymbol symbol)
bool IsTagRecord(llvm::codeview::CVType cvt)
llvm::codeview::TypeIndex LookThroughModifierRecord(llvm::codeview::CVType modifier)
bool IsForwardRefUdt(llvm::codeview::CVType cvt)
lldb::AccessType TranslateMemberAccess(llvm::codeview::MemberAccess access)
llvm::codeview::TypeIndex GetFieldListIndex(llvm::codeview::CVType cvt)
size_t GetSizeOfType(PdbTypeSymId id, llvm::pdb::TpiStream &tpi)
PdbTypeSymId GetBestPossibleDecl(PdbTypeSymId id, llvm::pdb::TpiStream &tpi)
A class that represents a running process on the host machine.
void * opaque_compiler_type_t
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eLanguageTypeC_plus_plus
ISO C++:1998.
static clang::Decl * GetDecl(const CompilerDecl &decl)
Returns the clang::Decl of the given CompilerDecl.
const llvm::codeview::UnionRecord & asUnion() const
static CVTagRecord create(llvm::codeview::CVType type)
const llvm::codeview::ClassRecord & asClass() const
const llvm::codeview::EnumRecord & asEnum() const
const llvm::codeview::TagRecord & asTag() const
Represents a single compile unit.
llvm::pdb::ModuleDebugStreamRef m_debug_stream
llvm::codeview::TypeIndex index
llvm::codeview::TypeIndex type