LLDB mainline
PdbAstBuilderClang.cpp
Go to the documentation of this file.
2
3#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
4#include "llvm/DebugInfo/CodeView/Formatters.h"
5#include "llvm/DebugInfo/CodeView/LazyRandomTypeCollection.h"
6#include "llvm/DebugInfo/CodeView/RecordName.h"
7#include "llvm/DebugInfo/CodeView/SymbolDeserializer.h"
8#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
9#include "llvm/DebugInfo/CodeView/SymbolRecordHelpers.h"
10#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
11#include "llvm/DebugInfo/CodeView/TypeVisitorCallbacks.h"
12#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
13#include "llvm/DebugInfo/PDB/Native/PublicsStream.h"
14#include "llvm/DebugInfo/PDB/Native/SymbolStream.h"
15#include "llvm/DebugInfo/PDB/Native/TpiStream.h"
16#include "llvm/Demangle/MicrosoftDemangle.h"
17
18#include "PdbUtil.h"
23#include "SymbolFileNativePDB.h"
24#include "UdtRecordCompleter.h"
25#include "lldb/Core/Module.h"
29#include <optional>
30#include <string_view>
31
32using namespace lldb_private;
33using namespace lldb_private::npdb;
34using namespace llvm::codeview;
35using namespace llvm::pdb;
36
37namespace {
38struct CreateMethodDecl : public TypeVisitorCallbacks {
39 CreateMethodDecl(PdbIndex &m_index, TypeSystemClang &m_clang,
40 TypeIndex func_type_index,
41 clang::FunctionDecl *&function_decl,
43 llvm::StringRef proc_name, ConstString mangled_name,
44 CompilerType func_ct)
45 : m_index(m_index), m_clang(m_clang), func_type_index(func_type_index),
46 function_decl(function_decl), parent_ty(parent_ty),
47 proc_name(proc_name), mangled_name(mangled_name), func_ct(func_ct) {}
48 PdbIndex &m_index;
49 TypeSystemClang &m_clang;
50 TypeIndex func_type_index;
51 clang::FunctionDecl *&function_decl;
53 llvm::StringRef proc_name;
54 ConstString mangled_name;
55 CompilerType func_ct;
56
57 llvm::Error visitKnownMember(CVMemberRecord &cvr,
58 OverloadedMethodRecord &overloaded) override {
59 TypeIndex method_list_idx = overloaded.MethodList;
60
61 CVType method_list_type = m_index.tpi().getType(method_list_idx);
62 assert(method_list_type.kind() == LF_METHODLIST);
63
64 MethodOverloadListRecord method_list;
65 llvm::Error err = TypeDeserializer::deserializeAs<MethodOverloadListRecord>(
66 method_list_type, method_list);
67 if (err) {
68 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
69 "Failed to deserialize {1} as MethodOverloadList: {0}",
70 method_list_idx);
71 // Continue even if we couldn't deserialize.
72 return llvm::Error::success();
73 }
74
75 for (const OneMethodRecord &method : method_list.Methods) {
76 if (method.getType().getIndex() == func_type_index.getIndex())
77 AddMethod(overloaded.Name, method.getOptions(), method.Attrs);
78 }
79
80 return llvm::Error::success();
81 }
82
83 llvm::Error visitKnownMember(CVMemberRecord &cvr,
84 OneMethodRecord &record) override {
85 AddMethod(record.getName(), record.getOptions(), record.Attrs);
86 return llvm::Error::success();
87 }
88
89 void AddMethod(llvm::StringRef name, MethodOptions options,
90 MemberAttributes attrs) {
91 if (name != proc_name || function_decl)
92 return;
93 bool is_virtual = attrs.isVirtual();
94 bool is_static = attrs.isStatic();
95 bool is_artificial = (options & MethodOptions::CompilerGenerated) ==
96 MethodOptions::CompilerGenerated;
97 function_decl = m_clang.AddMethodToCXXRecordType(
98 parent_ty, proc_name, mangled_name, func_ct,
99 /*is_virtual=*/is_virtual, /*is_static=*/is_static,
100 /*is_inline=*/false, /*is_explicit=*/false,
101 /*is_attr_used=*/false, /*is_artificial=*/is_artificial);
102 }
103};
104} // namespace
105
106static clang::TagTypeKind TranslateUdtKind(const TagRecord &cr) {
107 switch (cr.Kind) {
108 case TypeRecordKind::Class:
109 return clang::TagTypeKind::Class;
110 case TypeRecordKind::Struct:
111 return clang::TagTypeKind::Struct;
112 case TypeRecordKind::Union:
113 return clang::TagTypeKind::Union;
114 case TypeRecordKind::Interface:
115 return clang::TagTypeKind::Interface;
116 case TypeRecordKind::Enum:
117 return clang::TagTypeKind::Enum;
118 default:
119 lldbassert(false && "Invalid tag record kind!");
120 return clang::TagTypeKind::Struct;
121 }
122}
123
124static bool IsCVarArgsFunction(llvm::ArrayRef<TypeIndex> args) {
125 if (args.empty())
126 return false;
127 return args.back() == TypeIndex::None();
128}
129
130static bool
131AnyScopesHaveTemplateParams(llvm::ArrayRef<llvm::ms_demangle::Node *> scopes) {
132 for (llvm::ms_demangle::Node *n : scopes) {
133 auto *idn = static_cast<llvm::ms_demangle::IdentifierNode *>(n);
134 if (idn->TemplateParams)
135 return true;
136 }
137 return false;
138}
139
140static std::optional<clang::CallingConv>
141TranslateCallingConvention(llvm::codeview::CallingConvention conv) {
142 using CC = llvm::codeview::CallingConvention;
143 switch (conv) {
144
145 case CC::NearC:
146 case CC::FarC:
147 return clang::CallingConv::CC_C;
148 case CC::NearPascal:
149 case CC::FarPascal:
150 return clang::CallingConv::CC_X86Pascal;
151 case CC::NearFast:
152 case CC::FarFast:
153 return clang::CallingConv::CC_X86FastCall;
154 case CC::NearStdCall:
155 case CC::FarStdCall:
156 return clang::CallingConv::CC_X86StdCall;
157 case CC::ThisCall:
158 return clang::CallingConv::CC_X86ThisCall;
159 case CC::NearVector:
160 return clang::CallingConv::CC_X86VectorCall;
161 default:
162 return std::nullopt;
163 }
164}
165
166static bool IsAnonymousNamespaceName(llvm::StringRef name) {
167 return name == "`anonymous namespace'" || name == "`anonymous-namespace'";
168}
169
172
176
177std::pair<clang::DeclContext *, std::string>
179 TypeIndex ti) {
181 m_clang.GetSymbolFile()->GetBackingSymbolFile());
182 // FIXME: Move this to GetDeclContextContainingUID.
183 if (!record.hasUniqueName())
184 return CreateDeclInfoForUndecoratedName(record.Name);
185
186 llvm::ms_demangle::Demangler demangler;
187 std::string_view sv(record.UniqueName.begin(), record.UniqueName.size());
188 llvm::ms_demangle::TagTypeNode *ttn = demangler.parseTagUniqueName(sv);
189 if (demangler.Error)
190 return CreateDeclInfoForUndecoratedName(record.Name);
191
192 llvm::ms_demangle::IdentifierNode *idn =
193 ttn->QualifiedName->getUnqualifiedIdentifier();
194 std::string uname = idn->toString(llvm::ms_demangle::OF_NoTagSpecifier);
195
196 llvm::ms_demangle::NodeArrayNode *name_components =
197 ttn->QualifiedName->Components;
198 llvm::ArrayRef<llvm::ms_demangle::Node *> scopes(name_components->Nodes,
199 name_components->Count - 1);
200
201 clang::DeclContext *context = m_clang.GetTranslationUnitDecl();
202
203 // If this type doesn't have a parent type in the debug info, then the best we
204 // can do is to say that it's either a series of namespaces (if the scope is
205 // non-empty), or the translation unit (if the scope is empty).
206 std::optional<TypeIndex> parent_index = pdb->GetParentType(ti);
207 if (!parent_index) {
208 if (scopes.empty())
209 return {context, uname};
210
211 // If there is no parent in the debug info, but some of the scopes have
212 // template params, then this is a case of bad debug info. See, for
213 // example, llvm.org/pr39607. We don't want to create an ambiguity between
214 // a NamespaceDecl and a CXXRecordDecl, so instead we create a class at
215 // global scope with the fully qualified name.
216 if (AnyScopesHaveTemplateParams(scopes))
217 return {context, std::string(record.Name)};
218
219 for (llvm::ms_demangle::Node *scope : scopes) {
220 auto *nii = static_cast<llvm::ms_demangle::NamedIdentifierNode *>(scope);
221 std::string str = nii->toString();
222 context = GetOrCreateNamespaceDecl(str.c_str(), *context);
223 }
224 return {context, uname};
225 }
226
227 // Otherwise, all we need to do is get the parent type of this type and
228 // recurse into our lazy type creation / AST reconstruction logic to get an
229 // LLDB TypeSP for the parent. This will cause the AST to automatically get
230 // the right DeclContext created for any parent.
231 clang::QualType parent_qt = GetOrCreateClangType(*parent_index);
232 if (parent_qt.isNull())
233 return {nullptr, ""};
234
235 context = clang::TagDecl::castToDeclContext(parent_qt->getAsTagDecl());
236 return {context, uname};
237}
238
239static bool isLocalVariableType(SymbolKind K) {
240 switch (K) {
241 case S_REGISTER:
242 case S_REGREL32:
243 case S_REGREL32_INDIR:
244 case S_LOCAL:
245 return true;
246 default:
247 break;
248 }
249 return false;
250}
251
254 m_clang.GetSymbolFile()->GetBackingSymbolFile());
255 PdbIndex &index = pdb->GetIndex();
256 CVSymbol cvs = index.ReadSymbolRecord(id);
257
258 if (isLocalVariableType(cvs.kind())) {
259 clang::DeclContext *scope = GetParentClangDeclContext(id);
260 if (!scope)
261 return nullptr;
262 clang::Decl *scope_decl = clang::Decl::castFromDeclContext(scope);
263 PdbCompilandSymId scope_id =
264 PdbSymUid(m_decl_to_status[scope_decl].uid).asCompilandSym();
265 return GetOrCreateVariableDecl(scope_id, id);
266 }
267
268 switch (cvs.kind()) {
269 case S_GPROC32:
270 case S_LPROC32:
271 return GetOrCreateFunctionDecl(id);
272 case S_GDATA32:
273 case S_LDATA32:
274 case S_GTHREAD32:
275 case S_CONSTANT:
276 // global variable
277 return nullptr;
278 case S_BLOCK32:
279 return GetOrCreateBlockDecl(id);
280 case S_INLINESITE:
282 default:
283 return nullptr;
284 }
285}
286
288 if (clang::Decl *result = TryGetDecl(uid))
289 return ToCompilerDecl(result);
290
291 clang::Decl *result = nullptr;
292 switch (uid.kind()) {
295 break;
296 case PdbSymUidKind::Type: {
297 clang::QualType qt = GetOrCreateClangType(uid.asTypeSym());
298 if (qt.isNull())
299 return CompilerDecl();
300 if (auto *tag = qt->getAsTagDecl()) {
301 result = tag;
302 break;
303 }
304 return CompilerDecl();
305 }
306 default:
307 return CompilerDecl();
308 }
309
310 if (!result)
311 return CompilerDecl();
312 m_uid_to_decl[toOpaqueUid(uid)] = result;
313 return ToCompilerDecl(result);
314}
315
316clang::DeclContext *
318 if (uid.kind() == PdbSymUidKind::CompilandSym) {
319 if (uid.asCompilandSym().offset == 0)
321 }
322 clang::Decl *decl = FromCompilerDecl(GetOrCreateDeclForUid(uid));
323 if (!decl)
324 return nullptr;
325
326 return clang::Decl::castToDeclContext(decl);
327}
328
333
334std::pair<clang::DeclContext *, std::string>
337 m_clang.GetSymbolFile()->GetBackingSymbolFile());
338 PdbIndex &index = pdb->GetIndex();
339 MSVCUndecoratedNameParser parser(name);
340 llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs = parser.GetSpecifiers();
341
343
344 llvm::StringRef uname = specs.back().GetBaseName();
345 specs = specs.drop_back();
346 if (specs.empty())
347 return {context, std::string(name)};
348
349 llvm::StringRef scope_name = specs.back().GetFullName();
350
351 // It might be a class name, try that first.
352 std::vector<TypeIndex> types = index.tpi().findRecordsByName(scope_name);
353 while (!types.empty()) {
354 clang::QualType qt = GetOrCreateClangType(types.back());
355 if (qt.isNull())
356 continue;
357 clang::TagDecl *tag = qt->getAsTagDecl();
358 if (tag)
359 return {clang::TagDecl::castToDeclContext(tag), std::string(uname)};
360 types.pop_back();
361 }
362
363 // If that fails, treat it as a series of namespaces.
364 for (const MSVCUndecoratedNameSpecifier &spec : specs) {
365 std::string ns_name = spec.GetBaseName().str();
366 context = GetOrCreateNamespaceDecl(ns_name.c_str(), *context);
367 }
368 return {context, std::string(uname)};
369}
370
371clang::DeclContext *
373 PdbCompilandSymId uid) {
375 m_clang.GetSymbolFile()->GetBackingSymbolFile());
376 PdbIndex &index = pdb->GetIndex();
377 CVSymbol sym = index.ReadSymbolRecord(uid);
378
379 llvm::StringRef symbol_name = getSymbolName(sym);
380
381 std::optional<PdbTypeSymId> func_id = GetFunctionType(sym);
382 if (!func_id || !symbol_name.contains("::"))
383 return CreateDeclInfoForUndecoratedName(symbol_name).first;
384
385 // Try to get the context from class type of an LF_MFUNCTION.
386 // For some types, we might not find a class type.
387 auto get_member_fn_context = [&]() -> clang::DeclContext * {
388 TypeIndex id = func_id->index;
389
390 if (func_id->is_ipi) {
391 // Type from IPI, for example from S_INLINESITE
392 std::optional<CVType> func_id_type =
393 index.ipi().tryGetType(func_id->index);
394 if (!func_id_type || func_id_type->kind() != LF_MFUNC_ID)
395 return nullptr;
396
397 MemberFuncIdRecord record;
398 llvm::Error err = TypeDeserializer::deserializeAs<MemberFuncIdRecord>(
399 *func_id_type, record);
400 if (err) {
401 llvm::consumeError(std::move(err));
402 return nullptr;
403 }
404
405 id = record.FunctionType;
406 }
407
408 std::optional<CVType> func_type = index.tpi().tryGetType(id);
409 if (!func_type || func_type->kind() != LF_MFUNCTION)
410 return nullptr;
411
412 MemberFunctionRecord mfr(TypeRecordKind::MemberFunction);
413
414 llvm::Error err =
415 TypeDeserializer::deserializeAs<MemberFunctionRecord>(*func_type, mfr);
416 if (err || mfr.ClassType.isNoneType()) {
417 llvm::consumeError(std::move(err));
418 return nullptr;
419 }
420
421 clang::QualType qt = GetOrCreateClangType(mfr.ClassType);
422 if (qt.isNull())
423 return nullptr;
424 clang::TagDecl *tag = qt->getAsTagDecl();
425 if (!tag)
426 return nullptr;
427
428 return clang::TagDecl::castToDeclContext(tag);
429 };
430
431 clang::DeclContext *context = get_member_fn_context();
432 if (!context)
433 return CreateDeclInfoForUndecoratedName(symbol_name).first;
434
435 return context;
436}
437
438clang::DeclContext *
440 // We must do this *without* calling GetOrCreate on the current uid, as
441 // that would be an infinite recursion.
443 m_clang.GetSymbolFile()->GetBackingSymbolFile());
444 PdbIndex &index = pdb->GetIndex();
445 switch (uid.kind()) {
447 std::optional<PdbCompilandSymId> scope =
448 pdb->FindSymbolScope(uid.asCompilandSym());
449 if (scope)
451
453 }
454 case PdbSymUidKind::Type: {
455 // It could be a namespace, class, or global. We don't support nested
456 // functions yet. Anyway, we just need to consult the parent type map.
457 PdbTypeSymId type_id = uid.asTypeSym();
458 std::optional<TypeIndex> parent_index = pdb->GetParentType(type_id.index);
459 if (!parent_index)
461 return GetOrCreateClangDeclContextForUid(PdbTypeSymId(*parent_index));
462 }
464 // In this case the parent DeclContext is the one for the class that this
465 // member is inside of.
466 break;
468 // If this refers to a compiland symbol, just recurse in with that symbol.
469 // The only other possibilities are S_CONSTANT and S_UDT, in which case we
470 // need to parse the undecorated name to figure out the scope, then look
471 // that up in the TPI stream. If it's found, it's a type, othewrise it's
472 // a series of namespaces.
473 // FIXME: do this.
474 CVSymbol global = index.ReadSymbolRecord(uid.asGlobalSym());
475 switch (global.kind()) {
476 case SymbolKind::S_GDATA32:
477 case SymbolKind::S_LDATA32:
478 return CreateDeclInfoForUndecoratedName(getSymbolName(global)).first;
479 case SymbolKind::S_PROCREF:
480 case SymbolKind::S_LPROCREF: {
481 ProcRefSym ref{global.kind()};
482 llvm::Error err =
483 SymbolDeserializer::deserializeAs<ProcRefSym>(global, ref);
484 if (err) {
485 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
486 "Failed to deserialize {1} as ProcRef: {0}",
487 uid.asGlobalSym());
488 return nullptr;
489 }
490 PdbCompilandSymId cu_sym_id{ref.modi(), ref.SymOffset};
491 return GetParentClangDeclContext(cu_sym_id);
492 }
493 case SymbolKind::S_CONSTANT:
494 case SymbolKind::S_UDT:
495 return CreateDeclInfoForUndecoratedName(getSymbolName(global)).first;
496 default:
497 break;
498 }
499 break;
500 }
501 default:
502 break;
503 }
505}
506
510
512 if (GetClangASTImporter().CanImport(ct))
514
515 clang::QualType qt = FromCompilerType(ct);
516 if (qt.isNull())
517 return false;
518 clang::TagDecl *tag = qt->getAsTagDecl();
519 if (qt->isArrayType()) {
520 const clang::Type *element_type = qt->getArrayElementTypeNoTypeQual();
521 tag = element_type->getAsTagDecl();
522 }
523 if (!tag)
524 return false;
525
526 return CompleteTagDecl(*tag);
527}
528
529bool PdbAstBuilderClang::CompleteTagDecl(clang::TagDecl &tag) {
530 // If this is not in our map, it's an error.
531 auto status_iter = m_decl_to_status.find(&tag);
532 lldbassert(status_iter != m_decl_to_status.end());
533
534 // If it's already complete, just return.
535 DeclStatus &status = status_iter->second;
536 if (status.resolved)
537 return true;
538
539 PdbTypeSymId type_id = PdbSymUid(status.uid).asTypeSym();
540 PdbIndex &index = static_cast<SymbolFileNativePDB *>(
541 m_clang.GetSymbolFile()->GetBackingSymbolFile())
542 ->GetIndex();
543 lldbassert(IsTagRecord(type_id, index.tpi()));
544
545 clang::QualType tag_qt = m_clang.getASTContext().getCanonicalTagType(&tag);
546 TypeSystemClang::SetHasExternalStorage(tag_qt.getAsOpaquePtr(), false);
547
548 TypeIndex tag_ti = type_id.index;
549 CVType cvt = index.tpi().getType(tag_ti);
550 if (cvt.kind() == LF_MODIFIER)
551 tag_ti = LookThroughModifierRecord(cvt);
552
553 PdbTypeSymId best_ti = GetBestPossibleDecl(tag_ti, index.tpi());
554 cvt = index.tpi().getType(best_ti.index);
556
557 if (IsForwardRefUdt(cvt)) {
558 // If we can't find a full decl for this forward ref anywhere in the debug
559 // info, then we have no way to complete it.
560 return false;
561 }
562
563 TypeIndex field_list_ti = GetFieldListIndex(cvt);
564 CVType field_list_cvt = index.tpi().getType(field_list_ti);
565 if (field_list_cvt.kind() != LF_FIELDLIST)
566 return false;
567 FieldListRecord field_list;
568 if (llvm::Error error = TypeDeserializer::deserializeAs<FieldListRecord>(
569 field_list_cvt, field_list))
570 llvm::consumeError(std::move(error));
571
572 // Visit all members of this class, then perform any finalization necessary
573 // to complete the class.
574 CompilerType ct = ToCompilerType(tag_qt);
575 UdtRecordCompleter completer(best_ti, ct, tag, *this, index, m_decl_to_status,
577 llvm::Error error =
578 llvm::codeview::visitMemberRecordStream(field_list.Data, completer);
579 completer.complete();
580
581 m_decl_to_status[&tag].resolved = true;
582 if (error) {
583 llvm::consumeError(std::move(error));
584 return false;
585 }
586 return true;
587}
588
590 if (ti == TypeIndex::NullptrT())
592
593 if (ti.getSimpleMode() != SimpleTypeMode::Direct) {
594 clang::QualType direct_type = GetOrCreateClangType(ti.makeDirect());
595 if (direct_type.isNull())
596 return {};
597 return m_clang.getASTContext().getPointerType(direct_type);
598 }
599
600 if (ti.getSimpleKind() == SimpleTypeKind::NotTranslated)
601 return {};
602
603 lldb::BasicType bt = GetCompilerTypeForSimpleKind(ti.getSimpleKind());
604 if (bt == lldb::eBasicTypeInvalid)
605 return {};
606
607 return GetBasicType(bt);
608}
609
610clang::QualType
611PdbAstBuilderClang::CreatePointerType(const PointerRecord &pointer) {
612 clang::QualType pointee_type = GetOrCreateClangType(pointer.ReferentType);
613
614 // This can happen for pointers to LF_VTSHAPE records, which we shouldn't
615 // create in the AST.
616 if (pointee_type.isNull())
617 return {};
618
619 if (pointer.isPointerToMember()) {
620 MemberPointerInfo mpi = pointer.getMemberInfo();
621 clang::QualType class_type = GetOrCreateClangType(mpi.ContainingType);
622 if (class_type.isNull())
623 return {};
624 if (clang::TagDecl *tag = class_type->getAsTagDecl()) {
625 clang::MSInheritanceAttr::Spelling spelling;
626 switch (mpi.Representation) {
627 case llvm::codeview::PointerToMemberRepresentation::SingleInheritanceData:
628 case llvm::codeview::PointerToMemberRepresentation::
629 SingleInheritanceFunction:
630 spelling =
631 clang::MSInheritanceAttr::Spelling::Keyword_single_inheritance;
632 break;
633 case llvm::codeview::PointerToMemberRepresentation::
634 MultipleInheritanceData:
635 case llvm::codeview::PointerToMemberRepresentation::
636 MultipleInheritanceFunction:
637 spelling =
638 clang::MSInheritanceAttr::Spelling::Keyword_multiple_inheritance;
639 break;
640 case llvm::codeview::PointerToMemberRepresentation::
641 VirtualInheritanceData:
642 case llvm::codeview::PointerToMemberRepresentation::
643 VirtualInheritanceFunction:
644 spelling =
645 clang::MSInheritanceAttr::Spelling::Keyword_virtual_inheritance;
646 break;
647 case llvm::codeview::PointerToMemberRepresentation::Unknown:
648 spelling =
649 clang::MSInheritanceAttr::Spelling::Keyword_unspecified_inheritance;
650 break;
651 default:
652 spelling = clang::MSInheritanceAttr::Spelling::SpellingNotCalculated;
653 break;
654 }
655 tag->addAttr(clang::MSInheritanceAttr::CreateImplicit(
656 m_clang.getASTContext(), spelling));
657 }
658 return m_clang.getASTContext().getMemberPointerType(
659 pointee_type, /*Qualifier=*/std::nullopt,
660 class_type->getAsCXXRecordDecl());
661 }
662
663 clang::QualType pointer_type;
664 if (pointer.getMode() == PointerMode::LValueReference)
665 pointer_type = m_clang.getASTContext().getLValueReferenceType(pointee_type);
666 else if (pointer.getMode() == PointerMode::RValueReference)
667 pointer_type = m_clang.getASTContext().getRValueReferenceType(pointee_type);
668 else
669 pointer_type = m_clang.getASTContext().getPointerType(pointee_type);
670
671 if ((pointer.getOptions() & PointerOptions::Const) != PointerOptions::None)
672 pointer_type.addConst();
673
674 if ((pointer.getOptions() & PointerOptions::Volatile) != PointerOptions::None)
675 pointer_type.addVolatile();
676
677 if ((pointer.getOptions() & PointerOptions::Restrict) != PointerOptions::None)
678 pointer_type.addRestrict();
679
680 return pointer_type;
681}
682
683clang::QualType
684PdbAstBuilderClang::CreateModifierType(const ModifierRecord &modifier) {
685 clang::QualType unmodified_type = GetOrCreateClangType(modifier.ModifiedType);
686 if (unmodified_type.isNull())
687 return {};
688
689 if ((modifier.Modifiers & ModifierOptions::Const) != ModifierOptions::None)
690 unmodified_type.addConst();
691 if ((modifier.Modifiers & ModifierOptions::Volatile) != ModifierOptions::None)
692 unmodified_type.addVolatile();
693
694 return unmodified_type;
695}
696
698 const TagRecord &record) {
699 clang::DeclContext *context = nullptr;
700 std::string uname;
701 std::tie(context, uname) = CreateDeclInfoForType(record, id.index);
702 if (!context)
703 return {};
704
705 clang::TagTypeKind ttk = TranslateUdtKind(record);
706 ClangASTMetadata metadata;
707 metadata.SetUserID(toOpaqueUid(id));
708 metadata.SetIsDynamicCXXType(false);
709
710 CompilerType ct = m_clang.CreateRecordType(
711 context, OptionalClangModuleID(), uname, llvm::to_underlying(ttk),
713
714 lldbassert(ct.IsValid());
715
717
718 // Even if it's possible, don't complete it at this point. Just mark it
719 // forward resolved, and if/when LLDB needs the full definition, it can
720 // ask us.
721 clang::QualType result =
722 clang::QualType::getFromOpaquePtr(ct.GetOpaqueQualType());
723
724 TypeSystemClang::SetHasExternalStorage(result.getAsOpaquePtr(), true);
725 return result;
726}
727
729 auto iter = m_uid_to_decl.find(toOpaqueUid(uid));
730 if (iter != m_uid_to_decl.end())
731 return iter->second;
732 return nullptr;
733}
734
735clang::NamespaceDecl *
737 clang::DeclContext &context) {
738 clang::NamespaceDecl *ns = m_clang.GetUniqueNamespaceDeclaration(
739 IsAnonymousNamespaceName(name) ? nullptr : name, &context,
741 m_known_namespaces.insert(ns);
742 m_parent_to_namespaces[&context].insert(ns);
743 return ns;
744}
745
746clang::BlockDecl *
748 if (clang::Decl *decl = TryGetDecl(block_id))
749 return llvm::dyn_cast<clang::BlockDecl>(decl);
750
751 clang::DeclContext *scope = GetParentClangDeclContext(block_id);
752
753 clang::BlockDecl *block_decl =
754 m_clang.CreateBlockDeclaration(scope, OptionalClangModuleID());
755 m_uid_to_decl.insert({toOpaqueUid(block_id), block_decl});
756
757 DeclStatus status;
758 status.resolved = true;
759 status.uid = toOpaqueUid(block_id);
760 m_decl_to_status.insert({block_decl, status});
761
762 return block_decl;
763}
764
765clang::VarDecl *
767 clang::DeclContext &scope) {
768 VariableInfo var_info = GetVariableNameInfo(sym);
769 clang::QualType qt = GetOrCreateClangType(var_info.type);
770 if (qt.isNull())
771 return nullptr;
772
773 clang::VarDecl *var_decl = m_clang.CreateVariableDeclaration(
774 &scope, OptionalClangModuleID(), var_info.name.str().c_str(), qt);
775
776 m_uid_to_decl[toOpaqueUid(uid)] = var_decl;
777 DeclStatus status;
778 status.resolved = true;
779 status.uid = toOpaqueUid(uid);
780 m_decl_to_status.insert({var_decl, status});
781 return var_decl;
782}
783
784clang::VarDecl *
786 PdbCompilandSymId var_id) {
787 if (clang::Decl *decl = TryGetDecl(var_id))
788 return llvm::dyn_cast<clang::VarDecl>(decl);
789
790 clang::DeclContext *scope = GetOrCreateClangDeclContextForUid(scope_id);
791 if (!scope)
792 return nullptr;
793
795 m_clang.GetSymbolFile()->GetBackingSymbolFile());
796 PdbIndex &index = pdb->GetIndex();
797 CVSymbol sym = index.ReadSymbolRecord(var_id);
798 return CreateVariableDecl(PdbSymUid(var_id), sym, *scope);
799}
800
801clang::VarDecl *
803 if (clang::Decl *decl = TryGetDecl(var_id))
804 return llvm::dyn_cast<clang::VarDecl>(decl);
805
807 m_clang.GetSymbolFile()->GetBackingSymbolFile());
808 PdbIndex &index = pdb->GetIndex();
809 CVSymbol sym = index.ReadSymbolRecord(var_id);
811 return CreateVariableDecl(PdbSymUid(var_id), sym, *context);
812}
813
815 if (clang::Decl *decl = TryGetDecl(id)) {
816 if (auto *tnd = llvm::dyn_cast<clang::TypedefNameDecl>(decl))
817 return ToCompilerType(m_clang.getASTContext().getTypeDeclType(tnd));
818 return CompilerType();
819 }
820
822 m_clang.GetSymbolFile()->GetBackingSymbolFile());
823 PdbIndex &index = pdb->GetIndex();
824 CVSymbol sym = index.ReadSymbolRecord(id);
825 lldbassert(sym.kind() == S_UDT);
826 llvm::Expected<UDTSym> udt = SymbolDeserializer::deserializeAs<UDTSym>(sym);
827 if (!udt) {
828 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), udt.takeError(),
829 "Failed to deserialize {1} as UDT: {0}", id);
830 return CompilerType();
831 }
832
833 clang::DeclContext *scope = GetParentClangDeclContext(id);
834
835 PdbTypeSymId real_type_id{udt->Type, false};
836 clang::QualType qt = GetOrCreateClangType(real_type_id);
837 if (qt.isNull() || !scope)
838 return CompilerType();
839
840 std::string uname = std::string(DropNameScope(udt->Name));
841
843 uname.c_str(), ToCompilerDeclContext(scope), 0);
844 DeclStatus status;
845 status.resolved = true;
846 status.uid = toOpaqueUid(id);
847 m_decl_to_status.insert({m_clang.GetAsTypedefDecl(ct), status});
848 return ct;
849}
850
852 CompilerType ct = m_clang.GetBasicType(type);
853 return clang::QualType::getFromOpaquePtr(ct.GetOpaqueQualType());
854}
855
857 if (type.index.isSimple())
858 return CreateSimpleType(type.index);
859
861 m_clang.GetSymbolFile()->GetBackingSymbolFile());
862 PdbIndex &index = pdb->GetIndex();
863 CVType cvt = index.tpi().getType(type.index);
864
865 if (cvt.kind() == LF_MODIFIER) {
866 ModifierRecord modifier;
867 llvm::Error err =
868 TypeDeserializer::deserializeAs<ModifierRecord>(cvt, modifier);
869 if (err) {
870 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
871 "Failed to deserialize {1} as Modifier: {0}", type.index);
872 return {};
873 }
874 return CreateModifierType(modifier);
875 }
876
877 if (cvt.kind() == LF_POINTER) {
878 PointerRecord pointer;
879 llvm::Error err =
880 TypeDeserializer::deserializeAs<PointerRecord>(cvt, pointer);
881 if (err) {
882 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
883 "Failed to deserialize {1} as Pointer: {0}", type.index);
884 return {};
885 }
886 return CreatePointerType(pointer);
887 }
888
889 if (IsTagRecord(cvt)) {
891 if (tag.kind() == CVTagRecord::Union)
892 return CreateRecordType(type.index, tag.asUnion());
893 if (tag.kind() == CVTagRecord::Enum)
894 return CreateEnumType(type.index, tag.asEnum());
895 return CreateRecordType(type.index, tag.asClass());
896 }
897
898 if (cvt.kind() == LF_ARRAY) {
899 ArrayRecord ar;
900 llvm::Error err = TypeDeserializer::deserializeAs<ArrayRecord>(cvt, ar);
901 if (err) {
902 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
903 "Failed to deserialize {1} as Array: {0}", type.index);
904 return {};
905 }
906 return CreateArrayType(ar);
907 }
908
909 if (cvt.kind() == LF_PROCEDURE) {
910 ProcedureRecord pr;
911 llvm::Error err = TypeDeserializer::deserializeAs<ProcedureRecord>(cvt, pr);
912 if (err) {
913 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
914 "Failed to deserialize {1} as Procedure: {0}", type.index);
915 return {};
916 }
917 return CreateFunctionType(pr.ArgumentList, pr.ReturnType, pr.CallConv,
918 /*type_quals=*/0);
919 }
920
921 if (cvt.kind() == LF_MFUNCTION) {
922 MemberFunctionRecord mfr;
923 llvm::Error err =
924 TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, mfr);
925 if (err) {
926 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
927 "Failed to deserialize {1} as MemberFunction: {0}",
928 type.index);
929 return {};
930 }
931 unsigned int type_quals = 0;
932 if (!mfr.ThisType.isNoneType()) {
933 clang::QualType this_type = GetOrCreateClangType(mfr.getThisType());
934 if (!this_type.isNull())
935 type_quals = this_type->getPointeeType().getLocalFastQualifiers();
936 }
937 return CreateFunctionType(mfr.ArgumentList, mfr.ReturnType, mfr.CallConv,
938 type_quals);
939 }
940
941 return {};
942}
943
945 if (type.index.isNoneType())
946 return {};
947
948 lldb::user_id_t uid = toOpaqueUid(type);
949 auto iter = m_uid_to_type.find(uid);
950 if (iter != m_uid_to_type.end())
951 return iter->second;
952
954 m_clang.GetSymbolFile()->GetBackingSymbolFile());
955 PdbIndex &index = pdb->GetIndex();
956 PdbTypeSymId best_type = GetBestPossibleDecl(type, index.tpi());
957
958 clang::QualType qt;
959 if (best_type.index != type.index) {
960 // This is a forward decl. Call GetOrCreate on the full decl, then map the
961 // forward decl id to the full decl QualType.
962 clang::QualType qt = GetOrCreateClangType(best_type);
963 if (qt.isNull())
964 return {};
965 m_uid_to_type[toOpaqueUid(type)] = qt;
966 return qt;
967 }
968
969 // This is either a full decl, or a forward decl with no matching full decl
970 // in the debug info.
971 qt = CreateType(type);
972 if (qt.isNull())
973 return {};
974
975 m_uid_to_type[toOpaqueUid(type)] = qt;
976 if (IsTagRecord(type, index.tpi())) {
977 clang::TagDecl *tag = qt->getAsTagDecl();
978 lldbassert(m_decl_to_status.count(tag) == 0);
979
980 DeclStatus &status = m_decl_to_status[tag];
981 status.uid = uid;
982 status.resolved = false;
983 }
984 return qt;
985}
986
988 clang::QualType qt = GetOrCreateClangType(type);
989 if (qt.isNull())
990 return {};
991 return ToCompilerType(qt);
992}
993
995 PdbCompilandSymId func_id, llvm::StringRef func_name, TypeIndex func_ti,
996 CompilerType func_ct, uint32_t param_count,
997 clang::StorageClass func_storage, bool is_inline,
998 clang::DeclContext *parent) {
999 clang::FunctionDecl *function_decl = nullptr;
1000 if (parent->isRecord()) {
1002 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1003 PdbIndex &index = pdb->GetIndex();
1004 clang::CanQualType parent_qt =
1005 m_clang.getASTContext().getCanonicalTypeDeclType(
1006 llvm::cast<clang::TypeDecl>(parent));
1007 lldb::opaque_compiler_type_t parent_opaque_ty =
1008 ToCompilerType(parent_qt).GetOpaqueQualType();
1009 // FIXME: Remove this workaround.
1010 auto iter = m_cxx_record_map.find(parent_opaque_ty);
1011 if (iter != m_cxx_record_map.end()) {
1012 if (iter->getSecond().contains({func_name, func_ct})) {
1013 return nullptr;
1014 }
1015 }
1016
1017 CVType cvt = index.tpi().getType(func_ti);
1018 MemberFunctionRecord func_record(static_cast<TypeRecordKind>(cvt.kind()));
1019 llvm::Error err =
1020 TypeDeserializer::deserializeAs<MemberFunctionRecord>(cvt, func_record);
1021 if (err) {
1022 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1023 "Failed to deserialize {1} as MemberFunction: {0}",
1024 func_ti);
1025 return nullptr;
1026 }
1027 TypeIndex class_index = func_record.getClassType();
1028
1029 CVType parent_cvt = index.tpi().getType(class_index);
1030 if (!IsTagRecord(parent_cvt))
1031 return nullptr;
1032 TagRecord tag_record = CVTagRecord::create(parent_cvt).asTag();
1033 // If it's a forward reference, try to get the real TypeIndex.
1034 if (tag_record.isForwardRef()) {
1035 llvm::Expected<TypeIndex> eti =
1036 index.tpi().findFullDeclForForwardRef(class_index);
1037 if (eti) {
1038 CVType resolved_tag_record = index.tpi().getType(*eti);
1039 if (!IsTagRecord(resolved_tag_record))
1040 return nullptr;
1041 tag_record = CVTagRecord::create(resolved_tag_record).asTag();
1042 } else {
1043 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), eti.takeError(),
1044 "failed to find full decl for forward ref: {0}");
1045 }
1046 }
1047
1048 ConstString mangled_name(
1049 pdb->FindMangledFunctionName(func_id).value_or(llvm::StringRef()));
1050
1051 if (!tag_record.FieldList.isSimple()) {
1052 CVType field_list_cvt = index.tpi().getType(tag_record.FieldList);
1053 FieldListRecord field_list;
1054 if (llvm::Error error = TypeDeserializer::deserializeAs<FieldListRecord>(
1055 field_list_cvt, field_list))
1056 llvm::consumeError(std::move(error));
1057 CreateMethodDecl process(index, m_clang, func_ti, function_decl,
1058 parent_opaque_ty, func_name, mangled_name,
1059 func_ct);
1060 if (llvm::Error err = visitMemberRecordStream(field_list.Data, process))
1061 llvm::consumeError(std::move(err));
1062 }
1063
1064 if (!function_decl) {
1065 function_decl = m_clang.AddMethodToCXXRecordType(
1066 parent_opaque_ty, func_name, mangled_name, func_ct,
1067 /*is_virtual=*/false, /*is_static=*/false,
1068 /*is_inline=*/false, /*is_explicit=*/false,
1069 /*is_attr_used=*/false, /*is_artificial=*/false);
1070 }
1071 m_cxx_record_map[parent_opaque_ty].insert({func_name, func_ct});
1072 } else {
1073 function_decl = m_clang.CreateFunctionDeclaration(
1074 parent, OptionalClangModuleID(), func_name, func_ct, func_storage,
1075 is_inline, /*asm_label=*/{});
1076 CreateFunctionParameters(func_id, *function_decl, param_count);
1077 }
1078 return function_decl;
1079}
1080
1082 PdbCompilandSymId inlinesite_id) {
1084 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1085 PdbIndex &index = pdb->GetIndex();
1086 CompilandIndexItem *cii = index.compilands().GetCompiland(inlinesite_id.modi);
1087 CVSymbol sym = cii->m_debug_stream.readSymbolAtOffset(inlinesite_id.offset);
1088 InlineSiteSym inline_site(static_cast<SymbolRecordKind>(sym.kind()));
1089 llvm::Error err =
1090 SymbolDeserializer::deserializeAs<InlineSiteSym>(sym, inline_site);
1091 if (err) {
1092 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1093 "Failed to deserialize {1} as InlineSite: {0}",
1094 inlinesite_id);
1095 return nullptr;
1096 }
1097
1098 // Inlinee is the id index to the function id record that is inlined.
1099 PdbTypeSymId func_id(inline_site.Inlinee, true);
1100 // Look up the function decl by the id index to see if we have created a
1101 // function decl for a different inlinesite that refers the same function.
1102 if (clang::Decl *decl = TryGetDecl(func_id))
1103 return llvm::dyn_cast<clang::FunctionDecl>(decl);
1104 clang::FunctionDecl *function_decl =
1105 CreateFunctionDeclFromId(func_id, inlinesite_id);
1106 if (function_decl == nullptr)
1107 return nullptr;
1108
1109 // Use inline site id in m_decl_to_status because it's expected to be a
1110 // PdbCompilandSymId so that we can parse local variables info after it.
1111 uint64_t inlinesite_uid = toOpaqueUid(inlinesite_id);
1112 DeclStatus status;
1113 status.resolved = true;
1114 status.uid = inlinesite_uid;
1115 m_decl_to_status.insert({function_decl, status});
1116 // Use the index in IPI stream as uid in m_uid_to_decl, because index in IPI
1117 // stream are unique and there could be multiple inline sites (different ids)
1118 // referring the same inline function. This avoid creating multiple same
1119 // inline function delcs.
1120 uint64_t func_uid = toOpaqueUid(func_id);
1121 lldbassert(m_uid_to_decl.count(func_uid) == 0);
1122 m_uid_to_decl[func_uid] = function_decl;
1123 return function_decl;
1124}
1125
1126clang::FunctionDecl *
1128 PdbCompilandSymId func_sid) {
1129 lldbassert(func_tid.is_ipi);
1131 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1132 PdbIndex &index = pdb->GetIndex();
1133 std::optional<CVType> func_cvt =
1134 index.ipi().typeCollection().tryGetType(func_tid.index);
1135 if (!func_cvt)
1136 return nullptr;
1137 llvm::StringRef func_name;
1138 TypeIndex func_ti;
1139 clang::DeclContext *parent = nullptr;
1140 switch (func_cvt->kind()) {
1141 case LF_MFUNC_ID: {
1142 MemberFuncIdRecord mfr;
1143 llvm::Error err =
1144 TypeDeserializer::deserializeAs<MemberFuncIdRecord>(*func_cvt, mfr);
1145 if (err) {
1146 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1147 "Failed to deserialize {1} (IPI) as MemberFuncId: {0}",
1148 func_tid.index);
1149 return nullptr;
1150 }
1151 func_name = mfr.getName();
1152 func_ti = mfr.getFunctionType();
1153 PdbTypeSymId class_type_id(mfr.ClassType, false);
1154 parent = GetOrCreateClangDeclContextForUid(class_type_id);
1155 break;
1156 }
1157 case LF_FUNC_ID: {
1158 FuncIdRecord fir;
1159 llvm::Error err =
1160 TypeDeserializer::deserializeAs<FuncIdRecord>(*func_cvt, fir);
1161 if (err) {
1162 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1163 "Failed to deserialize {1} (IPI) as FuncId: {0}",
1164 func_tid.index);
1165 return nullptr;
1166 }
1167 func_name = fir.getName();
1168 func_ti = fir.getFunctionType();
1170 if (!fir.ParentScope.isNoneType()) {
1171 CVType parent_cvt = index.ipi().getType(fir.ParentScope);
1172 if (parent_cvt.kind() == LF_STRING_ID) {
1173 StringIdRecord sir;
1174 err = TypeDeserializer::deserializeAs<StringIdRecord>(parent_cvt, sir);
1175 if (err) {
1176 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1177 "Failed to deserialize {1} (IPI) as StringId: {0}",
1178 fir.ParentScope);
1179 return nullptr;
1180 }
1181 parent = GetOrCreateNamespaceDecl(sir.String.data(), *parent);
1182 }
1183 }
1184 break;
1185 }
1186 default:
1187 lldbassert(false && "Invalid function id type!");
1188 }
1189 clang::QualType func_qt = GetOrCreateClangType(func_ti);
1190 if (func_qt.isNull() || !parent)
1191 return nullptr;
1192 CompilerType func_ct = ToCompilerType(func_qt);
1193 uint32_t param_count =
1194 llvm::cast<clang::FunctionProtoType>(func_qt)->getNumParams();
1195 return CreateFunctionDecl(func_sid, func_name, func_ti, func_ct, param_count,
1196 clang::SC_None, true, parent);
1197}
1198
1199clang::FunctionDecl *
1201 if (clang::Decl *decl = TryGetDecl(func_id))
1202 return llvm::dyn_cast<clang::FunctionDecl>(decl);
1203
1204 clang::DeclContext *parent = GetParentClangDeclContext(PdbSymUid(func_id));
1205 if (!parent)
1206 return nullptr;
1207 std::string context_name;
1208 if (clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(parent)) {
1209 context_name = ns->getQualifiedNameAsString();
1210 } else if (clang::TagDecl *tag = llvm::dyn_cast<clang::TagDecl>(parent)) {
1211 context_name = tag->getQualifiedNameAsString();
1212 }
1213
1215 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1216 PdbIndex &index = pdb->GetIndex();
1217 CVSymbol cvs = index.ReadSymbolRecord(func_id);
1218 ProcSym proc(static_cast<SymbolRecordKind>(cvs.kind()));
1219 llvm::Error err = SymbolDeserializer::deserializeAs<ProcSym>(cvs, proc);
1220 if (err) {
1221 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1222 "Failed to deserialize {1} as Proc: {0}", func_id);
1223 return nullptr;
1224 }
1225
1226 PdbTypeSymId type_id(proc.FunctionType);
1227 clang::QualType qt = GetOrCreateClangType(type_id);
1228 if (qt.isNull())
1229 return nullptr;
1230
1231 clang::StorageClass storage = clang::SC_None;
1232 if (proc.Kind == SymbolRecordKind::ProcSym)
1233 storage = clang::SC_Static;
1234
1235 const clang::FunctionProtoType *func_type =
1236 llvm::dyn_cast<clang::FunctionProtoType>(qt);
1237 if (!func_type)
1238 return nullptr;
1239
1240 CompilerType func_ct = ToCompilerType(qt);
1241
1242 llvm::StringRef proc_name = proc.Name;
1243 if (!context_name.empty() && !(proc_name.consume_front(context_name) &&
1244 proc_name.consume_front("::"))) {
1245 // If we have some context, but the function name doesn't start with it, use
1246 // the basename.
1247 MSVCUndecoratedNameParser parser(proc.Name);
1248 llvm::ArrayRef<MSVCUndecoratedNameSpecifier> specs(parser.GetSpecifiers());
1249 if (!specs.empty())
1250 proc_name = specs.back().GetBaseName();
1251 }
1252 clang::FunctionDecl *function_decl =
1253 CreateFunctionDecl(func_id, proc_name, proc.FunctionType, func_ct,
1254 func_type->getNumParams(), storage, false, parent);
1255 if (function_decl == nullptr)
1256 return nullptr;
1257
1258 lldbassert(m_uid_to_decl.count(toOpaqueUid(func_id)) == 0);
1259 m_uid_to_decl[toOpaqueUid(func_id)] = function_decl;
1260 DeclStatus status;
1261 status.resolved = true;
1262 status.uid = toOpaqueUid(func_id);
1263 m_decl_to_status.insert({function_decl, status});
1264
1265 return function_decl;
1266}
1267
1271
1276
1280
1282 PdbCompilandSymId var_id) {
1283 GetOrCreateVariableDecl(scope_id, var_id);
1284}
1285
1289
1291 PdbCompilandSymId func_id, clang::FunctionDecl &function_decl,
1292 uint32_t param_count) {
1294 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1295 PdbIndex &index = pdb->GetIndex();
1296 CompilandIndexItem *cii = index.compilands().GetCompiland(func_id.modi);
1297 CVSymbolArray scope =
1298 cii->m_debug_stream.getSymbolArrayForScope(func_id.offset);
1299
1300 scope.drop_front();
1301 auto begin = scope.begin();
1302 auto end = scope.end();
1303 std::vector<clang::ParmVarDecl *> params;
1304 for (uint32_t i = 0; i < param_count && begin != end;) {
1305 uint32_t record_offset = begin.offset();
1306 PdbCompilandSymId sym_id(func_id.modi, record_offset);
1307 CVSymbol sym = *begin++;
1308
1309 TypeIndex param_type;
1310 llvm::StringRef param_name;
1311 switch (sym.kind()) {
1312 case S_REGREL32: {
1313 RegRelativeSym reg(SymbolRecordKind::RegRelativeSym);
1314 llvm::Error err =
1315 SymbolDeserializer::deserializeAs<RegRelativeSym>(sym, reg);
1316 if (err) {
1317 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1318 "Failed to deserialize {1} as RegRelative: {0}", sym_id);
1319 return;
1320 }
1321 param_type = reg.Type;
1322 param_name = reg.Name;
1323 break;
1324 }
1325 case S_REGREL32_INDIR: {
1326 RegRelativeIndirSym reg(SymbolRecordKind::RegRelativeIndirSym);
1327 llvm::Error err =
1328 SymbolDeserializer::deserializeAs<RegRelativeIndirSym>(sym, reg);
1329 if (err) {
1330 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1331 "Failed to deserialize {1} as RegRelativeIndir: {0}",
1332 sym_id);
1333 return;
1334 }
1335 param_type = reg.Type;
1336 param_name = reg.Name;
1337 break;
1338 }
1339 case S_REGISTER: {
1340 RegisterSym reg(SymbolRecordKind::RegisterSym);
1341 llvm::Error err =
1342 SymbolDeserializer::deserializeAs<RegisterSym>(sym, reg);
1343 if (err) {
1344 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1345 "Failed to deserialize {1} as Register: {0}", sym_id);
1346 return;
1347 }
1348 param_type = reg.Index;
1349 param_name = reg.Name;
1350 break;
1351 }
1352 case S_LOCAL: {
1353 LocalSym local(SymbolRecordKind::LocalSym);
1354 llvm::Error err = SymbolDeserializer::deserializeAs<LocalSym>(sym, local);
1355 if (err) {
1356 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1357 "Failed to deserialize {1} as Local: {0}", sym_id);
1358 return;
1359 }
1360 if ((local.Flags & LocalSymFlags::IsParameter) == LocalSymFlags::None)
1361 continue;
1362 param_type = local.Type;
1363 param_name = local.Name;
1364 break;
1365 }
1366 case S_BLOCK32:
1367 case S_INLINESITE:
1368 case S_INLINESITE2:
1369 // All parameters should come before the first block/inlinesite. If that
1370 // isn't the case, then perhaps this is bad debug info that doesn't
1371 // contain information about all parameters.
1372 return;
1373 default:
1374 continue;
1375 }
1376
1377 PdbCompilandSymId param_uid(func_id.modi, record_offset);
1378 clang::QualType qt = GetOrCreateClangType(param_type);
1379 if (qt.isNull())
1380 return;
1381
1382 CompilerType param_type_ct = m_clang.GetType(qt);
1383 clang::ParmVarDecl *param = m_clang.CreateParameterDeclaration(
1384 &function_decl, OptionalClangModuleID(), param_name.str().c_str(),
1385 param_type_ct, clang::SC_None, true);
1386 lldbassert(m_uid_to_decl.count(toOpaqueUid(param_uid)) == 0);
1387
1388 m_uid_to_decl[toOpaqueUid(param_uid)] = param;
1389 params.push_back(param);
1390 ++i;
1391 }
1392
1393 if (!params.empty() && params.size() == param_count)
1394 function_decl.setParams(params);
1395}
1396
1398 const EnumRecord &er) {
1399 clang::DeclContext *decl_context = nullptr;
1400 std::string uname;
1401 std::tie(decl_context, uname) = CreateDeclInfoForType(er, id.index);
1402 if (!decl_context)
1403 return {};
1404
1405 clang::QualType underlying_type = GetOrCreateClangType(er.UnderlyingType);
1406 if (underlying_type.isNull())
1407 return {};
1408
1409 Declaration declaration;
1410 CompilerType enum_ct = m_clang.CreateEnumerationType(
1411 uname, decl_context, OptionalClangModuleID(), declaration,
1412 ToCompilerType(underlying_type), er.isScoped());
1413
1416
1417 return clang::QualType::getFromOpaquePtr(enum_ct.GetOpaqueQualType());
1418}
1419
1420clang::QualType PdbAstBuilderClang::CreateArrayType(const ArrayRecord &ar) {
1421 clang::QualType element_type = GetOrCreateClangType(ar.ElementType);
1423
1425 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1426 PdbIndex &index = pdb->GetIndex();
1427 uint64_t element_size = GetSizeOfType({ar.ElementType}, index.tpi());
1428 if (element_type.isNull() || element_size == 0)
1429 return {};
1430 uint64_t element_count = ar.Size / element_size;
1431
1432 CompilerType array_ct = m_clang.CreateArrayType(ToCompilerType(element_type),
1433 element_count, false);
1434 return clang::QualType::getFromOpaquePtr(array_ct.GetOpaqueQualType());
1435}
1436
1438 TypeIndex args_type_idx, TypeIndex return_type_idx,
1439 llvm::codeview::CallingConvention calling_convention,
1440 unsigned int type_quals) {
1442 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1443 PdbIndex &index = pdb->GetIndex();
1444 TpiStream &stream = index.tpi();
1445 CVType args_cvt = stream.getType(args_type_idx);
1446 ArgListRecord args;
1447 llvm::Error err =
1448 TypeDeserializer::deserializeAs<ArgListRecord>(args_cvt, args);
1449 if (err) {
1450 LLDB_LOG_ERROR(GetLog(LLDBLog::Symbols), std::move(err),
1451 "Failed to deserialize {1} as ArgList: {0}", args_type_idx);
1452 return {};
1453 }
1454
1455 llvm::ArrayRef<TypeIndex> arg_indices = llvm::ArrayRef(args.ArgIndices);
1456 bool is_variadic = IsCVarArgsFunction(arg_indices);
1457 if (is_variadic)
1458 arg_indices = arg_indices.drop_back();
1459
1460 std::vector<CompilerType> arg_types;
1461 arg_types.reserve(arg_indices.size());
1462
1463 for (TypeIndex arg_index : arg_indices) {
1464 clang::QualType arg_type = GetOrCreateClangType(arg_index);
1465 if (arg_type.isNull())
1466 continue;
1467 arg_types.push_back(ToCompilerType(arg_type));
1468 }
1469
1470 clang::QualType return_type = GetOrCreateClangType(return_type_idx);
1471 if (return_type.isNull())
1472 return {};
1473
1474 std::optional<clang::CallingConv> cc =
1475 TranslateCallingConvention(calling_convention);
1476 if (!cc)
1477 return {};
1478
1479 CompilerType return_ct = ToCompilerType(return_type);
1480 CompilerType func_sig_ast_type = m_clang.CreateFunctionType(
1481 return_ct, arg_types, is_variadic, type_quals, *cc);
1482
1483 return clang::QualType::getFromOpaquePtr(
1484 func_sig_ast_type.GetOpaqueQualType());
1485}
1486
1487static bool isTagDecl(clang::DeclContext &context) {
1488 return llvm::isa<clang::TagDecl>(&context);
1489}
1490
1491static bool isFunctionDecl(clang::DeclContext &context) {
1492 return llvm::isa<clang::FunctionDecl>(&context);
1493}
1494
1495static bool isBlockDecl(clang::DeclContext &context) {
1496 return llvm::isa<clang::BlockDecl>(&context);
1497}
1498
1499void PdbAstBuilderClang::ParseNamespace(clang::DeclContext &context) {
1500 clang::NamespaceDecl *ns = llvm::dyn_cast<clang::NamespaceDecl>(&context);
1501 if (m_parsed_namespaces.contains(ns))
1502 return;
1503 std::string qname = ns->getQualifiedNameAsString();
1505 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1506 PdbIndex &index = pdb->GetIndex();
1507 TypeIndex ti{index.tpi().TypeIndexBegin()};
1508 for (const CVType &cvt : index.tpi().typeArray()) {
1509 PdbTypeSymId tid{ti};
1510 ++ti;
1511
1512 if (!IsTagRecord(cvt))
1513 continue;
1514
1516
1517 // Call CreateDeclInfoForType unconditionally so that the namespace info
1518 // gets created. But only call CreateRecordType if the namespace name
1519 // matches.
1520 clang::DeclContext *context = nullptr;
1521 std::string uname;
1522 std::tie(context, uname) = CreateDeclInfoForType(tag.asTag(), tid.index);
1523 if (!context || !context->isNamespace())
1524 continue;
1525
1526 clang::NamespaceDecl *ns = llvm::cast<clang::NamespaceDecl>(context);
1527 llvm::StringRef ns_name = ns->getName();
1528 if (ns_name.starts_with(qname)) {
1529 ns_name = ns_name.drop_front(qname.size());
1530 if (ns_name.starts_with("::"))
1532 }
1533 }
1535 m_parsed_namespaces.insert(ns);
1536}
1537
1539 llvm::call_once(m_parse_all_types, [this]() {
1541 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1542 PdbIndex &index = pdb->GetIndex();
1543 TypeIndex ti{index.tpi().TypeIndexBegin()};
1544 for (const CVType &cvt : index.tpi().typeArray()) {
1545 PdbTypeSymId tid{ti};
1546 ++ti;
1547
1548 if (!IsTagRecord(cvt))
1549 continue;
1550
1552 }
1553 });
1554}
1555
1557 llvm::call_once(m_parse_functions_and_non_local_vars, [this]() {
1559 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1560 PdbIndex &index = pdb->GetIndex();
1561 uint32_t module_count = index.dbi().modules().getModuleCount();
1562 for (uint16_t modi = 0; modi < module_count; ++modi) {
1564 const CVSymbolArray &symbols = cii.m_debug_stream.getSymbolArray();
1565 auto iter = symbols.begin();
1566 while (iter != symbols.end()) {
1567 PdbCompilandSymId sym_id{modi, iter.offset()};
1568
1569 switch (iter->kind()) {
1570 case S_GPROC32:
1571 case S_LPROC32:
1573 iter = symbols.at(getScopeEndOffset(*iter));
1574 break;
1575 case S_GDATA32:
1576 case S_GTHREAD32:
1577 case S_LDATA32:
1578 case S_LTHREAD32:
1580 ++iter;
1581 break;
1582 default:
1583 ++iter;
1584 continue;
1585 }
1586 }
1587 }
1588 });
1589}
1590
1591static CVSymbolArray skipFunctionParameters(clang::Decl &decl,
1592 const CVSymbolArray &symbols) {
1593 clang::FunctionDecl *func_decl = llvm::dyn_cast<clang::FunctionDecl>(&decl);
1594 if (!func_decl)
1595 return symbols;
1596 unsigned int params = func_decl->getNumParams();
1597 if (params == 0)
1598 return symbols;
1599
1600 CVSymbolArray result = symbols;
1601
1602 while (!result.empty()) {
1603 if (params == 0)
1604 return result;
1605
1606 CVSymbol sym = *result.begin();
1607 result.drop_front();
1608
1609 if (!isLocalVariableType(sym.kind()))
1610 continue;
1611
1612 --params;
1613 }
1614 return result;
1615}
1616
1619 m_clang.GetSymbolFile()->GetBackingSymbolFile());
1620 PdbIndex &index = pdb->GetIndex();
1621 CVSymbol sym = index.ReadSymbolRecord(block_id);
1622 lldbassert(sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32 ||
1623 sym.kind() == S_BLOCK32 || sym.kind() == S_INLINESITE);
1624 CompilandIndexItem &cii =
1625 index.compilands().GetOrCreateCompiland(block_id.modi);
1626 CVSymbolArray symbols =
1627 cii.m_debug_stream.getSymbolArrayForScope(block_id.offset);
1628
1629 // Function parameters should already have been created when the function was
1630 // parsed.
1631 if (sym.kind() == S_GPROC32 || sym.kind() == S_LPROC32)
1632 symbols =
1633 skipFunctionParameters(*m_uid_to_decl[toOpaqueUid(block_id)], symbols);
1634
1635 symbols.drop_front();
1636 auto begin = symbols.begin();
1637 while (begin != symbols.end()) {
1638 PdbCompilandSymId child_sym_id(block_id.modi, begin.offset());
1639 GetOrCreateSymbolForId(child_sym_id);
1640 if (begin->kind() == S_BLOCK32 || begin->kind() == S_INLINESITE) {
1641 ParseBlockChildren(child_sym_id);
1642 begin = symbols.at(getScopeEndOffset(*begin));
1643 }
1644 ++begin;
1645 }
1646}
1647
1649 clang::DeclContext &context) {
1650
1651 clang::Decl *decl = clang::Decl::castFromDeclContext(&context);
1652 lldbassert(decl);
1653
1654 auto iter = m_decl_to_status.find(decl);
1655 lldbassert(iter != m_decl_to_status.end());
1656
1657 if (auto *tag = llvm::dyn_cast<clang::TagDecl>(&context)) {
1658 CompleteTagDecl(*tag);
1659 return;
1660 }
1661
1662 if (isFunctionDecl(context) || isBlockDecl(context)) {
1663 PdbCompilandSymId block_id = PdbSymUid(iter->second.uid).asCompilandSym();
1664 ParseBlockChildren(block_id);
1665 }
1666}
1667
1669 clang::DeclContext *dc = FromCompilerDeclContext(context);
1670 if (!dc)
1671 return;
1672
1673 // Namespaces aren't explicitly represented in the debug info, and the only
1674 // way to parse them is to parse all type info, demangling every single type
1675 // and trying to reconstruct the DeclContext hierarchy this way. Since this
1676 // is an expensive operation, we have to special case it so that we do other
1677 // work (such as parsing the items that appear within the namespaces) at the
1678 // same time.
1679 if (dc->isTranslationUnit()) {
1680 ParseAllTypes();
1682 return;
1683 }
1684
1685 if (dc->isNamespace()) {
1686 ParseNamespace(*dc);
1687 return;
1688 }
1689
1690 if (isTagDecl(*dc) || isFunctionDecl(*dc) || isBlockDecl(*dc)) {
1692 return;
1693 }
1694}
1695
1697 return m_clang.GetCompilerDecl(decl);
1698}
1699
1701 return m_clang.GetType(qt);
1702}
1703
1707
1709PdbAstBuilderClang::ToCompilerDeclContext(clang::DeclContext *context) {
1710 return m_clang.CreateDeclContext(context);
1711}
1712
1714 if (decl.GetTypeSystem() != nullptr)
1715 return ClangUtil::GetDecl(decl);
1716 return nullptr;
1717}
1718
1719clang::DeclContext *
1721 return static_cast<clang::DeclContext *>(context.GetOpaqueDeclContext());
1722}
1723
1724void PdbAstBuilderClang::Dump(Stream &stream, llvm::StringRef filter,
1725 bool show_color) {
1726 m_clang.Dump(stream.AsRawOstream(), filter, show_color);
1727}
1728
1731 llvm::StringRef name) {
1732 clang::DeclContext *parent = FromCompilerDeclContext(parent_ctx);
1733 NamespaceSet *set;
1734
1735 if (parent) {
1736 auto it = m_parent_to_namespaces.find(parent);
1737 if (it == m_parent_to_namespaces.end())
1738 return {};
1739
1740 set = &it->second;
1741 } else {
1742 // In this case, search through all known namespaces
1743 set = &m_known_namespaces;
1744 }
1745 assert(set);
1746
1747 for (clang::NamespaceDecl *namespace_decl : *set)
1748 if (namespace_decl->getName() == name)
1749 return ToCompilerDeclContext(namespace_decl);
1750
1751 for (clang::NamespaceDecl *namespace_decl : *set)
1752 if (namespace_decl->isAnonymousNamespace())
1753 return FindNamespaceDecl(ToCompilerDeclContext(namespace_decl), name);
1754
1755 return {};
1756}
static llvm::raw_ostream & error(Stream &strm)
#define lldbassert(x)
Definition LLDBAssert.h:16
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:394
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)
void SetUserID(lldb::user_id_t user_id)
void SetIsDynamicCXXType(std::optional< bool > b)
Represents a generic declaration context in a program.
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.
Definition ConstString.h:40
A class that describes the declaration location of a lldb object.
Definition Declaration.h:24
A stream class that can stream formatted output to a file.
Definition Stream.h:28
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition Stream.h:405
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 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)
clang::QualType CreateFunctionType(TypeIndex args_type_idx, TypeIndex return_type_idx, llvm::codeview::CallingConvention calling_convention, unsigned int type_quals)
clang::DeclContext * GetOrCreateDeclContextForCompilandSymbol(PdbCompilandSymId uid)
clang::QualType CreateModifierType(const llvm::codeview::ModifierRecord &modifier)
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)
void EnsureVariable(PdbCompilandSymId scope_id, PdbCompilandSymId var_id) override
clang::VarDecl * CreateVariableDecl(PdbSymUid uid, llvm::codeview::CVSymbol sym, clang::DeclContext &scope)
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
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
clang::QualType CreateRecordType(PdbTypeSymId id, const llvm::codeview::TagRecord &record)
CompilerDeclContext GetParentDeclContext(PdbSymUid uid) override
clang::DeclContext * FromCompilerDeclContext(CompilerDeclContext context)
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)
clang::DeclContext * GetOrCreateClangDeclContextForUid(PdbSymUid uid)
PdbIndex - Lazy access to the important parts of a PDB file.
Definition PdbIndex.h:47
llvm::pdb::TpiStream & ipi()
Definition PdbIndex.h:127
CompileUnitIndex & compilands()
Definition PdbIndex.h:142
llvm::pdb::DbiStream & dbi()
Definition PdbIndex.h:121
llvm::codeview::CVSymbol ReadSymbolRecord(PdbCompilandSymId cu_sym) const
Definition PdbIndex.cpp:187
llvm::pdb::TpiStream & tpi()
Definition PdbIndex.h:124
PdbGlobalSymId asGlobalSym() const
PdbCompilandSymId asCompilandSym() const
PdbTypeSymId asTypeSym() const
PdbSymUidKind kind() const
std::optional< PdbTypeSymId > GetFunctionType(llvm::codeview::CVSymbol symbol)
Definition PdbUtil.cpp:1199
llvm::StringRef DropNameScope(llvm::StringRef name)
Definition PdbUtil.cpp:600
uint64_t toOpaqueUid(const T &cid)
Definition PdbSymUid.h:111
lldb::BasicType GetCompilerTypeForSimpleKind(llvm::codeview::SimpleTypeKind kind)
VariableInfo GetVariableNameInfo(llvm::codeview::CVSymbol symbol)
bool IsTagRecord(llvm::codeview::CVType cvt)
Definition PdbUtil.cpp:518
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)
Definition PdbUtil.cpp:1145
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.
Definition Log.h:327
void * opaque_compiler_type_t
Definition lldb-types.h:90
BasicType
Basic types enumeration for the public API SBType::GetBasicType().
@ eLanguageTypeC_plus_plus
ISO C++:1998.
uint64_t user_id_t
Definition lldb-types.h:82
static clang::QualType GetQualType(const CompilerType &ct)
Definition ClangUtil.cpp:36
static clang::Decl * GetDecl(const CompilerDecl &decl)
Returns the clang::Decl of the given CompilerDecl.
Definition ClangUtil.cpp:31
const llvm::codeview::UnionRecord & asUnion() const
Definition PdbUtil.h:62
static CVTagRecord create(llvm::codeview::CVType type)
Definition PdbUtil.cpp:198
const llvm::codeview::ClassRecord & asClass() const
Definition PdbUtil.h:52
const llvm::codeview::EnumRecord & asEnum() const
Definition PdbUtil.h:57
const llvm::codeview::TagRecord & asTag() const
Definition PdbUtil.h:44
Represents a single compile unit.
llvm::pdb::ModuleDebugStreamRef m_debug_stream
llvm::codeview::TypeIndex index
Definition PdbSymUid.h:73
llvm::codeview::TypeIndex type
Definition PdbUtil.h:114