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());
277 if (!tag_decl_ctx->hasExternalLexicalStorage()) {
285 for (
size_t i = 0; i < attributes.
Size(); ++i) {
293 case DW_AT_abstract_origin:
297 case DW_AT_accessibility:
302 case DW_AT_artificial:
306 case DW_AT_bit_stride:
310 case DW_AT_byte_size:
314 case DW_AT_alignment:
318 case DW_AT_byte_stride:
322 case DW_AT_calling_convention:
326 case DW_AT_containing_type:
330 case DW_AT_decl_file:
335 case DW_AT_decl_line:
338 case DW_AT_decl_column:
342 case DW_AT_declaration:
350 case DW_AT_enum_class:
367 case DW_AT_linkage_name:
368 case DW_AT_MIPS_linkage_name:
376 case DW_AT_object_pointer:
380 case DW_AT_signature:
384 case DW_AT_specification:
392 case DW_AT_virtuality:
396 case DW_AT_APPLE_objc_complete_type:
400 case DW_AT_APPLE_objc_direct:
404 case DW_AT_APPLE_runtime_class:
408 case DW_AT_GNU_vector:
411 case DW_AT_export_symbols:
414 case DW_AT_rvalue_reference:
417 case DW_AT_reference:
426 return unit->GetAbsolutePath().GetPath();
427 return "<missing DWARF unit path>";
432 bool *type_is_new_ptr) {
434 *type_is_new_ptr =
false;
439 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
444 clang::DeclContext *context =
447 dwarf->GetObjectFile()->GetModule()->LogMessage(
449 "DWARFASTParserClang::ParseTypeFromDWARF "
450 "(die = {0:x16}, decl_ctx = {1:p} (die "
451 "{2:x16})) {3} ({4}) name = '{5}')",
457 if (
auto [it, inserted] =
462 return it->getSecond()->shared_from_this();
471 if (clang::DeclContext *decl_ctx =
477 *type_is_new_ptr =
true;
483 case DW_TAG_base_type:
484 case DW_TAG_pointer_type:
485 case DW_TAG_reference_type:
486 case DW_TAG_rvalue_reference_type:
487 case DW_TAG_const_type:
488 case DW_TAG_restrict_type:
489 case DW_TAG_volatile_type:
490 case DW_TAG_LLVM_ptrauth_type:
491 case DW_TAG_atomic_type:
492 case DW_TAG_unspecified_type:
495 case DW_TAG_structure_type:
496 case DW_TAG_union_type:
497 case DW_TAG_class_type:
500 case DW_TAG_enumeration_type:
503 case DW_TAG_inlined_subroutine:
504 case DW_TAG_subprogram:
505 case DW_TAG_subroutine_type:
508 case DW_TAG_array_type:
511 case DW_TAG_ptr_to_member_type:
515 dwarf->GetObjectFile()->GetModule()->ReportError(
516 "[{0:x16}]: unhandled type tag {1:x4} ({2}), "
517 "please file a bug and "
518 "attach the file at the start of this error message",
525 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
530static std::optional<uint32_t>
533 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
541 Value initialValue(0);
543 uint32_t block_length = form_value.
Unsigned();
544 uint32_t block_offset =
554 "ExtractDataMemberLocation failed: {0}");
558 return memberOffset->ResolveValue(
nullptr).UInt();
562 auto getAttr = [&](llvm::dwarf::Attribute Attr,
unsigned defaultValue = 0) {
565 const unsigned key = getAttr(DW_AT_LLVM_ptrauth_key);
566 const bool addr_disc = getAttr(DW_AT_LLVM_ptrauth_address_discriminated);
567 const unsigned extra = getAttr(DW_AT_LLVM_ptrauth_extra_discriminator);
568 const bool isapointer = getAttr(DW_AT_LLVM_ptrauth_isa_pointer);
569 const bool authenticates_null_values =
570 getAttr(DW_AT_LLVM_ptrauth_authenticates_null_values);
571 const unsigned authentication_mode_int = getAttr(
572 DW_AT_LLVM_ptrauth_authentication_mode,
573 static_cast<unsigned>(clang::PointerAuthenticationMode::SignAndAuth));
574 clang::PointerAuthenticationMode authentication_mode =
575 clang::PointerAuthenticationMode::SignAndAuth;
576 if (authentication_mode_int >=
577 static_cast<unsigned>(clang::PointerAuthenticationMode::None) &&
578 authentication_mode_int <=
579 static_cast<unsigned>(
580 clang::PointerAuthenticationMode::SignAndAuth)) {
581 authentication_mode =
582 static_cast<clang::PointerAuthenticationMode
>(authentication_mode_int);
585 "[{0:x16}]: invalid pointer authentication mode method {1:x4}",
586 die.
GetOffset(), authentication_mode_int);
588 auto ptr_auth = clang::PointerAuthQualifier::Create(
589 key, addr_disc, extra, authentication_mode, isapointer,
590 authenticates_null_values);
598 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
608 if (tag == DW_TAG_typedef) {
658 encoding_uid.Reference());
664 case DW_TAG_unspecified_type:
665 if (attrs.
name ==
"nullptr_t" || attrs.
name ==
"decltype(nullptr)") {
666 resolve_state = Type::ResolveState::Full;
674 case DW_TAG_base_type:
675 resolve_state = Type::ResolveState::Full;
681 case DW_TAG_pointer_type:
684 case DW_TAG_reference_type:
687 case DW_TAG_rvalue_reference_type:
693 case DW_TAG_const_type:
696 case DW_TAG_restrict_type:
699 case DW_TAG_volatile_type:
702 case DW_TAG_LLVM_ptrauth_type:
706 case DW_TAG_atomic_type:
713 if (tag == DW_TAG_pointer_type) {
721 if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name,
""),
726 if (function_pointer_type) {
730 bool function_type_is_new_pointer;
732 sc, function_type, &function_type_is_new_pointer);
734 if (lldb_function_type_sp) {
736 lldb_function_type_sp->GetForwardCompilerType());
739 resolve_state = Type::ResolveState::Full;
752 if (attrs.
name ==
"id") {
754 dwarf->GetObjectFile()->GetModule()->LogMessage(
756 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
757 "is Objective-C 'id' built-in type.",
763 resolve_state = Type::ResolveState::Full;
764 }
else if (attrs.
name ==
"Class") {
766 dwarf->GetObjectFile()->GetModule()->LogMessage(
768 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
769 "is Objective-C 'Class' built-in type.",
775 resolve_state = Type::ResolveState::Full;
776 }
else if (attrs.
name ==
"SEL") {
778 dwarf->GetObjectFile()->GetModule()->LogMessage(
780 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
781 "is Objective-C 'selector' built-in type.",
787 resolve_state = Type::ResolveState::Full;
796 if (encoding_die && encoding_die.
Tag() == DW_TAG_structure_type) {
797 llvm::StringRef struct_name = encoding_die.
GetName();
798 if (struct_name ==
"objc_object") {
800 dwarf->GetObjectFile()->GetModule()->LogMessage(
802 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
803 "is 'objc_object*', which we overrode to 'id'.",
809 resolve_state = Type::ResolveState::Full;
818 &attrs.
decl, clang_type, resolve_state, payload);
823 if (llvm::StringRef(die.
GetName()).contains(
"<"))
844 unique_typename, decl_declaration);
846 dwarf->GetUniqueDWARFASTTypeMap().Find(
847 unique_typename, decl_die, decl_declaration,
850 unique_ast_entry_type->UpdateToDefDIE(def_die, def_attrs.
decl,
852 }
else if (
Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups)) {
855 "Failed to find {0:x16} {1} ({2}) type \"{3}\" in "
856 "UniqueDWARFASTTypeMap",
864 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
873 def_die =
dwarf->FindDefinitionDIE(decl_die);
877 if (debug_map_symfile) {
885 dwarf->GetObjectFile()->GetModule()->LogMessage(
887 "SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a "
888 "forward declaration, complete DIE is {5}",
891 def_die ? llvm::utohexstr(def_die.
GetID()) :
"not found");
895 if (
auto [it, inserted] =
dwarf->GetDIEToType().try_emplace(
900 return it->getSecond()->shared_from_this();
911 Type *enumerator_type =
917 if (!enumerator_clang_type) {
920 "", DW_ATE_signed, *attrs.
byte_size * 8);
933 &attrs.
decl, clang_type, Type::ResolveState::Forward,
936 clang::DeclContext *type_decl_ctx =
939 if (decl_die != def_die) {
941 dwarf->GetDIEToType()[def_die.
GetDIE()] = type_sp.get();
948 bool is_signed =
false;
951 type_sp->
GetByteSize(
nullptr).value_or(0), def_die);
955 dwarf->GetObjectFile()->GetModule()->ReportError(
956 "DWARF DIE at {0:x16} named \"{1}\" was not able to start its "
957 "definition.\nPlease file a bug and attach the file at the "
958 "start of this error message",
964static clang::CallingConv
967 case llvm::dwarf::DW_CC_normal:
969 case llvm::dwarf::DW_CC_BORLAND_stdcall:
970 return clang::CC_X86StdCall;
971 case llvm::dwarf::DW_CC_BORLAND_msfastcall:
972 return clang::CC_X86FastCall;
973 case llvm::dwarf::DW_CC_LLVM_vectorcall:
974 return clang::CC_X86VectorCall;
975 case llvm::dwarf::DW_CC_BORLAND_pascal:
976 return clang::CC_X86Pascal;
977 case llvm::dwarf::DW_CC_LLVM_Win64:
978 return clang::CC_Win64;
979 case llvm::dwarf::DW_CC_LLVM_X86_64SysV:
980 return clang::CC_X86_64SysV;
981 case llvm::dwarf::DW_CC_LLVM_X86RegCall:
982 return clang::CC_X86RegCall;
987 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
988 LLDB_LOG(log,
"Unsupported DW_AT_calling_convention value: {0}",
1001 const auto tag = die.
Tag();
1006 TypeSP complete_objc_class_type_sp =
1007 dwarf->FindCompleteObjCDefinitionTypeForDIE(
DWARFDIE(), class_name,
1010 if (!complete_objc_class_type_sp)
1014 complete_objc_class_type_sp->GetForwardCompilerType();
1016 if (!type_clang_forward_type)
1026 if (!objc_method_decl) {
1027 dwarf->GetObjectFile()->GetModule()->ReportError(
1028 "[{0:x16}]: invalid Objective-C method {1:x4} ({2}), "
1029 "please file a bug and attach the file at the start of "
1030 "this error message",
1044 bool is_static,
bool &ignore_containing_context) {
1045 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
1049 Type *class_type =
dwarf->ResolveType(decl_ctx_die);
1053 if (class_type->
GetID() != decl_ctx_die.
GetID() ||
1060 std::vector<DWARFDIE> failures;
1072 return {
true, type_ptr->shared_from_this()};
1086 clang::DeclContext *spec_clang_decl_ctx =
1088 if (spec_clang_decl_ctx)
1091 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1092 "{0:x8}: DW_AT_specification({1:x16}"
1096 return {
true,
nullptr};
1108 if (abs_clang_decl_ctx)
1111 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1112 "{0:x8}: DW_AT_abstract_origin({1:x16}"
1116 return {
true,
nullptr};
1132 return {
true,
nullptr};
1134 const bool is_attr_used =
false;
1138 const auto accessibility =
1147 if (cxx_method_decl) {
1153 char const *object_pointer_name =
1155 if (object_pointer_name) {
1157 LLDB_LOGF(log,
"Setting object pointer name: %s on method object %p.\n",
1158 object_pointer_name,
static_cast<void *
>(cxx_method_decl));
1162 ignore_containing_context =
true;
1167 const bool type_handled = cxx_method_decl !=
nullptr || attrs.
is_artificial;
1169 return {type_handled,
nullptr};
1175 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
1180 bool is_variadic =
false;
1181 bool is_static =
false;
1182 bool has_template_params =
false;
1184 unsigned type_quals = 0;
1190 Type *func_type =
nullptr;
1200 std::vector<CompilerType> function_param_types;
1201 std::vector<clang::ParmVarDecl *> function_param_decls;
1206 clang::DeclContext *containing_decl_ctx =
1208 const clang::Decl::Kind containing_decl_kind =
1209 containing_decl_ctx->getDeclKind();
1215 if (is_cxx_method) {
1220 bool skip_artificial =
true;
1222 is_variadic, has_template_params,
1223 function_param_types, function_param_decls,
1227 bool ignore_containing_context =
false;
1238 if (is_cxx_method && has_template_params) {
1239 ignore_containing_context =
true;
1240 is_cxx_method =
false;
1243 clang::CallingConv calling_convention =
1250 function_param_types.size(), is_variadic,
1251 type_quals, calling_convention, attrs.
ref_qual);
1254 bool type_handled =
false;
1255 if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
1256 if (std::optional<const ObjCLanguage::MethodName> objc_method =
1261 }
else if (is_cxx_method) {
1262 auto [handled, type_sp] =
1264 ignore_containing_context);
1268 type_handled = handled;
1272 if (!type_handled) {
1273 clang::FunctionDecl *function_decl =
nullptr;
1274 clang::FunctionDecl *template_function_decl =
nullptr;
1279 if (
dwarf->ResolveType(abs_die)) {
1280 function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
1283 if (function_decl) {
1289 if (!function_decl) {
1290 char *name_buf =
nullptr;
1297 llvm::ItaniumPartialDemangler D;
1299 name_buf = D.getFunctionBaseName(
nullptr,
nullptr);
1307 : containing_decl_ctx,
1310 std::free(name_buf);
1312 if (has_template_params) {
1317 : containing_decl_ctx,
1320 clang::FunctionTemplateDecl *func_template_decl =
1323 template_function_decl, template_param_infos);
1325 template_function_decl, func_template_decl, template_param_infos);
1330 if (function_decl) {
1342 function_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(
1347 if (!function_param_decls.empty()) {
1349 if (template_function_decl)
1351 function_param_decls);
1357 char const *object_pointer_name =
1359 if (object_pointer_name) {
1362 "Setting object pointer name: %s on function "
1364 object_pointer_name,
static_cast<void *
>(function_decl));
1371 return dwarf->MakeType(
1385 Type *element_type =
dwarf->ResolveTypeUID(type_die,
true);
1394 byte_stride = array_info->byte_stride;
1395 bit_stride = array_info->bit_stride;
1397 if (byte_stride == 0 && bit_stride == 0)
1398 byte_stride = element_type->
GetByteSize(
nullptr).value_or(0);
1402 uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
1404 if (array_info && array_info->element_orders.size() > 0) {
1405 auto end = array_info->element_orders.rend();
1406 for (
auto pos = array_info->element_orders.rbegin(); pos != end; ++pos) {
1408 array_element_type, *pos, attrs.
is_vector);
1410 uint64_t num_elements = pos->value_or(0);
1411 array_element_type = clang_type;
1412 array_element_bit_stride = num_elements
1413 ? array_element_bit_stride * num_elements
1414 : array_element_bit_stride;
1418 array_element_type, std::nullopt, attrs.
is_vector);
1422 dwarf->MakeType(die.
GetID(), empty_name, array_element_bit_stride / 8,
1424 &attrs.
decl, clang_type, Type::ResolveState::Full);
1425 type_sp->SetEncodingType(element_type);
1440 if ((class_type ==
nullptr) || (pointee_type ==
nullptr))
1447 class_clang_type, pointee_clang_type);
1449 if (std::optional<uint64_t> clang_type_size =
1451 return dwarf->MakeType(die.
GetID(), attrs.
name, *clang_type_size,
nullptr,
1453 clang_type, Type::ResolveState::Forward);
1462 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
1471 if (attributes.
Size() == 0)
1475 AccessType accessibility = default_accessibility;
1476 bool is_virtual =
false;
1477 bool is_base_of_class =
true;
1478 off_t member_byte_offset = 0;
1480 for (uint32_t i = 0; i < attributes.
Size(); ++i) {
1486 encoding_form = form_value;
1488 case DW_AT_data_member_location:
1489 if (
auto maybe_offset =
1491 member_byte_offset = *maybe_offset;
1494 case DW_AT_accessibility:
1499 case DW_AT_virtuality:
1500 is_virtual = form_value.
Boolean();
1510 if (base_class_type ==
nullptr) {
1511 module_sp->ReportError(
"{0:x16}: DW_TAG_inheritance failed to "
1512 "resolve the base class at {1:x16}"
1513 " from enclosing type {2:x16}. \nPlease file "
1514 "a bug and attach the file at the start of "
1515 "this error message",
1523 assert(base_class_clang_type);
1525 ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
1528 std::unique_ptr<clang::CXXBaseSpecifier> result =
1530 accessibility, is_virtual,
1535 base_classes.push_back(std::move(result));
1553 clang::CharUnits::fromQuantity(member_byte_offset)));
1566 if (sc_parent_tag == DW_TAG_compile_unit ||
1567 sc_parent_tag == DW_TAG_partial_unit) {
1569 }
else if (sc.
function !=
nullptr && sc_parent_die) {
1570 symbol_context_scope =
1572 if (symbol_context_scope ==
nullptr)
1573 symbol_context_scope = sc.
function;
1575 symbol_context_scope = sc.
module_sp.get();
1578 if (symbol_context_scope !=
nullptr)
1579 type_sp->SetSymbolContextScope(symbol_context_scope);
1593 decl_declaration.
Clear();
1594 std::string qualified_name;
1597 while (parent_decl_ctx_die) {
1601 const dw_tag_t parent_tag = parent_decl_ctx_die.
Tag();
1602 switch (parent_tag) {
1603 case DW_TAG_namespace: {
1604 if (
const char *namespace_name = parent_decl_ctx_die.
GetName()) {
1605 qualified_name.insert(0,
"::");
1606 qualified_name.insert(0, namespace_name);
1608 qualified_name.insert(0,
"(anonymous namespace)::");
1614 case DW_TAG_class_type:
1615 case DW_TAG_structure_type:
1616 case DW_TAG_union_type: {
1617 if (
const char *class_union_struct_name = parent_decl_ctx_die.
GetName()) {
1618 qualified_name.insert(
1620 qualified_name.insert(0,
"::");
1621 qualified_name.insert(0, class_union_struct_name);
1628 parent_decl_ctx_die.
Clear();
1633 if (qualified_name.empty())
1634 qualified_name.append(
"::");
1636 qualified_name.append(unique_typename.
GetCString());
1650 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
1654 uint64_t byte_size = attrs.
byte_size.value_or(0);
1674 dwarf->GetUniqueDWARFASTTypeMap().Find(
1675 unique_typename, die, unique_decl, byte_size,
1677 if (
TypeSP type_sp = unique_ast_entry_type->m_type_sp) {
1678 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1685 unique_ast_entry_type->m_is_forward_declaration) {
1686 unique_ast_entry_type->UpdateToDefDIE(die, unique_decl, byte_size);
1687 clang_type = type_sp->GetForwardCompilerType();
1691 dwarf->GetForwardDeclCompilerTypeToDIE().insert_or_assign(
1703 int tag_decl_kind = -1;
1705 if (tag == DW_TAG_structure_type) {
1706 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Struct);
1708 }
else if (tag == DW_TAG_union_type) {
1709 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Union);
1711 }
else if (tag == DW_TAG_class_type) {
1712 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Class);
1726 dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.
name,
true);
1730 if (debug_map_symfile) {
1734 die, attrs.
name,
true);
1740 dwarf->GetObjectFile()->GetModule()->LogMessage(
1742 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an "
1743 "incomplete objc type, complete type is {5:x8}",
1759 assert(tag_decl_kind != -1);
1761 clang::DeclContext *containing_decl_ctx =
1765 containing_decl_ctx, die,
1771 const clang::Decl::Kind containing_decl_kind =
1772 containing_decl_ctx->getDeclKind();
1783 clang::ClassTemplateDecl *class_template_decl =
1787 if (!class_template_decl) {
1789 dwarf->GetObjectFile()->GetModule()->LogMessage(
1791 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" "
1792 "clang::ClassTemplateDecl failed to return a decl.",
1799 clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1802 tag_decl_kind, template_param_infos);
1820 Type::ResolveState::Forward,
1826 clang::DeclContext *type_decl_ctx =
1834 auto unique_ast_entry_up = std::make_unique<UniqueDWARFASTType>();
1838 unique_ast_entry_up->m_type_sp = type_sp;
1839 unique_ast_entry_up->m_die = die;
1840 unique_ast_entry_up->m_declaration = unique_decl;
1841 unique_ast_entry_up->m_byte_size = byte_size;
1843 dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
1844 *unique_ast_entry_up);
1852 dwarf->GetForwardDeclCompilerTypeToDIE()
1857 assert(inserted &&
"Type already in the forward declaration map!");
1866 clang::CXXRecordDecl *record_decl =
1868 if (record_decl && record_decl->getDefinition()) {
1869 record_decl->setHasTrivialSpecialMemberForCall();
1874 clang::CXXRecordDecl *record_decl =
1877 record_decl->setArgPassingRestrictions(
1878 clang::RecordArgPassingKind::CannotPassInRegs);
1888 const CompilerType &class_opaque_type,
const char *property_name,
1892 const char *property_setter_name,
const char *property_getter_name,
1921 bool is_template_template_argument =
false;
1924 case DW_TAG_GNU_template_parameter_pack: {
1926 std::make_unique<TypeSystemClang::TemplateParameterInfos>());
1931 if (
const char *name = die.
GetName()) {
1936 case DW_TAG_GNU_template_template_param:
1937 is_template_template_argument =
true;
1939 case DW_TAG_template_type_parameter:
1940 case DW_TAG_template_value_parameter: {
1942 if (attributes.
Size() == 0)
1945 const char *name =
nullptr;
1946 const char *template_name =
nullptr;
1948 uint64_t uval64 = 0;
1949 bool uval64_valid =
false;
1950 bool is_default_template_arg =
false;
1952 for (
size_t i = 0; i < attributes.
Size(); ++i) {
1961 case DW_AT_GNU_template_name:
1974 case DW_AT_const_value:
1976 uval64_valid =
true;
1980 case DW_AT_default_value:
1982 is_default_template_arg = form_value.
Boolean();
1993 if (!is_template_template_argument) {
1994 bool is_signed =
false;
1998 if (name && !name[0])
2001 if (tag == DW_TAG_template_value_parameter && uval64_valid) {
2002 std::optional<uint64_t> size = clang_type.
GetBitSize(
nullptr);
2005 llvm::APInt apint(*size, uval64, is_signed);
2007 name, clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed),
2009 is_default_template_arg));
2014 is_default_template_arg));
2019 name, clang::TemplateArgument(clang::TemplateName(tplt_type),
2020 is_default_template_arg));
2042 case DW_TAG_template_type_parameter:
2043 case DW_TAG_template_value_parameter:
2044 case DW_TAG_GNU_template_parameter_pack:
2045 case DW_TAG_GNU_template_template_param:
2054 return !template_param_infos.
IsEmpty() ||
2065 std::vector<DWARFDIE> contained_type_dies;
2077 if (tag == DW_TAG_structure_type) {
2079 }
else if (tag == DW_TAG_union_type) {
2081 }
else if (tag == DW_TAG_class_type) {
2085 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
2087 std::vector<DWARFDIE> member_function_dies;
2091 contained_type_dies, delayed_properties,
2092 default_accessibility, layout_info);
2095 for (
const DWARFDIE &die : member_function_dies)
2096 dwarf->ResolveType(die);
2101 dwarf->GetObjCMethods(class_name, [&](
DWARFDIE method_die) {
2107 property.Finalize();
2111 if (!bases.empty()) {
2115 for (
const auto &base_class : bases) {
2116 clang::TypeSourceInfo *type_source_info = base_class->getTypeSourceInfo();
2117 if (type_source_info)
2138 clang::CXXRecordDecl *record_decl =
2147 for (
const DWARFDIE &die : contained_type_dies)
2148 dwarf->ResolveType(die);
2150 return (
bool)clang_type;
2158 bool is_signed =
false;
2165 return (
bool)clang_type;
2173 std::lock_guard<std::recursive_mutex> guard(
2174 dwarf->GetObjectFile()->GetModule()->GetMutex());
2187 case DW_TAG_structure_type:
2188 case DW_TAG_union_type:
2189 case DW_TAG_class_type:
2192 case DW_TAG_enumeration_type:
2196 assert(
false &&
"not a forward clang type decl!");
2213 auto opaque_decl_ctx =
2224 if (clang_decl !=
nullptr)
2239 clang::DeclContext *clang_decl_ctx =
2248 uint32_t enumerator_byte_size,
const DWARFDIE &parent_die) {
2252 size_t enumerators_added = 0;
2256 if (tag != DW_TAG_enumerator)
2260 if (attributes.
Size() == 0)
2263 const char *name =
nullptr;
2264 bool got_value =
false;
2265 int64_t enum_value = 0;
2268 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2273 case DW_AT_const_value:
2276 enum_value = form_value.
Signed();
2278 enum_value = form_value.
Unsigned();
2285 case DW_AT_description:
2287 case DW_AT_decl_file:
2291 case DW_AT_decl_line:
2294 case DW_AT_decl_column:
2303 if (name && name[0] && got_value) {
2305 clang_type, decl, name, enum_value, enumerator_byte_size * 8);
2306 ++enumerators_added;
2309 return enumerators_added;
2314 bool is_static =
false;
2315 bool is_variadic =
false;
2316 bool has_template_params =
false;
2317 unsigned type_quals = 0;
2318 std::vector<CompilerType> param_types;
2319 std::vector<clang::ParmVarDecl *> param_decls;
2325 clang::DeclContext *containing_decl_ctx =
2328 has_template_params, param_types, param_decls,
2331 for (
size_t i = 0; i < param_types.size(); i++) {
2334 sstr << param_types[i].GetTypeName();
2339 if (type_quals & clang::Qualifiers::Const)
2351 const char *name =
nullptr;
2352 const char *mangled =
nullptr;
2353 std::optional<int> decl_file;
2354 std::optional<int> decl_line;
2355 std::optional<int> decl_column;
2356 std::optional<int> call_file;
2357 std::optional<int> call_line;
2358 std::optional<int> call_column;
2363 if (tag != DW_TAG_subprogram)
2367 decl_column, call_file, call_line, call_column,
2372 else if ((die.
GetParent().
Tag() == DW_TAG_compile_unit ||
2378 name && strcmp(name,
"main") != 0) {
2387 std::unique_ptr<Declaration> decl_up;
2388 if (decl_file || decl_line || decl_column)
2389 decl_up = std::make_unique<Declaration>(
2391 decl_line ? *decl_line : 0, decl_column ? *decl_column : 0);
2401 std::make_shared<Function>(&comp_unit,
2403 func_user_id, func_name, func_type,
2406 if (func_sp.get() !=
nullptr) {
2408 func_sp->GetFrameBaseExpression() = frame_base;
2410 return func_sp.get();
2419struct PropertyAttributes {
2420 explicit PropertyAttributes(
const DWARFDIE &die);
2421 const char *prop_name =
nullptr;
2422 const char *prop_getter_name =
nullptr;
2423 const char *prop_setter_name =
nullptr;
2425 uint32_t prop_attributes = 0;
2428struct DiscriminantValue {
2431 uint32_t byte_offset;
2436struct VariantMember {
2438 bool IsDefault()
const;
2440 std::optional<uint32_t> discr_value;
2443 uint32_t byte_offset;
2451 std::vector<VariantMember> &members();
2453 DiscriminantValue &discriminant();
2456 std::vector<VariantMember> _members;
2457 DiscriminantValue _discriminant;
2462ConstString VariantMember::GetName()
const {
return this->variant_name; }
2464bool VariantMember::IsDefault()
const {
return !discr_value; }
2467 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant);
2471 for (
auto child_die : die.
children()) {
2472 switch (child_die.Tag()) {
2473 case llvm::dwarf::DW_TAG_member: {
2475 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2484 type_ref = form_value;
2487 case DW_AT_data_member_location:
2488 if (
auto maybe_offset =
2490 byte_offset = *maybe_offset;
2507DiscriminantValue::DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp) {
2510 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2516 type_ref = form_value;
2518 case DW_AT_data_member_location:
2519 if (
auto maybe_offset =
2521 byte_offset = *maybe_offset;
2532 : _members(), _discriminant(die, module_sp) {
2534 for (
auto child : die.
children()) {
2535 if (child.Tag() == llvm::dwarf::DW_TAG_variant) {
2536 _members.push_back(VariantMember(child, module_sp));
2541std::vector<VariantMember> &VariantPart::members() {
return this->_members; }
2543DiscriminantValue &VariantPart::discriminant() {
return this->_discriminant; }
2548 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2559 case DW_AT_bit_offset:
2562 case DW_AT_bit_size:
2565 case DW_AT_byte_size:
2568 case DW_AT_const_value:
2571 case DW_AT_data_bit_offset:
2574 case DW_AT_data_member_location:
2575 if (
auto maybe_offset =
2580 case DW_AT_accessibility:
2584 case DW_AT_artificial:
2587 case DW_AT_declaration:
2614PropertyAttributes::PropertyAttributes(
const DWARFDIE &die) {
2617 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2622 case DW_AT_APPLE_property_name:
2625 case DW_AT_APPLE_property_getter:
2626 prop_getter_name = form_value.
AsCString();
2628 case DW_AT_APPLE_property_setter:
2629 prop_setter_name = form_value.
AsCString();
2631 case DW_AT_APPLE_property_attribute:
2632 prop_attributes = form_value.
Unsigned();
2646 if (prop_getter_name && prop_getter_name[0] ==
'-') {
2647 std::optional<const ObjCLanguage::MethodName> prop_getter_method =
2649 if (prop_getter_method)
2654 if (prop_setter_name && prop_setter_name[0] ==
'-') {
2655 std::optional<const ObjCLanguage::MethodName> prop_setter_method =
2657 if (prop_setter_method)
2663 if (!prop_getter_name)
2664 prop_getter_name = prop_name;
2665 if (!prop_setter_name && prop_name[0] &&
2666 !(prop_attributes & DW_APPLE_PROPERTY_readonly)) {
2669 ss.
Printf(
"set%c%s:", toupper(prop_name[0]), &prop_name[1]);
2672 prop_setter_name = fixed_setter.
GetCString();
2681 assert(die.
Tag() == DW_TAG_APPLE_property);
2686 const PropertyAttributes propAttrs(die);
2688 if (!propAttrs.prop_name) {
2689 module_sp->ReportError(
"{0:x8}: DW_TAG_APPLE_property has no name.",
2696 module_sp->ReportError(
2697 "{0:x8}: DW_TAG_APPLE_property '{1}' refers to type {2:x16}"
2698 " which was unable to be parsed",
2699 die.
GetID(), propAttrs.prop_name,
2706 delayed_properties.emplace_back(
2707 class_clang_type, propAttrs.prop_name,
2709 propAttrs.prop_getter_name, propAttrs.prop_attributes, metadata);
2715 assert(qt->isIntegralOrEnumerationType());
2718 return llvm::createStringError(llvm::inconvertibleErrorCode(),
2719 "TypeSystem not clang");
2723 const unsigned type_bits = ast.getIntWidth(qt);
2724 const bool is_unsigned = qt->isUnsignedIntegerType();
2728 constexpr std::size_t max_bit_size = 64;
2733 if (type_bits > max_bit_size) {
2734 auto msg = llvm::formatv(
"Can only parse integers with up to {0} bits, but "
2735 "given integer has {1} bits.",
2736 max_bit_size, type_bits);
2737 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2741 llvm::APInt result(max_bit_size, form_value.
Unsigned(), !is_unsigned);
2747 const unsigned required_bits =
2748 is_unsigned ? result.getActiveBits() : result.getSignificantBits();
2751 if (required_bits > type_bits) {
2752 std::string value_as_str = is_unsigned
2753 ? std::to_string(form_value.
Unsigned())
2754 : std::to_string(form_value.
Signed());
2755 auto msg = llvm::formatv(
"Can't store {0} value {1} in integer with {2} "
2757 (is_unsigned ?
"unsigned" :
"signed"),
2758 value_as_str, type_bits);
2759 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2763 if (result.getBitWidth() > type_bits)
2764 result = result.trunc(type_bits);
2771 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
2772 assert(die.
Tag() == DW_TAG_member || die.
Tag() == DW_TAG_variable);
2779 auto accessibility =
2784 class_clang_type, attrs.
name, ct, accessibility);
2786 LLDB_LOG(log,
"Failed to add variable to the record type");
2795 llvm::Expected<llvm::APInt> const_value_or_err =
2797 if (!const_value_or_err) {
2799 "Failed to add const value to variable {1}: {0}",
2800 v->getQualifiedNameAsString());
2814 assert(die.
Tag() == DW_TAG_member);
2819 const uint64_t parent_byte_size =
2821 const uint64_t parent_bit_size =
2846 module_sp->ReportError(
2847 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
2848 " which was unable to be parsed",
2851 module_sp->ReportError(
"{0:x8}: DW_TAG_member refers to type {1:x16}"
2852 " which was unable to be parsed",
2858 const uint64_t character_width = 8;
2859 const uint64_t word_width = 32;
2863 ? default_accessibility
2872 this_field_info.
bit_offset = field_bit_offset;
2884 this_field_info.
bit_offset += byte_size.value_or(0) * 8;
2898 !(parent_die.
Tag() == DW_TAG_union_type &&
2900 ((this_field_info.
bit_offset >= parent_bit_size) ||
2906 "{0:x16}: {1} ({2}) bitfield named \"{3}\" has invalid "
2907 "bit offset ({4:x8}) member will be ignored. Please file a bug "
2909 "compiler and include the preprocessed output for {5}\n",
2916 field_bit_offset = this_field_info.
bit_offset;
2921 bool detect_unnamed_bitfields =
true;
2924 detect_unnamed_bitfields =
2927 if (detect_unnamed_bitfields) {
2928 std::optional<FieldInfo> unnamed_field_info;
2929 uint64_t last_field_end =
2937 if (last_field_end != 0 && ((last_field_end % word_width) != 0))
2938 last_field_end += word_width - (last_field_end % word_width);
2942 this_field_info, layout_info)) {
2946 unnamed_field_info->bit_offset = last_field_end;
2949 if (unnamed_field_info) {
2950 clang::FieldDecl *unnamed_bitfield_decl =
2952 class_clang_type, llvm::StringRef(),
2955 accessibility, unnamed_field_info->bit_size);
2958 unnamed_bitfield_decl, unnamed_field_info->bit_offset));
2962 last_field_info = this_field_info;
2965 last_field_info.
bit_offset = field_bit_offset;
2967 if (std::optional<uint64_t> clang_type_size =
2969 last_field_info.
bit_size = *clang_type_size * character_width;
2995 uint64_t member_array_size;
2996 bool member_array_is_incomplete;
2998 if (member_clang_type.
IsArrayType(&member_array_element_type,
3000 &member_array_is_incomplete) &&
3001 !member_array_is_incomplete) {
3002 uint64_t parent_byte_size =
3006 if (member_array_size != 1 &&
3007 (member_array_size != 0 ||
3009 module_sp->ReportError(
3010 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
3011 " which extends beyond the bounds of {3:x8}",
3025 class_clang_type, attrs.
name, member_clang_type, accessibility,
3031 std::make_pair(field_decl, field_bit_offset));
3036 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
3037 std::vector<DWARFDIE> &member_function_dies,
3038 std::vector<DWARFDIE> &contained_type_dies,
3057 case DW_TAG_APPLE_property:
3061 case DW_TAG_variant_part:
3064 default_accessibility, layout_info);
3068 case DW_TAG_variable: {
3074 default_accessibility, layout_info, last_field_info);
3077 case DW_TAG_subprogram:
3079 member_function_dies.push_back(die);
3082 case DW_TAG_inheritance:
3084 module_sp, base_classes, layout_info);
3088 if (llvm::dwarf::isType(tag))
3089 contained_type_dies.push_back(die);
3098 clang::DeclContext *containing_decl_ctx,
const DWARFDIE &parent_die,
3099 bool skip_artificial,
bool &is_static,
bool &is_variadic,
3100 bool &has_template_params, std::vector<CompilerType> &function_param_types,
3101 std::vector<clang::ParmVarDecl *> &function_param_decls,
3102 unsigned &type_quals) {
3110 case DW_TAG_formal_parameter: {
3112 if (attributes.
Size() == 0) {
3117 const char *name =
nullptr;
3119 bool is_artificial =
false;
3122 clang::StorageClass storage = clang::SC_None;
3124 for (i = 0; i < attributes.
Size(); ++i) {
3133 param_type_die_form = form_value;
3135 case DW_AT_artificial:
3136 is_artificial = form_value.
Boolean();
3138 case DW_AT_location:
3139 case DW_AT_const_value:
3140 case DW_AT_default_value:
3141 case DW_AT_description:
3142 case DW_AT_endianity:
3143 case DW_AT_is_optional:
3145 case DW_AT_variable_parameter:
3147 case DW_AT_abstract_origin:
3155 if (skip_artificial && is_artificial) {
3163 (name ==
nullptr || ::strcmp(name,
"this") == 0)) {
3171 type_quals |= clang::Qualifiers::Const;
3173 type_quals |= clang::Qualifiers::Volatile;
3188 assert(param_var_decl);
3189 function_param_decls.push_back(param_var_decl);
3197 case DW_TAG_unspecified_parameters:
3201 case DW_TAG_template_type_parameter:
3202 case DW_TAG_template_value_parameter:
3203 case DW_TAG_GNU_template_parameter_pack:
3209 has_template_params =
true;
3223 switch (die.
Tag()) {
3224 case DW_TAG_constant:
3225 case DW_TAG_formal_parameter:
3226 case DW_TAG_imported_declaration:
3227 case DW_TAG_imported_module:
3229 case DW_TAG_variable:
3243 return cache_pos->second;
3258 clang::Decl *decl =
nullptr;
3259 switch (die.
Tag()) {
3260 case DW_TAG_variable:
3261 case DW_TAG_constant:
3262 case DW_TAG_formal_parameter: {
3265 if (
dwarf && type) {
3266 const char *name = die.
GetName();
3267 clang::DeclContext *decl_context =
3269 dwarf->GetDeclContextContainingUID(die.
GetID()));
3276 case DW_TAG_imported_declaration: {
3281 if (imported_decl) {
3282 clang::DeclContext *decl_context =
3284 dwarf->GetDeclContextContainingUID(die.
GetID()));
3285 if (clang::NamedDecl *clang_imported_decl =
3286 llvm::dyn_cast<clang::NamedDecl>(
3294 case DW_TAG_imported_module: {
3301 if (imported_decl_ctx) {
3302 clang::DeclContext *decl_context =
3304 dwarf->GetDeclContextContainingUID(die.
GetID()));
3305 if (clang::NamespaceDecl *ns_decl =
3330 bool try_parsing_type =
true;
3331 switch (die.
Tag()) {
3332 case DW_TAG_compile_unit:
3333 case DW_TAG_partial_unit:
3335 try_parsing_type =
false;
3338 case DW_TAG_namespace:
3340 try_parsing_type =
false;
3343 case DW_TAG_imported_declaration:
3345 try_parsing_type =
false;
3348 case DW_TAG_lexical_block:
3350 try_parsing_type =
false;
3357 if (decl_ctx ==
nullptr && try_parsing_type) {
3377 parent = parent.GetParent()) {
3379 if (tag == DW_TAG_module) {
3399 switch (die.
Tag()) {
3400 case DW_TAG_subprogram:
3401 case DW_TAG_inlined_subroutine:
3411 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3418 assert(0 &&
"Shouldn't call GetContainingFunctionWithAbstractOrigin on "
3419 "something not in a function");
3425 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3447 assert(die.
Tag() == DW_TAG_lexical_block);
3448 DWARFDIE containing_function_with_abstract_origin =
3450 if (!containing_function_with_abstract_origin) {
3454 die, containing_function_with_abstract_origin);
3461 if (die && die.
Tag() == DW_TAG_lexical_block) {
3462 clang::BlockDecl *decl =
3467 clang::DeclContext *decl_context =
3481clang::NamespaceDecl *
3483 if (die && die.
Tag() == DW_TAG_namespace) {
3486 clang::NamespaceDecl *namespace_decl =
3489 return namespace_decl;
3491 const char *namespace_name = die.
GetName();
3492 clang::DeclContext *containing_decl_ctx =
3503 return namespace_decl;
3509clang::NamespaceDecl *
3511 assert(die && die.
Tag() == DW_TAG_imported_declaration);
3517 return static_cast<clang::NamespaceDecl *
>(it->getSecond());
3519 clang::NamespaceDecl *namespace_decl =
nullptr;
3526 switch (imported_uid.
Tag()) {
3527 case DW_TAG_imported_declaration:
3530 case DW_TAG_namespace:
3537 if (!namespace_decl)
3542 return namespace_decl;
3549 DWARFDIE decl_ctx_die =
dwarf->GetDeclContextDIEContainingDIE(die);
3551 if (decl_ctx_die_copy)
3552 *decl_ctx_die_copy = decl_ctx_die;
3555 clang::DeclContext *clang_decl_ctx =
3558 return clang_decl_ctx;
3584 if (!class_type || !src_class_die || !dst_class_die)
3586 if (src_class_die.
Tag() != dst_class_die.
Tag())
3596 if (die.
Tag() != DW_TAG_subprogram)
3608 map_artificial.Append(const_name, die);
3610 map.Append(const_name, die);
3619 src_die = src_die.GetSibling()) {
3620 gather(src_die, src_name_to_die, src_name_to_die_artificial);
3623 dst_die = dst_die.GetSibling()) {
3624 gather(dst_die, dst_name_to_die, dst_name_to_die_artificial);
3626 const uint32_t src_size = src_name_to_die.
GetSize();
3627 const uint32_t dst_size = dst_name_to_die.
GetSize();
3630 bool fast_path =
true;
3632 if (src_size != dst_size)
3638 for (idx = 0; idx < src_size; ++idx) {
3642 if (src_die.
Tag() != dst_die.
Tag())
3649 if (src_name == dst_name || (strcmp(src_name, dst_name) == 0))
3665 clang::DeclContext *dst_decl_ctx =
3670 if (
Type *src_child_type = die_to_type.lookup(src.
GetDIE()))
3671 die_to_type[dst.GetDIE()] = src_child_type;
3678 for (idx = 0; idx < src_size; ++idx) {
3688 src_name_to_die.
Sort();
3690 for (idx = 0; idx < dst_size; ++idx) {
3695 if (src_die && (src_die.
Tag() == dst_die.
Tag()))
3696 link(src_die, dst_die);
3698 failures.push_back(dst_die);
3703 const uint32_t src_size_artificial = src_name_to_die_artificial.
GetSize();
3704 const uint32_t dst_size_artificial = dst_name_to_die_artificial.
GetSize();
3706 if (src_size_artificial && dst_size_artificial) {
3707 dst_name_to_die_artificial.
Sort();
3709 for (idx = 0; idx < src_size_artificial; ++idx) {
3715 dst_name_to_die_artificial.
Find(src_name_artificial,
DWARFDIE());
3719 link(src_die, dst_die);
3723 if (dst_size_artificial) {
3724 for (idx = 0; idx < dst_size_artificial; ++idx) {
3730 return !failures.empty();
3734 FieldInfo const &last_field_info, uint64_t last_field_end,
3739 if (this_field_info.
bit_offset <= last_field_end)
3753 const bool have_base = layout_info.
base_offsets.size() != 0;
3754 const bool this_is_first_field =
3756 const bool first_field_is_vptr =
3759 if (have_base && (this_is_first_field || first_field_is_vptr))
3770 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant_part);
3772 LanguageType::eLanguageTypeRust);
3776 VariantPart variants(die, parent_die, module_sp);
3778 auto discriminant_type =
3779 die.
ResolveTypeUID(variants.discriminant().type_ref.Reference());
3786 llvm::formatv(
"{0}$Inner", class_clang_type.
GetTypeName(
false))),
3791 for (
auto member : variants.members()) {
3793 auto has_discriminant = !member.IsDefault();
3795 auto member_type = die.
ResolveTypeUID(member.type_ref.Reference());
3800 std::string(llvm::formatv(
"{0}$Variant", member.GetName())),
3801 llvm::to_underlying(clang::TagTypeKind::Struct),
3805 auto offset = member.byte_offset;
3807 if (has_discriminant) {
3809 field_type,
"$discr$", discriminant_type->GetFullCompilerType(),
3811 offset += discriminant_type->GetByteSize(
nullptr).value_or(0);
3815 member_type->GetFullCompilerType(),
3820 auto name = has_discriminant
3821 ? llvm::formatv(
"$variant${0}", member.discr_value.value())
3822 : std::string(
"$variant$");
3826 field_type, default_accesibility, 0);
3832 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
CompilerType m_property_opaque_type
const char * m_property_setter_name
uint32_t m_property_attributes
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, ClangASTMetadata metadata)
ClangASTMetadata m_metadata
const char * m_property_name
lldb::TypeSP ParsePointerToMemberType(const lldb_private::plugin::dwarf::DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs)
bool CompleteEnumType(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::Type *type, const lldb_private::CompilerType &clang_type)
void ParseRustVariantPart(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_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...
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.
bool CompleteTypeFromDWARF(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::Type *type, const lldb_private::CompilerType &compiler_type) override
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
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)
bool CompleteRecordType(const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::Type *type, const lldb_private::CompilerType &clang_type)
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.
bool ParseChildMembers(const lldb_private::plugin::dwarf::DWARFDIE &die, const 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)
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.
DIEToDeclMap m_die_to_decl
size_t ParseChildEnumerators(const lldb_private::CompilerType &compiler_type, bool is_signed, uint32_t enumerator_byte_size, const lldb_private::plugin::dwarf::DWARFDIE &parent_die)
~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.
clang::DeclContext * GetCachedClangDeclContextForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die)
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
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()
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)
CompilerType CreateArrayType(const CompilerType &element_type, std::optional< size_t > element_count, bool is_vector)
bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td)
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
static bool IsCXXClassType(const CompilerType &type)
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)
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, std::optional< ClangASTMetadata > metadata=std::nullopt, bool exports_symbols=false)
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)
static bool SetHasExternalStorage(lldb::opaque_compiler_type_t type, bool has_extern)
void SetMetadata(const clang::Decl *object, ClangASTMetadata meta_data)
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 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)
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.