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"
38 CreateMethodDecl(PdbIndex &m_index, TypeSystemClang &m_clang,
39 TypeIndex func_type_index,
40 clang::FunctionDecl *&function_decl,
42 llvm::StringRef proc_name, ConstString mangled_name,
44 : m_index(m_index), m_clang(m_clang), func_type_index(func_type_index),
45 function_decl(function_decl), parent_ty(parent_ty),
46 proc_name(proc_name), mangled_name(mangled_name), func_ct(func_ct) {}
48 TypeSystemClang &m_clang;
49 TypeIndex func_type_index;
50 clang::FunctionDecl *&function_decl;
52 llvm::StringRef proc_name;
53 ConstString mangled_name;
56 llvm::Error visitKnownMember(CVMemberRecord &cvr,
57 OverloadedMethodRecord &overloaded)
override {
58 TypeIndex method_list_idx = overloaded.MethodList;
60 CVType method_list_type = m_index.tpi().getType(method_list_idx);
61 assert(method_list_type.kind() == LF_METHODLIST);
63 MethodOverloadListRecord method_list;
64 llvm::cantFail(TypeDeserializer::deserializeAs<MethodOverloadListRecord>(
65 method_list_type, method_list));
67 for (
const OneMethodRecord &method : method_list.Methods) {
68 if (method.getType().getIndex() == func_type_index.getIndex())
69 AddMethod(overloaded.Name, method.getOptions(), method.Attrs);
72 return llvm::Error::success();
75 llvm::Error visitKnownMember(CVMemberRecord &cvr,
76 OneMethodRecord &record)
override {
77 AddMethod(record.getName(), record.getOptions(), record.Attrs);
78 return llvm::Error::success();
81 void AddMethod(llvm::StringRef name, MethodOptions options,
82 MemberAttributes attrs) {
83 if (name != proc_name || function_decl)
85 bool is_virtual = attrs.isVirtual();
86 bool is_static = attrs.isStatic();
87 bool is_artificial = (options & MethodOptions::CompilerGenerated) ==
88 MethodOptions::CompilerGenerated;
89 function_decl = m_clang.AddMethodToCXXRecordType(
90 parent_ty, proc_name, mangled_name, func_ct,
91 is_virtual, is_static,
93 false, is_artificial);
100 case TypeRecordKind::Class:
101 return clang::TagTypeKind::Class;
102 case TypeRecordKind::Struct:
103 return clang::TagTypeKind::Struct;
104 case TypeRecordKind::Union:
105 return clang::TagTypeKind::Union;
106 case TypeRecordKind::Interface:
107 return clang::TagTypeKind::Interface;
108 case TypeRecordKind::Enum:
109 return clang::TagTypeKind::Enum;
111 lldbassert(
false &&
"Invalid tag record kind!");
112 return clang::TagTypeKind::Struct;
119 return args.back() == TypeIndex::None();
124 for (llvm::ms_demangle::Node *n : scopes) {
125 auto *idn =
static_cast<llvm::ms_demangle::IdentifierNode *
>(n);
126 if (idn->TemplateParams)
132static std::optional<clang::CallingConv>
134 using CC = llvm::codeview::CallingConvention;
139 return clang::CallingConv::CC_C;
142 return clang::CallingConv::CC_X86Pascal;
145 return clang::CallingConv::CC_X86FastCall;
146 case CC::NearStdCall:
148 return clang::CallingConv::CC_X86StdCall;
150 return clang::CallingConv::CC_X86ThisCall;
152 return clang::CallingConv::CC_X86VectorCall;
159 return name ==
"`anonymous namespace'" || name ==
"`anonymous-namespace'";
169std::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};
235 case S_REGREL32_INDIR:
246 m_clang.GetSymbolFile()->GetBackingSymbolFile());
254 clang::Decl *scope_decl = clang::Decl::castFromDeclContext(scope);
260 switch (cvs.kind()) {
283 clang::Decl *result =
nullptr;
284 switch (uid.
kind()) {
292 if (
auto *tag = qt->getAsTagDecl()) {
318 return clang::Decl::castToDeclContext(decl);
326std::pair<clang::DeclContext *, std::string>
329 m_clang.GetSymbolFile()->GetBackingSymbolFile());
332 llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.
GetSpecifiers();
336 llvm::StringRef uname = specs.back().GetBaseName();
337 specs = specs.drop_back();
339 return {context, std::string(name)};
341 llvm::StringRef scope_name = specs.back().GetFullName();
344 std::vector<TypeIndex> types = index.
tpi().findRecordsByName(scope_name);
345 while (!types.empty()) {
349 clang::TagDecl *tag = qt->getAsTagDecl();
351 return {clang::TagDecl::castToDeclContext(tag), std::string(uname)};
357 std::string ns_name = spec.GetBaseName().str();
360 return {context, std::string(uname)};
368 m_clang.GetSymbolFile()->GetBackingSymbolFile());
370 switch (uid.
kind()) {
372 std::optional<PdbCompilandSymId> scope =
384 std::optional<TypeIndex> parent_index =
pdb->GetParentType(type_id.
index);
401 switch (global.kind()) {
402 case SymbolKind::S_GDATA32:
403 case SymbolKind::S_LDATA32:
405 case SymbolKind::S_PROCREF:
406 case SymbolKind::S_LPROCREF: {
407 ProcRefSym ref{global.kind()};
409 SymbolDeserializer::deserializeAs<ProcRefSym>(global, ref));
413 case SymbolKind::S_CONSTANT:
414 case SymbolKind::S_UDT:
438 clang::TagDecl *tag = qt->getAsTagDecl();
439 if (qt->isArrayType()) {
440 const clang::Type *element_type = qt->getArrayElementTypeNoTypeQual();
441 tag = element_type->getAsTagDecl();
461 m_clang.GetSymbolFile()->GetBackingSymbolFile())
465 clang::QualType tag_qt =
m_clang.getASTContext().getCanonicalTagType(&tag);
469 CVType cvt = index.
tpi().getType(tag_ti);
470 if (cvt.kind() == LF_MODIFIER)
474 cvt = index.
tpi().getType(best_ti.
index);
484 CVType field_list_cvt = index.
tpi().getType(field_list_ti);
485 if (field_list_cvt.kind() != LF_FIELDLIST)
487 FieldListRecord field_list;
488 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
489 field_list_cvt, field_list))
490 llvm::consumeError(std::move(
error));
498 llvm::codeview::visitMemberRecordStream(field_list.Data, completer);
503 llvm::consumeError(std::move(
error));
510 if (ti == TypeIndex::NullptrT())
513 if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
515 if (direct_type.isNull())
517 return m_clang.getASTContext().getPointerType(direct_type);
520 if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
536 if (pointee_type.isNull())
539 if (pointer.isPointerToMember()) {
540 MemberPointerInfo mpi = pointer.getMemberInfo();
542 if (class_type.isNull())
544 if (clang::TagDecl *tag = class_type->getAsTagDecl()) {
545 clang::MSInheritanceAttr::Spelling spelling;
546 switch (mpi.Representation) {
547 case llvm::codeview::PointerToMemberRepresentation::SingleInheritanceData:
548 case llvm::codeview::PointerToMemberRepresentation::
549 SingleInheritanceFunction:
551 clang::MSInheritanceAttr::Spelling::Keyword_single_inheritance;
553 case llvm::codeview::PointerToMemberRepresentation::
554 MultipleInheritanceData:
555 case llvm::codeview::PointerToMemberRepresentation::
556 MultipleInheritanceFunction:
558 clang::MSInheritanceAttr::Spelling::Keyword_multiple_inheritance;
560 case llvm::codeview::PointerToMemberRepresentation::
561 VirtualInheritanceData:
562 case llvm::codeview::PointerToMemberRepresentation::
563 VirtualInheritanceFunction:
565 clang::MSInheritanceAttr::Spelling::Keyword_virtual_inheritance;
567 case llvm::codeview::PointerToMemberRepresentation::Unknown:
569 clang::MSInheritanceAttr::Spelling::Keyword_unspecified_inheritance;
572 spelling = clang::MSInheritanceAttr::Spelling::SpellingNotCalculated;
575 tag->addAttr(clang::MSInheritanceAttr::CreateImplicit(
576 m_clang.getASTContext(), spelling));
578 return m_clang.getASTContext().getMemberPointerType(
579 pointee_type, std::nullopt,
580 class_type->getAsCXXRecordDecl());
583 clang::QualType pointer_type;
584 if (pointer.getMode() == PointerMode::LValueReference)
585 pointer_type =
m_clang.getASTContext().getLValueReferenceType(pointee_type);
586 else if (pointer.getMode() == PointerMode::RValueReference)
587 pointer_type =
m_clang.getASTContext().getRValueReferenceType(pointee_type);
589 pointer_type =
m_clang.getASTContext().getPointerType(pointee_type);
591 if ((pointer.getOptions() & PointerOptions::Const) != PointerOptions::None)
592 pointer_type.addConst();
594 if ((pointer.getOptions() & PointerOptions::Volatile) != PointerOptions::None)
595 pointer_type.addVolatile();
597 if ((pointer.getOptions() & PointerOptions::Restrict) != PointerOptions::None)
598 pointer_type.addRestrict();
606 if (unmodified_type.isNull())
609 if ((modifier.Modifiers & ModifierOptions::Const) != ModifierOptions::None)
610 unmodified_type.addConst();
611 if ((modifier.Modifiers & ModifierOptions::Volatile) != ModifierOptions::None)
612 unmodified_type.addVolatile();
614 return unmodified_type;
618 const TagRecord &record) {
619 clang::DeclContext *context =
nullptr;
641 clang::QualType result =
655clang::NamespaceDecl *
657 clang::DeclContext &context) {
658 clang::NamespaceDecl *ns =
m_clang.GetUniqueNamespaceDeclaration(
669 return llvm::dyn_cast<clang::BlockDecl>(decl);
673 clang::BlockDecl *block_decl =
687 clang::DeclContext &scope) {
693 clang::VarDecl *var_decl =
m_clang.CreateVariableDeclaration(
708 return llvm::dyn_cast<clang::VarDecl>(decl);
715 m_clang.GetSymbolFile()->GetBackingSymbolFile());
724 return llvm::dyn_cast<clang::VarDecl>(decl);
727 m_clang.GetSymbolFile()->GetBackingSymbolFile());
736 if (
auto *tnd = llvm::dyn_cast<clang::TypedefNameDecl>(decl))
742 m_clang.GetSymbolFile()->GetBackingSymbolFile());
746 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
752 if (qt.isNull() || !scope)
772 if (type.
index.isSimple())
776 m_clang.GetSymbolFile()->GetBackingSymbolFile());
778 CVType cvt = index.
tpi().getType(type.
index);
780 if (cvt.kind() == LF_MODIFIER) {
781 ModifierRecord modifier;
783 TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier));
787 if (cvt.kind() == LF_POINTER) {
788 PointerRecord pointer;
790 TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer));
803 if (cvt.kind() == LF_ARRAY) {
805 llvm::cantFail(TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar));
809 if (cvt.kind() == LF_PROCEDURE) {
811 llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr));
815 if (cvt.kind() == LF_MFUNCTION) {
816 MemberFunctionRecord mfr;
818 TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr));
826 if (type.
index.isNoneType())
835 m_clang.GetSymbolFile()->GetBackingSymbolFile());
858 clang::TagDecl *tag = qt->getAsTagDecl();
878 clang::StorageClass func_storage,
bool is_inline,
879 clang::DeclContext *parent) {
880 clang::FunctionDecl *function_decl =
nullptr;
881 if (parent->isRecord()) {
883 m_clang.GetSymbolFile()->GetBackingSymbolFile());
885 clang::CanQualType parent_qt =
886 m_clang.getASTContext().getCanonicalTypeDeclType(
887 llvm::cast<clang::TypeDecl>(parent));
893 if (iter->getSecond().contains({func_name, func_ct})) {
898 CVType cvt = index.
tpi().getType(func_ti);
899 MemberFunctionRecord func_record(
static_cast<TypeRecordKind
>(cvt.kind()));
900 llvm::cantFail(TypeDeserializer::deserializeAs<MemberFunctionRecord>(
902 TypeIndex class_index = func_record.getClassType();
904 CVType parent_cvt = index.
tpi().getType(class_index);
907 if (tag_record.isForwardRef()) {
908 llvm::Expected<TypeIndex> eti =
909 index.
tpi().findFullDeclForForwardRef(class_index);
914 "failed to find full decl for forward ref: {0}");
919 pdb->FindMangledFunctionName(func_id).value_or(llvm::StringRef()));
921 if (!tag_record.FieldList.isSimple()) {
922 CVType field_list_cvt = index.
tpi().getType(tag_record.FieldList);
923 FieldListRecord field_list;
924 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
925 field_list_cvt, field_list))
926 llvm::consumeError(std::move(
error));
927 CreateMethodDecl process(index,
m_clang, func_ti, function_decl,
928 parent_opaque_ty, func_name, mangled_name,
930 if (llvm::Error err = visitMemberRecordStream(field_list.Data, process))
931 llvm::consumeError(std::move(err));
934 if (!function_decl) {
935 function_decl =
m_clang.AddMethodToCXXRecordType(
936 parent_opaque_ty, func_name, mangled_name, func_ct,
943 function_decl =
m_clang.CreateFunctionDeclaration(
948 return function_decl;
954 m_clang.GetSymbolFile()->GetBackingSymbolFile());
958 InlineSiteSym inline_site(
static_cast<SymbolRecordKind
>(sym.kind()));
959 cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site));
966 return llvm::dyn_cast<clang::FunctionDecl>(decl);
967 clang::FunctionDecl *function_decl =
969 if (function_decl ==
nullptr)
974 uint64_t inlinesite_uid =
toOpaqueUid(inlinesite_id);
977 status.
uid = inlinesite_uid;
986 return function_decl;
994 m_clang.GetSymbolFile()->GetBackingSymbolFile());
996 std::optional<CVType> func_cvt =
997 index.
ipi().typeCollection().tryGetType(func_tid.
index);
1000 llvm::StringRef func_name;
1002 clang::DeclContext *parent =
nullptr;
1003 switch (func_cvt->kind()) {
1005 MemberFuncIdRecord mfr;
1007 TypeDeserializer::deserializeAs<MemberFuncIdRecord>(*func_cvt, mfr));
1008 func_name = mfr.getName();
1009 func_ti = mfr.getFunctionType();
1016 cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(*func_cvt, fir));
1017 func_name = fir.getName();
1018 func_ti = fir.getFunctionType();
1020 if (!fir.ParentScope.isNoneType()) {
1021 CVType parent_cvt = index.
ipi().getType(fir.ParentScope);
1022 if (parent_cvt.kind() == LF_STRING_ID) {
1025 TypeDeserializer::deserializeAs<StringIdRecord>(parent_cvt, sir));
1032 lldbassert(
false &&
"Invalid function id type!");
1035 if (func_qt.isNull() || !parent)
1038 uint32_t param_count =
1039 llvm::cast<clang::FunctionProtoType>(func_qt)->getNumParams();
1041 clang::SC_None,
true, parent);
1044clang::FunctionDecl *
1047 return llvm::dyn_cast<clang::FunctionDecl>(decl);
1052 std::string context_name;
1053 if (clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(parent)) {
1054 context_name = ns->getQualifiedNameAsString();
1055 }
else if (clang::TagDecl *tag = llvm::dyn_cast<clang::TagDecl>(parent)) {
1056 context_name = tag->getQualifiedNameAsString();
1060 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1063 ProcSym proc(
static_cast<SymbolRecordKind
>(cvs.kind()));
1064 llvm::cantFail(SymbolDeserializer::deserializeAs<ProcSym>(cvs, proc));
1071 clang::StorageClass storage = clang::SC_None;
1072 if (proc.Kind == SymbolRecordKind::ProcSym)
1073 storage = clang::SC_Static;
1075 const clang::FunctionProtoType *func_type =
1076 llvm::dyn_cast<clang::FunctionProtoType>(qt);
1080 llvm::StringRef proc_name = proc.Name;
1081 proc_name.consume_front(context_name);
1082 proc_name.consume_front(
"::");
1083 clang::FunctionDecl *function_decl =
1085 func_type->getNumParams(), storage,
false, parent);
1086 if (function_decl ==
nullptr)
1096 return function_decl;
1123 uint32_t param_count) {
1125 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1128 CVSymbolArray scope =
1132 auto begin = scope.begin();
1133 auto end = scope.end();
1134 std::vector<clang::ParmVarDecl *> params;
1135 for (uint32_t i = 0; i < param_count && begin != end;) {
1136 uint32_t record_offset = begin.offset();
1137 CVSymbol sym = *begin++;
1140 llvm::StringRef param_name;
1141 switch (sym.kind()) {
1143 RegRelativeSym reg(SymbolRecordKind::RegRelativeSym);
1144 cantFail(SymbolDeserializer::deserializeAs<RegRelativeSym>(sym, reg));
1145 param_type = reg.Type;
1146 param_name = reg.Name;
1149 case S_REGREL32_INDIR: {
1150 RegRelativeIndirSym reg(SymbolRecordKind::RegRelativeIndirSym);
1152 SymbolDeserializer::deserializeAs<RegRelativeIndirSym>(sym, reg));
1153 param_type = reg.Type;
1154 param_name = reg.Name;
1158 RegisterSym reg(SymbolRecordKind::RegisterSym);
1159 cantFail(SymbolDeserializer::deserializeAs<RegisterSym>(sym, reg));
1160 param_type = reg.Index;
1161 param_name = reg.Name;
1165 LocalSym local(SymbolRecordKind::LocalSym);
1166 cantFail(SymbolDeserializer::deserializeAs<LocalSym>(sym, local));
1167 if ((local.Flags & LocalSymFlags::IsParameter) == LocalSymFlags::None)
1169 param_type = local.Type;
1170 param_name = local.Name;
1190 clang::ParmVarDecl *param =
m_clang.CreateParameterDeclaration(
1192 param_type_ct, clang::SC_None,
true);
1196 params.push_back(param);
1200 if (!params.empty() && params.size() == param_count)
1201 function_decl.setParams(params);
1205 const EnumRecord &er) {
1206 clang::DeclContext *decl_context =
nullptr;
1213 if (underlying_type.isNull())
1232 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1235 if (element_type.isNull() || element_size == 0)
1237 uint64_t element_count = ar.Size / element_size;
1240 element_count,
false);
1246 llvm::codeview::CallingConvention calling_convention) {
1248 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1250 TpiStream &stream = index.
tpi();
1251 CVType args_cvt = stream.getType(args_type_idx);
1254 TypeDeserializer::deserializeAs<ArgListRecord>(args_cvt, args));
1256 llvm::ArrayRef<TypeIndex> arg_indices = llvm::ArrayRef(args.ArgIndices);
1259 arg_indices = arg_indices.drop_back();
1261 std::vector<CompilerType> arg_types;
1262 arg_types.reserve(arg_indices.size());
1264 for (
TypeIndex arg_index : arg_indices) {
1266 if (arg_type.isNull())
1272 if (return_type.isNull())
1275 std::optional<clang::CallingConv> cc =
1282 m_clang.CreateFunctionType(return_ct, arg_types, is_variadic, 0, *cc);
1284 return clang::QualType::getFromOpaquePtr(
1289 return llvm::isa<clang::TagDecl>(&context);
1293 return llvm::isa<clang::FunctionDecl>(&context);
1297 return llvm::isa<clang::BlockDecl>(&context);
1301 clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(&context);
1304 std::string qname = ns->getQualifiedNameAsString();
1306 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1309 for (
const CVType &cvt : index.
tpi().typeArray()) {
1321 clang::DeclContext *context =
nullptr;
1324 if (!context || !context->isNamespace())
1327 clang::NamespaceDecl *ns = llvm::cast<clang::NamespaceDecl>(context);
1328 llvm::StringRef ns_name = ns->getName();
1329 if (ns_name.starts_with(qname)) {
1330 ns_name = ns_name.drop_front(qname.size());
1331 if (ns_name.starts_with(
"::"))
1342 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1345 for (
const CVType &cvt : index.
tpi().typeArray()) {
1360 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1362 uint32_t module_count = index.
dbi().modules().getModuleCount();
1363 for (uint16_t modi = 0; modi < module_count; ++modi) {
1365 const CVSymbolArray &symbols = cii.
m_debug_stream.getSymbolArray();
1366 auto iter = symbols.begin();
1367 while (iter != symbols.end()) {
1370 switch (iter->kind()) {
1374 iter = symbols.at(getScopeEndOffset(*iter));
1393 const CVSymbolArray &symbols) {
1394 clang::FunctionDecl *func_decl = llvm::dyn_cast<clang::FunctionDecl>(&decl);
1397 unsigned int params = func_decl->getNumParams();
1401 CVSymbolArray result = symbols;
1403 while (!result.empty()) {
1407 CVSymbol sym = *result.begin();
1408 result.drop_front();
1420 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1423 lldbassert(sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32 ||
1424 sym.kind() == S_BLOCK32 || sym.kind() == S_INLINESITE);
1427 CVSymbolArray symbols =
1432 if (sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32)
1436 symbols.drop_front();
1437 auto begin = symbols.begin();
1438 while (begin != symbols.end()) {
1441 if (begin->kind() == S_BLOCK32 || begin->kind() == S_INLINESITE) {
1443 begin = symbols.at(getScopeEndOffset(*begin));
1450 clang::DeclContext &context) {
1452 clang::Decl *decl = clang::Decl::castFromDeclContext(&context);
1458 if (
auto *tag = llvm::dyn_cast<clang::TagDecl>(&context)) {
1480 if (dc->isTranslationUnit()) {
1486 if (dc->isNamespace()) {
1498 return m_clang.GetCompilerDecl(decl);
1511 return m_clang.CreateDeclContext(context);
1532 llvm::StringRef name) {
1548 for (clang::NamespaceDecl *namespace_decl : *set)
1549 if (namespace_decl->getName() == name)
1552 for (clang::NamespaceDecl *namespace_decl : *set)
1553 if (namespace_decl->isAnonymousNamespace())
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOG_ERROR(log, error,...)
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.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
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