40#include "clang/AST/CXXInheritance.h"
41#include "clang/AST/DeclCXX.h"
42#include "clang/AST/DeclObjC.h"
43#include "clang/AST/DeclTemplate.h"
44#include "clang/AST/Type.h"
45#include "llvm/Demangle/Demangle.h"
54#ifdef ENABLE_DEBUG_PRINTF
56#define DEBUG_PRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
58#define DEBUG_PRINTF(fmt, ...)
68 m_die_to_decl_ctx(), m_decl_ctx_to_die() {}
74 case clang::Decl::CXXRecord:
75 case clang::Decl::ClassTemplateSpecialization:
96 while (Parent.IsValid()) {
97 if (Parent.Tag() == DW_TAG_module)
110 parent = parent.GetParent()) {
112 if (tag == DW_TAG_module)
113 top_module_die = parent;
114 else if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
118 return top_module_die;
127 if (clang_module_die) {
128 const char *module_name = clang_module_die.
GetName();
140 return FieldName.starts_with(
"_vptr$")
142 || FieldName.starts_with(
"_vptr.");
145std::optional<DWARFFormValue>
147 assert(die.
Tag() == DW_TAG_member || die.
Tag() == DW_TAG_variable);
157 auto *CU = die.
GetCU();
166 dwarf->FindGlobalVariables(name, parent_decl_ctx, UINT_MAX, variables);
171 auto const &die_to_var =
dwarf->GetDIEToVariable();
172 auto it = die_to_var.find(die.
GetDIE());
173 if (it == die_to_var.end())
176 auto var_sp = it->getSecond();
177 assert(var_sp !=
nullptr);
179 if (!var_sp->GetLocationIsConstantValueData())
182 auto def =
dwarf->GetDIE(var_sp->GetID());
183 auto def_attrs = def.GetAttributes();
185 if (!def_attrs.ExtractFormValueAtIndex(
186 def_attrs.FindAttributeIndex(llvm::dwarf::DW_AT_const_value),
197 if (!clang_module_sp)
209 llvm::DenseSet<SymbolFile *> searched_symbol_files;
210 clang_module_sp->GetSymbolFile()->FindTypes(decl_context, languages,
211 searched_symbol_files, pcm_types);
212 if (pcm_types.
Empty()) {
221 searched_symbol_files.insert(&sym_file);
224 module.GetSymbolFile()->FindTypes(decl_context, languages,
225 searched_symbol_files, pcm_types);
226 return pcm_types.GetSize();
260 auto type_sp =
dwarf->MakeType(
261 die.
GetID(), pcm_type_sp->GetName(), pcm_type_sp->GetByteSize(
nullptr),
263 &pcm_type_sp->GetDeclaration(), type, Type::ResolveState::Forward,
265 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
280 lldbassert(started &&
"Unable to start a class type definition.");
294 clang::DeclContext *decl_ctx,
296 const char *type_name_cstr) {
297 auto *tag_decl_ctx = clang::dyn_cast<clang::TagDecl>(decl_ctx);
303 if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx->isBeingDefined())
312 if (type && ast_importer.
CanImport(type)) {
317 "Unable to complete the Decl context for DIE {0} at offset "
318 "{1:x16}.\nPlease file a bug report.",
319 type_name_cstr ? type_name_cstr :
"", die.
GetOffset());
329 for (
size_t i = 0; i < attributes.
Size(); ++i) {
337 case DW_AT_abstract_origin:
341 case DW_AT_accessibility:
346 case DW_AT_artificial:
350 case DW_AT_bit_stride:
354 case DW_AT_byte_size:
358 case DW_AT_alignment:
362 case DW_AT_byte_stride:
366 case DW_AT_calling_convention:
370 case DW_AT_containing_type:
374 case DW_AT_decl_file:
379 case DW_AT_decl_line:
382 case DW_AT_decl_column:
386 case DW_AT_declaration:
394 case DW_AT_enum_class:
411 case DW_AT_linkage_name:
412 case DW_AT_MIPS_linkage_name:
420 case DW_AT_object_pointer:
424 case DW_AT_signature:
428 case DW_AT_specification:
436 case DW_AT_virtuality:
440 case DW_AT_APPLE_objc_complete_type:
444 case DW_AT_APPLE_objc_direct:
448 case DW_AT_APPLE_runtime_class:
452 case DW_AT_GNU_vector:
455 case DW_AT_export_symbols:
458 case DW_AT_rvalue_reference:
461 case DW_AT_reference:
470 return unit->GetAbsolutePath().GetPath();
471 return "<missing DWARF unit path>";
476 bool *type_is_new_ptr) {
478 *type_is_new_ptr =
false;
483 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
488 clang::DeclContext *context =
491 dwarf->GetObjectFile()->GetModule()->LogMessage(
493 "DWARFASTParserClang::ParseTypeFromDWARF "
494 "(die = {0:x16}, decl_ctx = {1:p} (die "
495 "{2:x16})) {3} name = '{4}')",
504 return type_ptr->shared_from_this();
513 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
514 if (clang::DeclContext *decl_ctx =
523 *type_is_new_ptr =
true;
531 case DW_TAG_base_type:
532 case DW_TAG_pointer_type:
533 case DW_TAG_reference_type:
534 case DW_TAG_rvalue_reference_type:
535 case DW_TAG_const_type:
536 case DW_TAG_restrict_type:
537 case DW_TAG_volatile_type:
538 case DW_TAG_atomic_type:
539 case DW_TAG_unspecified_type: {
544 case DW_TAG_structure_type:
545 case DW_TAG_union_type:
546 case DW_TAG_class_type: {
551 case DW_TAG_enumeration_type: {
556 case DW_TAG_inlined_subroutine:
557 case DW_TAG_subprogram:
558 case DW_TAG_subroutine_type: {
562 case DW_TAG_array_type: {
566 case DW_TAG_ptr_to_member_type: {
571 dwarf->GetObjectFile()->GetModule()->ReportError(
572 "[{0:x16}]: unhandled type tag {1:x4} ({2}), "
573 "please file a bug and "
574 "attach the file at the start of this error message",
585static std::optional<uint32_t>
594 Value initialValue(0);
595 Value memberOffset(0);
597 uint32_t block_length = form_value.
Unsigned();
598 uint32_t block_offset =
603 module_sp,
DataExtractor(debug_info_data, block_offset, block_length),
616 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
625 if (tag == DW_TAG_typedef) {
675 encoding_uid.Reference());
681 case DW_TAG_unspecified_type:
682 if (attrs.
name ==
"nullptr_t" || attrs.
name ==
"decltype(nullptr)") {
683 resolve_state = Type::ResolveState::Full;
691 case DW_TAG_base_type:
692 resolve_state = Type::ResolveState::Full;
698 case DW_TAG_pointer_type:
701 case DW_TAG_reference_type:
704 case DW_TAG_rvalue_reference_type:
710 case DW_TAG_const_type:
713 case DW_TAG_restrict_type:
716 case DW_TAG_volatile_type:
719 case DW_TAG_atomic_type:
726 if (tag == DW_TAG_pointer_type) {
734 if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name,
""),
739 if (function_pointer_type) {
743 bool function_type_is_new_pointer;
745 sc, function_type, &function_type_is_new_pointer);
747 if (lldb_function_type_sp) {
749 lldb_function_type_sp->GetForwardCompilerType());
752 resolve_state = Type::ResolveState::Full;
765 if (attrs.
name ==
"id") {
767 dwarf->GetObjectFile()->GetModule()->LogMessage(
769 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' "
770 "is Objective-C 'id' built-in type.",
775 resolve_state = Type::ResolveState::Full;
776 }
else if (attrs.
name ==
"Class") {
778 dwarf->GetObjectFile()->GetModule()->LogMessage(
780 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' "
781 "is Objective-C 'Class' built-in type.",
786 resolve_state = Type::ResolveState::Full;
787 }
else if (attrs.
name ==
"SEL") {
789 dwarf->GetObjectFile()->GetModule()->LogMessage(
791 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} '{2}' "
792 "is Objective-C 'selector' built-in type.",
797 resolve_state = Type::ResolveState::Full;
806 if (encoding_die && encoding_die.
Tag() == DW_TAG_structure_type) {
807 llvm::StringRef struct_name = encoding_die.
GetName();
808 if (struct_name ==
"objc_object") {
810 dwarf->GetObjectFile()->GetModule()->LogMessage(
812 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} "
813 "'{2}' is 'objc_object*', which we overrode to "
819 resolve_state = Type::ResolveState::Full;
828 &attrs.
decl, clang_type, resolve_state,
831 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
837 if (llvm::StringRef(die.
GetName()).contains(
"<"))
850 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
860 type_sp =
dwarf->FindDefinitionTypeForDWARFDeclContext(die);
864 if (debug_map_symfile) {
873 dwarf->GetObjectFile()->GetModule()->LogMessage(
875 "SymbolFileDWARF({0:p}) - {1:x16}}: {2} type \"{3}\" is a "
876 "forward declaration, complete type is {4:x8}",
877 static_cast<void *
>(
this), die.
GetOffset(),
885 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
886 clang::DeclContext *defn_decl_ctx =
899 m_ast.weak_from_this(),
900 dwarf->GetForwardDeclDIEToCompilerType().lookup(die.
GetDIE()));
903 Type *enumerator_type =
909 if (!enumerator_clang_type) {
912 "", DW_ATE_signed, *attrs.
byte_size * 8);
932 &attrs.
decl, clang_type, Type::ResolveState::Forward,
937 bool is_signed =
false;
944 dwarf->GetObjectFile()->GetModule()->ReportError(
945 "DWARF DIE at {0:x16} named \"{1}\" was not able to start its "
946 "definition.\nPlease file a bug and attach the file at the "
947 "start of this error message",
953static clang::CallingConv
956 case llvm::dwarf::DW_CC_normal:
958 case llvm::dwarf::DW_CC_BORLAND_stdcall:
959 return clang::CC_X86StdCall;
960 case llvm::dwarf::DW_CC_BORLAND_msfastcall:
961 return clang::CC_X86FastCall;
962 case llvm::dwarf::DW_CC_LLVM_vectorcall:
963 return clang::CC_X86VectorCall;
964 case llvm::dwarf::DW_CC_BORLAND_pascal:
965 return clang::CC_X86Pascal;
966 case llvm::dwarf::DW_CC_LLVM_Win64:
967 return clang::CC_Win64;
968 case llvm::dwarf::DW_CC_LLVM_X86_64SysV:
969 return clang::CC_X86_64SysV;
970 case llvm::dwarf::DW_CC_LLVM_X86RegCall:
971 return clang::CC_X86RegCall;
976 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
977 LLDB_LOG(log,
"Unsupported DW_AT_calling_convention value: {0}",
986 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
991 bool is_variadic =
false;
992 bool is_static =
false;
993 bool has_template_params =
false;
995 unsigned type_quals = 0;
997 std::string object_pointer_name;
1000 if (object_pointer_name_cstr)
1001 object_pointer_name = object_pointer_name_cstr;
1008 Type *func_type =
nullptr;
1018 std::vector<CompilerType> function_param_types;
1019 std::vector<clang::ParmVarDecl *> function_param_decls;
1024 clang::DeclContext *containing_decl_ctx =
1026 const clang::Decl::Kind containing_decl_kind =
1027 containing_decl_ctx->getDeclKind();
1033 if (is_cxx_method) {
1038 bool skip_artificial =
true;
1040 is_variadic, has_template_params,
1041 function_param_types, function_param_decls,
1045 bool ignore_containing_context =
false;
1056 if (is_cxx_method && has_template_params) {
1057 ignore_containing_context =
true;
1058 is_cxx_method =
false;
1061 clang::CallingConv calling_convention =
1068 function_param_types.size(), is_variadic,
1069 type_quals, calling_convention, attrs.
ref_qual);
1072 bool type_handled =
false;
1073 if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
1074 std::optional<const ObjCLanguage::MethodName> objc_method =
1078 ConstString class_name(objc_method->GetClassName());
1080 TypeSP complete_objc_class_type_sp(
1082 class_name,
false));
1084 if (complete_objc_class_type_sp) {
1086 complete_objc_class_type_sp->GetForwardCompilerType();
1088 type_clang_forward_type))
1089 class_opaque_type = type_clang_forward_type;
1093 if (class_opaque_type) {
1094 clang::ObjCMethodDecl *objc_method_decl =
1098 type_handled = objc_method_decl !=
nullptr;
1103 dwarf->GetObjectFile()->GetModule()->ReportError(
1104 "[{0:x16}]: invalid Objective-C method {1:x4} ({2}), "
1105 "please file a bug and attach the file at the start of "
1106 "this error message",
1110 }
else if (is_cxx_method) {
1113 Type *class_type =
dwarf->ResolveType(decl_ctx_die);
1115 if (class_type->
GetID() != decl_ctx_die.
GetID() ||
1123 if (class_type_die) {
1124 std::vector<DWARFDIE> failures;
1127 class_type, failures);
1136 return type_ptr->shared_from_this();
1151 clang::DeclContext *spec_clang_decl_ctx =
1153 if (spec_clang_decl_ctx) {
1156 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1157 "{0:x8}: DW_AT_specification({1:x16}"
1161 type_handled =
true;
1170 clang::DeclContext *abs_clang_decl_ctx =
1172 if (abs_clang_decl_ctx) {
1175 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1176 "{0:x8}: DW_AT_abstract_origin({1:x16}"
1180 type_handled =
true;
1191 type_handled =
true;
1193 llvm::PrettyStackTraceFormat stack_trace(
1194 "SymbolFileDWARF::ParseType() is adding a method "
1195 "%s to class %s in DIE 0x%8.8" PRIx64
" from %s",
1198 dwarf->GetObjectFile()->GetFileSpec().GetPath().c_str());
1200 const bool is_attr_used =
false;
1208 clang::CXXMethodDecl *cxx_method_decl =
1216 type_handled = cxx_method_decl !=
nullptr;
1221 if (cxx_method_decl) {
1227 if (!object_pointer_name.empty()) {
1230 "Setting object pointer name: %s on method "
1232 object_pointer_name.c_str(),
1233 static_cast<void *
>(cxx_method_decl));
1237 ignore_containing_context =
true;
1263 return type_ptr->shared_from_this();
1271 type_handled =
true;
1279 if (!type_handled) {
1280 clang::FunctionDecl *function_decl =
nullptr;
1281 clang::FunctionDecl *template_function_decl =
nullptr;
1286 if (
dwarf->ResolveType(abs_die)) {
1287 function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
1290 if (function_decl) {
1296 if (!function_decl) {
1297 char *name_buf =
nullptr;
1304 llvm::ItaniumPartialDemangler D;
1306 name_buf = D.getFunctionBaseName(
nullptr,
nullptr);
1314 : containing_decl_ctx,
1317 std::free(name_buf);
1319 if (has_template_params) {
1324 : containing_decl_ctx,
1327 clang::FunctionTemplateDecl *func_template_decl =
1330 template_function_decl, template_param_infos);
1332 template_function_decl, func_template_decl, template_param_infos);
1337 if (function_decl) {
1349 function_decl->addAttr(clang::AsmLabelAttr::CreateImplicit(
1354 if (!function_param_decls.empty()) {
1356 if (template_function_decl)
1358 function_param_decls);
1364 if (!object_pointer_name.empty()) {
1367 "Setting object pointer name: %s on function "
1369 object_pointer_name.c_str(),
1370 static_cast<void *
>(function_decl));
1377 return dwarf->MakeType(
1391 Type *element_type =
dwarf->ResolveTypeUID(type_die,
true);
1400 byte_stride = array_info->byte_stride;
1401 bit_stride = array_info->bit_stride;
1403 if (byte_stride == 0 && bit_stride == 0)
1404 byte_stride = element_type->
GetByteSize(
nullptr).value_or(0);
1408 uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
1410 if (array_info && array_info->element_orders.size() > 0) {
1411 uint64_t num_elements = 0;
1412 auto end = array_info->element_orders.rend();
1413 for (
auto pos = array_info->element_orders.rbegin(); pos != end; ++pos) {
1414 num_elements = *pos;
1417 array_element_type = clang_type;
1418 array_element_bit_stride = num_elements
1419 ? array_element_bit_stride * num_elements
1420 : array_element_bit_stride;
1428 dwarf->MakeType(die.
GetID(), empty_name, array_element_bit_stride / 8,
1430 &attrs.
decl, clang_type, Type::ResolveState::Full);
1431 type_sp->SetEncodingType(element_type);
1446 if ((class_type ==
nullptr) || (pointee_type ==
nullptr))
1453 class_clang_type, pointee_clang_type);
1455 if (std::optional<uint64_t> clang_type_size =
1457 return dwarf->MakeType(die.
GetID(), attrs.
name, *clang_type_size,
nullptr,
1459 clang_type, Type::ResolveState::Forward);
1468 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
1477 if (attributes.
Size() == 0)
1481 AccessType accessibility = default_accessibility;
1482 bool is_virtual =
false;
1483 bool is_base_of_class =
true;
1484 off_t member_byte_offset = 0;
1486 for (uint32_t i = 0; i < attributes.
Size(); ++i) {
1492 encoding_form = form_value;
1494 case DW_AT_data_member_location:
1495 if (
auto maybe_offset =
1497 member_byte_offset = *maybe_offset;
1500 case DW_AT_accessibility:
1505 case DW_AT_virtuality:
1506 is_virtual = form_value.
Boolean();
1516 if (base_class_type ==
nullptr) {
1517 module_sp->ReportError(
"{0:x16}: DW_TAG_inheritance failed to "
1518 "resolve the base class at {1:x16}"
1519 " from enclosing type {2:x16}. \nPlease file "
1520 "a bug and attach the file at the start of "
1521 "this error message",
1529 assert(base_class_clang_type);
1531 ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
1534 std::unique_ptr<clang::CXXBaseSpecifier> result =
1536 accessibility, is_virtual,
1541 base_classes.push_back(std::move(result));
1559 clang::CharUnits::fromQuantity(member_byte_offset)));
1573 if (sc_parent_tag == DW_TAG_compile_unit ||
1574 sc_parent_tag == DW_TAG_partial_unit) {
1576 }
else if (sc.
function !=
nullptr && sc_parent_die) {
1577 symbol_context_scope =
1579 if (symbol_context_scope ==
nullptr)
1580 symbol_context_scope = sc.
function;
1582 symbol_context_scope = sc.
module_sp.get();
1585 if (symbol_context_scope !=
nullptr)
1586 type_sp->SetSymbolContextScope(symbol_context_scope);
1588 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1596 const char *name = die.
GetName();
1599 std::string qualified_name;
1602 while (parent_decl_ctx_die) {
1606 const dw_tag_t parent_tag = parent_decl_ctx_die.
Tag();
1607 switch (parent_tag) {
1608 case DW_TAG_namespace: {
1609 if (
const char *namespace_name = parent_decl_ctx_die.
GetName()) {
1610 qualified_name.insert(0,
"::");
1611 qualified_name.insert(0, namespace_name);
1613 qualified_name.insert(0,
"(anonymous namespace)::");
1619 case DW_TAG_class_type:
1620 case DW_TAG_structure_type:
1621 case DW_TAG_union_type: {
1622 if (
const char *class_union_struct_name = parent_decl_ctx_die.
GetName()) {
1623 qualified_name.insert(
1625 qualified_name.insert(0,
"::");
1626 qualified_name.insert(0, class_union_struct_name);
1633 parent_decl_ctx_die.
Clear();
1638 if (qualified_name.empty())
1639 qualified_name.append(
"::");
1641 qualified_name.append(name);
1644 return qualified_name;
1656 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
1662 auto unique_ast_entry_up = std::make_unique<UniqueDWARFASTType>();
1673 if (!qualified_name.empty())
1675 unique_decl.
Clear();
1678 if (
dwarf->GetUniqueDWARFASTTypeMap().Find(
1679 unique_typename, die, unique_decl, attrs.
byte_size.value_or(-1),
1680 *unique_ast_entry_up)) {
1681 type_sp = unique_ast_entry_up->m_type_sp;
1683 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1694 int tag_decl_kind = -1;
1696 if (tag == DW_TAG_structure_type) {
1697 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Struct);
1699 }
else if (tag == DW_TAG_union_type) {
1700 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Union);
1702 }
else if (tag == DW_TAG_class_type) {
1703 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Class);
1732 dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.
name,
true);
1736 dwarf->GetDebugMapSymfile();
1737 if (debug_map_symfile) {
1741 die, attrs.
name,
true);
1747 dwarf->GetObjectFile()->GetModule()->LogMessage(
1749 "SymbolFileDWARF({0:p}) - {1:x16}: {2} type "
1751 "incomplete objc type, complete type is {4:x8}",
1752 static_cast<void *
>(
this), die.
GetOffset(),
1760 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1773 dwarf->GetObjectFile()->GetModule()->LogMessage(
1775 "SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" is a "
1776 "forward declaration, trying to find complete type",
1789 type_sp =
dwarf->FindDefinitionTypeForDWARFDeclContext(die);
1793 if (debug_map_symfile) {
1802 dwarf->GetObjectFile()->GetModule()->LogMessage(
1804 "SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" is a "
1805 "forward declaration, complete type is {4:x8}",
1806 static_cast<void *
>(
this), die.
GetOffset(),
1813 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1814 clang::DeclContext *defn_decl_ctx =
1821 assert(tag_decl_kind != -1);
1823 bool clang_type_was_created =
false;
1825 m_ast.weak_from_this(),
1826 dwarf->GetForwardDeclDIEToCompilerType().lookup(die.
GetDIE()));
1828 clang::DeclContext *decl_ctx =
1837 const clang::Decl::Kind containing_decl_kind = decl_ctx->getDeclKind();
1848 clang::ClassTemplateDecl *class_template_decl =
1852 if (!class_template_decl) {
1854 dwarf->GetObjectFile()->GetModule()->LogMessage(
1856 "SymbolFileDWARF({0:p}) - {1:x16}: {2} type \"{3}\" "
1857 "clang::ClassTemplateDecl failed to return a decl.",
1858 static_cast<void *
>(
this), die.
GetOffset(),
1864 clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1867 tag_decl_kind, template_param_infos);
1869 class_specialization_decl);
1870 clang_type_was_created =
true;
1876 if (!clang_type_was_created) {
1877 clang_type_was_created =
true;
1889 type_sp =
dwarf->MakeType(
1892 Type::ResolveState::Forward,
1898 unique_ast_entry_up->m_type_sp = type_sp;
1899 unique_ast_entry_up->m_die = die;
1900 unique_ast_entry_up->m_declaration = unique_decl;
1901 unique_ast_entry_up->m_byte_size = attrs.
byte_size.value_or(0);
1902 dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
1903 *unique_ast_entry_up);
1915 dwarf->GetObjectFile()->GetModule()->ReportError(
1917 "DWARF DIE at {0:x16} named \"{1}\" was not able to start "
1919 "definition.\nPlease file a bug and attach the file at the "
1920 "start of this error message",
1933 clang::RecordDecl *record_decl =
1942 }
else if (clang_type_was_created) {
1960 assert(!
dwarf->GetForwardDeclCompilerTypeToDIE().count(
1963 "Type already in the forward declaration map!");
1967 dwarf->GetForwardDeclDIEToCompilerType()[die.
GetDIE()] =
1969 dwarf->GetForwardDeclCompilerTypeToDIE().try_emplace(
1981 clang::CXXRecordDecl *record_decl =
1983 if (record_decl && record_decl->getDefinition()) {
1984 record_decl->setHasTrivialSpecialMemberForCall();
1989 clang::CXXRecordDecl *record_decl =
1992 record_decl->setArgPassingRestrictions(
1993 clang::RecordArgPassingKind::CannotPassInRegs);
2003 const CompilerType &class_opaque_type,
const char *property_name,
2007 const char *property_setter_name,
const char *property_getter_name,
2014 if (metadata !=
nullptr) {
2061 bool is_template_template_argument =
false;
2064 case DW_TAG_GNU_template_parameter_pack: {
2066 std::make_unique<TypeSystemClang::TemplateParameterInfos>());
2071 if (
const char *name = die.
GetName()) {
2076 case DW_TAG_GNU_template_template_param:
2077 is_template_template_argument =
true;
2079 case DW_TAG_template_type_parameter:
2080 case DW_TAG_template_value_parameter: {
2082 if (attributes.
Size() == 0)
2085 const char *name =
nullptr;
2086 const char *template_name =
nullptr;
2088 uint64_t uval64 = 0;
2089 bool uval64_valid =
false;
2090 bool is_default_template_arg =
false;
2092 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2101 case DW_AT_GNU_template_name:
2114 case DW_AT_const_value:
2116 uval64_valid =
true;
2120 case DW_AT_default_value:
2122 is_default_template_arg = form_value.
Boolean();
2133 if (!is_template_template_argument) {
2134 bool is_signed =
false;
2138 if (name && !name[0])
2141 if (tag == DW_TAG_template_value_parameter && uval64_valid) {
2142 std::optional<uint64_t> size = clang_type.
GetBitSize(
nullptr);
2145 llvm::APInt apint(*size, uval64, is_signed);
2147 name, clang::TemplateArgument(ast, llvm::APSInt(apint, !is_signed),
2149 is_default_template_arg));
2154 is_default_template_arg));
2159 name, clang::TemplateArgument(clang::TemplateName(tplt_type),
2160 is_default_template_arg));
2182 case DW_TAG_template_type_parameter:
2183 case DW_TAG_template_value_parameter:
2184 case DW_TAG_GNU_template_parameter_pack:
2185 case DW_TAG_GNU_template_template_param:
2194 return !template_param_infos.
IsEmpty() ||
2207 const bool type_is_objc_object_or_interface =
2209 if (type_is_objc_object_or_interface) {
2216 if (tag == DW_TAG_structure_type) {
2218 }
else if (tag == DW_TAG_union_type) {
2220 }
else if (tag == DW_TAG_class_type) {
2224 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
2226 std::vector<DWARFDIE> member_function_dies;
2230 delayed_properties, default_accessibility, layout_info);
2233 for (
const DWARFDIE &die : member_function_dies)
2234 dwarf->ResolveType(die);
2236 if (type_is_objc_object_or_interface) {
2239 dwarf->GetObjCMethods(class_name, [&](
DWARFDIE method_die) {
2245 property.Finalize();
2249 if (!bases.empty()) {
2253 for (
const auto &base_class : bases) {
2254 clang::TypeSourceInfo *type_source_info =
2255 base_class->getTypeSourceInfo();
2256 if (type_source_info)
2281 clang::CXXRecordDecl *record_decl =
2287 return (
bool)clang_type;
2295 bool is_signed =
false;
2302 return (
bool)clang_type;
2310 std::lock_guard<std::recursive_mutex> guard(
2311 dwarf->GetObjectFile()->GetModule()->GetMutex());
2324 case DW_TAG_structure_type:
2325 case DW_TAG_union_type:
2326 case DW_TAG_class_type:
2328 case DW_TAG_enumeration_type:
2331 assert(
false &&
"not a forward clang type decl!");
2340 auto opaque_decl_ctx =
2351 if (clang_decl !=
nullptr)
2366 clang::DeclContext *clang_decl_ctx =
2375 uint32_t enumerator_byte_size,
const DWARFDIE &parent_die) {
2379 size_t enumerators_added = 0;
2383 if (tag != DW_TAG_enumerator)
2387 if (attributes.
Size() == 0)
2390 const char *name =
nullptr;
2391 bool got_value =
false;
2392 int64_t enum_value = 0;
2395 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2400 case DW_AT_const_value:
2403 enum_value = form_value.
Signed();
2405 enum_value = form_value.
Unsigned();
2412 case DW_AT_description:
2414 case DW_AT_decl_file:
2418 case DW_AT_decl_line:
2421 case DW_AT_decl_column:
2430 if (name && name[0] && got_value) {
2432 clang_type, decl, name, enum_value, enumerator_byte_size * 8);
2433 ++enumerators_added;
2436 return enumerators_added;
2441 bool is_static =
false;
2442 bool is_variadic =
false;
2443 bool has_template_params =
false;
2444 unsigned type_quals = 0;
2445 std::vector<CompilerType> param_types;
2446 std::vector<clang::ParmVarDecl *> param_decls;
2452 clang::DeclContext *containing_decl_ctx =
2455 has_template_params, param_types, param_decls,
2458 for (
size_t i = 0; i < param_types.size(); i++) {
2461 sstr << param_types[i].GetTypeName();
2466 if (type_quals & clang::Qualifiers::Const)
2478 const char *name =
nullptr;
2479 const char *mangled =
nullptr;
2480 std::optional<int> decl_file;
2481 std::optional<int> decl_line;
2482 std::optional<int> decl_column;
2483 std::optional<int> call_file;
2484 std::optional<int> call_line;
2485 std::optional<int> call_column;
2490 if (tag != DW_TAG_subprogram)
2494 decl_column, call_file, call_line, call_column,
2499 else if ((die.
GetParent().
Tag() == DW_TAG_compile_unit ||
2505 name && strcmp(name,
"main") != 0) {
2514 std::unique_ptr<Declaration> decl_up;
2515 if (decl_file || decl_line || decl_column)
2516 decl_up = std::make_unique<Declaration>(
2518 decl_line ? *decl_line : 0, decl_column ? *decl_column : 0);
2528 std::make_shared<Function>(&comp_unit,
2530 func_user_id, func_name, func_type,
2533 if (func_sp.get() !=
nullptr) {
2535 func_sp->GetFrameBaseExpression() = frame_base;
2537 return func_sp.get();
2546struct PropertyAttributes {
2547 explicit PropertyAttributes(
const DWARFDIE &die);
2548 const char *prop_name =
nullptr;
2549 const char *prop_getter_name =
nullptr;
2550 const char *prop_setter_name =
nullptr;
2552 uint32_t prop_attributes = 0;
2555struct DiscriminantValue {
2558 uint32_t byte_offset;
2563struct VariantMember {
2565 bool IsDefault()
const;
2567 std::optional<uint32_t> discr_value;
2570 uint32_t byte_offset;
2578 std::vector<VariantMember> &members();
2580 DiscriminantValue &discriminant();
2583 std::vector<VariantMember> _members;
2584 DiscriminantValue _discriminant;
2589ConstString VariantMember::GetName()
const {
return this->variant_name; }
2591bool VariantMember::IsDefault()
const {
return !discr_value; }
2594 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant);
2598 for (
auto child_die : die.
children()) {
2599 switch (child_die.Tag()) {
2600 case llvm::dwarf::DW_TAG_member: {
2602 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2611 type_ref = form_value;
2614 case DW_AT_data_member_location:
2615 if (
auto maybe_offset =
2617 byte_offset = *maybe_offset;
2634DiscriminantValue::DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp) {
2637 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2643 type_ref = form_value;
2645 case DW_AT_data_member_location:
2646 if (
auto maybe_offset =
2648 byte_offset = *maybe_offset;
2659 : _members(), _discriminant(die, module_sp) {
2661 for (
auto child : die.
children()) {
2662 if (child.Tag() == llvm::dwarf::DW_TAG_variant) {
2663 _members.push_back(VariantMember(child, module_sp));
2668std::vector<VariantMember> &VariantPart::members() {
return this->_members; }
2670DiscriminantValue &VariantPart::discriminant() {
return this->_discriminant; }
2675 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2686 case DW_AT_bit_offset:
2689 case DW_AT_bit_size:
2692 case DW_AT_byte_size:
2695 case DW_AT_const_value:
2698 case DW_AT_data_bit_offset:
2701 case DW_AT_data_member_location:
2702 if (
auto maybe_offset =
2707 case DW_AT_accessibility:
2711 case DW_AT_artificial:
2714 case DW_AT_declaration:
2741PropertyAttributes::PropertyAttributes(
const DWARFDIE &die) {
2744 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2749 case DW_AT_APPLE_property_name:
2752 case DW_AT_APPLE_property_getter:
2753 prop_getter_name = form_value.
AsCString();
2755 case DW_AT_APPLE_property_setter:
2756 prop_setter_name = form_value.
AsCString();
2758 case DW_AT_APPLE_property_attribute:
2759 prop_attributes = form_value.
Unsigned();
2773 if (prop_getter_name && prop_getter_name[0] ==
'-') {
2774 std::optional<const ObjCLanguage::MethodName> prop_getter_method =
2776 if (prop_getter_method)
2781 if (prop_setter_name && prop_setter_name[0] ==
'-') {
2782 std::optional<const ObjCLanguage::MethodName> prop_setter_method =
2784 if (prop_setter_method)
2790 if (!prop_getter_name)
2791 prop_getter_name = prop_name;
2792 if (!prop_setter_name && prop_name[0] &&
2793 !(prop_attributes & DW_APPLE_PROPERTY_readonly)) {
2796 ss.
Printf(
"set%c%s:", toupper(prop_name[0]), &prop_name[1]);
2799 prop_setter_name = fixed_setter.
GetCString();
2808 assert(die.
Tag() == DW_TAG_APPLE_property);
2813 const PropertyAttributes propAttrs(die);
2815 if (!propAttrs.prop_name) {
2816 module_sp->ReportError(
"{0:x8}: DW_TAG_APPLE_property has no name.",
2823 module_sp->ReportError(
2824 "{0:x8}: DW_TAG_APPLE_property '{1}' refers to type {2:x16}"
2825 " which was unable to be parsed",
2826 die.
GetID(), propAttrs.prop_name,
2834 class_clang_type, propAttrs.prop_name,
2836 propAttrs.prop_getter_name, propAttrs.prop_attributes, &metadata));
2842 assert(qt->isIntegralOrEnumerationType());
2845 return llvm::createStringError(llvm::inconvertibleErrorCode(),
2846 "TypeSystem not clang");
2850 const unsigned type_bits = ast.getIntWidth(qt);
2851 const bool is_unsigned = qt->isUnsignedIntegerType();
2855 constexpr std::size_t max_bit_size = 64;
2860 if (type_bits > max_bit_size) {
2861 auto msg = llvm::formatv(
"Can only parse integers with up to {0} bits, but "
2862 "given integer has {1} bits.",
2863 max_bit_size, type_bits);
2864 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2868 llvm::APInt result(max_bit_size, form_value.
Unsigned(), !is_unsigned);
2874 const unsigned required_bits =
2875 is_unsigned ? result.getActiveBits() : result.getSignificantBits();
2878 if (required_bits > type_bits) {
2879 std::string value_as_str = is_unsigned
2880 ? std::to_string(form_value.
Unsigned())
2881 : std::to_string(form_value.
Signed());
2882 auto msg = llvm::formatv(
"Can't store {0} value {1} in integer with {2} "
2884 (is_unsigned ?
"unsigned" :
"signed"),
2885 value_as_str, type_bits);
2886 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2890 if (result.getBitWidth() > type_bits)
2891 result = result.trunc(type_bits);
2898 Log *log =
GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
2899 assert(die.
Tag() == DW_TAG_member || die.
Tag() == DW_TAG_variable);
2906 auto accessibility =
2911 class_clang_type, attrs.
name, ct, accessibility);
2913 LLDB_LOG(log,
"Failed to add variable to the record type");
2928 if (!maybe_const_form_value) {
2930 if (!maybe_const_form_value)
2934 llvm::Expected<llvm::APInt> const_value_or_err =
2936 if (!const_value_or_err) {
2938 "Failed to add const value to variable {1}: {0}",
2939 v->getQualifiedNameAsString());
2953 assert(die.
Tag() == DW_TAG_member);
2958 const uint64_t parent_byte_size =
2960 const uint64_t parent_bit_size =
2985 module_sp->ReportError(
2986 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
2987 " which was unable to be parsed",
2990 module_sp->ReportError(
"{0:x8}: DW_TAG_member refers to type {1:x16}"
2991 " which was unable to be parsed",
2997 const uint64_t character_width = 8;
2998 const uint64_t word_width = 32;
3002 ? default_accessibility
3011 this_field_info.
bit_offset = field_bit_offset;
3023 this_field_info.
bit_offset += byte_size.value_or(0) * 8;
3037 !(parent_die.
Tag() == DW_TAG_union_type &&
3039 ((this_field_info.
bit_offset >= parent_bit_size) ||
3045 "{0:x16}: {1} bitfield named \"{2}\" has invalid "
3046 "bit offset ({3:x8}) member will be ignored. Please file a bug "
3048 "compiler and include the preprocessed output for {4}\n",
3055 field_bit_offset = this_field_info.
bit_offset;
3060 bool detect_unnamed_bitfields =
true;
3063 detect_unnamed_bitfields =
3066 if (detect_unnamed_bitfields) {
3067 std::optional<FieldInfo> unnamed_field_info;
3068 uint64_t last_field_end =
3076 if (last_field_end != 0 && ((last_field_end % word_width) != 0))
3077 last_field_end += word_width - (last_field_end % word_width);
3081 this_field_info, layout_info)) {
3085 unnamed_field_info->bit_offset = last_field_end;
3088 if (unnamed_field_info) {
3089 clang::FieldDecl *unnamed_bitfield_decl =
3091 class_clang_type, llvm::StringRef(),
3094 accessibility, unnamed_field_info->bit_size);
3097 unnamed_bitfield_decl, unnamed_field_info->bit_offset));
3101 last_field_info = this_field_info;
3104 last_field_info.
bit_offset = field_bit_offset;
3106 if (std::optional<uint64_t> clang_type_size =
3108 last_field_info.
bit_size = *clang_type_size * character_width;
3134 uint64_t member_array_size;
3135 bool member_array_is_incomplete;
3137 if (member_clang_type.
IsArrayType(&member_array_element_type,
3139 &member_array_is_incomplete) &&
3140 !member_array_is_incomplete) {
3141 uint64_t parent_byte_size =
3145 if (member_array_size != 1 &&
3146 (member_array_size != 0 ||
3148 module_sp->ReportError(
3149 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
3150 " which extends beyond the bounds of {3:x8}",
3164 class_clang_type, attrs.
name, member_clang_type, accessibility,
3170 std::make_pair(field_decl, field_bit_offset));
3175 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
3176 std::vector<DWARFDIE> &member_function_dies,
3195 case DW_TAG_APPLE_property:
3199 case DW_TAG_variant_part:
3202 default_accessibility, layout_info);
3206 case DW_TAG_variable: {
3212 default_accessibility, layout_info, last_field_info);
3215 case DW_TAG_subprogram:
3217 member_function_dies.push_back(die);
3220 case DW_TAG_inheritance:
3222 module_sp, base_classes, layout_info);
3234 clang::DeclContext *containing_decl_ctx,
const DWARFDIE &parent_die,
3235 bool skip_artificial,
bool &is_static,
bool &is_variadic,
3236 bool &has_template_params, std::vector<CompilerType> &function_param_types,
3237 std::vector<clang::ParmVarDecl *> &function_param_decls,
3238 unsigned &type_quals) {
3246 case DW_TAG_formal_parameter: {
3248 if (attributes.
Size() == 0) {
3253 const char *name =
nullptr;
3255 bool is_artificial =
false;
3258 clang::StorageClass storage = clang::SC_None;
3260 for (i = 0; i < attributes.
Size(); ++i) {
3269 param_type_die_form = form_value;
3271 case DW_AT_artificial:
3272 is_artificial = form_value.
Boolean();
3274 case DW_AT_location:
3275 case DW_AT_const_value:
3276 case DW_AT_default_value:
3277 case DW_AT_description:
3278 case DW_AT_endianity:
3279 case DW_AT_is_optional:
3281 case DW_AT_variable_parameter:
3283 case DW_AT_abstract_origin:
3291 if (skip_artificial && is_artificial) {
3299 (name ==
nullptr || ::strcmp(name,
"this") == 0)) {
3307 type_quals |= clang::Qualifiers::Const;
3309 type_quals |= clang::Qualifiers::Volatile;
3324 assert(param_var_decl);
3325 function_param_decls.push_back(param_var_decl);
3333 case DW_TAG_unspecified_parameters:
3337 case DW_TAG_template_type_parameter:
3338 case DW_TAG_template_value_parameter:
3339 case DW_TAG_GNU_template_parameter_pack:
3345 has_template_params =
true;
3359 switch (die.
Tag()) {
3360 case DW_TAG_variable:
3361 case DW_TAG_constant:
3362 case DW_TAG_formal_parameter:
3363 case DW_TAG_imported_declaration:
3364 case DW_TAG_imported_module:
3372 return cache_pos->second;
3387 clang::Decl *decl =
nullptr;
3388 switch (die.
Tag()) {
3389 case DW_TAG_variable:
3390 case DW_TAG_constant:
3391 case DW_TAG_formal_parameter: {
3394 if (
dwarf && type) {
3395 const char *name = die.
GetName();
3396 clang::DeclContext *decl_context =
3398 dwarf->GetDeclContextContainingUID(die.
GetID()));
3405 case DW_TAG_imported_declaration: {
3410 if (imported_decl) {
3411 clang::DeclContext *decl_context =
3413 dwarf->GetDeclContextContainingUID(die.
GetID()));
3414 if (clang::NamedDecl *clang_imported_decl =
3415 llvm::dyn_cast<clang::NamedDecl>(
3423 case DW_TAG_imported_module: {
3430 if (imported_decl_ctx) {
3431 clang::DeclContext *decl_context =
3433 dwarf->GetDeclContextContainingUID(die.
GetID()));
3434 if (clang::NamespaceDecl *ns_decl =
3459 bool try_parsing_type =
true;
3460 switch (die.
Tag()) {
3461 case DW_TAG_compile_unit:
3462 case DW_TAG_partial_unit:
3464 try_parsing_type =
false;
3467 case DW_TAG_namespace:
3469 try_parsing_type =
false;
3472 case DW_TAG_imported_declaration:
3474 try_parsing_type =
false;
3477 case DW_TAG_lexical_block:
3479 try_parsing_type =
false;
3486 if (decl_ctx ==
nullptr && try_parsing_type) {
3506 parent = parent.GetParent()) {
3508 if (tag == DW_TAG_module) {
3528 switch (die.
Tag()) {
3529 case DW_TAG_subprogram:
3530 case DW_TAG_inlined_subroutine:
3540 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3547 assert(0 &&
"Shouldn't call GetContainingFunctionWithAbstractOrigin on "
3548 "something not in a function");
3554 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3576 assert(die.
Tag() == DW_TAG_lexical_block);
3577 DWARFDIE containing_function_with_abstract_origin =
3579 if (!containing_function_with_abstract_origin) {
3583 die, containing_function_with_abstract_origin);
3590 if (die && die.
Tag() == DW_TAG_lexical_block) {
3591 clang::BlockDecl *decl =
3596 clang::DeclContext *decl_context =
3610clang::NamespaceDecl *
3612 if (die && die.
Tag() == DW_TAG_namespace) {
3615 clang::NamespaceDecl *namespace_decl =
3618 return namespace_decl;
3620 const char *namespace_name = die.
GetName();
3621 clang::DeclContext *containing_decl_ctx =
3632 return namespace_decl;
3638clang::NamespaceDecl *
3640 assert(die && die.
Tag() == DW_TAG_imported_declaration);
3646 return static_cast<clang::NamespaceDecl *
>(it->getSecond());
3648 clang::NamespaceDecl *namespace_decl =
nullptr;
3655 switch (imported_uid.
Tag()) {
3656 case DW_TAG_imported_declaration:
3659 case DW_TAG_namespace:
3666 if (!namespace_decl)
3671 return namespace_decl;
3678 DWARFDIE decl_ctx_die =
dwarf->GetDeclContextDIEContainingDIE(die);
3680 if (decl_ctx_die_copy)
3681 *decl_ctx_die_copy = decl_ctx_die;
3684 clang::DeclContext *clang_decl_ctx =
3687 return clang_decl_ctx;
3713 if (!class_type || !src_class_die || !dst_class_die)
3715 if (src_class_die.
Tag() != dst_class_die.
Tag())
3725 if (die.
Tag() != DW_TAG_subprogram)
3737 map_artificial.Append(const_name, die);
3739 map.Append(const_name, die);
3748 src_die = src_die.GetSibling()) {
3749 gather(src_die, src_name_to_die, src_name_to_die_artificial);
3752 dst_die = dst_die.GetSibling()) {
3753 gather(dst_die, dst_name_to_die, dst_name_to_die_artificial);
3755 const uint32_t src_size = src_name_to_die.
GetSize();
3756 const uint32_t dst_size = dst_name_to_die.
GetSize();
3759 bool fast_path =
true;
3761 if (src_size != dst_size)
3767 for (idx = 0; idx < src_size; ++idx) {
3771 if (src_die.
Tag() != dst_die.
Tag())
3778 if (src_name == dst_name || (strcmp(src_name, dst_name) == 0))
3794 clang::DeclContext *dst_decl_ctx =
3799 if (
Type *src_child_type = die_to_type[src.
GetDIE()])
3800 die_to_type[dst.GetDIE()] = src_child_type;
3807 for (idx = 0; idx < src_size; ++idx) {
3817 src_name_to_die.
Sort();
3819 for (idx = 0; idx < dst_size; ++idx) {
3824 if (src_die && (src_die.
Tag() == dst_die.
Tag()))
3825 link(src_die, dst_die);
3827 failures.push_back(dst_die);
3832 const uint32_t src_size_artificial = src_name_to_die_artificial.
GetSize();
3833 const uint32_t dst_size_artificial = dst_name_to_die_artificial.
GetSize();
3835 if (src_size_artificial && dst_size_artificial) {
3836 dst_name_to_die_artificial.
Sort();
3838 for (idx = 0; idx < src_size_artificial; ++idx) {
3844 dst_name_to_die_artificial.
Find(src_name_artificial,
DWARFDIE());
3848 link(src_die, dst_die);
3852 if (dst_size_artificial) {
3853 for (idx = 0; idx < dst_size_artificial; ++idx) {
3859 return !failures.empty();
3863 FieldInfo const &last_field_info, uint64_t last_field_end,
3868 if (this_field_info.
bit_offset <= last_field_end)
3882 const bool have_base = layout_info.
base_offsets.size() != 0;
3883 const bool this_is_first_field =
3885 const bool first_field_is_vptr =
3888 if (have_base && (this_is_first_field || first_field_is_vptr))
3898 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant_part);
3900 LanguageType::eLanguageTypeRust);
3904 VariantPart variants(die, parent_die, module_sp);
3906 auto discriminant_type =
3907 die.
ResolveTypeUID(variants.discriminant().type_ref.Reference());
3914 llvm::formatv(
"{0}$Inner", class_clang_type.
GetTypeName(
false))),
3919 for (
auto member : variants.members()) {
3921 auto has_discriminant = !member.IsDefault();
3923 auto member_type = die.
ResolveTypeUID(member.type_ref.Reference());
3928 std::string(llvm::formatv(
"{0}$Variant", member.GetName())),
3929 llvm::to_underlying(clang::TagTypeKind::Struct),
3933 auto offset = member.byte_offset;
3935 if (has_discriminant) {
3937 field_type,
"$discr$", discriminant_type->GetFullCompilerType(),
3939 offset += discriminant_type->GetByteSize(
nullptr).value_or(0);
3943 member_type->GetFullCompilerType(),
3948 auto name = has_discriminant
3949 ? llvm::formatv(
"$variant${0}", member.discr_value.value())
3950 : std::string(
"$variant$");
3954 field_type, default_accesibility, 0);
3960 llvm::StringRef(
"$variants$"),
static bool DeclKindIsCXXClass(clang::Decl::Kind decl_kind)
static std::string GetUnitName(const DWARFDIE &die)
static void ForcefullyCompleteType(CompilerType type)
static clang::CallingConv ConvertDWARFCallingConventionToClang(const ParsedDWARFTypeAttributes &attrs)
static bool IsSubroutine(const DWARFDIE &die)
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 serves a similar purpose as RequireCompleteType above, but it avoids completing the typ...
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
std::optional< lldb_private::plugin::dwarf::DWARFFormValue > FindConstantOnVariableDefinition(lldb_private::plugin::dwarf::DWARFDIE die)
Tries to find the definition DW_TAG_variable DIE of the the specified DW_TAG_member 'die'.
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)
lldb_private::ConstString GetDIEClassTemplateParams(const lldb_private::plugin::dwarf::DWARFDIE &die) override
Returns the template parameters of a class DWARFDIE as a string.
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
std::string GetCPlusPlusQualifiedName(const lldb_private::plugin::dwarf::DWARFDIE &die)
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
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)
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
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, DelayedPropertyList &delayed_properties, const lldb::AccessType default_accessibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info)
size_t ParseChildEnumerators(lldb_private::CompilerType &compiler_type, bool is_signed, uint32_t enumerator_byte_size, const lldb_private::plugin::dwarf::DWARFDIE &parent_die)
lldb::TypeSP ParseSubroutine(const lldb_private::plugin::dwarf::DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs)
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.
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 bool 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, Value &result, Status *error_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.
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.
unsigned int UInt(unsigned int fail_value=0) const
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 GetTypeAtIndex(uint32_t idx)
The implementation of lldb::Type's m_payload field for TypeSystemClang.
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...
CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) override
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)
static clang::RecordDecl * GetAsRecordDecl(const CompilerType &type)
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)
clang::ASTContext & getASTContext()
Returns the clang::ASTContext instance managed by this TypeSystemClang.
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)
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.
@ 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
Scalar & ResolveValue(ExecutionContext *exe_ctx, Module *module=nullptr)
lldb_private::Type * GetTypeForDIE(const DWARFDIE &die)
static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility)
virtual CompilerDeclContext GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die)=0
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
const char * GetTagAsCString() 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's -gmodules debug info forma...
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
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)
lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(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).
bool ForEachExternalModule(CompileUnit &, llvm::DenseSet< SymbolFile * > &, llvm::function_ref< bool(Module &)>) override
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 DWARFDeclContext GetDWARFDeclContext(const DWARFDIE &die)
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)
const char * DW_TAG_value_to_name(uint32_t val)
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)
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
void Insert(lldb::LanguageType language)
lldb::user_id_t GetID() const
Get accessor for the user ID.