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};
244 m_clang.GetSymbolFile()->GetBackingSymbolFile());
252 clang::Decl *scope_decl = clang::Decl::castFromDeclContext(scope);
258 switch (cvs.kind()) {
281 clang::Decl *result =
nullptr;
282 switch (uid.
kind()) {
290 if (
auto *tag = qt->getAsTagDecl()) {
316 return clang::Decl::castToDeclContext(decl);
324std::pair<clang::DeclContext *, std::string>
327 m_clang.GetSymbolFile()->GetBackingSymbolFile());
330 llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.
GetSpecifiers();
334 llvm::StringRef uname = specs.back().GetBaseName();
335 specs = specs.drop_back();
337 return {context, std::string(name)};
339 llvm::StringRef scope_name = specs.back().GetFullName();
342 std::vector<TypeIndex> types = index.
tpi().findRecordsByName(scope_name);
343 while (!types.empty()) {
347 clang::TagDecl *tag = qt->getAsTagDecl();
349 return {clang::TagDecl::castToDeclContext(tag), std::string(uname)};
355 std::string ns_name = spec.GetBaseName().str();
358 return {context, std::string(uname)};
366 m_clang.GetSymbolFile()->GetBackingSymbolFile());
368 switch (uid.
kind()) {
370 std::optional<PdbCompilandSymId> scope =
382 std::optional<TypeIndex> parent_index =
pdb->GetParentType(type_id.
index);
399 switch (global.kind()) {
400 case SymbolKind::S_GDATA32:
401 case SymbolKind::S_LDATA32:
403 case SymbolKind::S_PROCREF:
404 case SymbolKind::S_LPROCREF: {
405 ProcRefSym ref{global.kind()};
407 SymbolDeserializer::deserializeAs<ProcRefSym>(global, ref));
411 case SymbolKind::S_CONSTANT:
412 case SymbolKind::S_UDT:
436 clang::TagDecl *tag = qt->getAsTagDecl();
437 if (qt->isArrayType()) {
438 const clang::Type *element_type = qt->getArrayElementTypeNoTypeQual();
439 tag = element_type->getAsTagDecl();
459 m_clang.GetSymbolFile()->GetBackingSymbolFile())
463 clang::QualType tag_qt =
m_clang.getASTContext().getCanonicalTagType(&tag);
467 CVType cvt = index.
tpi().getType(tag_ti);
468 if (cvt.kind() == LF_MODIFIER)
472 cvt = index.
tpi().getType(best_ti.
index);
482 CVType field_list_cvt = index.
tpi().getType(field_list_ti);
483 if (field_list_cvt.kind() != LF_FIELDLIST)
485 FieldListRecord field_list;
486 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
487 field_list_cvt, field_list))
488 llvm::consumeError(std::move(
error));
496 llvm::codeview::visitMemberRecordStream(field_list.Data, completer);
501 llvm::consumeError(std::move(
error));
508 if (ti == TypeIndex::NullptrT())
511 if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
513 if (direct_type.isNull())
515 return m_clang.getASTContext().getPointerType(direct_type);
518 if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
534 if (pointee_type.isNull())
537 if (pointer.isPointerToMember()) {
538 MemberPointerInfo mpi = pointer.getMemberInfo();
540 if (class_type.isNull())
542 if (clang::TagDecl *tag = class_type->getAsTagDecl()) {
543 clang::MSInheritanceAttr::Spelling spelling;
544 switch (mpi.Representation) {
545 case llvm::codeview::PointerToMemberRepresentation::SingleInheritanceData:
546 case llvm::codeview::PointerToMemberRepresentation::
547 SingleInheritanceFunction:
549 clang::MSInheritanceAttr::Spelling::Keyword_single_inheritance;
551 case llvm::codeview::PointerToMemberRepresentation::
552 MultipleInheritanceData:
553 case llvm::codeview::PointerToMemberRepresentation::
554 MultipleInheritanceFunction:
556 clang::MSInheritanceAttr::Spelling::Keyword_multiple_inheritance;
558 case llvm::codeview::PointerToMemberRepresentation::
559 VirtualInheritanceData:
560 case llvm::codeview::PointerToMemberRepresentation::
561 VirtualInheritanceFunction:
563 clang::MSInheritanceAttr::Spelling::Keyword_virtual_inheritance;
565 case llvm::codeview::PointerToMemberRepresentation::Unknown:
567 clang::MSInheritanceAttr::Spelling::Keyword_unspecified_inheritance;
570 spelling = clang::MSInheritanceAttr::Spelling::SpellingNotCalculated;
573 tag->addAttr(clang::MSInheritanceAttr::CreateImplicit(
574 m_clang.getASTContext(), spelling));
576 return m_clang.getASTContext().getMemberPointerType(
577 pointee_type, std::nullopt,
578 class_type->getAsCXXRecordDecl());
581 clang::QualType pointer_type;
582 if (pointer.getMode() == PointerMode::LValueReference)
583 pointer_type =
m_clang.getASTContext().getLValueReferenceType(pointee_type);
584 else if (pointer.getMode() == PointerMode::RValueReference)
585 pointer_type =
m_clang.getASTContext().getRValueReferenceType(pointee_type);
587 pointer_type =
m_clang.getASTContext().getPointerType(pointee_type);
589 if ((pointer.getOptions() & PointerOptions::Const) != PointerOptions::None)
590 pointer_type.addConst();
592 if ((pointer.getOptions() & PointerOptions::Volatile) != PointerOptions::None)
593 pointer_type.addVolatile();
595 if ((pointer.getOptions() & PointerOptions::Restrict) != PointerOptions::None)
596 pointer_type.addRestrict();
604 if (unmodified_type.isNull())
607 if ((modifier.Modifiers & ModifierOptions::Const) != ModifierOptions::None)
608 unmodified_type.addConst();
609 if ((modifier.Modifiers & ModifierOptions::Volatile) != ModifierOptions::None)
610 unmodified_type.addVolatile();
612 return unmodified_type;
616 const TagRecord &record) {
617 clang::DeclContext *context =
nullptr;
639 clang::QualType result =
653clang::NamespaceDecl *
655 clang::DeclContext &context) {
656 clang::NamespaceDecl *ns =
m_clang.GetUniqueNamespaceDeclaration(
667 return llvm::dyn_cast<clang::BlockDecl>(decl);
671 clang::BlockDecl *block_decl =
685 clang::DeclContext &scope) {
691 clang::VarDecl *var_decl =
m_clang.CreateVariableDeclaration(
706 return llvm::dyn_cast<clang::VarDecl>(decl);
713 m_clang.GetSymbolFile()->GetBackingSymbolFile());
722 return llvm::dyn_cast<clang::VarDecl>(decl);
725 m_clang.GetSymbolFile()->GetBackingSymbolFile());
734 if (
auto *tnd = llvm::dyn_cast<clang::TypedefNameDecl>(decl))
740 m_clang.GetSymbolFile()->GetBackingSymbolFile());
744 UDTSym udt = llvm::cantFail(SymbolDeserializer::deserializeAs<UDTSym>(sym));
750 if (qt.isNull() || !scope)
770 if (type.
index.isSimple())
774 m_clang.GetSymbolFile()->GetBackingSymbolFile());
776 CVType cvt = index.
tpi().getType(type.
index);
778 if (cvt.kind() == LF_MODIFIER) {
779 ModifierRecord modifier;
781 TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier));
785 if (cvt.kind() == LF_POINTER) {
786 PointerRecord pointer;
788 TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer));
801 if (cvt.kind() == LF_ARRAY) {
803 llvm::cantFail(TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar));
807 if (cvt.kind() == LF_PROCEDURE) {
809 llvm::cantFail(TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr));
813 if (cvt.kind() == LF_MFUNCTION) {
814 MemberFunctionRecord mfr;
816 TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr));
824 if (type.
index.isNoneType())
833 m_clang.GetSymbolFile()->GetBackingSymbolFile());
856 clang::TagDecl *tag = qt->getAsTagDecl();
876 clang::StorageClass func_storage,
bool is_inline,
877 clang::DeclContext *parent) {
878 clang::FunctionDecl *function_decl =
nullptr;
879 if (parent->isRecord()) {
881 m_clang.GetSymbolFile()->GetBackingSymbolFile());
883 clang::CanQualType parent_qt =
884 m_clang.getASTContext().getCanonicalTypeDeclType(
885 llvm::cast<clang::TypeDecl>(parent));
891 if (iter->getSecond().contains({func_name, func_ct})) {
896 CVType cvt = index.
tpi().getType(func_ti);
897 MemberFunctionRecord func_record(
static_cast<TypeRecordKind
>(cvt.kind()));
898 llvm::cantFail(TypeDeserializer::deserializeAs<MemberFunctionRecord>(
900 TypeIndex class_index = func_record.getClassType();
902 CVType parent_cvt = index.
tpi().getType(class_index);
905 if (tag_record.isForwardRef()) {
906 llvm::Expected<TypeIndex> eti =
907 index.
tpi().findFullDeclForForwardRef(class_index);
914 pdb->FindMangledFunctionName(func_id).value_or(llvm::StringRef()));
916 if (!tag_record.FieldList.isSimple()) {
917 CVType field_list_cvt = index.
tpi().getType(tag_record.FieldList);
918 FieldListRecord field_list;
919 if (llvm::Error
error = TypeDeserializer::deserializeAs<FieldListRecord>(
920 field_list_cvt, field_list))
921 llvm::consumeError(std::move(
error));
922 CreateMethodDecl process(index,
m_clang, func_ti, function_decl,
923 parent_opaque_ty, func_name, mangled_name,
925 if (llvm::Error err = visitMemberRecordStream(field_list.Data, process))
926 llvm::consumeError(std::move(err));
929 if (!function_decl) {
930 function_decl =
m_clang.AddMethodToCXXRecordType(
931 parent_opaque_ty, func_name, mangled_name, func_ct,
938 function_decl =
m_clang.CreateFunctionDeclaration(
943 return function_decl;
949 m_clang.GetSymbolFile()->GetBackingSymbolFile());
953 InlineSiteSym inline_site(
static_cast<SymbolRecordKind
>(sym.kind()));
954 cantFail(SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site));
961 return llvm::dyn_cast<clang::FunctionDecl>(decl);
962 clang::FunctionDecl *function_decl =
964 if (function_decl ==
nullptr)
969 uint64_t inlinesite_uid =
toOpaqueUid(inlinesite_id);
972 status.
uid = inlinesite_uid;
981 return function_decl;
989 m_clang.GetSymbolFile()->GetBackingSymbolFile());
991 std::optional<CVType> func_cvt =
992 index.
ipi().typeCollection().tryGetType(func_tid.
index);
995 llvm::StringRef func_name;
997 clang::DeclContext *parent =
nullptr;
998 switch (func_cvt->kind()) {
1000 MemberFuncIdRecord mfr;
1002 TypeDeserializer::deserializeAs<MemberFuncIdRecord>(*func_cvt, mfr));
1003 func_name = mfr.getName();
1004 func_ti = mfr.getFunctionType();
1011 cantFail(TypeDeserializer::deserializeAs<FuncIdRecord>(*func_cvt, fir));
1012 func_name = fir.getName();
1013 func_ti = fir.getFunctionType();
1015 if (!fir.ParentScope.isNoneType()) {
1016 CVType parent_cvt = index.
ipi().getType(fir.ParentScope);
1017 if (parent_cvt.kind() == LF_STRING_ID) {
1020 TypeDeserializer::deserializeAs<StringIdRecord>(parent_cvt, sir));
1027 lldbassert(
false &&
"Invalid function id type!");
1030 if (func_qt.isNull() || !parent)
1033 uint32_t param_count =
1034 llvm::cast<clang::FunctionProtoType>(func_qt)->getNumParams();
1036 clang::SC_None,
true, parent);
1039clang::FunctionDecl *
1042 return llvm::dyn_cast<clang::FunctionDecl>(decl);
1047 std::string context_name;
1048 if (clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(parent)) {
1049 context_name = ns->getQualifiedNameAsString();
1050 }
else if (clang::TagDecl *tag = llvm::dyn_cast<clang::TagDecl>(parent)) {
1051 context_name = tag->getQualifiedNameAsString();
1055 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1058 ProcSym proc(
static_cast<SymbolRecordKind
>(cvs.kind()));
1059 llvm::cantFail(SymbolDeserializer::deserializeAs<ProcSym>(cvs, proc));
1066 clang::StorageClass storage = clang::SC_None;
1067 if (proc.Kind == SymbolRecordKind::ProcSym)
1068 storage = clang::SC_Static;
1070 const clang::FunctionProtoType *func_type =
1071 llvm::dyn_cast<clang::FunctionProtoType>(qt);
1075 llvm::StringRef proc_name = proc.Name;
1076 proc_name.consume_front(context_name);
1077 proc_name.consume_front(
"::");
1078 clang::FunctionDecl *function_decl =
1080 func_type->getNumParams(), storage,
false, parent);
1081 if (function_decl ==
nullptr)
1091 return function_decl;
1118 uint32_t param_count) {
1120 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1123 CVSymbolArray scope =
1127 auto begin = scope.begin();
1128 auto end = scope.end();
1129 std::vector<clang::ParmVarDecl *> params;
1130 for (uint32_t i = 0; i < param_count && begin != end;) {
1131 uint32_t record_offset = begin.offset();
1132 CVSymbol sym = *begin++;
1135 llvm::StringRef param_name;
1136 switch (sym.kind()) {
1138 RegRelativeSym reg(SymbolRecordKind::RegRelativeSym);
1139 cantFail(SymbolDeserializer::deserializeAs<RegRelativeSym>(sym, reg));
1140 param_type = reg.Type;
1141 param_name = reg.Name;
1145 RegisterSym reg(SymbolRecordKind::RegisterSym);
1146 cantFail(SymbolDeserializer::deserializeAs<RegisterSym>(sym, reg));
1147 param_type = reg.Index;
1148 param_name = reg.Name;
1152 LocalSym local(SymbolRecordKind::LocalSym);
1153 cantFail(SymbolDeserializer::deserializeAs<LocalSym>(sym, local));
1154 if ((local.Flags & LocalSymFlags::IsParameter) == LocalSymFlags::None)
1156 param_type = local.Type;
1157 param_name = local.Name;
1177 clang::ParmVarDecl *param =
m_clang.CreateParameterDeclaration(
1179 param_type_ct, clang::SC_None,
true);
1183 params.push_back(param);
1187 if (!params.empty() && params.size() == param_count)
1188 function_decl.setParams(params);
1192 const EnumRecord &er) {
1193 clang::DeclContext *decl_context =
nullptr;
1200 if (underlying_type.isNull())
1219 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1222 if (element_type.isNull() || element_size == 0)
1224 uint64_t element_count = ar.Size / element_size;
1227 element_count,
false);
1233 llvm::codeview::CallingConvention calling_convention) {
1235 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1237 TpiStream &stream = index.
tpi();
1238 CVType args_cvt = stream.getType(args_type_idx);
1241 TypeDeserializer::deserializeAs<ArgListRecord>(args_cvt, args));
1243 llvm::ArrayRef<TypeIndex> arg_indices = llvm::ArrayRef(args.ArgIndices);
1246 arg_indices = arg_indices.drop_back();
1248 std::vector<CompilerType> arg_types;
1249 arg_types.reserve(arg_indices.size());
1251 for (
TypeIndex arg_index : arg_indices) {
1253 if (arg_type.isNull())
1259 if (return_type.isNull())
1262 std::optional<clang::CallingConv> cc =
1269 m_clang.CreateFunctionType(return_ct, arg_types, is_variadic, 0, *cc);
1271 return clang::QualType::getFromOpaquePtr(
1276 return llvm::isa<clang::TagDecl>(&context);
1280 return llvm::isa<clang::FunctionDecl>(&context);
1284 return llvm::isa<clang::BlockDecl>(&context);
1288 clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(&context);
1291 std::string qname = ns->getQualifiedNameAsString();
1293 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1296 for (
const CVType &cvt : index.
tpi().typeArray()) {
1308 clang::DeclContext *context =
nullptr;
1311 if (!context || !context->isNamespace())
1314 clang::NamespaceDecl *ns = llvm::cast<clang::NamespaceDecl>(context);
1315 llvm::StringRef ns_name = ns->getName();
1316 if (ns_name.starts_with(qname)) {
1317 ns_name = ns_name.drop_front(qname.size());
1318 if (ns_name.starts_with(
"::"))
1329 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1332 for (
const CVType &cvt : index.
tpi().typeArray()) {
1347 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1349 uint32_t module_count = index.
dbi().modules().getModuleCount();
1350 for (uint16_t modi = 0; modi < module_count; ++modi) {
1352 const CVSymbolArray &symbols = cii.
m_debug_stream.getSymbolArray();
1353 auto iter = symbols.begin();
1354 while (iter != symbols.end()) {
1357 switch (iter->kind()) {
1361 iter = symbols.at(getScopeEndOffset(*iter));
1380 const CVSymbolArray &symbols) {
1381 clang::FunctionDecl *func_decl = llvm::dyn_cast<clang::FunctionDecl>(&decl);
1384 unsigned int params = func_decl->getNumParams();
1388 CVSymbolArray result = symbols;
1390 while (!result.empty()) {
1394 CVSymbol sym = *result.begin();
1395 result.drop_front();
1407 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1410 lldbassert(sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32 ||
1411 sym.kind() == S_BLOCK32 || sym.kind() == S_INLINESITE);
1414 CVSymbolArray symbols =
1419 if (sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32)
1423 symbols.drop_front();
1424 auto begin = symbols.begin();
1425 while (begin != symbols.end()) {
1428 if (begin->kind() == S_BLOCK32 || begin->kind() == S_INLINESITE) {
1430 begin = symbols.at(getScopeEndOffset(*begin));
1437 clang::DeclContext &context) {
1439 clang::Decl *decl = clang::Decl::castFromDeclContext(&context);
1445 if (
auto *tag = llvm::dyn_cast<clang::TagDecl>(&context)) {
1467 if (dc->isTranslationUnit()) {
1473 if (dc->isNamespace()) {
1485 return m_clang.GetCompilerDecl(decl);
1498 return m_clang.CreateDeclContext(context);
1519 llvm::StringRef name) {
1535 for (clang::NamespaceDecl *namespace_decl : *set)
1536 if (namespace_decl->getName() == name)
1539 for (clang::NamespaceDecl *namespace_decl : *set)
1540 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