40#include "clang/AST/CXXInheritance.h"
41#include "clang/AST/DeclBase.h"
42#include "clang/AST/DeclCXX.h"
43#include "clang/AST/DeclObjC.h"
44#include "clang/AST/DeclTemplate.h"
45#include "clang/AST/Type.h"
46#include "llvm/ADT/StringExtras.h"
47#include "llvm/Demangle/Demangle.h"
56#ifdef ENABLE_DEBUG_PRINTF
58#define DEBUG_PRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
60#define DEBUG_PRINTF(fmt, ...)
70 m_die_to_decl_ctx(), m_decl_ctx_to_die() {}
76 case clang::Decl::CXXRecord:
77 case clang::Decl::ClassTemplateSpecialization:
98 while (Parent.IsValid()) {
99 if (Parent.Tag() == DW_TAG_module)
112 parent = parent.GetParent()) {
114 if (tag == DW_TAG_module)
115 top_module_die = parent;
116 else if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
120 return top_module_die;
129 if (clang_module_die) {
130 const char *module_name = clang_module_die.
GetName();
142 return FieldName.starts_with(
"_vptr$")
144 || FieldName.starts_with(
"_vptr.");
150 case DW_TAG_class_type:
151 case DW_TAG_structure_type:
152 case DW_TAG_union_type:
163 if (!clang_module_sp)
169 std::vector<lldb_private::CompilerContext> die_context = die.
GetDeclContext();
170 TypeQuery query(die_context, TypeQueryOptions::e_module_search |
171 TypeQueryOptions::e_find_one);
176 clang_module_sp->FindTypes(query, results);
188 sym_file.ForEachExternalModule(
190 module.FindTypes(query, results);
191 pcm_type_sp = results.GetTypeMap().FirstType();
192 return (bool)pcm_type_sp;
222 auto type_sp =
dwarf->MakeType(
223 die.
GetID(), pcm_type_sp->GetName(), pcm_type_sp->GetByteSize(
nullptr),
225 &pcm_type_sp->GetDeclaration(), type, Type::ResolveState::Forward,
245 clang::DeclContext *decl_ctx,
247 const char *type_name_cstr) {
248 auto *tag_decl_ctx = clang::dyn_cast<clang::TagDecl>(decl_ctx);
253 if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx->isBeingDefined())
261 if (type && ast_importer.
CanImport(type)) {
266 "Unable to complete the Decl context for DIE {0} at offset "
267 "{1:x16}.\nPlease file a bug report.",
268 type_name_cstr ? type_name_cstr :
"", die.
GetOffset());
273 tag_decl_ctx->startDefinition();
278 for (
size_t i = 0; i < attributes.
Size(); ++i) {
286 case DW_AT_abstract_origin:
290 case DW_AT_accessibility:
295 case DW_AT_artificial:
299 case DW_AT_bit_stride:
303 case DW_AT_byte_size:
307 case DW_AT_alignment:
311 case DW_AT_byte_stride:
315 case DW_AT_calling_convention:
319 case DW_AT_containing_type:
323 case DW_AT_decl_file:
328 case DW_AT_decl_line:
331 case DW_AT_decl_column:
335 case DW_AT_declaration:
343 case DW_AT_enum_class:
360 case DW_AT_linkage_name:
361 case DW_AT_MIPS_linkage_name:
369 case DW_AT_object_pointer:
373 case DW_AT_signature:
377 case DW_AT_specification:
385 case DW_AT_virtuality:
389 case DW_AT_APPLE_objc_complete_type:
393 case DW_AT_APPLE_objc_direct:
397 case DW_AT_APPLE_runtime_class:
401 case DW_AT_GNU_vector:
404 case DW_AT_export_symbols:
407 case DW_AT_rvalue_reference:
410 case DW_AT_reference:
419 return unit->GetAbsolutePath().GetPath();
420 return "<missing DWARF unit path>";
425 bool *type_is_new_ptr) {
427 *type_is_new_ptr =
false;
432 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
437 clang::DeclContext *context =
440 dwarf->GetObjectFile()->GetModule()->LogMessage(
442 "DWARFASTParserClang::ParseTypeFromDWARF "
443 "(die = {0:x16}, decl_ctx = {1:p} (die "
444 "{2:x16})) {3} ({4}) name = '{5}')",
450 if (
auto [it, inserted] =
455 return it->getSecond()->shared_from_this();
464 if (clang::DeclContext *decl_ctx =
470 *type_is_new_ptr =
true;
476 case DW_TAG_base_type:
477 case DW_TAG_pointer_type:
478 case DW_TAG_reference_type:
479 case DW_TAG_rvalue_reference_type:
480 case DW_TAG_const_type:
481 case DW_TAG_restrict_type:
482 case DW_TAG_volatile_type:
483 case DW_TAG_LLVM_ptrauth_type:
484 case DW_TAG_atomic_type:
485 case DW_TAG_unspecified_type:
488 case DW_TAG_structure_type:
489 case DW_TAG_union_type:
490 case DW_TAG_class_type:
493 case DW_TAG_enumeration_type:
496 case DW_TAG_inlined_subroutine:
497 case DW_TAG_subprogram:
498 case DW_TAG_subroutine_type:
501 case DW_TAG_array_type:
504 case DW_TAG_ptr_to_member_type:
508 dwarf->GetObjectFile()->GetModule()->ReportError(
509 "[{0:x16}]: unhandled type tag {1:x4} ({2}), "
510 "please file a bug and "
511 "attach the file at the start of this error message",
518 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
523static std::optional<uint32_t>
526 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
534 Value initialValue(0);
536 uint32_t block_length = form_value.
Unsigned();
537 uint32_t block_offset =
547 "ExtractDataMemberLocation failed: {0}");
551 return memberOffset->ResolveValue(
nullptr).UInt();
555 auto getAttr = [&](llvm::dwarf::Attribute Attr,
unsigned defaultValue = 0) {
558 const unsigned key = getAttr(DW_AT_LLVM_ptrauth_key);
559 const bool addr_disc = getAttr(DW_AT_LLVM_ptrauth_address_discriminated);
560 const unsigned extra = getAttr(DW_AT_LLVM_ptrauth_extra_discriminator);
561 const bool isapointer = getAttr(DW_AT_LLVM_ptrauth_isa_pointer);
562 const bool authenticates_null_values =
563 getAttr(DW_AT_LLVM_ptrauth_authenticates_null_values);
564 const unsigned authentication_mode_int = getAttr(
565 DW_AT_LLVM_ptrauth_authentication_mode,
566 static_cast<unsigned>(clang::PointerAuthenticationMode::SignAndAuth));
567 clang::PointerAuthenticationMode authentication_mode =
568 clang::PointerAuthenticationMode::SignAndAuth;
569 if (authentication_mode_int >=
570 static_cast<unsigned>(clang::PointerAuthenticationMode::None) &&
571 authentication_mode_int <=
572 static_cast<unsigned>(
573 clang::PointerAuthenticationMode::SignAndAuth)) {
574 authentication_mode =
575 static_cast<clang::PointerAuthenticationMode
>(authentication_mode_int);
578 "[{0:x16}]: invalid pointer authentication mode method {1:x4}",
579 die.
GetOffset(), authentication_mode_int);
581 auto ptr_auth = clang::PointerAuthQualifier::Create(
582 key, addr_disc, extra, authentication_mode, isapointer,
583 authenticates_null_values);
591 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
601 if (tag == DW_TAG_typedef) {
651 encoding_uid.Reference());
657 case DW_TAG_unspecified_type:
658 if (attrs.
name ==
"nullptr_t" || attrs.
name ==
"decltype(nullptr)") {
659 resolve_state = Type::ResolveState::Full;
667 case DW_TAG_base_type:
668 resolve_state = Type::ResolveState::Full;
674 case DW_TAG_pointer_type:
677 case DW_TAG_reference_type:
680 case DW_TAG_rvalue_reference_type:
686 case DW_TAG_const_type:
689 case DW_TAG_restrict_type:
692 case DW_TAG_volatile_type:
695 case DW_TAG_LLVM_ptrauth_type:
699 case DW_TAG_atomic_type:
706 if (tag == DW_TAG_pointer_type) {
714 if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name,
""),
719 if (function_pointer_type) {
723 bool function_type_is_new_pointer;
725 sc, function_type, &function_type_is_new_pointer);
727 if (lldb_function_type_sp) {
729 lldb_function_type_sp->GetForwardCompilerType());
732 resolve_state = Type::ResolveState::Full;
745 if (attrs.
name ==
"id") {
747 dwarf->GetObjectFile()->GetModule()->LogMessage(
749 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
750 "is Objective-C 'id' built-in type.",
756 resolve_state = Type::ResolveState::Full;
757 }
else if (attrs.
name ==
"Class") {
759 dwarf->GetObjectFile()->GetModule()->LogMessage(
761 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
762 "is Objective-C 'Class' built-in type.",
768 resolve_state = Type::ResolveState::Full;
769 }
else if (attrs.
name ==
"SEL") {
771 dwarf->GetObjectFile()->GetModule()->LogMessage(
773 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
774 "is Objective-C 'selector' built-in type.",
780 resolve_state = Type::ResolveState::Full;
789 if (encoding_die && encoding_die.
Tag() == DW_TAG_structure_type) {
790 llvm::StringRef struct_name = encoding_die.
GetName();
791 if (struct_name ==
"objc_object") {
793 dwarf->GetObjectFile()->GetModule()->LogMessage(
795 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
796 "is 'objc_object*', which we overrode to 'id'.",
802 resolve_state = Type::ResolveState::Full;
811 &attrs.
decl, clang_type, resolve_state, payload);
816 if (llvm::StringRef(die.
GetName()).contains(
"<"))
837 unique_typename, decl_declaration);
839 dwarf->GetUniqueDWARFASTTypeMap().Find(
840 unique_typename, decl_die, decl_declaration,
843 unique_ast_entry_type->UpdateToDefDIE(def_die, def_attrs.
decl,
845 }
else if (
Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups)) {
848 "Failed to find {0:x16} {1} ({2}) type \"{3}\" in "
849 "UniqueDWARFASTTypeMap",
857 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
866 def_die =
dwarf->FindDefinitionDIE(decl_die);
870 if (debug_map_symfile) {
878 dwarf->GetObjectFile()->GetModule()->LogMessage(
880 "SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a "
881 "forward declaration, complete DIE is {5}",
884 def_die ? llvm::utohexstr(def_die.
GetID()) :
"not found");
888 if (
auto [it, inserted] =
dwarf->GetDIEToType().try_emplace(
893 return it->getSecond()->shared_from_this();
904 Type *enumerator_type =
910 if (!enumerator_clang_type) {
913 "", DW_ATE_signed, *attrs.
byte_size * 8);
926 &attrs.
decl, clang_type, Type::ResolveState::Forward,
929 clang::DeclContext *type_decl_ctx =
932 if (decl_die != def_die) {
934 dwarf->GetDIEToType()[def_die.
GetDIE()] = type_sp.get();
941 bool is_signed =
false;
944 type_sp->
GetByteSize(
nullptr).value_or(0), def_die);
948 dwarf->GetObjectFile()->GetModule()->ReportError(
949 "DWARF DIE at {0:x16} named \"{1}\" was not able to start its "
950 "definition.\nPlease file a bug and attach the file at the "
951 "start of this error message",
957static clang::CallingConv
960 case llvm::dwarf::DW_CC_normal:
962 case llvm::dwarf::DW_CC_BORLAND_stdcall:
963 return clang::CC_X86StdCall;
964 case llvm::dwarf::DW_CC_BORLAND_msfastcall:
965 return clang::CC_X86FastCall;
966 case llvm::dwarf::DW_CC_LLVM_vectorcall:
967 return clang::CC_X86VectorCall;
968 case llvm::dwarf::DW_CC_BORLAND_pascal:
969 return clang::CC_X86Pascal;
970 case llvm::dwarf::DW_CC_LLVM_Win64:
971 return clang::CC_Win64;
972 case llvm::dwarf::DW_CC_LLVM_X86_64SysV:
973 return clang::CC_X86_64SysV;
974 case llvm::dwarf::DW_CC_LLVM_X86RegCall:
975 return clang::CC_X86RegCall;
980 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
981 LLDB_LOG(log,
"Unsupported DW_AT_calling_convention value: {0}",
994 const auto tag = die.
Tag();
999 TypeSP complete_objc_class_type_sp =
1000 dwarf->FindCompleteObjCDefinitionTypeForDIE(
DWARFDIE(), class_name,
1003 if (!complete_objc_class_type_sp)
1007 complete_objc_class_type_sp->GetForwardCompilerType();
1009 if (!type_clang_forward_type)
1019 if (!objc_method_decl) {
1020 dwarf->GetObjectFile()->GetModule()->ReportError(
1021 "[{0:x16}]: invalid Objective-C method {1:x4} ({2}), "
1022 "please file a bug and attach the file at the start of "
1023 "this error message",
1037 bool is_static,
bool &ignore_containing_context) {
1038 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
1042 Type *class_type =
dwarf->ResolveType(decl_ctx_die);
1046 if (class_type->
GetID() != decl_ctx_die.
GetID() ||
1053 std::vector<DWARFDIE> failures;
1065 return {
true, type_ptr->shared_from_this()};
1079 clang::DeclContext *spec_clang_decl_ctx =
1081 if (spec_clang_decl_ctx)
1084 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1085 "{0:x8}: DW_AT_specification({1:x16}"
1089 return {
true,
nullptr};
1101 if (abs_clang_decl_ctx)
1104 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1105 "{0:x8}: DW_AT_abstract_origin({1:x16}"
1109 return {
true,
nullptr};
1125 return {
true,
nullptr};
1127 const bool is_attr_used =
false;
1131 const auto accessibility =
1140 if (cxx_method_decl) {
1146 char const *object_pointer_name =
1148 if (object_pointer_name) {
1150 LLDB_LOGF(log,
"Setting object pointer name: %s on method object %p.\n",
1151 object_pointer_name,
static_cast<void *
>(cxx_method_decl));
1155 ignore_containing_context =
true;
1160 const bool type_handled = cxx_method_decl !=
nullptr || attrs.
is_artificial;
1162 return {type_handled,
nullptr};
1168 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
1173 bool is_variadic =
false;
1174 bool is_static =
false;
1175 bool has_template_params =
false;
1177 unsigned type_quals = 0;
1183 Type *func_type =
nullptr;
1193 std::vector<CompilerType> function_param_types;
1194 std::vector<clang::ParmVarDecl *> function_param_decls;
1199 clang::DeclContext *containing_decl_ctx =
1201 const clang::Decl::Kind containing_decl_kind =
1202 containing_decl_ctx->getDeclKind();
1208 if (is_cxx_method) {
1213 bool skip_artificial =
true;
1215 is_variadic, has_template_params,
1216 function_param_types, function_param_decls,
1220 bool ignore_containing_context =
false;
1231 if (is_cxx_method && has_template_params) {
1232 ignore_containing_context =
true;
1233 is_cxx_method =
false;
1236 clang::CallingConv calling_convention =
1243 function_param_types.size(), is_variadic,
1244 type_quals, calling_convention, attrs.
ref_qual);
1247 bool type_handled =
false;
1248 if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
1249 if (std::optional<const ObjCLanguage::MethodName> objc_method =
1254 }
else if (is_cxx_method) {
1255 auto [handled, type_sp] =
1257 ignore_containing_context);
1261 type_handled = handled;
1265 if (!type_handled) {
1266 clang::FunctionDecl *function_decl =
nullptr;
1267 clang::FunctionDecl *template_function_decl =
nullptr;
1272 if (
dwarf->ResolveType(abs_die)) {
1273 function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
1276 if (function_decl) {
1282 if (!function_decl) {
1283 char *name_buf =
nullptr;
1290 llvm::ItaniumPartialDemangler D;
1292 name_buf = D.getFunctionBaseName(
nullptr,
nullptr);
1300 : containing_decl_ctx,
1303 std::free(name_buf);
1305 if (has_template_params) {
1310 : containing_decl_ctx,
1313 clang::FunctionTemplateDecl *func_template_decl =
1316 template_function_decl, template_param_infos);
1318 template_function_decl, func_template_decl, template_param_infos);
1323 if (function_decl) {
1335 function_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(
1340 if (!function_param_decls.empty()) {
1342 if (template_function_decl)
1344 function_param_decls);
1350 char const *object_pointer_name =
1352 if (object_pointer_name) {
1355 "Setting object pointer name: %s on function "
1357 object_pointer_name,
static_cast<void *
>(function_decl));
1364 return dwarf->MakeType(
1378 Type *element_type =
dwarf->ResolveTypeUID(type_die,
true);
1387 byte_stride = array_info->byte_stride;
1388 bit_stride = array_info->bit_stride;
1390 if (byte_stride == 0 && bit_stride == 0)
1391 byte_stride = element_type->
GetByteSize(
nullptr).value_or(0);
1395 uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
1397 if (array_info && array_info->element_orders.size() > 0) {
1398 uint64_t num_elements = 0;
1399 auto end = array_info->element_orders.rend();
1400 for (
auto pos = array_info->element_orders.rbegin(); pos != end; ++pos) {
1401 num_elements = *pos;
1404 array_element_type = clang_type;
1405 array_element_bit_stride = num_elements
1406 ? array_element_bit_stride * num_elements
1407 : array_element_bit_stride;
1415 dwarf->MakeType(die.
GetID(), empty_name, array_element_bit_stride / 8,
1417 &attrs.
decl, clang_type, Type::ResolveState::Full);
1418 type_sp->SetEncodingType(element_type);
1433 if ((class_type ==
nullptr) || (pointee_type ==
nullptr))
1440 class_clang_type, pointee_clang_type);
1442 if (std::optional<uint64_t> clang_type_size =
1444 return dwarf->MakeType(die.
GetID(), attrs.
name, *clang_type_size,
nullptr,
1446 clang_type, Type::ResolveState::Forward);
1455 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
1464 if (attributes.
Size() == 0)
1468 AccessType accessibility = default_accessibility;
1469 bool is_virtual =
false;
1470 bool is_base_of_class =
true;
1471 off_t member_byte_offset = 0;
1473 for (uint32_t i = 0; i < attributes.
Size(); ++i) {
1479 encoding_form = form_value;
1481 case DW_AT_data_member_location:
1482 if (
auto maybe_offset =
1484 member_byte_offset = *maybe_offset;
1487 case DW_AT_accessibility:
1492 case DW_AT_virtuality:
1493 is_virtual = form_value.
Boolean();
1503 if (base_class_type ==
nullptr) {
1504 module_sp->ReportError(
"{0:x16}: DW_TAG_inheritance failed to "
1505 "resolve the base class at {1:x16}"
1506 " from enclosing type {2:x16}. \nPlease file "
1507 "a bug and attach the file at the start of "
1508 "this error message",
1516 assert(base_class_clang_type);
1518 ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
1521 std::unique_ptr<clang::CXXBaseSpecifier> result =
1523 accessibility, is_virtual,
1528 base_classes.push_back(std::move(result));
1546 clang::CharUnits::fromQuantity(member_byte_offset)));
1559 if (sc_parent_tag == DW_TAG_compile_unit ||
1560 sc_parent_tag == DW_TAG_partial_unit) {
1562 }
else if (sc.
function !=
nullptr && sc_parent_die) {
1563 symbol_context_scope =
1565 if (symbol_context_scope ==
nullptr)
1566 symbol_context_scope = sc.
function;
1568 symbol_context_scope = sc.
module_sp.get();
1571 if (symbol_context_scope !=
nullptr)
1572 type_sp->SetSymbolContextScope(symbol_context_scope);
1586 decl_declaration.
Clear();
1587 std::string qualified_name;
1590 while (parent_decl_ctx_die) {
1594 const dw_tag_t parent_tag = parent_decl_ctx_die.
Tag();
1595 switch (parent_tag) {
1596 case DW_TAG_namespace: {
1597 if (
const char *namespace_name = parent_decl_ctx_die.
GetName()) {
1598 qualified_name.insert(0,
"::");
1599 qualified_name.insert(0, namespace_name);
1601 qualified_name.insert(0,
"(anonymous namespace)::");
1607 case DW_TAG_class_type:
1608 case DW_TAG_structure_type:
1609 case DW_TAG_union_type: {
1610 if (
const char *class_union_struct_name = parent_decl_ctx_die.
GetName()) {
1611 qualified_name.insert(
1613 qualified_name.insert(0,
"::");
1614 qualified_name.insert(0, class_union_struct_name);
1621 parent_decl_ctx_die.
Clear();
1626 if (qualified_name.empty())
1627 qualified_name.append(
"::");
1629 qualified_name.append(unique_typename.
GetCString());
1643 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
1647 uint64_t byte_size = attrs.
byte_size.value_or(0);
1667 dwarf->GetUniqueDWARFASTTypeMap().Find(
1668 unique_typename, die, unique_decl, byte_size,
1670 if (
TypeSP type_sp = unique_ast_entry_type->m_type_sp) {
1671 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1678 unique_ast_entry_type->m_is_forward_declaration) {
1679 unique_ast_entry_type->UpdateToDefDIE(die, unique_decl, byte_size);
1680 clang_type = type_sp->GetForwardCompilerType();
1684 dwarf->GetForwardDeclCompilerTypeToDIE().insert_or_assign(
1696 int tag_decl_kind = -1;
1698 if (tag == DW_TAG_structure_type) {
1699 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Struct);
1701 }
else if (tag == DW_TAG_union_type) {
1702 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Union);
1704 }
else if (tag == DW_TAG_class_type) {
1705 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Class);
1719 dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.
name,
true);
1723 if (debug_map_symfile) {
1727 die, attrs.
name,
true);
1733 dwarf->GetObjectFile()->GetModule()->LogMessage(
1735 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an "
1736 "incomplete objc type, complete type is {5:x8}",
1752 assert(tag_decl_kind != -1);
1754 clang::DeclContext *containing_decl_ctx =
1758 containing_decl_ctx, die,
1764 const clang::Decl::Kind containing_decl_kind =
1765 containing_decl_ctx->getDeclKind();
1776 clang::ClassTemplateDecl *class_template_decl =
1780 if (!class_template_decl) {
1782 dwarf->GetObjectFile()->GetModule()->LogMessage(
1784 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" "
1785 "clang::ClassTemplateDecl failed to return a decl.",
1792 clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1795 tag_decl_kind, template_param_infos);
1813 Type::ResolveState::Forward,
1819 clang::DeclContext *type_decl_ctx =
1827 auto unique_ast_entry_up = std::make_unique<UniqueDWARFASTType>();
1831 unique_ast_entry_up->m_type_sp = type_sp;
1832 unique_ast_entry_up->m_die = die;
1833 unique_ast_entry_up->m_declaration = unique_decl;
1834 unique_ast_entry_up->m_byte_size = byte_size;
1836 dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
1837 *unique_ast_entry_up);
1845 dwarf->GetForwardDeclCompilerTypeToDIE()
1850 assert(inserted &&
"Type already in the forward declaration map!");
1859 clang::CXXRecordDecl *record_decl =
1861 if (record_decl && record_decl->getDefinition()) {
1862 record_decl->setHasTrivialSpecialMemberForCall();
1867 clang::CXXRecordDecl *record_decl =
1870 record_decl->setArgPassingRestrictions(
1871 clang::RecordArgPassingKind::CannotPassInRegs);
1881 const CompilerType &class_opaque_type,
const char *property_name,
1885 const char *property_setter_name,
const char *property_getter_name,
1892 if (metadata !=
nullptr) {
1939 bool is_template_template_argument =
false;
1942 case DW_TAG_GNU_template_parameter_pack: {
1944 std::make_unique<TypeSystemClang::TemplateParameterInfos>());
1949 if (
const char *name = die.
GetName()) {
1954 case DW_TAG_GNU_template_template_param:
1955 is_template_template_argument =
true;
1957 case DW_TAG_template_type_parameter:
1958 case DW_TAG_template_value_parameter: {
1960 if (attributes.
Size() == 0)
1963 const char *name =
nullptr;
1964 const char *template_name =
nullptr;
1966 uint64_t uval64 = 0;
1967 bool uval64_valid =
false;
1968 bool is_default_template_arg =
false;
1970 for (
size_t i = 0; i < attributes.
Size(); ++i) {
1979 case DW_AT_GNU_template_name:
1992 case DW_AT_const_value:
1994 uval64_valid =
true;
1998 case DW_AT_default_value:
2000 is_default_template_arg = form_value.
Boolean();
2011 if (!is_template_template_argument) {
2012 bool is_signed =
false;
2016 if (name && !name[0])
2019 if (tag == DW_TAG_template_value_parameter && uval64_valid) {
2020 std::optional<uint64_t> size = clang_type.
GetBitSize(
nullptr);
2023 llvm::APInt apint(*size, uval64, is_signed);
2025 name, clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed),
2027 is_default_template_arg));
2032 is_default_template_arg));
2037 name, clang::TemplateArgument(clang::TemplateName(tplt_type),
2038 is_default_template_arg));
2060 case DW_TAG_template_type_parameter:
2061 case DW_TAG_template_value_parameter:
2062 case DW_TAG_GNU_template_parameter_pack:
2063 case DW_TAG_GNU_template_template_param:
2072 return !template_param_infos.
IsEmpty() ||
2083 std::vector<DWARFDIE> contained_type_dies;
2095 if (tag == DW_TAG_structure_type) {
2097 }
else if (tag == DW_TAG_union_type) {
2099 }
else if (tag == DW_TAG_class_type) {
2103 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
2105 std::vector<DWARFDIE> member_function_dies;
2109 contained_type_dies, delayed_properties,
2110 default_accessibility, layout_info);
2113 for (
const DWARFDIE &die : member_function_dies)
2114 dwarf->ResolveType(die);
2119 dwarf->GetObjCMethods(class_name, [&](
DWARFDIE method_die) {
2125 property.Finalize();
2129 if (!bases.empty()) {
2133 for (
const auto &base_class : bases) {
2134 clang::TypeSourceInfo *type_source_info = base_class->getTypeSourceInfo();
2135 if (type_source_info)
2156 clang::CXXRecordDecl *record_decl =
2165 for (
const DWARFDIE &die : contained_type_dies)
2166 dwarf->ResolveType(die);
2168 return (
bool)clang_type;
2176 bool is_signed =
false;
2183 return (
bool)clang_type;
2191 std::lock_guard<std::recursive_mutex> guard(
2192 dwarf->GetObjectFile()->GetModule()->GetMutex());
2205 case DW_TAG_structure_type:
2206 case DW_TAG_union_type:
2207 case DW_TAG_class_type:
2210 case DW_TAG_enumeration_type:
2214 assert(
false &&
"not a forward clang type decl!");
2231 auto opaque_decl_ctx =
2242 if (clang_decl !=
nullptr)
2257 clang::DeclContext *clang_decl_ctx =
2266 uint32_t enumerator_byte_size,
const DWARFDIE &parent_die) {
2270 size_t enumerators_added = 0;
2274 if (tag != DW_TAG_enumerator)
2278 if (attributes.
Size() == 0)
2281 const char *name =
nullptr;
2282 bool got_value =
false;
2283 int64_t enum_value = 0;
2286 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2291 case DW_AT_const_value:
2294 enum_value = form_value.
Signed();
2296 enum_value = form_value.
Unsigned();
2303 case DW_AT_description:
2305 case DW_AT_decl_file:
2309 case DW_AT_decl_line:
2312 case DW_AT_decl_column:
2321 if (name && name[0] && got_value) {
2323 clang_type, decl, name, enum_value, enumerator_byte_size * 8);
2324 ++enumerators_added;
2327 return enumerators_added;
2332 bool is_static =
false;
2333 bool is_variadic =
false;
2334 bool has_template_params =
false;
2335 unsigned type_quals = 0;
2336 std::vector<CompilerType> param_types;
2337 std::vector<clang::ParmVarDecl *> param_decls;
2343 clang::DeclContext *containing_decl_ctx =
2346 has_template_params, param_types, param_decls,
2349 for (
size_t i = 0; i < param_types.size(); i++) {
2352 sstr << param_types[i].GetTypeName();
2357 if (type_quals & clang::Qualifiers::Const)
2369 const char *name =
nullptr;
2370 const char *mangled =
nullptr;
2371 std::optional<int> decl_file;
2372 std::optional<int> decl_line;
2373 std::optional<int> decl_column;
2374 std::optional<int> call_file;
2375 std::optional<int> call_line;
2376 std::optional<int> call_column;
2381 if (tag != DW_TAG_subprogram)
2385 decl_column, call_file, call_line, call_column,
2390 else if ((die.
GetParent().
Tag() == DW_TAG_compile_unit ||
2396 name && strcmp(name,
"main") != 0) {
2405 std::unique_ptr<Declaration> decl_up;
2406 if (decl_file || decl_line || decl_column)
2407 decl_up = std::make_unique<Declaration>(
2409 decl_line ? *decl_line : 0, decl_column ? *decl_column : 0);
2419 std::make_shared<Function>(&comp_unit,
2421 func_user_id, func_name, func_type,
2424 if (func_sp.get() !=
nullptr) {
2426 func_sp->GetFrameBaseExpression() = frame_base;
2428 return func_sp.get();
2437struct PropertyAttributes {
2438 explicit PropertyAttributes(
const DWARFDIE &die);
2439 const char *prop_name =
nullptr;
2440 const char *prop_getter_name =
nullptr;
2441 const char *prop_setter_name =
nullptr;
2443 uint32_t prop_attributes = 0;
2446struct DiscriminantValue {
2449 uint32_t byte_offset;
2454struct VariantMember {
2456 bool IsDefault()
const;
2458 std::optional<uint32_t> discr_value;
2461 uint32_t byte_offset;
2469 std::vector<VariantMember> &members();
2471 DiscriminantValue &discriminant();
2474 std::vector<VariantMember> _members;
2475 DiscriminantValue _discriminant;
2480ConstString VariantMember::GetName()
const {
return this->variant_name; }
2482bool VariantMember::IsDefault()
const {
return !discr_value; }
2485 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant);
2489 for (
auto child_die : die.
children()) {
2490 switch (child_die.Tag()) {
2491 case llvm::dwarf::DW_TAG_member: {
2493 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2502 type_ref = form_value;
2505 case DW_AT_data_member_location:
2506 if (
auto maybe_offset =
2508 byte_offset = *maybe_offset;
2525DiscriminantValue::DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp) {
2528 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2534 type_ref = form_value;
2536 case DW_AT_data_member_location:
2537 if (
auto maybe_offset =
2539 byte_offset = *maybe_offset;
2550 : _members(), _discriminant(die, module_sp) {
2552 for (
auto child : die.
children()) {
2553 if (child.Tag() == llvm::dwarf::DW_TAG_variant) {
2554 _members.push_back(VariantMember(child, module_sp));
2559std::vector<VariantMember> &VariantPart::members() {
return this->_members; }
2561DiscriminantValue &VariantPart::discriminant() {
return this->_discriminant; }
2566 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2577 case DW_AT_bit_offset:
2580 case DW_AT_bit_size:
2583 case DW_AT_byte_size:
2586 case DW_AT_const_value:
2589 case DW_AT_data_bit_offset:
2592 case DW_AT_data_member_location:
2593 if (
auto maybe_offset =
2598 case DW_AT_accessibility:
2602 case DW_AT_artificial:
2605 case DW_AT_declaration:
2632PropertyAttributes::PropertyAttributes(
const DWARFDIE &die) {
2635 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2640 case DW_AT_APPLE_property_name:
2643 case DW_AT_APPLE_property_getter:
2644 prop_getter_name = form_value.
AsCString();
2646 case DW_AT_APPLE_property_setter:
2647 prop_setter_name = form_value.
AsCString();
2649 case DW_AT_APPLE_property_attribute:
2650 prop_attributes = form_value.
Unsigned();
2664 if (prop_getter_name && prop_getter_name[0] ==
'-') {
2665 std::optional<const ObjCLanguage::MethodName> prop_getter_method =
2667 if (prop_getter_method)
2672 if (prop_setter_name && prop_setter_name[0] ==
'-') {
2673 std::optional<const ObjCLanguage::MethodName> prop_setter_method =
2675 if (prop_setter_method)
2681 if (!prop_getter_name)
2682 prop_getter_name = prop_name;
2683 if (!prop_setter_name && prop_name[0] &&
2684 !(prop_attributes & DW_APPLE_PROPERTY_readonly)) {
2687 ss.
Printf(
"set%c%s:", toupper(prop_name[0]), &prop_name[1]);
2690 prop_setter_name = fixed_setter.
GetCString();
2699 assert(die.
Tag() == DW_TAG_APPLE_property);
2704 const PropertyAttributes propAttrs(die);
2706 if (!propAttrs.prop_name) {
2707 module_sp->ReportError(
"{0:x8}: DW_TAG_APPLE_property has no name.",
2714 module_sp->ReportError(
2715 "{0:x8}: DW_TAG_APPLE_property '{1}' refers to type {2:x16}"
2716 " which was unable to be parsed",
2717 die.
GetID(), propAttrs.prop_name,
2725 class_clang_type, propAttrs.prop_name,
2727 propAttrs.prop_getter_name, propAttrs.prop_attributes, &metadata));
2733 assert(qt->isIntegralOrEnumerationType());
2736 return llvm::createStringError(llvm::inconvertibleErrorCode(),
2737 "TypeSystem not clang");
2741 const unsigned type_bits = ast.getIntWidth(qt);
2742 const bool is_unsigned = qt->isUnsignedIntegerType();
2746 constexpr std::size_t max_bit_size = 64;
2751 if (type_bits > max_bit_size) {
2752 auto msg = llvm::formatv(
"Can only parse integers with up to {0} bits, but "
2753 "given integer has {1} bits.",
2754 max_bit_size, type_bits);
2755 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2759 llvm::APInt result(max_bit_size, form_value.
Unsigned(), !is_unsigned);
2765 const unsigned required_bits =
2766 is_unsigned ? result.getActiveBits() : result.getSignificantBits();
2769 if (required_bits > type_bits) {
2770 std::string value_as_str = is_unsigned
2771 ? std::to_string(form_value.
Unsigned())
2772 : std::to_string(form_value.
Signed());
2773 auto msg = llvm::formatv(
"Can't store {0} value {1} in integer with {2} "
2775 (is_unsigned ?
"unsigned" :
"signed"),
2776 value_as_str, type_bits);
2777 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2781 if (result.getBitWidth() > type_bits)
2782 result = result.trunc(type_bits);
2789 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
2790 assert(die.
Tag() == DW_TAG_member || die.
Tag() == DW_TAG_variable);
2797 auto accessibility =
2802 class_clang_type, attrs.
name, ct, accessibility);
2804 LLDB_LOG(log,
"Failed to add variable to the record type");
2813 llvm::Expected<llvm::APInt> const_value_or_err =
2815 if (!const_value_or_err) {
2817 "Failed to add const value to variable {1}: {0}",
2818 v->getQualifiedNameAsString());
2832 assert(die.
Tag() == DW_TAG_member);
2837 const uint64_t parent_byte_size =
2839 const uint64_t parent_bit_size =
2864 module_sp->ReportError(
2865 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
2866 " which was unable to be parsed",
2869 module_sp->ReportError(
"{0:x8}: DW_TAG_member refers to type {1:x16}"
2870 " which was unable to be parsed",
2876 const uint64_t character_width = 8;
2877 const uint64_t word_width = 32;
2881 ? default_accessibility
2890 this_field_info.
bit_offset = field_bit_offset;
2902 this_field_info.
bit_offset += byte_size.value_or(0) * 8;
2916 !(parent_die.
Tag() == DW_TAG_union_type &&
2918 ((this_field_info.
bit_offset >= parent_bit_size) ||
2924 "{0:x16}: {1} ({2}) bitfield named \"{3}\" has invalid "
2925 "bit offset ({4:x8}) member will be ignored. Please file a bug "
2927 "compiler and include the preprocessed output for {5}\n",
2934 field_bit_offset = this_field_info.
bit_offset;
2939 bool detect_unnamed_bitfields =
true;
2942 detect_unnamed_bitfields =
2945 if (detect_unnamed_bitfields) {
2946 std::optional<FieldInfo> unnamed_field_info;
2947 uint64_t last_field_end =
2955 if (last_field_end != 0 && ((last_field_end % word_width) != 0))
2956 last_field_end += word_width - (last_field_end % word_width);
2960 this_field_info, layout_info)) {
2964 unnamed_field_info->bit_offset = last_field_end;
2967 if (unnamed_field_info) {
2968 clang::FieldDecl *unnamed_bitfield_decl =
2970 class_clang_type, llvm::StringRef(),
2973 accessibility, unnamed_field_info->bit_size);
2976 unnamed_bitfield_decl, unnamed_field_info->bit_offset));
2980 last_field_info = this_field_info;
2983 last_field_info.
bit_offset = field_bit_offset;
2985 if (std::optional<uint64_t> clang_type_size =
2987 last_field_info.
bit_size = *clang_type_size * character_width;
3013 uint64_t member_array_size;
3014 bool member_array_is_incomplete;
3016 if (member_clang_type.
IsArrayType(&member_array_element_type,
3018 &member_array_is_incomplete) &&
3019 !member_array_is_incomplete) {
3020 uint64_t parent_byte_size =
3024 if (member_array_size != 1 &&
3025 (member_array_size != 0 ||
3027 module_sp->ReportError(
3028 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
3029 " which extends beyond the bounds of {3:x8}",
3043 class_clang_type, attrs.
name, member_clang_type, accessibility,
3049 std::make_pair(field_decl, field_bit_offset));
3054 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
3055 std::vector<DWARFDIE> &member_function_dies,
3056 std::vector<DWARFDIE> &contained_type_dies,
3075 case DW_TAG_APPLE_property:
3079 case DW_TAG_variant_part:
3082 default_accessibility, layout_info);
3086 case DW_TAG_variable: {
3092 default_accessibility, layout_info, last_field_info);
3095 case DW_TAG_subprogram:
3097 member_function_dies.push_back(die);
3100 case DW_TAG_inheritance:
3102 module_sp, base_classes, layout_info);
3106 if (llvm::dwarf::isType(tag))
3107 contained_type_dies.push_back(die);
3116 clang::DeclContext *containing_decl_ctx,
const DWARFDIE &parent_die,
3117 bool skip_artificial,
bool &is_static,
bool &is_variadic,
3118 bool &has_template_params, std::vector<CompilerType> &function_param_types,
3119 std::vector<clang::ParmVarDecl *> &function_param_decls,
3120 unsigned &type_quals) {
3128 case DW_TAG_formal_parameter: {
3130 if (attributes.
Size() == 0) {
3135 const char *name =
nullptr;
3137 bool is_artificial =
false;
3140 clang::StorageClass storage = clang::SC_None;
3142 for (i = 0; i < attributes.
Size(); ++i) {
3151 param_type_die_form = form_value;
3153 case DW_AT_artificial:
3154 is_artificial = form_value.
Boolean();
3156 case DW_AT_location:
3157 case DW_AT_const_value:
3158 case DW_AT_default_value:
3159 case DW_AT_description:
3160 case DW_AT_endianity:
3161 case DW_AT_is_optional:
3163 case DW_AT_variable_parameter:
3165 case DW_AT_abstract_origin:
3173 if (skip_artificial && is_artificial) {
3181 (name ==
nullptr || ::strcmp(name,
"this") == 0)) {
3189 type_quals |= clang::Qualifiers::Const;
3191 type_quals |= clang::Qualifiers::Volatile;
3206 assert(param_var_decl);
3207 function_param_decls.push_back(param_var_decl);
3215 case DW_TAG_unspecified_parameters:
3219 case DW_TAG_template_type_parameter:
3220 case DW_TAG_template_value_parameter:
3221 case DW_TAG_GNU_template_parameter_pack:
3227 has_template_params =
true;
3241 switch (die.
Tag()) {
3242 case DW_TAG_constant:
3243 case DW_TAG_formal_parameter:
3244 case DW_TAG_imported_declaration:
3245 case DW_TAG_imported_module:
3247 case DW_TAG_variable:
3261 return cache_pos->second;
3276 clang::Decl *decl =
nullptr;
3277 switch (die.
Tag()) {
3278 case DW_TAG_variable:
3279 case DW_TAG_constant:
3280 case DW_TAG_formal_parameter: {
3283 if (
dwarf && type) {
3284 const char *name = die.
GetName();
3285 clang::DeclContext *decl_context =
3287 dwarf->GetDeclContextContainingUID(die.
GetID()));
3294 case DW_TAG_imported_declaration: {
3299 if (imported_decl) {
3300 clang::DeclContext *decl_context =
3302 dwarf->GetDeclContextContainingUID(die.
GetID()));
3303 if (clang::NamedDecl *clang_imported_decl =
3304 llvm::dyn_cast<clang::NamedDecl>(
3312 case DW_TAG_imported_module: {
3319 if (imported_decl_ctx) {
3320 clang::DeclContext *decl_context =
3322 dwarf->GetDeclContextContainingUID(die.
GetID()));
3323 if (clang::NamespaceDecl *ns_decl =
3348 bool try_parsing_type =
true;
3349 switch (die.
Tag()) {
3350 case DW_TAG_compile_unit:
3351 case DW_TAG_partial_unit:
3353 try_parsing_type =
false;
3356 case DW_TAG_namespace:
3358 try_parsing_type =
false;
3361 case DW_TAG_imported_declaration:
3363 try_parsing_type =
false;
3366 case DW_TAG_lexical_block:
3368 try_parsing_type =
false;
3375 if (decl_ctx ==
nullptr && try_parsing_type) {
3395 parent = parent.GetParent()) {
3397 if (tag == DW_TAG_module) {
3417 switch (die.
Tag()) {
3418 case DW_TAG_subprogram:
3419 case DW_TAG_inlined_subroutine:
3429 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3436 assert(0 &&
"Shouldn't call GetContainingFunctionWithAbstractOrigin on "
3437 "something not in a function");
3443 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3465 assert(die.
Tag() == DW_TAG_lexical_block);
3466 DWARFDIE containing_function_with_abstract_origin =
3468 if (!containing_function_with_abstract_origin) {
3472 die, containing_function_with_abstract_origin);
3479 if (die && die.
Tag() == DW_TAG_lexical_block) {
3480 clang::BlockDecl *decl =
3485 clang::DeclContext *decl_context =
3499clang::NamespaceDecl *
3501 if (die && die.
Tag() == DW_TAG_namespace) {
3504 clang::NamespaceDecl *namespace_decl =
3507 return namespace_decl;
3509 const char *namespace_name = die.
GetName();
3510 clang::DeclContext *containing_decl_ctx =
3521 return namespace_decl;
3527clang::NamespaceDecl *
3529 assert(die && die.
Tag() == DW_TAG_imported_declaration);
3535 return static_cast<clang::NamespaceDecl *
>(it->getSecond());
3537 clang::NamespaceDecl *namespace_decl =
nullptr;
3544 switch (imported_uid.
Tag()) {
3545 case DW_TAG_imported_declaration:
3548 case DW_TAG_namespace:
3555 if (!namespace_decl)
3560 return namespace_decl;
3567 DWARFDIE decl_ctx_die =
dwarf->GetDeclContextDIEContainingDIE(die);
3569 if (decl_ctx_die_copy)
3570 *decl_ctx_die_copy = decl_ctx_die;
3573 clang::DeclContext *clang_decl_ctx =
3576 return clang_decl_ctx;
3602 if (!class_type || !src_class_die || !dst_class_die)
3604 if (src_class_die.
Tag() != dst_class_die.
Tag())
3614 if (die.
Tag() != DW_TAG_subprogram)
3626 map_artificial.Append(const_name, die);
3628 map.Append(const_name, die);
3637 src_die = src_die.GetSibling()) {
3638 gather(src_die, src_name_to_die, src_name_to_die_artificial);
3641 dst_die = dst_die.GetSibling()) {
3642 gather(dst_die, dst_name_to_die, dst_name_to_die_artificial);
3644 const uint32_t src_size = src_name_to_die.
GetSize();
3645 const uint32_t dst_size = dst_name_to_die.
GetSize();
3648 bool fast_path =
true;
3650 if (src_size != dst_size)
3656 for (idx = 0; idx < src_size; ++idx) {
3660 if (src_die.
Tag() != dst_die.
Tag())
3667 if (src_name == dst_name || (strcmp(src_name, dst_name) == 0))
3683 clang::DeclContext *dst_decl_ctx =
3688 if (
Type *src_child_type = die_to_type.lookup(src.
GetDIE()))
3689 die_to_type[dst.GetDIE()] = src_child_type;
3696 for (idx = 0; idx < src_size; ++idx) {
3706 src_name_to_die.
Sort();
3708 for (idx = 0; idx < dst_size; ++idx) {
3713 if (src_die && (src_die.
Tag() == dst_die.
Tag()))
3714 link(src_die, dst_die);
3716 failures.push_back(dst_die);
3721 const uint32_t src_size_artificial = src_name_to_die_artificial.
GetSize();
3722 const uint32_t dst_size_artificial = dst_name_to_die_artificial.
GetSize();
3724 if (src_size_artificial && dst_size_artificial) {
3725 dst_name_to_die_artificial.
Sort();
3727 for (idx = 0; idx < src_size_artificial; ++idx) {
3733 dst_name_to_die_artificial.
Find(src_name_artificial,
DWARFDIE());
3737 link(src_die, dst_die);
3741 if (dst_size_artificial) {
3742 for (idx = 0; idx < dst_size_artificial; ++idx) {
3748 return !failures.empty();
3752 FieldInfo const &last_field_info, uint64_t last_field_end,
3757 if (this_field_info.
bit_offset <= last_field_end)
3771 const bool have_base = layout_info.
base_offsets.size() != 0;
3772 const bool this_is_first_field =
3774 const bool first_field_is_vptr =
3777 if (have_base && (this_is_first_field || first_field_is_vptr))
3787 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant_part);
3789 LanguageType::eLanguageTypeRust);
3793 VariantPart variants(die, parent_die, module_sp);
3795 auto discriminant_type =
3796 die.
ResolveTypeUID(variants.discriminant().type_ref.Reference());
3803 llvm::formatv(
"{0}$Inner", class_clang_type.
GetTypeName(
false))),
3808 for (
auto member : variants.members()) {
3810 auto has_discriminant = !member.IsDefault();
3812 auto member_type = die.
ResolveTypeUID(member.type_ref.Reference());
3817 std::string(llvm::formatv(
"{0}$Variant", member.GetName())),
3818 llvm::to_underlying(clang::TagTypeKind::Struct),
3822 auto offset = member.byte_offset;
3824 if (has_discriminant) {
3826 field_type,
"$discr$", discriminant_type->GetFullCompilerType(),
3828 offset += discriminant_type->GetByteSize(
nullptr).value_or(0);
3832 member_type->GetFullCompilerType(),
3837 auto name = has_discriminant
3838 ? llvm::formatv(
"$variant${0}", member.discr_value.value())
3839 : std::string(
"$variant$");
3843 field_type, default_accesibility, 0);
3849 llvm::StringRef(
"$variants$"),
static bool DeclKindIsCXXClass(clang::Decl::Kind decl_kind)
static std::string GetUnitName(const DWARFDIE &die)
static clang::CallingConv ConvertDWARFCallingConventionToClang(const ParsedDWARFTypeAttributes &attrs)
static bool IsSubroutine(const DWARFDIE &die)
static TypePayloadClang GetPtrAuthMofidierPayload(const DWARFDIE &die)
static bool TagIsRecordType(dw_tag_t tag)
Returns true for C++ constructs represented by clang::CXXRecordDecl.
static lldb::ModuleSP GetContainingClangModule(const DWARFDIE &die)
static DWARFDIE FindFirstChildWithAbstractOrigin(const DWARFDIE &block, const DWARFDIE &function)
static DWARFDIE FindAnyChildWithAbstractOrigin(const DWARFDIE &context)
static bool IsClangModuleFwdDecl(const DWARFDIE &Die)
Detect a forward declaration that is nested in a DW_TAG_module.
static DWARFDIE GetContainingClangModuleDIE(const DWARFDIE &die)
static DWARFDIE GetContainingFunctionWithAbstractOrigin(const DWARFDIE &die)
static void PrepareContextToReceiveMembers(TypeSystemClang &ast, ClangASTImporter &ast_importer, clang::DeclContext *decl_ctx, DWARFDIE die, const char *type_name_cstr)
This function ensures we are able to add members (nested types, functions, etc.) to this type.
static std::optional< uint32_t > ExtractDataMemberLocation(DWARFDIE const &die, DWARFFormValue const &form_value, ModuleSP module_sp)
static bool ShouldIgnoreArtificialField(llvm::StringRef FieldName)
#define DEBUG_PRINTF(fmt,...)
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
#define DIE_IS_BEING_PARSED
static llvm::StringRef GetName(XcodeSDK::Type type)
const char * m_property_getter_name
CompilerType m_class_opaque_type
std::unique_ptr< ClangASTMetadata > m_metadata_up
DelayedAddObjCClassProperty(const CompilerType &class_opaque_type, const char *property_name, const CompilerType &property_opaque_type, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, const ClangASTMetadata *metadata)
CompilerType m_property_opaque_type
const char * m_property_setter_name
uint32_t m_property_attributes
DelayedAddObjCClassProperty(const DelayedAddObjCClassProperty &rhs)
DelayedAddObjCClassProperty & operator=(const DelayedAddObjCClassProperty &rhs)
const char * m_property_name
lldb::TypeSP ParsePointerToMemberType(const lldb_private::plugin::dwarf::DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs)
clang::NamespaceDecl * ResolveImportedDeclarationDIE(const lldb_private::plugin::dwarf::DWARFDIE &die)
Returns the namespace decl that a DW_TAG_imported_declaration imports.
void CreateStaticMemberVariable(const lldb_private::plugin::dwarf::DWARFDIE &die, const MemberAttributes &attrs, const lldb_private::CompilerType &class_clang_type)
If the specified 'die' represents a static data member, creates a 'clang::VarDecl' for it and attache...
size_t ParseChildParameters(clang::DeclContext *containing_decl_ctx, const lldb_private::plugin::dwarf::DWARFDIE &parent_die, bool skip_artificial, bool &is_static, bool &is_variadic, bool &has_template_params, std::vector< lldb_private::CompilerType > &function_args, std::vector< clang::ParmVarDecl * > &function_param_decls, unsigned &type_quals)
std::unique_ptr< lldb_private::ClangASTImporter > m_clang_ast_importer_up
lldb::TypeSP ParseEnum(const lldb_private::SymbolContext &sc, const lldb_private::plugin::dwarf::DWARFDIE &die, ParsedDWARFTypeAttributes &attrs)
lldb::TypeSP UpdateSymbolContextScopeForType(const lldb_private::SymbolContext &sc, const lldb_private::plugin::dwarf::DWARFDIE &die, lldb::TypeSP type_sp)
If type_sp is valid, calculate and set its symbol context scope, and update the type list for its bac...
lldb_private::TypeSystemClang & m_ast
bool ShouldCreateUnnamedBitfield(FieldInfo const &last_field_info, uint64_t last_field_end, FieldInfo const &this_field_info, lldb_private::ClangASTImporter::LayoutInfo const &layout_info) const
Returns 'true' if we should create an unnamed bitfield and add it to the parser's current AST.
lldb::TypeSP ParseArrayType(const lldb_private::plugin::dwarf::DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs)
lldb_private::ClangASTImporter & GetClangASTImporter()
clang::BlockDecl * ResolveBlockDIE(const lldb_private::plugin::dwarf::DWARFDIE &die)
lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, const lldb_private::plugin::dwarf::DWARFDIE &die, bool *type_is_new_ptr) override
bool CompleteEnumType(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::Type *type, lldb_private::CompilerType &clang_type)
bool CompleteTypeFromDWARF(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::Type *type, lldb_private::CompilerType &compiler_type) override
clang::DeclContext * GetClangDeclContextContainingDIE(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::plugin::dwarf::DWARFDIE *decl_ctx_die)
clang::DeclContext * GetDeclContextForBlock(const lldb_private::plugin::dwarf::DWARFDIE &die)
void ParseInheritance(const lldb_private::plugin::dwarf::DWARFDIE &die, const lldb_private::plugin::dwarf::DWARFDIE &parent_die, const lldb_private::CompilerType class_clang_type, const lldb::AccessType default_accessibility, const lldb::ModuleSP &module_sp, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > &base_classes, lldb_private::ClangASTImporter::LayoutInfo &layout_info)
Parses a DW_TAG_inheritance DIE into a base/super class.
lldb_private::Function * ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit, const lldb_private::plugin::dwarf::DWARFDIE &die, const lldb_private::AddressRange &func_range) override
lldb::TypeSP ParseTypeModifier(const lldb_private::SymbolContext &sc, const lldb_private::plugin::dwarf::DWARFDIE &die, ParsedDWARFTypeAttributes &attrs)
lldb::TypeSP ParseTypeFromClangModule(const lldb_private::SymbolContext &sc, const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::Log *log)
Follow Clang Module Skeleton CU references to find a type definition.
DIEToDeclContextMap m_die_to_decl_ctx
void ParseObjCProperty(const lldb_private::plugin::dwarf::DWARFDIE &die, const lldb_private::plugin::dwarf::DWARFDIE &parent_die, const lldb_private::CompilerType &class_clang_type, DelayedPropertyList &delayed_properties)
Parses a DW_TAG_APPLE_property DIE and appends the parsed data to the list of delayed Objective-C pro...
void EnsureAllDIEsInDeclContextHaveBeenParsed(lldb_private::CompilerDeclContext decl_context) override
clang::NamespaceDecl * ResolveNamespaceDIE(const lldb_private::plugin::dwarf::DWARFDIE &die)
void GetUniqueTypeNameAndDeclaration(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb::LanguageType language, lldb_private::ConstString &unique_typename, lldb_private::Declaration &decl_declaration)
lldb_private::ConstString ConstructDemangledNameFromDWARF(const lldb_private::plugin::dwarf::DWARFDIE &die) override
lldb_private::CompilerDeclContext GetDeclContextContainingUIDFromDWARF(const lldb_private::plugin::dwarf::DWARFDIE &die) override
lldb::TypeSP ParseStructureLikeDIE(const lldb_private::SymbolContext &sc, const lldb_private::plugin::dwarf::DWARFDIE &die, ParsedDWARFTypeAttributes &attrs)
Parse a structure, class, or union type DIE.
void ParseRustVariantPart(lldb_private::plugin::dwarf::DWARFDIE &die, const lldb_private::plugin::dwarf::DWARFDIE &parent_die, lldb_private::CompilerType &class_clang_type, const lldb::AccessType default_accesibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info)
Parses DW_TAG_variant_part DIE into a structure that encodes all variants Note that this is currently...
DIEToDeclMap m_die_to_decl
~DWARFASTParserClang() override
std::vector< DelayedAddObjCClassProperty > DelayedPropertyList
bool CopyUniqueClassMethodTypes(const lldb_private::plugin::dwarf::DWARFDIE &src_class_die, const lldb_private::plugin::dwarf::DWARFDIE &dst_class_die, lldb_private::Type *class_type, std::vector< lldb_private::plugin::dwarf::DWARFDIE > &failures)
clang::DeclContext * GetClangDeclContextForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die)
bool ParseTemplateDIE(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::TypeSystemClang::TemplateParameterInfos &template_param_infos)
lldb_private::CompilerDeclContext GetDeclContextForUIDFromDWARF(const lldb_private::plugin::dwarf::DWARFDIE &die) override
std::string GetDIEClassTemplateParams(const lldb_private::plugin::dwarf::DWARFDIE &die) override
Returns the template parameters of a class DWARFDIE as a string.
llvm::Expected< llvm::APInt > ExtractIntFromFormValue(const lldb_private::CompilerType &int_type, const lldb_private::plugin::dwarf::DWARFFormValue &form_value) const
Extracts an value for a given Clang integer type from a DWARFFormValue.
bool CompleteRecordType(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::Type *type, lldb_private::CompilerType &clang_type)
clang::DeclContext * GetCachedClangDeclContextForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die)
bool ParseChildMembers(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::CompilerType &class_compiler_type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > &base_classes, std::vector< lldb_private::plugin::dwarf::DWARFDIE > &member_function_dies, std::vector< lldb_private::plugin::dwarf::DWARFDIE > &contained_type_dies, DelayedPropertyList &delayed_properties, const lldb::AccessType default_accessibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info)
DIEToModuleMap m_die_to_module
void ParseSingleMember(const lldb_private::plugin::dwarf::DWARFDIE &die, const lldb_private::plugin::dwarf::DWARFDIE &parent_die, const lldb_private::CompilerType &class_clang_type, lldb::AccessType default_accessibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info, FieldInfo &last_field_info)
DeclContextToDIEMap m_decl_ctx_to_die
size_t ParseChildEnumerators(lldb_private::CompilerType &compiler_type, bool is_signed, uint32_t enumerator_byte_size, const lldb_private::plugin::dwarf::DWARFDIE &parent_die)
std::pair< bool, lldb::TypeSP > ParseCXXMethod(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::CompilerType clang_type, const ParsedDWARFTypeAttributes &attrs, const lldb_private::plugin::dwarf::DWARFDIE &decl_ctx_die, bool is_static, bool &ignore_containing_context)
Helper function called by ParseSubroutine when parsing C++ methods.
lldb::TypeSP ParseSubroutine(const lldb_private::plugin::dwarf::DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs)
void MapDeclDIEToDefDIE(const lldb_private::plugin::dwarf::DWARFDIE &decl_die, const lldb_private::plugin::dwarf::DWARFDIE &def_die)
bool ParseObjCMethod(const lldb_private::ObjCLanguage::MethodName &objc_method, const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::CompilerType clang_type, const ParsedDWARFTypeAttributes &attrs, bool is_variadic)
Helper function called by ParseSubroutine when parsing ObjC-methods.
lldb_private::CompilerDecl GetDeclForUIDFromDWARF(const lldb_private::plugin::dwarf::DWARFDIE &die) override
bool ParseTemplateParameterInfos(const lldb_private::plugin::dwarf::DWARFDIE &parent_die, lldb_private::TypeSystemClang::TemplateParameterInfos &template_param_infos)
clang::Decl * GetClangDeclForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die)
void LinkDeclContextToDIE(clang::DeclContext *decl_ctx, const lldb_private::plugin::dwarf::DWARFDIE &die)
lldb_private::OptionalClangModuleID GetOwningClangModule(const lldb_private::plugin::dwarf::DWARFDIE &die)
A section + offset based address range class.
Address & GetBaseAddress()
Get accessor for the base address of the range.
bool IsValid() const
Check if the object state is valid.
Block * FindBlockByID(lldb::user_id_t block_id)
Manages and observes all Clang AST node importing in LLDB.
CompilerType CopyType(TypeSystemClang &dst, const CompilerType &src_type)
Copies the given type and the respective declarations to the destination type system.
bool CanImport(const CompilerType &type)
Returns true iff the given type was copied from another TypeSystemClang and the original type in this...
void SetRecordLayout(clang::RecordDecl *decl, const LayoutInfo &layout)
Sets the layout for the given RecordDecl.
bool RequireCompleteType(clang::QualType type)
A class that describes a compilation unit.
void AddFunction(lldb::FunctionSP &function_sp)
Add a function to this compile unit.
Represents a generic declaration context in a program.
void * GetOpaqueDeclContext() const
Represents a generic declaration such as a function declaration.
void * GetOpaqueDecl() const
std::shared_ptr< TypeSystemType > dyn_cast_or_null()
Return a shared_ptr<TypeSystemType> if dyn_cast succeeds.
Generic representation of a type in a programming language.
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
bool IsArrayType(CompilerType *element_type=nullptr, uint64_t *size=nullptr, bool *is_incomplete=nullptr) const
bool IsCompleteType() const
lldb::opaque_compiler_type_t GetOpaqueQualType() const
bool IsBeingDefined() const
bool IsIntegerOrEnumerationType(bool &is_signed) const
ConstString GetTypeName(bool BaseOnly=false) const
bool IsIntegerType(bool &is_signed) const
bool GetCompleteType() const
Type Completion.
std::optional< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
A uniqued constant string class.
void SetCString(const char *cstr)
Set the C string value.
bool IsEmpty() const
Test for empty string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
void SetString(llvm::StringRef s)
const char * GetCString() const
Get the string value as a C string.
"lldb/Expression/DWARFExpressionList.h" Encapsulates a range map from file address range to a single ...
bool IsValid() const
Return true if the location expression contains data.
static llvm::Expected< Value > Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::ModuleSP module_sp, const DataExtractor &opcodes, const plugin::dwarf::DWARFUnit *dwarf_cu, const lldb::RegisterKind reg_set, const Value *initial_value_ptr, const Value *object_address_ptr)
Evaluate a DWARF location expression in a particular context.
A class that describes the declaration location of a lldb object.
void SetLine(uint32_t line)
Set accessor for the declaration line number.
void SetColumn(uint16_t column)
Set accessor for the declaration column number.
void Clear()
Clear the object's state.
void SetFile(const FileSpec &file_spec)
Set accessor for the declaration file specification.
A class that describes a function.
Block & GetBlock(bool can_create)
Get accessor for the block list.
static bool LanguageIsCPlusPlus(lldb::LanguageType language)
static bool LanguageIsObjC(lldb::LanguageType language)
A class that handles mangled names.
void SetValue(ConstString name)
Set the string value in this object.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
A class that describes an executable image and its associated object and symbol files.
llvm::StringRef GetClassName() const
Returns a reference to the class name.
static std::optional< const MethodName > Create(llvm::StringRef name, bool strict)
The static factory method for creating a MethodName.
A plug-in interface definition class for object file parsers.
virtual lldb::ByteOrder GetByteOrder() const =0
Gets whether endian swapping should occur when extracting data from this object file.
llvm::StringRef GetString() const
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
Function * function
The Function for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
ObjectFile * GetObjectFile() override
lldb::TypeSP FirstType() const
The implementation of lldb::Type's m_payload field for TypeSystemClang.
A class that contains all state required for type lookups.
void AddLanguage(lldb::LanguageType language)
Add a language family to the list of languages that should produce a match.
This class tracks the state and results of a TypeQuery.
bool AlreadySearched(lldb_private::SymbolFile *sym_file)
Check if a SymbolFile object has already been searched by this type match object.
llvm::DenseSet< lldb_private::SymbolFile * > & GetSearchedSymbolFiles()
Access the set of searched symbol files.
void SetPackName(char const *name)
void SetParameterPack(std::unique_ptr< TemplateParameterInfos > args)
void InsertArg(char const *name, clang::TemplateArgument arg)
bool hasParameterPack() const
TemplateParameterInfos const & GetParameterPack() const
A TypeSystem implementation based on Clang.
clang::TranslationUnitDecl * GetTranslationUnitDecl()
void SetMetadata(const clang::Decl *object, ClangASTMetadata &meta_data)
CompilerType GetBasicType(lldb::BasicType type)
clang::UsingDecl * CreateUsingDeclaration(clang::DeclContext *current_decl_ctx, OptionalClangModuleID owning_module, clang::NamedDecl *target)
OptionalClangModuleID GetOrCreateClangModule(llvm::StringRef name, OptionalClangModuleID parent, bool is_framework=false, bool is_explicit=false)
Synthesize a clang::Module and return its ID or a default-constructed ID.
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size)
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
clang::FunctionTemplateDecl * CreateFunctionTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::FunctionDecl *func_decl, const TemplateParameterInfos &infos)
bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td)
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
static bool IsCXXClassType(const CompilerType &type)
static bool AddObjCClassProperty(const CompilerType &type, const char *property_name, const CompilerType &property_compiler_type, clang::ObjCIvarDecl *ivar_decl, const char *property_setter_name, const char *property_getter_name, uint32_t property_attributes, ClangASTMetadata *metadata)
CompilerType GetType(clang::QualType qt)
Creates a CompilerType from the given QualType with the current TypeSystemClang instance as the Compi...
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
bool TransferBaseClasses(lldb::opaque_compiler_type_t type, std::vector< std::unique_ptr< clang::CXXBaseSpecifier > > bases)
static void SetIntegerInitializerForVariable(clang::VarDecl *var, const llvm::APInt &init_value)
Initializes a variable with an integer value.
static void SetIsPacked(const CompilerType &type)
CompilerType CreateClassTemplateSpecializationType(clang::ClassTemplateSpecializationDecl *class_template_specialization_decl)
void CreateFunctionTemplateSpecializationInfo(clang::FunctionDecl *func_decl, clang::FunctionTemplateDecl *Template, const TemplateParameterInfos &infos)
CompilerDecl GetCompilerDecl(clang::Decl *decl)
Creates a CompilerDecl from the given Decl with the current TypeSystemClang instance as its typesyste...
std::string PrintTemplateParams(const TemplateParameterInfos &template_param_infos)
Return the template parameters (including surrounding <>) in string form.
CompilerDeclContext CreateDeclContext(clang::DeclContext *ctx)
Creates a CompilerDeclContext from the given DeclContext with the current TypeSystemClang instance as...
void SetMetadataAsUserID(const clang::Decl *decl, lldb::user_id_t user_id)
clang::FunctionDecl * CreateFunctionDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, llvm::StringRef name, const CompilerType &function_Type, clang::StorageClass storage, bool is_inline)
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(llvm::StringRef type_name, uint32_t dw_ate, uint32_t bit_size)
static void BuildIndirectFields(const CompilerType &type)
void AddMethodOverridesForCXXRecordType(lldb::opaque_compiler_type_t type)
CompilerType CreateBlockPointerType(const CompilerType &function_type)
clang::ClassTemplateSpecializationDecl * CreateClassTemplateSpecializationDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::ClassTemplateDecl *class_template_decl, int kind, const TemplateParameterInfos &infos)
clang::CXXMethodDecl * AddMethodToCXXRecordType(lldb::opaque_compiler_type_t type, llvm::StringRef name, const char *mangled_name, const CompilerType &method_type, lldb::AccessType access, bool is_virtual, bool is_static, bool is_inline, bool is_explicit, bool is_attr_used, bool is_artificial)
clang::EnumConstantDecl * AddEnumerationValueToEnumerationType(const CompilerType &enum_type, const Declaration &decl, const char *name, int64_t enum_value, uint32_t enum_value_bit_size)
clang::NamespaceDecl * GetUniqueNamespaceDeclaration(const char *name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, bool is_inline=false)
static clang::CXXRecordDecl * GetAsCXXRecordDecl(lldb::opaque_compiler_type_t type)
clang::UsingDirectiveDecl * CreateUsingDirectiveDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, clang::NamespaceDecl *ns_decl)
static bool CompleteTagDeclarationDefinition(const CompilerType &type)
static clang::ObjCMethodDecl * AddMethodToObjCObjectType(const CompilerType &type, const char *name, const CompilerType &method_compiler_type, bool is_artificial, bool is_variadic, bool is_objc_direct_call)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
CompilerType CreateEnumerationType(llvm::StringRef name, clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const Declaration &decl, const CompilerType &integer_qual_type, bool is_scoped)
clang::ParmVarDecl * CreateParameterDeclaration(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, const char *name, const CompilerType ¶m_type, int storage, bool add_decl=false)
static clang::NamespaceDecl * DeclContextGetAsNamespaceDecl(const CompilerDeclContext &dc)
CompilerType CreateArrayType(const CompilerType &element_type, size_t element_count, bool is_vector)
CompilerType GetTypeForDecl(clang::NamedDecl *decl)
static clang::DeclContext * DeclContextGetAsDeclContext(const CompilerDeclContext &dc)
static bool StartTagDeclarationDefinition(const CompilerType &type)
static clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type, lldb::AccessType access)
CompilerType CreateFunctionType(const CompilerType &result_type, const CompilerType *args, unsigned num_args, bool is_variadic, unsigned type_quals, clang::CallingConv cc=clang::CC_C, clang::RefQualifierKind ref_qual=clang::RQ_None)
void SetFunctionParameters(clang::FunctionDecl *function_decl, llvm::ArrayRef< clang::ParmVarDecl * > params)
static bool IsObjCObjectOrInterfaceType(const CompilerType &type)
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, ClangASTMetadata *metadata=nullptr, bool exports_symbols=false)
static void RequireCompleteType(CompilerType type)
Complete a type from debug info, or mark it as forcefully completed if there is no definition of the ...
clang::TemplateTemplateParmDecl * CreateTemplateTemplateParmDecl(const char *template_name)
clang::ClassTemplateDecl * ParseClassTemplateDecl(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, const char *parent_name, int tag_decl_kind, const TypeSystemClang::TemplateParameterInfos &template_param_infos)
clang::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
clang::VarDecl * CreateVariableDeclaration(clang::DeclContext *decl_context, OptionalClangModuleID owning_module, const char *name, clang::QualType type)
clang::BlockDecl * CreateBlockDeclaration(clang::DeclContext *ctx, OptionalClangModuleID owning_module)
CompilerType GetForwardCompilerType()
uint32_t GetEncodingMask()
@ eEncodingIsRestrictUID
This type is the type whose UID is m_encoding_uid with the restrict qualifier added.
@ eEncodingIsConstUID
This type is the type whose UID is m_encoding_uid with the const qualifier added.
@ eEncodingIsVolatileUID
This type is the type whose UID is m_encoding_uid with the volatile qualifier added.
@ eEncodingIsAtomicUID
This type is the type whose UID is m_encoding_uid as an atomic type.
@ eEncodingIsLLVMPtrAuthUID
This type is a signed pointer.
@ eEncodingInvalid
Invalid encoding.
@ eEncodingIsTypedefUID
This type is alias to a type whose UID is m_encoding_uid.
@ eEncodingIsPointerUID
This type is pointer to a type whose UID is m_encoding_uid.
@ eEncodingIsLValueReferenceUID
This type is L value reference to a type whose UID is m_encoding_uid.
@ eEncodingIsRValueReferenceUID
This type is R value reference to a type whose UID is m_encoding_uid.
@ eEncodingIsUID
This type is the type whose UID is m_encoding_uid.
CompilerType GetLayoutCompilerType()
std::optional< uint64_t > GetByteSize(ExecutionContextScope *exe_scope)
CompilerType GetFullCompilerType()
ConstString GetCStringAtIndex(uint32_t idx) const
T GetValueAtIndexUnchecked(uint32_t idx) const
T Find(ConstString unique_cstr, T fail_value) const
lldb_private::Type * GetTypeForDIE(const DWARFDIE &die)
static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility)
static std::optional< SymbolFile::ArrayInfo > ParseChildArrayInfo(const DWARFDIE &parent_die, const ExecutionContext *exe_ctx=nullptr)
DWARFUnit * CompileUnitAtIndex(uint32_t i) const
dw_attr_t AttributeAtIndex(uint32_t i) const
bool ExtractFormValueAtIndex(uint32_t i, DWARFFormValue &form_value) const
DWARFAttributes GetAttributes(Recurse recurse=Recurse::yes) const
std::optional< uint64_t > GetAttributeValueAsOptionalUnsigned(const dw_attr_t attr) const
const DWARFDataExtractor & GetData() const
const char * GetAttributeValueAsString(const dw_attr_t attr, const char *fail_value) const
std::optional< DIERef > GetDIERef() const
SymbolFileDWARF * GetDWARF() const
DWARFUnit * GetCU() const
bool Supports_DW_AT_APPLE_objc_complete_type() const
uint64_t GetAttributeValueAsUnsigned(const dw_attr_t attr, uint64_t fail_value) const
dw_offset_t GetOffset() const
lldb::user_id_t GetID() const
void GetName(Stream &s) const
DWARFDIE GetFirstChild() const
DWARFDIE GetParent() const
const char * GetMangledName() const
std::vector< CompilerContext > GetDeclContext() const
Return this DIE's decl context as it is needed to look up types in Clang modules.
DWARFDIE GetDIE(dw_offset_t die_offset) const
llvm::iterator_range< child_iterator > children() const
The range of all the children of this DIE.
bool GetDIENamesAndRanges(const char *&name, const char *&mangled, DWARFRangeList &ranges, std::optional< int > &decl_file, std::optional< int > &decl_line, std::optional< int > &decl_column, std::optional< int > &call_file, std::optional< int > &call_line, std::optional< int > &call_column, DWARFExpressionList *frame_base) const
DWARFDIE GetParentDeclContextDIE() const
Type * ResolveTypeUID(const DWARFDIE &die) const
DWARFDIE GetAttributeValueAsReferenceDIE(const dw_attr_t attr) const
DWARFDeclContext GetDWARFDeclContext() const
DWARFDIE GetReferencedDIE(const dw_attr_t attr) const
Type * ResolveType() const
const char * GetQualifiedName() const
SymbolFileDWARF & GetSymbolFileDWARF() const
bool Supports_unnamed_objc_bitfields()
uint64_t GetDWARFLanguageType()
FileSpec GetFile(size_t file_idx)
lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, ConstString type_name, bool must_be_implementation)
DWARFDIE FindDefinitionDIE(const DWARFDIE &die)
lldb::ModuleSP GetExternalModule(ConstString name)
llvm::DenseMap< const DWARFDebugInfoEntry *, Type * > DIEToTypePtr
static DWARFASTParser * GetDWARFParser(DWARFUnit &unit)
static lldb::LanguageType GetLanguageFamily(DWARFUnit &unit)
Same as GetLanguage() but reports all C++ versions as C++ (no version).
Type * ResolveType(const DWARFDIE &die, bool assert_not_being_parsed=true, bool resolve_function_context=false)
static CompilerDecl GetDecl(const DWARFDIE &die)
virtual DIEToTypePtr & GetDIEToType()
static lldb::LanguageType GetLanguage(DWARFUnit &unit)
static DWARFDIE GetParentSymbolContextDIE(const DWARFDIE &die)
static CompilerDeclContext GetDeclContext(const DWARFDIE &die)
llvm::dwarf::Tag dw_tag_t
llvm::dwarf::Attribute dw_attr_t
#define UNUSED_IF_ASSERT_DISABLED(x)
llvm::StringRef DW_TAG_value_to_name(dw_tag_t tag)
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.
std::shared_ptr< lldb_private::Function > FunctionSP
LanguageType
Programming language type.
@ eLanguageTypeObjC_plus_plus
Objective-C++.
@ eLanguageTypeObjC
Objective-C.
std::shared_ptr< lldb_private::Type > TypeSP
@ eEncodingSint
signed integer
std::shared_ptr< lldb_private::Module > ModuleSP
@ eRegisterKindDWARF
the register numbers seen DWARF
void SetIsArtificial(bool flag)
bool IsArtificial() const
bool NextBitfieldOffsetIsValid(const uint64_t next_bit_offset) const
void SetIsBitfield(bool flag)
Parsed form of all attributes that are relevant for parsing type members.
std::optional< uint64_t > byte_size
int64_t bit_offset
Indicates how many bits into the word (according to the host endianness) the low-order bit of the fie...
uint32_t member_byte_offset
Indicates the byte offset of the word from the base address of the structure.
lldb::AccessType accessibility
lldb_private::plugin::dwarf::DWARFFormValue encoding_form
size_t bit_size
Indicates the size of the field in bits.
std::optional< lldb_private::plugin::dwarf::DWARFFormValue > const_value_form
MemberAttributes(const lldb_private::plugin::dwarf::DWARFDIE &die, const lldb_private::plugin::dwarf::DWARFDIE &parent_die, lldb::ModuleSP module_sp)
Parsed form of all attributes that are relevant for type reconstruction.
lldb_private::Declaration decl
const char * mangled_name
lldb_private::ConstString name
lldb::AccessType accessibility
std::optional< uint64_t > alignment
bool is_complete_objc_class
lldb::LanguageType class_language
bool is_forward_declaration
std::optional< uint64_t > byte_size
lldb_private::plugin::dwarf::DWARFFormValue signature
lldb_private::plugin::dwarf::DWARFFormValue type
lldb_private::plugin::dwarf::DWARFDIE object_pointer
clang::StorageClass storage
ParsedDWARFTypeAttributes(const lldb_private::plugin::dwarf::DWARFDIE &die)
clang::RefQualifierKind ref_qual
Indicates ref-qualifier of C++ member function if present.
lldb_private::plugin::dwarf::DWARFFormValue specification
lldb_private::plugin::dwarf::DWARFFormValue abstract_origin
lldb_private::plugin::dwarf::DWARFFormValue containing_type
size_t calling_convention
llvm::DenseMap< const clang::FieldDecl *, uint64_t > field_offsets
static clang::QualType GetQualType(const CompilerType &ct)
static CompilerType RemoveFastQualifiers(const CompilerType &ct)
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
lldb::user_id_t GetID() const
Get accessor for the user ID.