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.getOptions(), method.Attrs);
71 return llvm::Error::success();
74 llvm::Error visitKnownMember(CVMemberRecord &cvr,
75 OneMethodRecord &record)
override {
76 AddMethod(record.getName(), record.getOptions(), record.Attrs);
77 return llvm::Error::success();
80 void AddMethod(llvm::StringRef name, MethodOptions options,
81 MemberAttributes attrs) {
82 if (name != proc_name || function_decl)
84 bool is_virtual = attrs.isVirtual();
85 bool is_static = attrs.isStatic();
86 bool is_artificial = (options & MethodOptions::CompilerGenerated) ==
87 MethodOptions::CompilerGenerated;
88 function_decl = m_clang.AddMethodToCXXRecordType(
89 parent_ty, proc_name, mangled_name, func_ct,
90 is_virtual, is_static,
92 false, is_artificial);
99 case TypeRecordKind::Class:
100 return clang::TagTypeKind::Class;
101 case TypeRecordKind::Struct:
102 return clang::TagTypeKind::Struct;
103 case TypeRecordKind::Union:
104 return clang::TagTypeKind::Union;
105 case TypeRecordKind::Interface:
106 return clang::TagTypeKind::Interface;
107 case TypeRecordKind::Enum:
108 return clang::TagTypeKind::Enum;
110 lldbassert(
false &&
"Invalid tag record kind!");
111 return clang::TagTypeKind::Struct;
118 return args.back() == TypeIndex::None();
123 for (llvm::ms_demangle::Node *n : scopes) {
124 auto *idn =
static_cast<llvm::ms_demangle::IdentifierNode *
>(n);
125 if (idn->TemplateParams)
131static std::optional<clang::CallingConv>
133 using CC = llvm::codeview::CallingConvention;
138 return clang::CallingConv::CC_C;
141 return clang::CallingConv::CC_X86Pascal;
144 return clang::CallingConv::CC_X86FastCall;
145 case CC::NearStdCall:
147 return clang::CallingConv::CC_X86StdCall;
149 return clang::CallingConv::CC_X86ThisCall;
151 return clang::CallingConv::CC_X86VectorCall;
158 return name ==
"`anonymous namespace'" || name ==
"`anonymous-namespace'";
168std::pair<clang::DeclContext *, std::string>
172 m_clang.GetSymbolFile()->GetBackingSymbolFile());
174 if (!record.hasUniqueName())
177 llvm::ms_demangle::Demangler demangler;
178 std::string_view sv(record.UniqueName.begin(), record.UniqueName.size());
179 llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
183 llvm::ms_demangle::IdentifierNode *idn =
184 ttn->QualifiedName->getUnqualifiedIdentifier();
185 std::string uname = idn->toString(llvm::ms_demangle::OF_NoTagSpecifier);
187 llvm::ms_demangle::NodeArrayNode *name_components =
188 ttn->QualifiedName->Components;
189 llvm::ArrayRef<llvm::ms_demangle::Node *> scopes(name_components->Nodes,
190 name_components->Count - 1);
192 clang::DeclContext *context =
m_clang.GetTranslationUnitDecl();
197 std::optional<TypeIndex> parent_index =
pdb->GetParentType(ti);
200 return {context, uname};
208 return {context, std::string(record.Name)};
210 for (llvm::ms_demangle::Node *scope : scopes) {
211 auto *nii =
static_cast<llvm::ms_demangle::NamedIdentifierNode *
>(scope);
212 std::string str = nii->toString();
215 return {context, uname};
223 if (parent_qt.isNull())
224 return {
nullptr,
""};
226 context = clang::TagDecl::castToDeclContext(parent_qt->getAsTagDecl());
227 return {context, uname};
234 case S_REGREL32_INDIR:
245 m_clang.GetSymbolFile()->GetBackingSymbolFile());
253 clang::Decl *scope_decl = clang::Decl::castFromDeclContext(scope);
259 switch (cvs.kind()) {
282 clang::Decl *result =
nullptr;
283 switch (uid.
kind()) {
291 if (
auto *tag = qt->getAsTagDecl()) {
317 return clang::Decl::castToDeclContext(decl);
325std::pair<clang::DeclContext *, std::string>
328 m_clang.GetSymbolFile()->GetBackingSymbolFile());
331 llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.
GetSpecifiers();
335 llvm::StringRef uname = specs.back().GetBaseName();
336 specs = specs.drop_back();
338 return {context, std::string(name)};
340 llvm::StringRef scope_name = specs.back().GetFullName();
343 std::vector<TypeIndex> types = index.
tpi().findRecordsByName(scope_name);
344 while (!types.empty()) {
348 clang::TagDecl *tag = qt->getAsTagDecl();
350 return {clang::TagDecl::castToDeclContext(tag), std::string(uname)};
356 std::string ns_name = spec.GetBaseName().str();
359 return {context, std::string(uname)};
367 m_clang.GetSymbolFile()->GetBackingSymbolFile());
369 switch (uid.
kind()) {
371 std::optional<PdbCompilandSymId> scope =
383 std::optional<TypeIndex> parent_index =
pdb->GetParentType(type_id.
index);
400 switch (global.kind()) {
401 case SymbolKind::S_GDATA32:
402 case SymbolKind::S_LDATA32:
404 case SymbolKind::S_PROCREF:
405 case SymbolKind::S_LPROCREF: {
406 ProcRefSym ref{global.kind()};
408 SymbolDeserializer::deserializeAs<ProcRefSym>(global, ref));
412 case SymbolKind::S_CONSTANT:
413 case SymbolKind::S_UDT:
437 clang::TagDecl *tag = qt->getAsTagDecl();
438 if (qt->isArrayType()) {
439 const clang::Type *element_type = qt->getArrayElementTypeNoTypeQual();
440 tag = element_type->getAsTagDecl();
460 m_clang.GetSymbolFile()->GetBackingSymbolFile())
464 clang::QualType tag_qt =
m_clang.getASTContext().getCanonicalTagType(&tag);
468 CVType cvt = index.
tpi().getType(tag_ti);
469 if (cvt.kind() == LF_MODIFIER)
473 cvt = index.
tpi().getType(best_ti.
index);
483 CVType field_list_cvt = index.
tpi().getType(field_list_ti);
484 if (field_list_cvt.kind() != LF_FIELDLIST)
486 FieldListRecord field_list;
487 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
488 field_list_cvt, field_list))
489 llvm::consumeError(std::move(
error));
497 llvm::codeview::visitMemberRecordStream(field_list.Data, completer);
502 llvm::consumeError(std::move(
error));
509 if (ti == TypeIndex::NullptrT())
512 if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
514 if (direct_type.isNull())
516 return m_clang.getASTContext().getPointerType(direct_type);
519 if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
535 if (pointee_type.isNull())
538 if (pointer.isPointerToMember()) {
539 MemberPointerInfo mpi = pointer.getMemberInfo();
541 if (class_type.isNull())
543 if (clang::TagDecl *tag = class_type->getAsTagDecl()) {
544 clang::MSInheritanceAttr::Spelling spelling;
545 switch (mpi.Representation) {
546 case llvm::codeview::PointerToMemberRepresentation::SingleInheritanceData:
547 case llvm::codeview::PointerToMemberRepresentation::
548 SingleInheritanceFunction:
550 clang::MSInheritanceAttr::Spelling::Keyword_single_inheritance;
552 case llvm::codeview::PointerToMemberRepresentation::
553 MultipleInheritanceData:
554 case llvm::codeview::PointerToMemberRepresentation::
555 MultipleInheritanceFunction:
557 clang::MSInheritanceAttr::Spelling::Keyword_multiple_inheritance;
559 case llvm::codeview::PointerToMemberRepresentation::
560 VirtualInheritanceData:
561 case llvm::codeview::PointerToMemberRepresentation::
562 VirtualInheritanceFunction:
564 clang::MSInheritanceAttr::Spelling::Keyword_virtual_inheritance;
566 case llvm::codeview::PointerToMemberRepresentation::Unknown:
568 clang::MSInheritanceAttr::Spelling::Keyword_unspecified_inheritance;
571 spelling = clang::MSInheritanceAttr::Spelling::SpellingNotCalculated;
574 tag->addAttr(clang::MSInheritanceAttr::CreateImplicit(
575 m_clang.getASTContext(), spelling));
577 return m_clang.getASTContext().getMemberPointerType(
578 pointee_type, std::nullopt,
579 class_type->getAsCXXRecordDecl());
582 clang::QualType pointer_type;
583 if (pointer.getMode() == PointerMode::LValueReference)
584 pointer_type =
m_clang.getASTContext().getLValueReferenceType(pointee_type);
585 else if (pointer.getMode() == PointerMode::RValueReference)
586 pointer_type =
m_clang.getASTContext().getRValueReferenceType(pointee_type);
588 pointer_type =
m_clang.getASTContext().getPointerType(pointee_type);
590 if ((pointer.getOptions() & PointerOptions::Const) != PointerOptions::None)
591 pointer_type.addConst();
593 if ((pointer.getOptions() & PointerOptions::Volatile) != PointerOptions::None)
594 pointer_type.addVolatile();
596 if ((pointer.getOptions() & PointerOptions::Restrict) != PointerOptions::None)
597 pointer_type.addRestrict();
605 if (unmodified_type.isNull())
608 if ((modifier.Modifiers & ModifierOptions::Const) != ModifierOptions::None)
609 unmodified_type.addConst();
610 if ((modifier.Modifiers & ModifierOptions::Volatile) != ModifierOptions::None)
611 unmodified_type.addVolatile();
613 return unmodified_type;
617 const TagRecord &record) {
618 clang::DeclContext *context =
nullptr;
640 clang::QualType result =
654clang::NamespaceDecl *
656 clang::DeclContext &context) {
657 clang::NamespaceDecl *ns =
m_clang.GetUniqueNamespaceDeclaration(
668 return llvm::dyn_cast<clang::BlockDecl>(decl);
672 clang::BlockDecl *block_decl =
686 clang::DeclContext &scope) {
692 clang::VarDecl *var_decl =
m_clang.CreateVariableDeclaration(
707 return llvm::dyn_cast<clang::VarDecl>(decl);
714 m_clang.GetSymbolFile()->GetBackingSymbolFile());
723 return llvm::dyn_cast<clang::VarDecl>(decl);
726 m_clang.GetSymbolFile()->GetBackingSymbolFile());
735 if (
auto *tnd = llvm::dyn_cast<clang::TypedefNameDecl>(decl))
741 m_clang.GetSymbolFile()->GetBackingSymbolFile());
745 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
751 if (qt.isNull() || !scope)
771 if (type.
index.isSimple())
775 m_clang.GetSymbolFile()->GetBackingSymbolFile());
777 CVType cvt = index.
tpi().getType(type.
index);
779 if (cvt.kind() == LF_MODIFIER) {
780 ModifierRecord modifier;
782 TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier));
786 if (cvt.kind() == LF_POINTER) {
787 PointerRecord pointer;
789 TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer));
802 if (cvt.kind() == LF_ARRAY) {
804 llvm::cantFail(TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar));
808 if (cvt.kind() == LF_PROCEDURE) {
810 llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr));
814 if (cvt.kind() == LF_MFUNCTION) {
815 MemberFunctionRecord mfr;
817 TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr));
825 if (type.
index.isNoneType())
834 m_clang.GetSymbolFile()->GetBackingSymbolFile());
857 clang::TagDecl *tag = qt->getAsTagDecl();
877 clang::StorageClass func_storage,
bool is_inline,
878 clang::DeclContext *parent) {
879 clang::FunctionDecl *function_decl =
nullptr;
880 if (parent->isRecord()) {
882 m_clang.GetSymbolFile()->GetBackingSymbolFile());
884 clang::CanQualType parent_qt =
885 m_clang.getASTContext().getCanonicalTypeDeclType(
886 llvm::cast<clang::TypeDecl>(parent));
892 if (iter->getSecond().contains({func_name, func_ct})) {
897 CVType cvt = index.
tpi().getType(func_ti);
898 MemberFunctionRecord func_record(
static_cast<TypeRecordKind
>(cvt.kind()));
899 llvm::cantFail(TypeDeserializer::deserializeAs<MemberFunctionRecord>(
901 TypeIndex class_index = func_record.getClassType();
903 CVType parent_cvt = index.
tpi().getType(class_index);
906 if (tag_record.isForwardRef()) {
907 llvm::Expected<TypeIndex> eti =
908 index.
tpi().findFullDeclForForwardRef(class_index);
915 pdb->FindMangledFunctionName(func_id).value_or(llvm::StringRef()));
917 if (!tag_record.FieldList.isSimple()) {
918 CVType field_list_cvt = index.
tpi().getType(tag_record.FieldList);
919 FieldListRecord field_list;
920 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
921 field_list_cvt, field_list))
922 llvm::consumeError(std::move(
error));
923 CreateMethodDecl process(index,
m_clang, func_ti, function_decl,
924 parent_opaque_ty, func_name, mangled_name,
926 if (llvm::Error err = visitMemberRecordStream(field_list.Data, process))
927 llvm::consumeError(std::move(err));
930 if (!function_decl) {
931 function_decl =
m_clang.AddMethodToCXXRecordType(
932 parent_opaque_ty, func_name, mangled_name, func_ct,
939 function_decl =
m_clang.CreateFunctionDeclaration(
944 return function_decl;
950 m_clang.GetSymbolFile()->GetBackingSymbolFile());
954 InlineSiteSym inline_site(
static_cast<SymbolRecordKind
>(sym.kind()));
955 cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site));
962 return llvm::dyn_cast<clang::FunctionDecl>(decl);
963 clang::FunctionDecl *function_decl =
965 if (function_decl ==
nullptr)
970 uint64_t inlinesite_uid =
toOpaqueUid(inlinesite_id);
973 status.
uid = inlinesite_uid;
982 return function_decl;
990 m_clang.GetSymbolFile()->GetBackingSymbolFile());
992 std::optional<CVType> func_cvt =
993 index.
ipi().typeCollection().tryGetType(func_tid.
index);
996 llvm::StringRef func_name;
998 clang::DeclContext *parent =
nullptr;
999 switch (func_cvt->kind()) {
1001 MemberFuncIdRecord mfr;
1003 TypeDeserializer::deserializeAs<MemberFuncIdRecord>(*func_cvt, mfr));
1004 func_name = mfr.getName();
1005 func_ti = mfr.getFunctionType();
1012 cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(*func_cvt, fir));
1013 func_name = fir.getName();
1014 func_ti = fir.getFunctionType();
1016 if (!fir.ParentScope.isNoneType()) {
1017 CVType parent_cvt = index.
ipi().getType(fir.ParentScope);
1018 if (parent_cvt.kind() == LF_STRING_ID) {
1021 TypeDeserializer::deserializeAs<StringIdRecord>(parent_cvt, sir));
1028 lldbassert(
false &&
"Invalid function id type!");
1031 if (func_qt.isNull() || !parent)
1034 uint32_t param_count =
1035 llvm::cast<clang::FunctionProtoType>(func_qt)->getNumParams();
1037 clang::SC_None,
true, parent);
1040clang::FunctionDecl *
1043 return llvm::dyn_cast<clang::FunctionDecl>(decl);
1048 std::string context_name;
1049 if (clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(parent)) {
1050 context_name = ns->getQualifiedNameAsString();
1051 }
else if (clang::TagDecl *tag = llvm::dyn_cast<clang::TagDecl>(parent)) {
1052 context_name = tag->getQualifiedNameAsString();
1056 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1059 ProcSym proc(
static_cast<SymbolRecordKind
>(cvs.kind()));
1060 llvm::cantFail(SymbolDeserializer::deserializeAs<ProcSym>(cvs, proc));
1067 clang::StorageClass storage = clang::SC_None;
1068 if (proc.Kind == SymbolRecordKind::ProcSym)
1069 storage = clang::SC_Static;
1071 const clang::FunctionProtoType *func_type =
1072 llvm::dyn_cast<clang::FunctionProtoType>(qt);
1076 llvm::StringRef proc_name = proc.Name;
1077 proc_name.consume_front(context_name);
1078 proc_name.consume_front(
"::");
1079 clang::FunctionDecl *function_decl =
1081 func_type->getNumParams(), storage,
false, parent);
1082 if (function_decl ==
nullptr)
1092 return function_decl;
1119 uint32_t param_count) {
1121 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1124 CVSymbolArray scope =
1128 auto begin = scope.begin();
1129 auto end = scope.end();
1130 std::vector<clang::ParmVarDecl *> params;
1131 for (uint32_t i = 0; i < param_count && begin != end;) {
1132 uint32_t record_offset = begin.offset();
1133 CVSymbol sym = *begin++;
1136 llvm::StringRef param_name;
1137 switch (sym.kind()) {
1139 RegRelativeSym reg(SymbolRecordKind::RegRelativeSym);
1140 cantFail(SymbolDeserializer::deserializeAs<RegRelativeSym>(sym, reg));
1141 param_type = reg.Type;
1142 param_name = reg.Name;
1145 case S_REGREL32_INDIR: {
1146 RegRelativeIndirSym reg(SymbolRecordKind::RegRelativeIndirSym);
1148 SymbolDeserializer::deserializeAs<RegRelativeIndirSym>(sym, reg));
1149 param_type = reg.Type;
1150 param_name = reg.Name;
1154 RegisterSym reg(SymbolRecordKind::RegisterSym);
1155 cantFail(SymbolDeserializer::deserializeAs<RegisterSym>(sym, reg));
1156 param_type = reg.Index;
1157 param_name = reg.Name;
1161 LocalSym local(SymbolRecordKind::LocalSym);
1162 cantFail(SymbolDeserializer::deserializeAs<LocalSym>(sym, local));
1163 if ((local.Flags & LocalSymFlags::IsParameter) == LocalSymFlags::None)
1165 param_type = local.Type;
1166 param_name = local.Name;
1186 clang::ParmVarDecl *param =
m_clang.CreateParameterDeclaration(
1188 param_type_ct, clang::SC_None,
true);
1192 params.push_back(param);
1196 if (!params.empty() && params.size() == param_count)
1197 function_decl.setParams(params);
1201 const EnumRecord &er) {
1202 clang::DeclContext *decl_context =
nullptr;
1209 if (underlying_type.isNull())
1228 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1231 if (element_type.isNull() || element_size == 0)
1233 uint64_t element_count = ar.Size / element_size;
1236 element_count,
false);
1242 llvm::codeview::CallingConvention calling_convention) {
1244 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1246 TpiStream &stream = index.
tpi();
1247 CVType args_cvt = stream.getType(args_type_idx);
1250 TypeDeserializer::deserializeAs<ArgListRecord>(args_cvt, args));
1252 llvm::ArrayRef<TypeIndex> arg_indices = llvm::ArrayRef(args.ArgIndices);
1255 arg_indices = arg_indices.drop_back();
1257 std::vector<CompilerType> arg_types;
1258 arg_types.reserve(arg_indices.size());
1260 for (
TypeIndex arg_index : arg_indices) {
1262 if (arg_type.isNull())
1268 if (return_type.isNull())
1271 std::optional<clang::CallingConv> cc =
1278 m_clang.CreateFunctionType(return_ct, arg_types, is_variadic, 0, *cc);
1280 return clang::QualType::getFromOpaquePtr(
1285 return llvm::isa<clang::TagDecl>(&context);
1289 return llvm::isa<clang::FunctionDecl>(&context);
1293 return llvm::isa<clang::BlockDecl>(&context);
1297 clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(&context);
1300 std::string qname = ns->getQualifiedNameAsString();
1302 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1305 for (
const CVType &cvt : index.
tpi().typeArray()) {
1317 clang::DeclContext *context =
nullptr;
1320 if (!context || !context->isNamespace())
1323 clang::NamespaceDecl *ns = llvm::cast<clang::NamespaceDecl>(context);
1324 llvm::StringRef ns_name = ns->getName();
1325 if (ns_name.starts_with(qname)) {
1326 ns_name = ns_name.drop_front(qname.size());
1327 if (ns_name.starts_with(
"::"))
1338 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1341 for (
const CVType &cvt : index.
tpi().typeArray()) {
1356 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1358 uint32_t module_count = index.
dbi().modules().getModuleCount();
1359 for (uint16_t modi = 0; modi < module_count; ++modi) {
1361 const CVSymbolArray &symbols = cii.
m_debug_stream.getSymbolArray();
1362 auto iter = symbols.begin();
1363 while (iter != symbols.end()) {
1366 switch (iter->kind()) {
1370 iter = symbols.at(getScopeEndOffset(*iter));
1389 const CVSymbolArray &symbols) {
1390 clang::FunctionDecl *func_decl = llvm::dyn_cast<clang::FunctionDecl>(&decl);
1393 unsigned int params = func_decl->getNumParams();
1397 CVSymbolArray result = symbols;
1399 while (!result.empty()) {
1403 CVSymbol sym = *result.begin();
1404 result.drop_front();
1416 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1419 lldbassert(sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32 ||
1420 sym.kind() == S_BLOCK32 || sym.kind() == S_INLINESITE);
1423 CVSymbolArray symbols =
1428 if (sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32)
1432 symbols.drop_front();
1433 auto begin = symbols.begin();
1434 while (begin != symbols.end()) {
1437 if (begin->kind() == S_BLOCK32 || begin->kind() == S_INLINESITE) {
1439 begin = symbols.at(getScopeEndOffset(*begin));
1446 clang::DeclContext &context) {
1448 clang::Decl *decl = clang::Decl::castFromDeclContext(&context);
1454 if (
auto *tag = llvm::dyn_cast<clang::TagDecl>(&context)) {
1476 if (dc->isTranslationUnit()) {
1482 if (dc->isNamespace()) {
1494 return m_clang.GetCompilerDecl(decl);
1507 return m_clang.CreateDeclContext(context);
1528 llvm::StringRef name) {
1544 for (clang::NamespaceDecl *namespace_decl : *set)
1545 if (namespace_decl->getName() == name)
1548 for (clang::NamespaceDecl *namespace_decl : *set)
1549 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
bool CompleteType(const CompilerType &compiler_type)
Represents a generic declaration context in a program.
void * GetOpaqueDeclContext() const
Represents a generic declaration such as a function declaration.
TypeSystem * GetTypeSystem() const
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::Decl * GetOrCreateSymbolForId(PdbCompilandSymId id)
std::pair< clang::DeclContext *, std::string > CreateDeclInfoForType(const llvm::codeview::TagRecord &record, TypeIndex ti)
void ParseDeclsForSimpleContext(clang::DeclContext &context)
CompilerDeclContext ToCompilerDeclContext(clang::DeclContext *context)
clang::FunctionDecl * GetOrCreateInlinedFunctionDecl(PdbCompilandSymId inlinesite_id)
llvm::DenseMap< clang::DeclContext *, NamespaceSet > m_parent_to_namespaces
void CreateFunctionParameters(PdbCompilandSymId func_id, clang::FunctionDecl &function_decl, uint32_t param_count)
bool CompleteType(CompilerType ct) override
clang::QualType GetBasicType(lldb::BasicType type)
clang::Decl * TryGetDecl(PdbSymUid uid) const
clang::QualType CreateType(PdbTypeSymId type)
clang::QualType CreateFunctionType(TypeIndex args_type_idx, TypeIndex return_type_idx, llvm::codeview::CallingConvention calling_convention)
clang::QualType CreateArrayType(const llvm::codeview::ArrayRecord &array)
llvm::DenseMap< clang::Decl *, DeclStatus > m_decl_to_status
llvm::DenseMap< lldb::opaque_compiler_type_t, llvm::SmallSet< std::pair< llvm::StringRef, CompilerType >, 8 > > m_cxx_record_map
clang::FunctionDecl * CreateFunctionDeclFromId(PdbTypeSymId func_tid, PdbCompilandSymId func_sid)
CompilerType GetOrCreateType(PdbTypeSymId type) override
clang::QualType CreatePointerType(const llvm::codeview::PointerRecord &pointer)
llvm::once_flag m_parse_functions_and_non_local_vars
NamespaceSet m_parsed_namespaces
clang::QualType CreateModifierType(const llvm::codeview::ModifierRecord &modifier)
CompilerDeclContext GetTranslationUnitDecl()
std::pair< clang::DeclContext *, std::string > CreateDeclInfoForUndecoratedName(llvm::StringRef uname)
clang::FunctionDecl * GetOrCreateFunctionDecl(PdbCompilandSymId func_id)
clang::NamespaceDecl * GetOrCreateNamespaceDecl(const char *name, clang::DeclContext &context)
TypeSystemClang & m_clang
llvm::once_flag m_parse_all_types
void EnsureVariable(PdbCompilandSymId scope_id, PdbCompilandSymId var_id) override
clang::VarDecl * CreateVariableDecl(PdbSymUid uid, llvm::codeview::CVSymbol sym, clang::DeclContext &scope)
void ParseAllFunctionsAndNonLocalVars()
void ParseDeclsForContext(CompilerDeclContext context) override
CompilerDecl ToCompilerDecl(clang::Decl *decl)
void EnsureFunction(PdbCompilandSymId func_id) override
llvm::DenseMap< lldb::user_id_t, clang::QualType > m_uid_to_type
void EnsureBlock(PdbCompilandSymId block_id) override
ClangASTImporter & GetClangASTImporter()
llvm::DenseMap< lldb::user_id_t, clang::Decl * > m_uid_to_decl
CompilerDecl GetOrCreateDeclForUid(PdbSymUid uid) override
CompilerDeclContext FindNamespaceDecl(CompilerDeclContext parent_ctx, llvm::StringRef name) override
void ParseNamespace(clang::DeclContext &parent)
llvm::DenseSet< clang::NamespaceDecl * > NamespaceSet
clang::VarDecl * GetOrCreateVariableDecl(PdbCompilandSymId scope_id, PdbCompilandSymId var_id)
clang::BlockDecl * GetOrCreateBlockDecl(PdbCompilandSymId block_id)
clang::QualType CreateSimpleType(TypeIndex ti)
clang::DeclContext * GetParentClangDeclContext(PdbSymUid uid)
clang::QualType FromCompilerType(CompilerType ct)
clang::QualType CreateEnumType(PdbTypeSymId id, const llvm::codeview::EnumRecord &record)
CompilerType GetOrCreateTypedefType(PdbGlobalSymId id) override
bool CompleteTagDecl(clang::TagDecl &tag)
clang::QualType CreateRecordType(PdbTypeSymId id, const llvm::codeview::TagRecord &record)
CompilerDeclContext GetParentDeclContext(PdbSymUid uid) override
clang::DeclContext * FromCompilerDeclContext(CompilerDeclContext context)
llvm::codeview::TypeIndex TypeIndex
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)
CompilerDeclContext GetOrCreateDeclContextForUid(PdbSymUid uid) override
void EnsureInlinedFunction(PdbCompilandSymId inlinesite_id) override
CompilerType ToCompilerType(clang::QualType qt)
clang::QualType GetOrCreateClangType(PdbTypeSymId type)
void ParseBlockChildren(PdbCompilandSymId block_id)
void Dump(Stream &stream, llvm::StringRef filter, bool show_color) override
clang::Decl * FromCompilerDecl(CompilerDecl decl)
PdbAstBuilderClang(TypeSystemClang &clang)
NamespaceSet m_known_namespaces
clang::DeclContext * GetOrCreateClangDeclContextForUid(PdbSymUid uid)
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)
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::QualType GetQualType(const CompilerType &ct)
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