42#include "clang/AST/CXXInheritance.h"
43#include "clang/AST/DeclBase.h"
44#include "clang/AST/DeclCXX.h"
45#include "clang/AST/DeclObjC.h"
46#include "clang/AST/DeclTemplate.h"
47#include "clang/AST/Type.h"
48#include "clang/Basic/Specifiers.h"
49#include "llvm/ADT/StringExtras.h"
50#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
51#include "llvm/DebugInfo/DWARF/DWARFTypePrinter.h"
52#include "llvm/Demangle/Demangle.h"
61#ifdef ENABLE_DEBUG_PRINTF
63#define DEBUG_PRINTF(fmt, ...) printf(fmt, __VA_ARGS__)
65#define DEBUG_PRINTF(fmt, ...)
71using namespace llvm::dwarf;
81 case clang::Decl::CXXRecord:
82 case clang::Decl::ClassTemplateSpecialization:
103 while (Parent.IsValid()) {
104 if (Parent.Tag() == DW_TAG_module)
106 Parent = Parent.GetParent();
117 parent = parent.GetParent()) {
119 if (tag == DW_TAG_module)
120 top_module_die = parent;
121 else if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
125 return top_module_die;
134 if (clang_module_die) {
135 const char *module_name = clang_module_die.
GetName();
147 return FieldName.starts_with(
"_vptr$")
149 || FieldName.starts_with(
"_vptr.");
155 case DW_TAG_class_type:
156 case DW_TAG_structure_type:
157 case DW_TAG_union_type:
168 assert(subprogram.
Tag() == DW_TAG_subprogram ||
169 subprogram.
Tag() == DW_TAG_inlined_subroutine ||
170 subprogram.
Tag() == DW_TAG_subroutine_type);
175 std::optional<size_t> object_pointer_index;
177 if (subprogram.
GetDIE()->GetAttributeValue(
178 subprogram.
GetCU(), DW_AT_object_pointer, form_value,
183 object_pointer_index = form_value.
Unsigned();
188 size_t param_index = 0;
189 for (
const auto &child : subprogram.
children()) {
190 if (child.Tag() != DW_TAG_formal_parameter)
193 if (param_index == object_pointer_index.value_or(0)) {
194 object_pointer = child;
208 if (object_pointer_index)
209 return object_pointer;
224 if (
const char *name = object_pointer.
GetName();
225 name && ::strcmp(name,
"this") != 0)
228 return object_pointer;
236 if (!subprogram || !object_parameter)
245 unsigned cv_quals = 0;
247 cv_quals |= clang::Qualifiers::Const;
249 cv_quals |= clang::Qualifiers::Volatile;
267 auto *obj = sym->GetMainObjectFile();
271 auto module_sp = obj->GetModule();
275 return module_sp->GetID();
280 module_id = get_module_id(
dwarf);
285 const auto die_id = die.
GetID();
301 if (!clang_module_sp)
307 std::vector<lldb_private::CompilerContext> die_context = die.
GetDeclContext();
308 TypeQuery query(die_context, TypeQueryOptions::e_module_search |
309 TypeQueryOptions::e_find_one);
314 clang_module_sp->FindTypes(query, results);
326 sym_file.ForEachExternalModule(
328 module.FindTypes(query, results);
329 pcm_type_sp = results.GetTypeMap().FirstType();
330 return (bool)pcm_type_sp;
360 auto type_sp =
dwarf->MakeType(
361 die.
GetID(), pcm_type_sp->GetName(),
362 llvm::expectedToOptional(pcm_type_sp->GetByteSize(
nullptr)),
nullptr,
384 clang::DeclContext *decl_ctx,
386 const char *type_name_cstr) {
387 auto *tag_decl_ctx = clang::dyn_cast<clang::TagDecl>(decl_ctx);
392 if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx->isBeingDefined())
400 if (type && ast_importer.
CanImport(type)) {
405 "Unable to complete the Decl context for DIE {0} at offset "
406 "{1:x16}.\nPlease file a bug report.",
407 type_name_cstr ? type_name_cstr :
"", die.
GetOffset());
416 if (!tag_decl_ctx->hasExternalLexicalStorage()) {
424 for (
size_t i = 0; i < attributes.
Size(); ++i) {
432 case DW_AT_abstract_origin:
436 case DW_AT_accessibility:
441 case DW_AT_artificial:
445 case DW_AT_bit_stride:
449 case DW_AT_byte_size:
457 case DW_AT_alignment:
461 case DW_AT_byte_stride:
465 case DW_AT_calling_convention:
469 case DW_AT_containing_type:
473 case DW_AT_decl_file:
478 case DW_AT_decl_line:
481 case DW_AT_decl_column:
485 case DW_AT_declaration:
493 case DW_AT_enum_class:
510 case DW_AT_linkage_name:
511 case DW_AT_MIPS_linkage_name:
519 case DW_AT_signature:
523 case DW_AT_specification:
531 case DW_AT_virtuality:
535 case DW_AT_APPLE_objc_complete_type:
539 case DW_AT_APPLE_objc_direct:
543 case DW_AT_APPLE_runtime_class:
547 case DW_AT_GNU_vector:
550 case DW_AT_export_symbols:
553 case DW_AT_rvalue_reference:
556 case DW_AT_reference:
559 case DW_AT_APPLE_enum_kind:
560 enum_kind =
static_cast<clang::EnumExtensibilityAttr::Kind
>(
569 return unit->GetAbsolutePath().GetPath();
570 return "<missing DWARF unit path>";
575 bool *type_is_new_ptr) {
577 *type_is_new_ptr =
false;
587 clang::DeclContext *context =
590 dwarf->GetObjectFile()->GetModule()->LogMessage(
592 "DWARFASTParserClang::ParseTypeFromDWARF "
593 "(die = {0:x16}, decl_ctx = {1:p} (die "
594 "{2:x16})) {3} ({4}) name = '{5}')",
600 if (
auto [it, inserted] =
605 return it->getSecond()->shared_from_this();
614 if (clang::DeclContext *decl_ctx =
620 *type_is_new_ptr =
true;
626 case DW_TAG_template_alias:
627 case DW_TAG_base_type:
628 case DW_TAG_pointer_type:
629 case DW_TAG_reference_type:
630 case DW_TAG_rvalue_reference_type:
631 case DW_TAG_const_type:
632 case DW_TAG_restrict_type:
633 case DW_TAG_volatile_type:
634 case DW_TAG_LLVM_ptrauth_type:
635 case DW_TAG_atomic_type:
636 case DW_TAG_unspecified_type:
639 case DW_TAG_structure_type:
640 case DW_TAG_union_type:
641 case DW_TAG_class_type:
644 case DW_TAG_enumeration_type:
647 case DW_TAG_inlined_subroutine:
648 case DW_TAG_subprogram:
649 case DW_TAG_subroutine_type:
652 case DW_TAG_array_type:
655 case DW_TAG_ptr_to_member_type:
659 dwarf->GetObjectFile()->GetModule()->ReportError(
660 "[{0:x16}]: unhandled type tag {1:x4} ({2}), "
661 "please file a bug and "
662 "attach the file at the start of this error message",
669 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
674static std::optional<uint32_t>
685 Value initialValue(0);
687 uint32_t block_length = form_value.
Unsigned();
688 uint32_t block_offset =
698 "ExtractDataMemberLocation failed: {0}");
702 return memberOffset->ResolveValue(
nullptr).UInt();
706 auto getAttr = [&](llvm::dwarf::Attribute Attr,
unsigned defaultValue = 0) {
709 const unsigned key = getAttr(DW_AT_LLVM_ptrauth_key);
710 const bool addr_disc = getAttr(DW_AT_LLVM_ptrauth_address_discriminated);
711 const unsigned extra = getAttr(DW_AT_LLVM_ptrauth_extra_discriminator);
712 const bool isapointer = getAttr(DW_AT_LLVM_ptrauth_isa_pointer);
713 const bool authenticates_null_values =
714 getAttr(DW_AT_LLVM_ptrauth_authenticates_null_values);
715 const unsigned authentication_mode_int = getAttr(
716 DW_AT_LLVM_ptrauth_authentication_mode,
717 static_cast<unsigned>(clang::PointerAuthenticationMode::SignAndAuth));
718 clang::PointerAuthenticationMode authentication_mode =
719 clang::PointerAuthenticationMode::SignAndAuth;
720 if (authentication_mode_int >=
721 static_cast<unsigned>(clang::PointerAuthenticationMode::None) &&
722 authentication_mode_int <=
723 static_cast<unsigned>(
724 clang::PointerAuthenticationMode::SignAndAuth)) {
725 authentication_mode =
726 static_cast<clang::PointerAuthenticationMode
>(authentication_mode_int);
729 "[{0:x16}]: invalid pointer authentication mode method {1:x4}",
730 die.
GetOffset(), authentication_mode_int);
732 auto ptr_auth = clang::PointerAuthQualifier::Create(
733 key, addr_disc, extra, authentication_mode, isapointer,
734 authenticates_null_values);
752 if (tag == DW_TAG_typedef || tag == DW_TAG_template_alias) {
802 encoding_uid.Reference());
808 case DW_TAG_unspecified_type:
809 if (attrs.
name ==
"nullptr_t" || attrs.
name ==
"decltype(nullptr)") {
818 case DW_TAG_base_type: {
826 clang_type =
m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
830 case DW_TAG_pointer_type:
833 case DW_TAG_reference_type:
836 case DW_TAG_rvalue_reference_type:
840 case DW_TAG_template_alias:
843 case DW_TAG_const_type:
846 case DW_TAG_restrict_type:
849 case DW_TAG_volatile_type:
852 case DW_TAG_LLVM_ptrauth_type:
856 case DW_TAG_atomic_type:
863 if (tag == DW_TAG_pointer_type) {
871 if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name,
""),
876 if (function_pointer_type) {
880 bool function_type_is_new_pointer;
882 sc, function_type, &function_type_is_new_pointer);
884 if (lldb_function_type_sp) {
885 clang_type =
m_ast.CreateBlockPointerType(
886 lldb_function_type_sp->GetForwardCompilerType());
902 if (attrs.
name ==
"id") {
904 dwarf->GetObjectFile()->GetModule()->LogMessage(
906 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
907 "is Objective-C 'id' built-in type.",
914 }
else if (attrs.
name ==
"Class") {
916 dwarf->GetObjectFile()->GetModule()->LogMessage(
918 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
919 "is Objective-C 'Class' built-in type.",
926 }
else if (attrs.
name ==
"SEL") {
928 dwarf->GetObjectFile()->GetModule()->LogMessage(
930 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
931 "is Objective-C 'selector' built-in type.",
946 if (encoding_die && encoding_die.
Tag() == DW_TAG_structure_type) {
947 llvm::StringRef struct_name = encoding_die.
GetName();
948 if (struct_name ==
"objc_object") {
950 dwarf->GetObjectFile()->GetModule()->LogMessage(
952 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
953 "is 'objc_object*', which we overrode to 'id'.",
968 &attrs.
decl, clang_type, resolve_state, payload);
975 if (llvm::StringRef(die.
GetName()).contains(
"<"))
979 llvm::raw_string_ostream os(name);
980 llvm::DWARFTypePrinter<DWARFDIE> type_printer(os);
981 type_printer.appendAndTerminateTemplateParameters(die);
996 unique_typename, decl_declaration);
998 dwarf->GetUniqueDWARFASTTypeMap().Find(
999 unique_typename, decl_die, decl_declaration,
1002 unique_ast_entry_type->UpdateToDefDIE(def_die, def_attrs.
decl,
1007 "Failed to find {0:x16} {1} ({2}) type \"{3}\" in "
1008 "UniqueDWARFASTTypeMap",
1025 def_die =
dwarf->FindDefinitionDIE(decl_die);
1029 if (debug_map_symfile) {
1037 dwarf->GetObjectFile()->GetModule()->LogMessage(
1039 "SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a "
1040 "forward declaration, complete DIE is {5}",
1043 def_die ? llvm::utohexstr(def_die.
GetID()) :
"not found");
1047 if (
auto [it, inserted] =
dwarf->GetDIEToType().try_emplace(
1052 return it->getSecond()->shared_from_this();
1063 Type *enumerator_type =
1065 if (enumerator_type)
1069 if (!enumerator_clang_type) {
1071 enumerator_clang_type =
m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
1072 "", DW_ATE_signed, *attrs.
byte_size * 8);
1089 clang::DeclContext *type_decl_ctx =
1092 if (decl_die != def_die) {
1094 dwarf->GetDIEToType()[def_die.
GetDIE()] = type_sp.get();
1099 dwarf->GetObjectFile()->GetModule()->ReportError(
1100 "DWARF DIE at {0:x16} named \"{1}\" was not able to start its "
1101 "definition.\nPlease file a bug and attach the file at the "
1102 "start of this error message",
1108static clang::CallingConv
1111 case llvm::dwarf::DW_CC_normal:
1113 case llvm::dwarf::DW_CC_BORLAND_stdcall:
1114 return clang::CC_X86StdCall;
1115 case llvm::dwarf::DW_CC_BORLAND_msfastcall:
1116 return clang::CC_X86FastCall;
1117 case llvm::dwarf::DW_CC_LLVM_vectorcall:
1118 return clang::CC_X86VectorCall;
1119 case llvm::dwarf::DW_CC_BORLAND_pascal:
1120 return clang::CC_X86Pascal;
1121 case llvm::dwarf::DW_CC_LLVM_Win64:
1122 return clang::CC_Win64;
1123 case llvm::dwarf::DW_CC_LLVM_X86_64SysV:
1124 return clang::CC_X86_64SysV;
1125 case llvm::dwarf::DW_CC_LLVM_X86RegCall:
1126 return clang::CC_X86RegCall;
1132 LLDB_LOG(log,
"Unsupported DW_AT_calling_convention value: {0}",
1145 const auto tag = die.
Tag();
1150 TypeSP complete_objc_class_type_sp =
1151 dwarf->FindCompleteObjCDefinitionTypeForDIE(
DWARFDIE(), class_name,
1154 if (!complete_objc_class_type_sp)
1158 complete_objc_class_type_sp->GetForwardCompilerType();
1160 if (!type_clang_forward_type)
1166 clang::ObjCMethodDecl *objc_method_decl =
m_ast.AddMethodToObjCObjectType(
1170 if (!objc_method_decl) {
1171 dwarf->GetObjectFile()->GetModule()->ReportError(
1172 "[{0:x16}]: invalid Objective-C method {1:x4} ({2}), "
1173 "please file a bug and attach the file at the start of "
1174 "this error message",
1180 m_ast.SetMetadataAsUserID(objc_method_decl, die.
GetID());
1188 const DWARFDIE &object_parameter,
bool &ignore_containing_context) {
1193 Type *class_type =
dwarf->ResolveType(decl_ctx_die);
1197 if (class_type->
GetID() != decl_ctx_die.
GetID() ||
1204 std::vector<DWARFDIE> failures;
1216 return {
true, type_ptr->shared_from_this()};
1230 clang::DeclContext *spec_clang_decl_ctx =
1232 if (spec_clang_decl_ctx)
1235 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1236 "{0:x8}: DW_AT_specification({1:x16}"
1240 return {
true,
nullptr};
1252 if (abs_clang_decl_ctx)
1255 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1256 "{0:x8}: DW_AT_abstract_origin({1:x16}"
1260 return {
true,
nullptr};
1273 const bool is_static = !object_parameter.
IsValid();
1279 return {
true,
nullptr};
1281 const bool is_attr_used =
false;
1285 const auto accessibility =
1288 clang::CXXMethodDecl *cxx_method_decl =
m_ast.AddMethodToCXXRecordType(
1294 if (cxx_method_decl) {
1300 if (
char const *object_pointer_name = object_parameter.
GetName()) {
1302 LLDB_LOGF(log,
"Setting object pointer name: %s on method object %p.\n",
1303 object_pointer_name,
static_cast<void *
>(cxx_method_decl));
1305 m_ast.SetMetadata(cxx_method_decl, metadata);
1307 ignore_containing_context =
true;
1312 const bool type_handled = cxx_method_decl !=
nullptr || attrs.
is_artificial;
1314 return {type_handled,
nullptr};
1325 bool is_variadic =
false;
1326 bool has_template_params =
false;
1332 Type *func_type =
nullptr;
1342 std::vector<CompilerType> function_param_types;
1343 llvm::SmallVector<llvm::StringRef> function_param_names;
1348 clang::DeclContext *containing_decl_ctx =
1350 assert(containing_decl_ctx);
1354 has_template_params, function_param_types,
1355 function_param_names);
1359 bool ignore_containing_context =
false;
1370 if (is_cxx_method && has_template_params) {
1371 ignore_containing_context =
true;
1372 is_cxx_method =
false;
1375 clang::CallingConv calling_convention =
1383 return_clang_type, function_param_types, is_variadic,
1388 bool type_handled =
false;
1389 if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
1390 if (std::optional<const ObjCLanguage::ObjCMethodName> objc_method =
1395 }
else if (is_cxx_method) {
1396 auto [handled, type_sp] =
1398 object_parameter, ignore_containing_context);
1402 type_handled = handled;
1406 if (!type_handled) {
1407 clang::FunctionDecl *function_decl =
nullptr;
1408 clang::FunctionDecl *template_function_decl =
nullptr;
1413 if (
dwarf->ResolveType(abs_die)) {
1414 function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
1417 if (function_decl) {
1423 if (!function_decl) {
1424 char *name_buf =
nullptr;
1431 llvm::ItaniumPartialDemangler D;
1433 name_buf = D.getFunctionBaseName(
nullptr,
nullptr);
1439 function_decl =
m_ast.CreateFunctionDeclaration(
1440 ignore_containing_context ?
m_ast.GetTranslationUnitDecl()
1441 : containing_decl_ctx,
1444 std::free(name_buf);
1446 if (has_template_params) {
1449 template_function_decl =
m_ast.CreateFunctionDeclaration(
1450 ignore_containing_context ?
m_ast.GetTranslationUnitDecl()
1451 : containing_decl_ctx,
1454 clang::FunctionTemplateDecl *func_template_decl =
1455 m_ast.CreateFunctionTemplateDecl(
1457 template_function_decl, template_param_infos);
1458 m_ast.CreateFunctionTemplateSpecializationInfo(
1459 template_function_decl, func_template_decl, template_param_infos);
1464 if (function_decl) {
1467 const clang::FunctionProtoType *function_prototype(
1468 llvm::cast<clang::FunctionProtoType>(
1470 const auto params =
m_ast.CreateParameterDeclarations(
1471 function_decl, *function_prototype, function_param_names);
1472 function_decl->setParams(params);
1473 if (template_function_decl)
1474 template_function_decl->setParams(params);
1479 if (
char const *object_pointer_name = object_parameter.
GetName()) {
1482 "Setting object pointer name: %s on function "
1484 object_pointer_name,
static_cast<void *
>(function_decl));
1486 m_ast.SetMetadata(function_decl, metadata);
1491 return dwarf->MakeType(
1505 Type *element_type =
dwarf->ResolveTypeUID(type_die,
true);
1514 byte_stride = array_info->byte_stride;
1515 bit_stride = array_info->bit_stride;
1517 if (byte_stride == 0 && bit_stride == 0)
1518 byte_stride = llvm::expectedToOptional(element_type->
GetByteSize(
nullptr))
1523 uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
1525 if (array_info && array_info->element_orders.size() > 0) {
1526 auto end = array_info->element_orders.rend();
1527 for (
auto pos = array_info->element_orders.rbegin(); pos != end; ++pos) {
1528 clang_type =
m_ast.CreateArrayType(
1529 array_element_type, *pos, attrs.
is_vector);
1531 uint64_t num_elements = pos->value_or(0);
1532 array_element_type = clang_type;
1533 array_element_bit_stride = num_elements
1534 ? array_element_bit_stride * num_elements
1535 : array_element_bit_stride;
1538 clang_type =
m_ast.CreateArrayType(
1539 array_element_type, std::nullopt, attrs.
is_vector);
1543 dwarf->MakeType(die.
GetID(), empty_name, array_element_bit_stride / 8,
1546 type_sp->SetEncodingType(element_type);
1548 m_ast.SetMetadataAsUserID(type, die.
GetID());
1561 if ((class_type ==
nullptr) || (pointee_type ==
nullptr))
1568 class_clang_type, pointee_clang_type);
1570 if (std::optional<uint64_t> clang_type_size =
1571 llvm::expectedToOptional(clang_type.
GetByteSize(
nullptr))) {
1572 return dwarf->MakeType(die.
GetID(), attrs.
name, *clang_type_size,
nullptr,
1583 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
1591 if (attributes.
Size() == 0)
1595 AccessType accessibility = default_accessibility;
1596 bool is_virtual =
false;
1597 bool is_base_of_class =
true;
1598 off_t member_byte_offset = 0;
1600 for (uint32_t i = 0; i < attributes.
Size(); ++i) {
1606 encoding_form = form_value;
1608 case DW_AT_data_member_location:
1609 if (
auto maybe_offset =
1611 member_byte_offset = *maybe_offset;
1614 case DW_AT_accessibility:
1619 case DW_AT_virtuality:
1620 is_virtual = form_value.
Boolean();
1630 if (base_class_type ==
nullptr) {
1631 module_sp->ReportError(
"{0:x16}: DW_TAG_inheritance failed to "
1632 "resolve the base class at {1:x16}"
1633 " from enclosing type {2:x16}. \nPlease file "
1634 "a bug and attach the file at the start of "
1635 "this error message",
1643 assert(base_class_clang_type);
1645 ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
1648 std::unique_ptr<clang::CXXBaseSpecifier> result =
1650 accessibility, is_virtual,
1655 base_classes.push_back(std::move(result));
1673 clang::CharUnits::fromQuantity(member_byte_offset)));
1686 if (sc_parent_tag == DW_TAG_compile_unit ||
1687 sc_parent_tag == DW_TAG_partial_unit) {
1689 }
else if (sc.
function !=
nullptr && sc_parent_die) {
1690 symbol_context_scope =
1692 if (symbol_context_scope ==
nullptr)
1693 symbol_context_scope = sc.
function;
1695 symbol_context_scope = sc.
module_sp.get();
1698 if (symbol_context_scope !=
nullptr)
1699 type_sp->SetSymbolContextScope(symbol_context_scope);
1716 decl_declaration.
Clear();
1717 std::string qualified_name;
1720 while (parent_decl_ctx_die) {
1724 const dw_tag_t parent_tag = parent_decl_ctx_die.
Tag();
1725 switch (parent_tag) {
1726 case DW_TAG_namespace: {
1727 if (
const char *namespace_name = parent_decl_ctx_die.
GetName()) {
1728 qualified_name.insert(0,
"::");
1729 qualified_name.insert(0, namespace_name);
1731 qualified_name.insert(0,
"(anonymous namespace)::");
1737 case DW_TAG_class_type:
1738 case DW_TAG_structure_type:
1739 case DW_TAG_union_type: {
1740 if (
const char *class_union_struct_name = parent_decl_ctx_die.
GetName()) {
1741 qualified_name.insert(0,
"::");
1742 qualified_name.insert(0,
1744 qualified_name.insert(0, class_union_struct_name);
1751 parent_decl_ctx_die.
Clear();
1756 if (qualified_name.empty())
1757 qualified_name.append(
"::");
1759 qualified_name.append(unique_typename.
GetCString());
1777 uint64_t byte_size = attrs.
byte_size.value_or(0);
1783 dwarf->GetObjectFile()->GetModule()->LogMessage(
1784 log,
"SymbolFileDWARF({0:p}) - {1:x16}: {2} has unique name: {3} ",
1789 dwarf->GetUniqueDWARFASTTypeMap().Find(
1790 unique_typename, die, unique_decl, byte_size,
1792 if (
TypeSP type_sp = unique_ast_entry_type->m_type_sp) {
1793 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1800 unique_ast_entry_type->m_is_forward_declaration) {
1801 unique_ast_entry_type->UpdateToDefDIE(die, unique_decl, byte_size);
1802 clang_type = type_sp->GetForwardCompilerType();
1806 dwarf->GetForwardDeclCompilerTypeToDIE().insert_or_assign(
1818 int tag_decl_kind = -1;
1820 if (tag == DW_TAG_structure_type) {
1821 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Struct);
1823 }
else if (tag == DW_TAG_union_type) {
1824 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Union);
1826 }
else if (tag == DW_TAG_class_type) {
1827 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Class);
1840 dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.
name,
true);
1844 if (debug_map_symfile) {
1848 die, attrs.
name,
true);
1854 dwarf->GetObjectFile()->GetModule()->LogMessage(
1856 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an "
1857 "incomplete objc type, complete type is {5:x8}",
1873 assert(tag_decl_kind != -1);
1875 clang::DeclContext *containing_decl_ctx =
1879 containing_decl_ctx, die,
1885 const clang::Decl::Kind containing_decl_kind =
1886 containing_decl_ctx->getDeclKind();
1898 clang::ClassTemplateDecl *class_template_decl =
1899 m_ast.ParseClassTemplateDecl(
1902 if (!class_template_decl) {
1904 dwarf->GetObjectFile()->GetModule()->LogMessage(
1906 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" "
1907 "clang::ClassTemplateDecl failed to return a decl.",
1914 clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1915 m_ast.CreateClassTemplateSpecializationDecl(
1917 tag_decl_kind, template_param_infos);
1918 if (!class_specialization_decl) {
1920 dwarf->GetObjectFile()->GetModule()->LogMessage(
1922 "SymbolFileDWARF({0:p}) - Failed to create specialization for "
1923 "clang::ClassTemplateDecl({1}, {2:p}).",
1924 this, llvm::StringRef(attrs.
name), class_template_decl);
1930 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
1932 m_ast.SetMetadata(class_template_decl, metadata);
1933 m_ast.SetMetadata(class_specialization_decl, metadata);
1937 clang_type =
m_ast.CreateRecordType(
1952 clang::DeclContext *type_decl_ctx =
1960 auto unique_ast_entry_up = std::make_unique<UniqueDWARFASTType>();
1964 unique_ast_entry_up->m_type_sp = type_sp;
1965 unique_ast_entry_up->m_die = die;
1966 unique_ast_entry_up->m_declaration = unique_decl;
1967 unique_ast_entry_up->m_byte_size = byte_size;
1969 dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
1970 *unique_ast_entry_up);
1978 dwarf->GetForwardDeclCompilerTypeToDIE()
1983 assert(inserted &&
"Type already in the forward declaration map!");
1992 clang::CXXRecordDecl *record_decl =
1994 if (record_decl && record_decl->getDefinition()) {
1995 record_decl->setHasTrivialSpecialMemberForCall();
2000 clang::CXXRecordDecl *record_decl =
2003 record_decl->setArgPassingRestrictions(
2004 clang::RecordArgPassingKind::CannotPassInRegs);
2014 const CompilerType &class_opaque_type,
const char *property_name,
2018 const char *property_setter_name,
const char *property_getter_name,
2043static std::optional<clang::APValue>
MakeAPValue(
const clang::ASTContext &ast,
2046 std::optional<uint64_t> bit_width =
2047 llvm::expectedToOptional(clang_type.
GetBitSize(
nullptr));
2049 return std::nullopt;
2051 bool is_signed =
false;
2054 llvm::APSInt apint(*bit_width, !is_signed);
2058 return clang::APValue(apint);
2064 return std::nullopt;
2066 return clang::APValue(llvm::APFloat(
2074 bool is_template_template_argument =
false;
2077 case DW_TAG_GNU_template_parameter_pack: {
2079 std::make_unique<TypeSystemClang::TemplateParameterInfos>());
2084 if (
const char *name = die.
GetName()) {
2089 case DW_TAG_GNU_template_template_param:
2090 is_template_template_argument =
true;
2092 case DW_TAG_template_type_parameter:
2093 case DW_TAG_template_value_parameter: {
2095 if (attributes.
Size() == 0)
2098 const char *name =
nullptr;
2099 const char *template_name =
nullptr;
2101 uint64_t uval64 = 0;
2102 bool uval64_valid =
false;
2103 bool is_default_template_arg =
false;
2105 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2114 case DW_AT_GNU_template_name:
2127 case DW_AT_const_value:
2129 uval64_valid =
true;
2133 case DW_AT_default_value:
2135 is_default_template_arg = form_value.
Boolean();
2142 clang::ASTContext &ast =
m_ast.getASTContext();
2146 if (!is_template_template_argument) {
2148 if (name && !name[0])
2151 if (tag == DW_TAG_template_value_parameter && uval64_valid) {
2152 if (
auto value =
MakeAPValue(ast, clang_type, uval64)) {
2154 name, clang::TemplateArgument(
2156 std::move(*value), is_default_template_arg));
2166 is_default_template_arg));
2168 auto *tplt_type =
m_ast.CreateTemplateTemplateParmDecl(template_name);
2170 name, clang::TemplateArgument(clang::TemplateName(tplt_type),
2171 is_default_template_arg));
2193 case DW_TAG_template_type_parameter:
2194 case DW_TAG_template_value_parameter:
2195 case DW_TAG_GNU_template_parameter_pack:
2196 case DW_TAG_GNU_template_template_param:
2205 return !template_param_infos.
IsEmpty() ||
2215 std::vector<DWARFDIE> contained_type_dies;
2227 if (tag == DW_TAG_structure_type) {
2229 }
else if (tag == DW_TAG_union_type) {
2231 }
else if (tag == DW_TAG_class_type) {
2235 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
2237 std::vector<DWARFDIE> member_function_dies;
2241 contained_type_dies, delayed_properties,
2242 default_accessibility, layout_info);
2245 for (
const DWARFDIE &die : member_function_dies)
2246 dwarf->ResolveType(die);
2251 dwarf->GetObjCMethods(class_name, [&](
DWARFDIE method_die) {
2257 property.Finalize();
2267 "WARNING: Type completion aborted because forward declaration for "
2268 "'{0}' is C++ while definition is Objective-C.",
2269 llvm::StringRef(die.
GetName()));
2273 if (!bases.empty()) {
2277 for (
const auto &base_class : bases) {
2278 clang::TypeSourceInfo *type_source_info = base_class->getTypeSourceInfo();
2279 if (type_source_info)
2281 m_ast.GetType(type_source_info->getType()));
2296 clang::CXXRecordDecl *record_decl =
2304 if (
m_ast.getASTContext().getTargetInfo().getCXXABI().isMicrosoft()) {
2305 auto IM = record_decl->calculateInheritanceModel();
2306 record_decl->addAttr(clang::MSInheritanceAttr::CreateImplicit(
2307 m_ast.getASTContext(),
true, {},
2308 clang::MSInheritanceAttr::Spelling(IM)));
2315 for (
const DWARFDIE &die : contained_type_dies)
2316 dwarf->ResolveType(die);
2318 return (
bool)clang_type;
2330 llvm::expectedToOptional(type->
GetByteSize(
nullptr)).value_or(0),
2335 return (
bool)clang_type;
2343 std::lock_guard<std::recursive_mutex> guard(
2344 dwarf->GetObjectFile()->GetModule()->GetMutex());
2357 case DW_TAG_structure_type:
2358 case DW_TAG_union_type:
2359 case DW_TAG_class_type:
2362 case DW_TAG_enumeration_type:
2366 assert(
false &&
"not a forward clang type decl!");
2383 auto opaque_decl_ctx =
2394 if (clang_decl !=
nullptr)
2395 return m_ast.GetCompilerDecl(clang_decl);
2403 return m_ast.CreateDeclContext(clang_decl_ctx);
2409 clang::DeclContext *clang_decl_ctx =
2412 return m_ast.CreateDeclContext(clang_decl_ctx);
2418 uint32_t enumerator_byte_size,
const DWARFDIE &parent_die) {
2422 size_t enumerators_added = 0;
2426 if (tag != DW_TAG_enumerator)
2430 if (attributes.
Size() == 0)
2433 const char *name =
nullptr;
2434 std::optional<uint64_t> enum_value;
2437 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2442 case DW_AT_const_value:
2444 enum_value = form_value.
Signed();
2446 enum_value = form_value.
Unsigned();
2453 case DW_AT_description:
2455 case DW_AT_decl_file:
2459 case DW_AT_decl_line:
2462 case DW_AT_decl_column:
2471 if (name && name[0] && enum_value) {
2472 m_ast.AddEnumerationValueToEnumerationType(
2473 clang_type, decl, name, *enum_value, enumerator_byte_size * 8);
2474 ++enumerators_added;
2477 return enumerators_added;
2482 bool is_variadic =
false;
2483 bool has_template_params =
false;
2484 std::vector<CompilerType> param_types;
2485 llvm::SmallVector<llvm::StringRef> param_names;
2492 clang::DeclContext *containing_decl_ctx =
2494 assert(containing_decl_ctx);
2496 const unsigned cv_quals =
2500 has_template_params, param_types, param_names);
2502 for (
size_t i = 0; i < param_types.size(); i++) {
2505 sstr << param_types[i].GetTypeName();
2510 if (cv_quals & clang::Qualifiers::Const)
2518 llvm::DWARFAddressRangesVector unused_func_ranges;
2519 const char *name =
nullptr;
2520 const char *mangled =
nullptr;
2521 std::optional<int> decl_file;
2522 std::optional<int> decl_line;
2523 std::optional<int> decl_column;
2524 std::optional<int> call_file;
2525 std::optional<int> call_line;
2526 std::optional<int> call_column;
2531 if (tag != DW_TAG_subprogram)
2535 decl_line, decl_column, call_file, call_line,
2536 call_column, &frame_base)) {
2540 else if ((die.
GetParent().
Tag() == DW_TAG_compile_unit ||
2546 name && strcmp(name,
"main") != 0) {
2557 std::unique_ptr<Declaration> decl_up;
2558 if (decl_file || decl_line || decl_column)
2559 decl_up = std::make_unique<Declaration>(
2560 die.
GetCU()->
GetFile(decl_file.value_or(0)), decl_line.value_or(0),
2561 decl_column.value_or(0));
2586 Address func_addr = func_ranges[0].GetBaseAddress();
2588 func_sp = std::make_shared<Function>(
2591 func_user_id, func_name, func_type, std::move(func_addr),
2592 std::move(func_ranges));
2594 if (func_sp.get() !=
nullptr) {
2596 func_sp->GetFrameBaseExpression() = frame_base;
2598 return func_sp.get();
2607struct PropertyAttributes {
2608 explicit PropertyAttributes(
const DWARFDIE &die);
2609 const char *prop_name =
nullptr;
2610 const char *prop_getter_name =
nullptr;
2611 const char *prop_setter_name =
nullptr;
2613 uint32_t prop_attributes = 0;
2616struct DiscriminantValue {
2617 explicit DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp);
2619 uint32_t byte_offset;
2621 DWARFFormValue type_ref;
2624struct VariantMember {
2625 explicit VariantMember(DWARFDIE &die,
ModuleSP module_sp);
2626 bool IsDefault()
const;
2628 std::optional<uint32_t> discr_value;
2629 DWARFFormValue type_ref;
2630 ConstString variant_name;
2631 uint32_t byte_offset;
2636 explicit VariantPart(
const DWARFDIE &die,
const DWARFDIE &parent_die,
2639 std::vector<VariantMember> &members();
2641 DiscriminantValue &discriminant();
2644 std::vector<VariantMember> _members;
2645 DiscriminantValue _discriminant;
2650ConstString VariantMember::GetName()
const {
return this->variant_name; }
2652bool VariantMember::IsDefault()
const {
return !discr_value; }
2654VariantMember::VariantMember(DWARFDIE &die,
lldb::ModuleSP module_sp) {
2655 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant);
2659 for (
auto child_die : die.
children()) {
2660 switch (child_die.Tag()) {
2661 case llvm::dwarf::DW_TAG_member: {
2662 DWARFAttributes attributes = child_die.GetAttributes();
2663 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2664 DWARFFormValue form_value;
2669 variant_name = ConstString(form_value.
AsCString());
2672 type_ref = form_value;
2675 case DW_AT_data_member_location:
2676 if (
auto maybe_offset =
2678 byte_offset = *maybe_offset;
2695DiscriminantValue::DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp) {
2697 DWARFAttributes attributes = referenced_die.GetAttributes();
2698 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2700 DWARFFormValue form_value;
2704 type_ref = form_value;
2706 case DW_AT_data_member_location:
2707 if (
auto maybe_offset =
2709 byte_offset = *maybe_offset;
2718VariantPart::VariantPart(
const DWARFDIE &die,
const DWARFDIE &parent_die,
2720 : _members(), _discriminant(die, module_sp) {
2722 for (
auto child : die.
children()) {
2723 if (child.Tag() == llvm::dwarf::DW_TAG_variant) {
2724 _members.push_back(VariantMember(child, module_sp));
2729std::vector<VariantMember> &VariantPart::members() {
return this->_members; }
2731DiscriminantValue &VariantPart::discriminant() {
return this->_discriminant; }
2736 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2747 case DW_AT_bit_offset:
2750 case DW_AT_bit_size:
2753 case DW_AT_byte_size:
2756 case DW_AT_const_value:
2759 case DW_AT_data_bit_offset:
2762 case DW_AT_data_member_location:
2763 if (
auto maybe_offset =
2768 case DW_AT_accessibility:
2772 case DW_AT_artificial:
2775 case DW_AT_declaration:
2802PropertyAttributes::PropertyAttributes(
const DWARFDIE &die) {
2805 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2810 case DW_AT_APPLE_property_name:
2813 case DW_AT_APPLE_property_getter:
2814 prop_getter_name = form_value.
AsCString();
2816 case DW_AT_APPLE_property_setter:
2817 prop_setter_name = form_value.
AsCString();
2819 case DW_AT_APPLE_property_attribute:
2820 prop_attributes = form_value.
Unsigned();
2830 ConstString fixed_setter;
2834 if (prop_getter_name && prop_getter_name[0] ==
'-') {
2835 std::optional<const ObjCLanguage::ObjCMethodName> prop_getter_method =
2837 if (prop_getter_method)
2839 ConstString(prop_getter_method->GetSelector()).GetCString();
2842 if (prop_setter_name && prop_setter_name[0] ==
'-') {
2843 std::optional<const ObjCLanguage::ObjCMethodName> prop_setter_method =
2845 if (prop_setter_method)
2847 ConstString(prop_setter_method->GetSelector()).GetCString();
2851 if (!prop_getter_name)
2852 prop_getter_name = prop_name;
2853 if (!prop_setter_name && prop_name[0] &&
2854 !(prop_attributes & DW_APPLE_PROPERTY_readonly)) {
2857 ss.
Printf(
"set%c%s:", toupper(prop_name[0]), &prop_name[1]);
2860 prop_setter_name = fixed_setter.
GetCString();
2869 assert(die.
Tag() == DW_TAG_APPLE_property);
2874 const PropertyAttributes propAttrs(die);
2876 if (!propAttrs.prop_name) {
2877 module_sp->ReportError(
"{0:x8}: DW_TAG_APPLE_property has no name.",
2884 module_sp->ReportError(
2885 "{0:x8}: DW_TAG_APPLE_property '{1}' refers to type {2:x16}"
2886 " which was unable to be parsed",
2887 die.
GetID(), propAttrs.prop_name,
2894 delayed_properties.emplace_back(
2895 class_clang_type, propAttrs.prop_name,
2897 propAttrs.prop_getter_name, propAttrs.prop_attributes, metadata);
2903 assert(qt->isIntegralOrEnumerationType());
2906 return llvm::createStringError(llvm::inconvertibleErrorCode(),
2907 "TypeSystem not clang");
2911 const unsigned type_bits = ast.getIntWidth(qt);
2912 const bool is_unsigned = qt->isUnsignedIntegerType();
2916 constexpr std::size_t max_bit_size = 64;
2921 if (type_bits > max_bit_size) {
2922 auto msg = llvm::formatv(
"Can only parse integers with up to {0} bits, but "
2923 "given integer has {1} bits.",
2924 max_bit_size, type_bits);
2925 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2929 llvm::APInt result(max_bit_size, form_value.
Unsigned(), !is_unsigned);
2935 const unsigned required_bits =
2936 is_unsigned ? result.getActiveBits() : result.getSignificantBits();
2939 if (required_bits > type_bits) {
2940 std::string value_as_str = is_unsigned
2941 ? std::to_string(form_value.
Unsigned())
2942 : std::to_string(form_value.
Signed());
2943 auto msg = llvm::formatv(
"Can't store {0} value {1} in integer with {2} "
2945 (is_unsigned ?
"unsigned" :
"signed"),
2946 value_as_str, type_bits);
2947 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2951 if (result.getBitWidth() > type_bits)
2952 result = result.trunc(type_bits);
2960 assert(die.
Tag() == DW_TAG_member || die.
Tag() == DW_TAG_variable);
2967 auto accessibility =
2972 class_clang_type, attrs.
name, ct, accessibility);
2974 LLDB_LOG(log,
"Failed to add variable to the record type");
2983 llvm::Expected<llvm::APInt> const_value_or_err =
2985 if (!const_value_or_err) {
2987 "Failed to add const value to variable {1}: {0}",
2988 v->getQualifiedNameAsString());
3002 assert(die.
Tag() == DW_TAG_member);
3007 const uint64_t parent_byte_size =
3009 const uint64_t parent_bit_size =
3034 module_sp->ReportError(
3035 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
3036 " which was unable to be parsed",
3039 module_sp->ReportError(
"{0:x8}: DW_TAG_member refers to type {1:x16}"
3040 " which was unable to be parsed",
3046 const uint64_t character_width = 8;
3050 ? default_accessibility
3059 this_field_info.
bit_offset = field_bit_offset;
3067 byte_size = llvm::expectedToOptional(member_type->
GetByteSize(
nullptr));
3071 this_field_info.
bit_offset += byte_size.value_or(0) * 8;
3085 !(parent_die.
Tag() == DW_TAG_union_type &&
3087 ((this_field_info.
bit_offset >= parent_bit_size) ||
3093 "{0:x16}: {1} ({2}) bitfield named \"{3}\" has invalid "
3094 "bit offset ({4:x8}) member will be ignored. Please file a bug "
3096 "compiler and include the preprocessed output for {5}\n",
3103 field_bit_offset = this_field_info.
bit_offset;
3108 bool detect_unnamed_bitfields =
true;
3111 detect_unnamed_bitfields =
3114 if (detect_unnamed_bitfields)
3116 last_field_info, this_field_info);
3118 last_field_info = this_field_info;
3123 this_field_info.
bit_offset = field_bit_offset;
3127 if (std::optional<uint64_t> clang_type_size =
3128 llvm::expectedToOptional(member_type->
GetByteSize(
nullptr))) {
3129 this_field_info.
bit_size = *clang_type_size * character_width;
3136 last_field_info = this_field_info;
3156 class_clang_type, attrs.
name, member_clang_type, accessibility,
3159 m_ast.SetMetadataAsUserID(field_decl, die.
GetID());
3162 std::make_pair(field_decl, field_bit_offset));
3167 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
3168 std::vector<DWARFDIE> &member_function_dies,
3169 std::vector<DWARFDIE> &contained_type_dies,
3187 case DW_TAG_APPLE_property:
3191 case DW_TAG_variant_part:
3194 default_accessibility, layout_info);
3198 case DW_TAG_variable: {
3204 default_accessibility, layout_info, last_field_info);
3207 case DW_TAG_subprogram:
3209 member_function_dies.push_back(die);
3212 case DW_TAG_inheritance:
3214 module_sp, base_classes, layout_info);
3218 if (llvm::dwarf::isType(tag))
3219 contained_type_dies.push_back(die);
3228 clang::DeclContext *containing_decl_ctx,
const DWARFDIE &parent_die,
3229 bool &is_variadic,
bool &has_template_params,
3230 std::vector<CompilerType> &function_param_types,
3238 case DW_TAG_formal_parameter: {
3248 function_param_names.emplace_back(die.
GetName());
3252 case DW_TAG_unspecified_parameters:
3256 case DW_TAG_template_type_parameter:
3257 case DW_TAG_template_value_parameter:
3258 case DW_TAG_GNU_template_parameter_pack:
3264 has_template_params =
true;
3272 assert(function_param_names.size() == function_param_types.size());
3279 switch (die.
Tag()) {
3280 case DW_TAG_constant:
3281 case DW_TAG_formal_parameter:
3282 case DW_TAG_imported_declaration:
3283 case DW_TAG_imported_module:
3285 case DW_TAG_variable:
3299 return cache_pos->second;
3314 clang::Decl *decl =
nullptr;
3315 switch (die.
Tag()) {
3316 case DW_TAG_variable:
3317 case DW_TAG_constant:
3318 case DW_TAG_formal_parameter: {
3321 if (
dwarf && type) {
3322 const char *name = die.
GetName();
3323 clang::DeclContext *decl_context =
3325 dwarf->GetDeclContextContainingUID(die.
GetID()));
3326 decl =
m_ast.CreateVariableDeclaration(
3332 case DW_TAG_imported_declaration: {
3337 if (imported_decl) {
3338 clang::DeclContext *decl_context =
3340 dwarf->GetDeclContextContainingUID(die.
GetID()));
3341 if (clang::NamedDecl *clang_imported_decl =
3342 llvm::dyn_cast<clang::NamedDecl>(
3344 decl =
m_ast.CreateUsingDeclaration(
3350 case DW_TAG_imported_module: {
3357 if (imported_decl_ctx) {
3358 clang::DeclContext *decl_context =
3360 dwarf->GetDeclContextContainingUID(die.
GetID()));
3361 if (clang::NamespaceDecl *ns_decl =
3364 decl =
m_ast.CreateUsingDirectiveDeclaration(
3386 bool try_parsing_type =
true;
3387 switch (die.
Tag()) {
3388 case DW_TAG_compile_unit:
3389 case DW_TAG_partial_unit:
3390 decl_ctx =
m_ast.GetTranslationUnitDecl();
3391 try_parsing_type =
false;
3394 case DW_TAG_namespace:
3396 try_parsing_type =
false;
3399 case DW_TAG_imported_declaration:
3401 try_parsing_type =
false;
3404 case DW_TAG_lexical_block:
3406 try_parsing_type =
false;
3413 if (decl_ctx ==
nullptr && try_parsing_type) {
3433 parent = parent.GetParent()) {
3435 if (tag == DW_TAG_module) {
3455 switch (die.
Tag()) {
3456 case DW_TAG_subprogram:
3457 case DW_TAG_inlined_subroutine:
3467 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3474 assert(0 &&
"Shouldn't call GetContainingFunctionWithAbstractOrigin on "
3475 "something not in a function");
3481 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3503 assert(die.
Tag() == DW_TAG_lexical_block);
3504 DWARFDIE containing_function_with_abstract_origin =
3506 if (!containing_function_with_abstract_origin) {
3510 die, containing_function_with_abstract_origin);
3517 if (die && die.
Tag() == DW_TAG_lexical_block) {
3518 clang::BlockDecl *decl =
3523 clang::DeclContext *decl_context =
3537clang::NamespaceDecl *
3539 if (die && die.
Tag() == DW_TAG_namespace) {
3542 clang::NamespaceDecl *namespace_decl =
3545 return namespace_decl;
3547 const char *namespace_name = die.
GetName();
3548 clang::DeclContext *containing_decl_ctx =
3553 namespace_decl =
m_ast.GetUniqueNamespaceDeclaration(
3559 return namespace_decl;
3565clang::NamespaceDecl *
3567 assert(die && die.
Tag() == DW_TAG_imported_declaration);
3573 return static_cast<clang::NamespaceDecl *
>(it->getSecond());
3575 clang::NamespaceDecl *namespace_decl =
nullptr;
3582 switch (imported_uid.
Tag()) {
3583 case DW_TAG_imported_declaration:
3586 case DW_TAG_namespace:
3593 if (!namespace_decl)
3598 return namespace_decl;
3605 DWARFDIE decl_ctx_die =
dwarf->GetDeclContextDIEContainingDIE(die);
3607 if (decl_ctx_die_copy)
3608 *decl_ctx_die_copy = decl_ctx_die;
3611 clang::DeclContext *clang_decl_ctx =
3614 return clang_decl_ctx;
3616 return m_ast.GetTranslationUnitDecl();
3640 if (!class_type || !src_class_die || !dst_class_die)
3642 if (src_class_die.
Tag() != dst_class_die.
Tag())
3652 if (die.
Tag() != DW_TAG_subprogram)
3664 map_artificial.Append(const_name, die);
3666 map.Append(const_name, die);
3675 src_die = src_die.GetSibling()) {
3676 gather(src_die, src_name_to_die, src_name_to_die_artificial);
3679 dst_die = dst_die.GetSibling()) {
3680 gather(dst_die, dst_name_to_die, dst_name_to_die_artificial);
3682 const uint32_t src_size = src_name_to_die.
GetSize();
3683 const uint32_t dst_size = dst_name_to_die.
GetSize();
3686 bool fast_path =
true;
3688 if (src_size != dst_size)
3694 for (idx = 0; idx < src_size; ++idx) {
3698 if (src_die.
Tag() != dst_die.
Tag())
3705 if (src_name == dst_name || (strcmp(src_name, dst_name) == 0))
3712 auto *src_dwarf_ast_parser = llvm::cast<DWARFASTParserClang>(
3714 auto *dst_dwarf_ast_parser = llvm::cast<DWARFASTParserClang>(
3718 clang::DeclContext *dst_decl_ctx =
3719 dst_dwarf_ast_parser->m_die_to_decl_ctx[dst.GetDIE()];
3721 src_dwarf_ast_parser->LinkDeclContextToDIE(dst_decl_ctx, src);
3723 if (
Type *src_child_type = die_to_type.lookup(src.
GetDIE()))
3724 die_to_type[dst.GetDIE()] = src_child_type;
3731 for (idx = 0; idx < src_size; ++idx) {
3741 src_name_to_die.
Sort();
3743 for (idx = 0; idx < dst_size; ++idx) {
3748 if (src_die && (src_die.
Tag() == dst_die.
Tag()))
3749 link(src_die, dst_die);
3751 failures.push_back(dst_die);
3756 const uint32_t src_size_artificial = src_name_to_die_artificial.
GetSize();
3757 const uint32_t dst_size_artificial = dst_name_to_die_artificial.
GetSize();
3759 if (src_size_artificial && dst_size_artificial) {
3760 dst_name_to_die_artificial.
Sort();
3762 for (idx = 0; idx < src_size_artificial; ++idx) {
3768 dst_name_to_die_artificial.
Find(src_name_artificial,
DWARFDIE());
3772 link(src_die, dst_die);
3776 if (dst_size_artificial) {
3777 for (idx = 0; idx < dst_size_artificial; ++idx) {
3783 return !failures.empty();
3787 FieldInfo const &last_field_info, uint64_t last_field_end,
3792 if (this_field_info.
bit_offset <= last_field_end)
3806 const bool have_base = layout_info.
base_offsets.size() != 0;
3807 const bool this_is_first_field =
3809 const bool first_field_is_vptr =
3812 if (have_base && (this_is_first_field || first_field_is_vptr))
3823 const uint64_t word_width = 32;
3831 if (last_field_end != 0 && ((last_field_end % word_width) != 0))
3832 last_field_end += word_width - (last_field_end % word_width);
3837 current_field, class_layout_info))
3842 const uint64_t unnamed_bit_size = current_field.
bit_offset - last_field_end;
3843 const uint64_t unnamed_bit_offset = last_field_end;
3845 clang::FieldDecl *unnamed_bitfield_decl =
3847 class_clang_type, llvm::StringRef(),
3852 std::make_pair(unnamed_bitfield_decl, unnamed_bit_offset));
3860 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant_part);
3866 VariantPart variants(die, parent_die, module_sp);
3868 auto discriminant_type =
3869 die.
ResolveTypeUID(variants.discriminant().type_ref.Reference());
3871 auto decl_context =
m_ast.GetDeclContextForType(class_clang_type);
3873 auto inner_holder =
m_ast.CreateRecordType(
3876 llvm::formatv(
"{0}$Inner", class_clang_type.
GetTypeName(
false))),
3878 m_ast.StartTagDeclarationDefinition(inner_holder);
3879 m_ast.SetIsPacked(inner_holder);
3881 for (
auto member : variants.members()) {
3883 auto has_discriminant = !member.IsDefault();
3885 auto member_type = die.
ResolveTypeUID(member.type_ref.Reference());
3887 auto field_type =
m_ast.CreateRecordType(
3890 std::string(llvm::formatv(
"{0}$Variant", member.GetName())),
3891 llvm::to_underlying(clang::TagTypeKind::Struct),
3894 m_ast.StartTagDeclarationDefinition(field_type);
3895 auto offset = member.byte_offset;
3897 if (has_discriminant) {
3898 m_ast.AddFieldToRecordType(
3899 field_type,
"$discr$", discriminant_type->GetFullCompilerType(),
3902 llvm::expectedToOptional(discriminant_type->GetByteSize(
nullptr))
3906 m_ast.AddFieldToRecordType(field_type,
"value",
3907 member_type->GetFullCompilerType(),
3910 m_ast.CompleteTagDeclarationDefinition(field_type);
3912 auto name = has_discriminant
3913 ? llvm::formatv(
"$variant${0}", member.discr_value.value())
3914 : std::string(
"$variant$");
3917 m_ast.AddFieldToRecordType(inner_holder, llvm::StringRef(name),
3918 field_type, default_accesibility, 0);
3923 auto inner_field =
m_ast.AddFieldToRecordType(class_clang_type,
3924 llvm::StringRef(
"$variants$"),
3927 m_ast.CompleteTagDeclarationDefinition(inner_holder);
static bool DeclKindIsCXXClass(clang::Decl::Kind decl_kind)
static std::string GetUnitName(const DWARFDIE &die)
static std::string MakeLLDBFuncAsmLabel(const DWARFDIE &die)
static unsigned GetCXXMethodCVQuals(const DWARFDIE &subprogram, const DWARFDIE &object_parameter)
In order to determine the CV-qualifiers for a C++ class method in DWARF, we have to look at the CV-qu...
static clang::CallingConv ConvertDWARFCallingConventionToClang(const ParsedDWARFTypeAttributes &attrs)
static bool IsSubroutine(const DWARFDIE &die)
static TypePayloadClang GetPtrAuthMofidierPayload(const DWARFDIE &die)
static std::optional< clang::APValue > MakeAPValue(const clang::ASTContext &ast, CompilerType clang_type, uint64_t value)
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...
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)
std::string GetDIEClassTemplateParams(lldb_private::plugin::dwarf::DWARFDIE die) override
Returns the template parameters of a class DWARFDIE as a string.
bool CompleteRecordType(const lldb_private::plugin::dwarf::DWARFDIE &die, const lldb_private::CompilerType &clang_type)
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)
lldb_private::plugin::dwarf::DWARFDIE GetObjectParameter(const lldb_private::plugin::dwarf::DWARFDIE &subprogram, const lldb_private::plugin::dwarf::DWARFDIE &decl_ctx_die)
Get the object parameter DIE if one exists, otherwise returns a default DWARFDIE.
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.
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::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)
bool ParseObjCMethod(const lldb_private::ObjCLanguage::ObjCMethodName &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.
~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
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
lldb_private::Function * ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit, const lldb_private::plugin::dwarf::DWARFDIE &die, lldb_private::AddressRanges func_ranges) override
void ParseChildParameters(clang::DeclContext *containing_decl_ctx, const lldb_private::plugin::dwarf::DWARFDIE &parent_die, bool &is_variadic, bool &has_template_params, std::vector< lldb_private::CompilerType > &function_param_types, llvm::SmallVectorImpl< llvm::StringRef > &function_param_names)
void AddUnnamedBitfieldToRecordTypeIfNeeded(lldb_private::ClangASTImporter::LayoutInfo &class_layout_info, const lldb_private::CompilerType &class_clang_type, const FieldInfo &previous_field, const FieldInfo ¤t_field)
Tries to detect whether class_clang_type contained an unnamed bit-field between previous_field and cu...
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)
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)
DWARFASTParserClang(lldb_private::TypeSystemClang &ast)
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)
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, const lldb_private::plugin::dwarf::DWARFDIE &object_parameter, bool &ignore_containing_context)
Helper function called by ParseSubroutine when parsing C++ methods.
A section + offset based address class.
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
Generic representation of a type in a programming language.
bool IsEnumerationType(bool &is_signed) const
TypeSystemSPWrapper GetTypeSystem() const
Accessors.
bool IsCompleteType() const
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
lldb::opaque_compiler_type_t GetOpaqueQualType() const
bool IsBeingDefined() const
bool IsIntegerOrEnumerationType(bool &is_signed) const
ConstString GetTypeName(bool BaseOnly=false) const
bool IsEnumerationIntegerTypeSigned() const
bool GetCompleteType() const
Type Completion.
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
bool IsFloatingPointType(bool &is_complex) const
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
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 Delegate *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 SetDemangledName(ConstString name)
void SetMangledName(ConstString name)
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 ObjCMethodName > Create(llvm::StringRef name, bool strict)
The static factory method for creating a ObjCMethodName.
llvm::StringRef GetClassName() const
Returns a reference to the class name.
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
Provides public interface for all SymbolFiles.
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.
static clang::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, lldb::AccessType access, uint32_t bitfield_bit_size)
bool SetDeclIsForcefullyCompleted(const clang::TagDecl *td)
static clang::DeclContext * GetDeclContextForType(clang::QualType type)
static bool IsCXXClassType(const CompilerType &type)
static clang::TagDecl * GetAsTagDecl(const CompilerType &type)
static void SetIntegerInitializerForVariable(clang::VarDecl *var, const llvm::APInt &init_value)
Initializes a variable with an integer value.
static void BuildIndirectFields(const CompilerType &type)
static bool CompleteTagDeclarationDefinition(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)
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)
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::ASTContext & getASTContext() const
Returns the clang::ASTContext instance managed by this TypeSystemClang.
static CompilerType CreateMemberPointerType(const CompilerType &type, const CompilerType &pointee_type)
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()
CompilerType GetFullCompilerType()
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope)
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)
DWARFASTParser(Kind kind)
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
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
const char * GetMangledName(bool substitute_name_allowed=true) const
DWARFDIE GetFirstChild() const
DWARFDIE GetParent() const
bool GetDIENamesAndRanges(const char *&name, const char *&mangled, llvm::DWARFAddressRangesVector &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 GetDIE(dw_offset_t die_offset) const
llvm::iterator_range< child_iterator > children() const
The range of all the children of this DIE.
DWARFDIE GetParentDeclContextDIE() const
bool IsStructUnionOrClass() const
Type * ResolveTypeUID(const DWARFDIE &die) const
std::vector< CompilerContext > GetDeclContext(bool derive_template_names=false) const
Return this DIE's decl context as it is needed to look up types in Clang modules.
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)
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)
virtual llvm::DenseMap< const DWARFDebugInfoEntry *, Type * > & GetDIEToType()
static CompilerDecl GetDecl(const DWARFDIE &die)
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.
@ eLanguageTypeUnknown
Unknown or invalid language value.
@ 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)
uint64_t GetEffectiveFieldEnd() const
If this field was folded into storage of a previous field, returns the offset in bits of where that s...
bool IsArtificial() const
uint64_t bit_offset
Offset of this field in bits from the beginning of the containing struct.
void SetEffectiveFieldEnd(uint64_t val)
bool NextBitfieldOffsetIsValid(const uint64_t next_bit_offset) const
uint64_t GetFieldEnd() const
Returns the offset in bits of where the storage this field occupies ends.
void SetIsBitfield(bool flag)
uint64_t bit_size
Size in bits that this field occupies.
bool is_bitfield
Set to 'true' if this field is a bit-field.
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
uint32_t encoding
Indicates ref-qualifier of C++ member function if present.
lldb_private::ConstString name
std::optional< clang::EnumExtensibilityAttr::Kind > enum_kind
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
clang::StorageClass storage
ParsedDWARFTypeAttributes(const lldb_private::plugin::dwarf::DWARFDIE &die)
clang::RefQualifierKind ref_qual
Has a value if this DIE represents an enum that was declared with enum_extensibility.
lldb_private::plugin::dwarf::DWARFFormValue specification
lldb_private::plugin::dwarf::DWARFFormValue abstract_origin
std::optional< uint64_t > data_bit_size
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)
Holds parsed information about a function call label that LLDB attaches as an AsmLabel to function AS...
std::string toString() const
Encode this FunctionCallLabel into its string representation.
lldb::user_id_t GetID() const
Get accessor for the user ID.