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_base_type:
627 case DW_TAG_pointer_type:
628 case DW_TAG_reference_type:
629 case DW_TAG_rvalue_reference_type:
630 case DW_TAG_const_type:
631 case DW_TAG_restrict_type:
632 case DW_TAG_volatile_type:
633 case DW_TAG_LLVM_ptrauth_type:
634 case DW_TAG_atomic_type:
635 case DW_TAG_unspecified_type:
638 case DW_TAG_structure_type:
639 case DW_TAG_union_type:
640 case DW_TAG_class_type:
643 case DW_TAG_enumeration_type:
646 case DW_TAG_inlined_subroutine:
647 case DW_TAG_subprogram:
648 case DW_TAG_subroutine_type:
651 case DW_TAG_array_type:
654 case DW_TAG_ptr_to_member_type:
658 dwarf->GetObjectFile()->GetModule()->ReportError(
659 "[{0:x16}]: unhandled type tag {1:x4} ({2}), "
660 "please file a bug and "
661 "attach the file at the start of this error message",
668 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
673static std::optional<uint32_t>
684 Value initialValue(0);
686 uint32_t block_length = form_value.
Unsigned();
687 uint32_t block_offset =
697 "ExtractDataMemberLocation failed: {0}");
701 return memberOffset->ResolveValue(
nullptr).UInt();
705 auto getAttr = [&](llvm::dwarf::Attribute Attr,
unsigned defaultValue = 0) {
708 const unsigned key = getAttr(DW_AT_LLVM_ptrauth_key);
709 const bool addr_disc = getAttr(DW_AT_LLVM_ptrauth_address_discriminated);
710 const unsigned extra = getAttr(DW_AT_LLVM_ptrauth_extra_discriminator);
711 const bool isapointer = getAttr(DW_AT_LLVM_ptrauth_isa_pointer);
712 const bool authenticates_null_values =
713 getAttr(DW_AT_LLVM_ptrauth_authenticates_null_values);
714 const unsigned authentication_mode_int = getAttr(
715 DW_AT_LLVM_ptrauth_authentication_mode,
716 static_cast<unsigned>(clang::PointerAuthenticationMode::SignAndAuth));
717 clang::PointerAuthenticationMode authentication_mode =
718 clang::PointerAuthenticationMode::SignAndAuth;
719 if (authentication_mode_int >=
720 static_cast<unsigned>(clang::PointerAuthenticationMode::None) &&
721 authentication_mode_int <=
722 static_cast<unsigned>(
723 clang::PointerAuthenticationMode::SignAndAuth)) {
724 authentication_mode =
725 static_cast<clang::PointerAuthenticationMode
>(authentication_mode_int);
728 "[{0:x16}]: invalid pointer authentication mode method {1:x4}",
729 die.
GetOffset(), authentication_mode_int);
731 auto ptr_auth = clang::PointerAuthQualifier::Create(
732 key, addr_disc, extra, authentication_mode, isapointer,
733 authenticates_null_values);
751 if (tag == DW_TAG_typedef) {
801 encoding_uid.Reference());
807 case DW_TAG_unspecified_type:
808 if (attrs.
name ==
"nullptr_t" || attrs.
name ==
"decltype(nullptr)") {
817 case DW_TAG_base_type: {
825 clang_type =
m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
829 case DW_TAG_pointer_type:
832 case DW_TAG_reference_type:
835 case DW_TAG_rvalue_reference_type:
841 case DW_TAG_const_type:
844 case DW_TAG_restrict_type:
847 case DW_TAG_volatile_type:
850 case DW_TAG_LLVM_ptrauth_type:
854 case DW_TAG_atomic_type:
861 if (tag == DW_TAG_pointer_type) {
869 if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name,
""),
874 if (function_pointer_type) {
878 bool function_type_is_new_pointer;
880 sc, function_type, &function_type_is_new_pointer);
882 if (lldb_function_type_sp) {
883 clang_type =
m_ast.CreateBlockPointerType(
884 lldb_function_type_sp->GetForwardCompilerType());
900 if (attrs.
name ==
"id") {
902 dwarf->GetObjectFile()->GetModule()->LogMessage(
904 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
905 "is Objective-C 'id' built-in type.",
912 }
else if (attrs.
name ==
"Class") {
914 dwarf->GetObjectFile()->GetModule()->LogMessage(
916 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
917 "is Objective-C 'Class' built-in type.",
924 }
else if (attrs.
name ==
"SEL") {
926 dwarf->GetObjectFile()->GetModule()->LogMessage(
928 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
929 "is Objective-C 'selector' built-in type.",
944 if (encoding_die && encoding_die.
Tag() == DW_TAG_structure_type) {
945 llvm::StringRef struct_name = encoding_die.
GetName();
946 if (struct_name ==
"objc_object") {
948 dwarf->GetObjectFile()->GetModule()->LogMessage(
950 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
951 "is 'objc_object*', which we overrode to 'id'.",
966 &attrs.
decl, clang_type, resolve_state, payload);
973 if (llvm::StringRef(die.
GetName()).contains(
"<"))
977 llvm::raw_string_ostream os(name);
978 llvm::DWARFTypePrinter<DWARFDIE> type_printer(os);
979 type_printer.appendAndTerminateTemplateParameters(die);
994 unique_typename, decl_declaration);
996 dwarf->GetUniqueDWARFASTTypeMap().Find(
997 unique_typename, decl_die, decl_declaration,
1000 unique_ast_entry_type->UpdateToDefDIE(def_die, def_attrs.
decl,
1005 "Failed to find {0:x16} {1} ({2}) type \"{3}\" in "
1006 "UniqueDWARFASTTypeMap",
1023 def_die =
dwarf->FindDefinitionDIE(decl_die);
1027 if (debug_map_symfile) {
1035 dwarf->GetObjectFile()->GetModule()->LogMessage(
1037 "SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a "
1038 "forward declaration, complete DIE is {5}",
1041 def_die ? llvm::utohexstr(def_die.
GetID()) :
"not found");
1045 if (
auto [it, inserted] =
dwarf->GetDIEToType().try_emplace(
1050 return it->getSecond()->shared_from_this();
1061 Type *enumerator_type =
1063 if (enumerator_type)
1067 if (!enumerator_clang_type) {
1069 enumerator_clang_type =
m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
1070 "", DW_ATE_signed, *attrs.
byte_size * 8);
1087 clang::DeclContext *type_decl_ctx =
1090 if (decl_die != def_die) {
1092 dwarf->GetDIEToType()[def_die.
GetDIE()] = type_sp.get();
1097 dwarf->GetObjectFile()->GetModule()->ReportError(
1098 "DWARF DIE at {0:x16} named \"{1}\" was not able to start its "
1099 "definition.\nPlease file a bug and attach the file at the "
1100 "start of this error message",
1106static clang::CallingConv
1109 case llvm::dwarf::DW_CC_normal:
1111 case llvm::dwarf::DW_CC_BORLAND_stdcall:
1112 return clang::CC_X86StdCall;
1113 case llvm::dwarf::DW_CC_BORLAND_msfastcall:
1114 return clang::CC_X86FastCall;
1115 case llvm::dwarf::DW_CC_LLVM_vectorcall:
1116 return clang::CC_X86VectorCall;
1117 case llvm::dwarf::DW_CC_BORLAND_pascal:
1118 return clang::CC_X86Pascal;
1119 case llvm::dwarf::DW_CC_LLVM_Win64:
1120 return clang::CC_Win64;
1121 case llvm::dwarf::DW_CC_LLVM_X86_64SysV:
1122 return clang::CC_X86_64SysV;
1123 case llvm::dwarf::DW_CC_LLVM_X86RegCall:
1124 return clang::CC_X86RegCall;
1130 LLDB_LOG(log,
"Unsupported DW_AT_calling_convention value: {0}",
1143 const auto tag = die.
Tag();
1148 TypeSP complete_objc_class_type_sp =
1149 dwarf->FindCompleteObjCDefinitionTypeForDIE(
DWARFDIE(), class_name,
1152 if (!complete_objc_class_type_sp)
1156 complete_objc_class_type_sp->GetForwardCompilerType();
1158 if (!type_clang_forward_type)
1164 clang::ObjCMethodDecl *objc_method_decl =
m_ast.AddMethodToObjCObjectType(
1168 if (!objc_method_decl) {
1169 dwarf->GetObjectFile()->GetModule()->ReportError(
1170 "[{0:x16}]: invalid Objective-C method {1:x4} ({2}), "
1171 "please file a bug and attach the file at the start of "
1172 "this error message",
1178 m_ast.SetMetadataAsUserID(objc_method_decl, die.
GetID());
1186 const DWARFDIE &object_parameter,
bool &ignore_containing_context) {
1191 Type *class_type =
dwarf->ResolveType(decl_ctx_die);
1195 if (class_type->
GetID() != decl_ctx_die.
GetID() ||
1202 std::vector<DWARFDIE> failures;
1214 return {
true, type_ptr->shared_from_this()};
1228 clang::DeclContext *spec_clang_decl_ctx =
1230 if (spec_clang_decl_ctx)
1233 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1234 "{0:x8}: DW_AT_specification({1:x16}"
1238 return {
true,
nullptr};
1250 if (abs_clang_decl_ctx)
1253 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1254 "{0:x8}: DW_AT_abstract_origin({1:x16}"
1258 return {
true,
nullptr};
1271 const bool is_static = !object_parameter.
IsValid();
1277 return {
true,
nullptr};
1279 const bool is_attr_used =
false;
1283 const auto accessibility =
1286 clang::CXXMethodDecl *cxx_method_decl =
m_ast.AddMethodToCXXRecordType(
1292 if (cxx_method_decl) {
1298 if (
char const *object_pointer_name = object_parameter.
GetName()) {
1300 LLDB_LOGF(log,
"Setting object pointer name: %s on method object %p.\n",
1301 object_pointer_name,
static_cast<void *
>(cxx_method_decl));
1303 m_ast.SetMetadata(cxx_method_decl, metadata);
1305 ignore_containing_context =
true;
1310 const bool type_handled = cxx_method_decl !=
nullptr || attrs.
is_artificial;
1312 return {type_handled,
nullptr};
1323 bool is_variadic =
false;
1324 bool has_template_params =
false;
1330 Type *func_type =
nullptr;
1340 std::vector<CompilerType> function_param_types;
1341 llvm::SmallVector<llvm::StringRef> function_param_names;
1346 clang::DeclContext *containing_decl_ctx =
1348 assert(containing_decl_ctx);
1352 has_template_params, function_param_types,
1353 function_param_names);
1357 bool ignore_containing_context =
false;
1368 if (is_cxx_method && has_template_params) {
1369 ignore_containing_context =
true;
1370 is_cxx_method =
false;
1373 clang::CallingConv calling_convention =
1381 return_clang_type, function_param_types, is_variadic,
1386 bool type_handled =
false;
1387 if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
1388 if (std::optional<const ObjCLanguage::ObjCMethodName> objc_method =
1393 }
else if (is_cxx_method) {
1394 auto [handled, type_sp] =
1396 object_parameter, ignore_containing_context);
1400 type_handled = handled;
1404 if (!type_handled) {
1405 clang::FunctionDecl *function_decl =
nullptr;
1406 clang::FunctionDecl *template_function_decl =
nullptr;
1411 if (
dwarf->ResolveType(abs_die)) {
1412 function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
1415 if (function_decl) {
1421 if (!function_decl) {
1422 char *name_buf =
nullptr;
1429 llvm::ItaniumPartialDemangler D;
1431 name_buf = D.getFunctionBaseName(
nullptr,
nullptr);
1437 function_decl =
m_ast.CreateFunctionDeclaration(
1438 ignore_containing_context ?
m_ast.GetTranslationUnitDecl()
1439 : containing_decl_ctx,
1442 std::free(name_buf);
1444 if (has_template_params) {
1447 template_function_decl =
m_ast.CreateFunctionDeclaration(
1448 ignore_containing_context ?
m_ast.GetTranslationUnitDecl()
1449 : containing_decl_ctx,
1452 clang::FunctionTemplateDecl *func_template_decl =
1453 m_ast.CreateFunctionTemplateDecl(
1455 template_function_decl, template_param_infos);
1456 m_ast.CreateFunctionTemplateSpecializationInfo(
1457 template_function_decl, func_template_decl, template_param_infos);
1462 if (function_decl) {
1465 const clang::FunctionProtoType *function_prototype(
1466 llvm::cast<clang::FunctionProtoType>(
1468 const auto params =
m_ast.CreateParameterDeclarations(
1469 function_decl, *function_prototype, function_param_names);
1470 function_decl->setParams(params);
1471 if (template_function_decl)
1472 template_function_decl->setParams(params);
1477 if (
char const *object_pointer_name = object_parameter.
GetName()) {
1480 "Setting object pointer name: %s on function "
1482 object_pointer_name,
static_cast<void *
>(function_decl));
1484 m_ast.SetMetadata(function_decl, metadata);
1489 return dwarf->MakeType(
1503 Type *element_type =
dwarf->ResolveTypeUID(type_die,
true);
1512 byte_stride = array_info->byte_stride;
1513 bit_stride = array_info->bit_stride;
1515 if (byte_stride == 0 && bit_stride == 0)
1516 byte_stride = llvm::expectedToOptional(element_type->
GetByteSize(
nullptr))
1521 uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
1523 if (array_info && array_info->element_orders.size() > 0) {
1524 auto end = array_info->element_orders.rend();
1525 for (
auto pos = array_info->element_orders.rbegin(); pos != end; ++pos) {
1526 clang_type =
m_ast.CreateArrayType(
1527 array_element_type, *pos, attrs.
is_vector);
1529 uint64_t num_elements = pos->value_or(0);
1530 array_element_type = clang_type;
1531 array_element_bit_stride = num_elements
1532 ? array_element_bit_stride * num_elements
1533 : array_element_bit_stride;
1536 clang_type =
m_ast.CreateArrayType(
1537 array_element_type, std::nullopt, attrs.
is_vector);
1541 dwarf->MakeType(die.
GetID(), empty_name, array_element_bit_stride / 8,
1544 type_sp->SetEncodingType(element_type);
1546 m_ast.SetMetadataAsUserID(type, die.
GetID());
1559 if ((class_type ==
nullptr) || (pointee_type ==
nullptr))
1566 class_clang_type, pointee_clang_type);
1568 if (std::optional<uint64_t> clang_type_size =
1569 llvm::expectedToOptional(clang_type.
GetByteSize(
nullptr))) {
1570 return dwarf->MakeType(die.
GetID(), attrs.
name, *clang_type_size,
nullptr,
1581 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
1589 if (attributes.
Size() == 0)
1593 AccessType accessibility = default_accessibility;
1594 bool is_virtual =
false;
1595 bool is_base_of_class =
true;
1596 off_t member_byte_offset = 0;
1598 for (uint32_t i = 0; i < attributes.
Size(); ++i) {
1604 encoding_form = form_value;
1606 case DW_AT_data_member_location:
1607 if (
auto maybe_offset =
1609 member_byte_offset = *maybe_offset;
1612 case DW_AT_accessibility:
1617 case DW_AT_virtuality:
1618 is_virtual = form_value.
Boolean();
1628 if (base_class_type ==
nullptr) {
1629 module_sp->ReportError(
"{0:x16}: DW_TAG_inheritance failed to "
1630 "resolve the base class at {1:x16}"
1631 " from enclosing type {2:x16}. \nPlease file "
1632 "a bug and attach the file at the start of "
1633 "this error message",
1641 assert(base_class_clang_type);
1643 ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
1646 std::unique_ptr<clang::CXXBaseSpecifier> result =
1648 accessibility, is_virtual,
1653 base_classes.push_back(std::move(result));
1671 clang::CharUnits::fromQuantity(member_byte_offset)));
1684 if (sc_parent_tag == DW_TAG_compile_unit ||
1685 sc_parent_tag == DW_TAG_partial_unit) {
1687 }
else if (sc.
function !=
nullptr && sc_parent_die) {
1688 symbol_context_scope =
1690 if (symbol_context_scope ==
nullptr)
1691 symbol_context_scope = sc.
function;
1693 symbol_context_scope = sc.
module_sp.get();
1696 if (symbol_context_scope !=
nullptr)
1697 type_sp->SetSymbolContextScope(symbol_context_scope);
1711 decl_declaration.
Clear();
1712 std::string qualified_name;
1715 while (parent_decl_ctx_die) {
1719 const dw_tag_t parent_tag = parent_decl_ctx_die.
Tag();
1720 switch (parent_tag) {
1721 case DW_TAG_namespace: {
1722 if (
const char *namespace_name = parent_decl_ctx_die.
GetName()) {
1723 qualified_name.insert(0,
"::");
1724 qualified_name.insert(0, namespace_name);
1726 qualified_name.insert(0,
"(anonymous namespace)::");
1732 case DW_TAG_class_type:
1733 case DW_TAG_structure_type:
1734 case DW_TAG_union_type: {
1735 if (
const char *class_union_struct_name = parent_decl_ctx_die.
GetName()) {
1736 qualified_name.insert(0,
"::");
1737 qualified_name.insert(0,
1739 qualified_name.insert(0, class_union_struct_name);
1746 parent_decl_ctx_die.
Clear();
1751 if (qualified_name.empty())
1752 qualified_name.append(
"::");
1754 qualified_name.append(unique_typename.
GetCString());
1772 uint64_t byte_size = attrs.
byte_size.value_or(0);
1778 dwarf->GetObjectFile()->GetModule()->LogMessage(
1779 log,
"SymbolFileDWARF({0:p}) - {1:x16}: {2} has unique name: {3} ",
1784 dwarf->GetUniqueDWARFASTTypeMap().Find(
1785 unique_typename, die, unique_decl, byte_size,
1787 if (
TypeSP type_sp = unique_ast_entry_type->m_type_sp) {
1788 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1795 unique_ast_entry_type->m_is_forward_declaration) {
1796 unique_ast_entry_type->UpdateToDefDIE(die, unique_decl, byte_size);
1797 clang_type = type_sp->GetForwardCompilerType();
1801 dwarf->GetForwardDeclCompilerTypeToDIE().insert_or_assign(
1813 int tag_decl_kind = -1;
1815 if (tag == DW_TAG_structure_type) {
1816 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Struct);
1818 }
else if (tag == DW_TAG_union_type) {
1819 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Union);
1821 }
else if (tag == DW_TAG_class_type) {
1822 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Class);
1835 dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.
name,
true);
1839 if (debug_map_symfile) {
1843 die, attrs.
name,
true);
1849 dwarf->GetObjectFile()->GetModule()->LogMessage(
1851 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an "
1852 "incomplete objc type, complete type is {5:x8}",
1868 assert(tag_decl_kind != -1);
1870 clang::DeclContext *containing_decl_ctx =
1874 containing_decl_ctx, die,
1880 const clang::Decl::Kind containing_decl_kind =
1881 containing_decl_ctx->getDeclKind();
1893 clang::ClassTemplateDecl *class_template_decl =
1894 m_ast.ParseClassTemplateDecl(
1897 if (!class_template_decl) {
1899 dwarf->GetObjectFile()->GetModule()->LogMessage(
1901 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" "
1902 "clang::ClassTemplateDecl failed to return a decl.",
1909 clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1910 m_ast.CreateClassTemplateSpecializationDecl(
1912 tag_decl_kind, template_param_infos);
1913 if (!class_specialization_decl) {
1915 dwarf->GetObjectFile()->GetModule()->LogMessage(
1917 "SymbolFileDWARF({0:p}) - Failed to create specialization for "
1918 "clang::ClassTemplateDecl({1}, {2:p}).",
1919 this, llvm::StringRef(attrs.
name), class_template_decl);
1925 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
1927 m_ast.SetMetadata(class_template_decl, metadata);
1928 m_ast.SetMetadata(class_specialization_decl, metadata);
1932 clang_type =
m_ast.CreateRecordType(
1947 clang::DeclContext *type_decl_ctx =
1955 auto unique_ast_entry_up = std::make_unique<UniqueDWARFASTType>();
1959 unique_ast_entry_up->m_type_sp = type_sp;
1960 unique_ast_entry_up->m_die = die;
1961 unique_ast_entry_up->m_declaration = unique_decl;
1962 unique_ast_entry_up->m_byte_size = byte_size;
1964 dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
1965 *unique_ast_entry_up);
1973 dwarf->GetForwardDeclCompilerTypeToDIE()
1978 assert(inserted &&
"Type already in the forward declaration map!");
1987 clang::CXXRecordDecl *record_decl =
1989 if (record_decl && record_decl->getDefinition()) {
1990 record_decl->setHasTrivialSpecialMemberForCall();
1995 clang::CXXRecordDecl *record_decl =
1998 record_decl->setArgPassingRestrictions(
1999 clang::RecordArgPassingKind::CannotPassInRegs);
2009 const CompilerType &class_opaque_type,
const char *property_name,
2013 const char *property_setter_name,
const char *property_getter_name,
2038static std::optional<clang::APValue>
MakeAPValue(
const clang::ASTContext &ast,
2041 std::optional<uint64_t> bit_width =
2042 llvm::expectedToOptional(clang_type.
GetBitSize(
nullptr));
2044 return std::nullopt;
2046 bool is_signed =
false;
2049 llvm::APSInt apint(*bit_width, !is_signed);
2053 return clang::APValue(apint);
2059 return std::nullopt;
2061 return clang::APValue(llvm::APFloat(
2069 bool is_template_template_argument =
false;
2072 case DW_TAG_GNU_template_parameter_pack: {
2074 std::make_unique<TypeSystemClang::TemplateParameterInfos>());
2079 if (
const char *name = die.
GetName()) {
2084 case DW_TAG_GNU_template_template_param:
2085 is_template_template_argument =
true;
2087 case DW_TAG_template_type_parameter:
2088 case DW_TAG_template_value_parameter: {
2090 if (attributes.
Size() == 0)
2093 const char *name =
nullptr;
2094 const char *template_name =
nullptr;
2096 uint64_t uval64 = 0;
2097 bool uval64_valid =
false;
2098 bool is_default_template_arg =
false;
2100 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2109 case DW_AT_GNU_template_name:
2122 case DW_AT_const_value:
2124 uval64_valid =
true;
2128 case DW_AT_default_value:
2130 is_default_template_arg = form_value.
Boolean();
2137 clang::ASTContext &ast =
m_ast.getASTContext();
2141 if (!is_template_template_argument) {
2143 if (name && !name[0])
2146 if (tag == DW_TAG_template_value_parameter && uval64_valid) {
2147 if (
auto value =
MakeAPValue(ast, clang_type, uval64)) {
2149 name, clang::TemplateArgument(
2151 std::move(*value), is_default_template_arg));
2161 is_default_template_arg));
2163 auto *tplt_type =
m_ast.CreateTemplateTemplateParmDecl(template_name);
2165 name, clang::TemplateArgument(clang::TemplateName(tplt_type),
2166 is_default_template_arg));
2188 case DW_TAG_template_type_parameter:
2189 case DW_TAG_template_value_parameter:
2190 case DW_TAG_GNU_template_parameter_pack:
2191 case DW_TAG_GNU_template_template_param:
2200 return !template_param_infos.
IsEmpty() ||
2210 std::vector<DWARFDIE> contained_type_dies;
2222 if (tag == DW_TAG_structure_type) {
2224 }
else if (tag == DW_TAG_union_type) {
2226 }
else if (tag == DW_TAG_class_type) {
2230 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
2232 std::vector<DWARFDIE> member_function_dies;
2236 contained_type_dies, delayed_properties,
2237 default_accessibility, layout_info);
2240 for (
const DWARFDIE &die : member_function_dies)
2241 dwarf->ResolveType(die);
2246 dwarf->GetObjCMethods(class_name, [&](
DWARFDIE method_die) {
2252 property.Finalize();
2262 "WARNING: Type completion aborted because forward declaration for "
2263 "'{0}' is C++ while definition is Objective-C.",
2264 llvm::StringRef(die.
GetName()));
2268 if (!bases.empty()) {
2272 for (
const auto &base_class : bases) {
2273 clang::TypeSourceInfo *type_source_info = base_class->getTypeSourceInfo();
2274 if (type_source_info)
2276 m_ast.GetType(type_source_info->getType()));
2291 clang::CXXRecordDecl *record_decl =
2299 if (
m_ast.getASTContext().getTargetInfo().getCXXABI().isMicrosoft()) {
2300 auto IM = record_decl->calculateInheritanceModel();
2301 record_decl->addAttr(clang::MSInheritanceAttr::CreateImplicit(
2302 m_ast.getASTContext(),
true, {},
2303 clang::MSInheritanceAttr::Spelling(IM)));
2310 for (
const DWARFDIE &die : contained_type_dies)
2311 dwarf->ResolveType(die);
2313 return (
bool)clang_type;
2325 llvm::expectedToOptional(type->
GetByteSize(
nullptr)).value_or(0),
2330 return (
bool)clang_type;
2338 std::lock_guard<std::recursive_mutex> guard(
2339 dwarf->GetObjectFile()->GetModule()->GetMutex());
2352 case DW_TAG_structure_type:
2353 case DW_TAG_union_type:
2354 case DW_TAG_class_type:
2357 case DW_TAG_enumeration_type:
2361 assert(
false &&
"not a forward clang type decl!");
2378 auto opaque_decl_ctx =
2389 if (clang_decl !=
nullptr)
2390 return m_ast.GetCompilerDecl(clang_decl);
2398 return m_ast.CreateDeclContext(clang_decl_ctx);
2404 clang::DeclContext *clang_decl_ctx =
2407 return m_ast.CreateDeclContext(clang_decl_ctx);
2413 uint32_t enumerator_byte_size,
const DWARFDIE &parent_die) {
2417 size_t enumerators_added = 0;
2421 if (tag != DW_TAG_enumerator)
2425 if (attributes.
Size() == 0)
2428 const char *name =
nullptr;
2429 std::optional<uint64_t> enum_value;
2432 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2437 case DW_AT_const_value:
2439 enum_value = form_value.
Signed();
2441 enum_value = form_value.
Unsigned();
2448 case DW_AT_description:
2450 case DW_AT_decl_file:
2454 case DW_AT_decl_line:
2457 case DW_AT_decl_column:
2466 if (name && name[0] && enum_value) {
2467 m_ast.AddEnumerationValueToEnumerationType(
2468 clang_type, decl, name, *enum_value, enumerator_byte_size * 8);
2469 ++enumerators_added;
2472 return enumerators_added;
2477 bool is_variadic =
false;
2478 bool has_template_params =
false;
2479 std::vector<CompilerType> param_types;
2480 llvm::SmallVector<llvm::StringRef> param_names;
2487 clang::DeclContext *containing_decl_ctx =
2489 assert(containing_decl_ctx);
2491 const unsigned cv_quals =
2495 has_template_params, param_types, param_names);
2497 for (
size_t i = 0; i < param_types.size(); i++) {
2500 sstr << param_types[i].GetTypeName();
2505 if (cv_quals & clang::Qualifiers::Const)
2513 llvm::DWARFAddressRangesVector unused_func_ranges;
2514 const char *name =
nullptr;
2515 const char *mangled =
nullptr;
2516 std::optional<int> decl_file;
2517 std::optional<int> decl_line;
2518 std::optional<int> decl_column;
2519 std::optional<int> call_file;
2520 std::optional<int> call_line;
2521 std::optional<int> call_column;
2526 if (tag != DW_TAG_subprogram)
2530 decl_line, decl_column, call_file, call_line,
2531 call_column, &frame_base)) {
2535 else if ((die.
GetParent().
Tag() == DW_TAG_compile_unit ||
2541 name && strcmp(name,
"main") != 0) {
2552 std::unique_ptr<Declaration> decl_up;
2553 if (decl_file || decl_line || decl_column)
2554 decl_up = std::make_unique<Declaration>(
2555 die.
GetCU()->
GetFile(decl_file.value_or(0)), decl_line.value_or(0),
2556 decl_column.value_or(0));
2581 Address func_addr = func_ranges[0].GetBaseAddress();
2583 func_sp = std::make_shared<Function>(
2586 func_user_id, func_name, func_type, std::move(func_addr),
2587 std::move(func_ranges));
2589 if (func_sp.get() !=
nullptr) {
2591 func_sp->GetFrameBaseExpression() = frame_base;
2593 return func_sp.get();
2602struct PropertyAttributes {
2603 explicit PropertyAttributes(
const DWARFDIE &die);
2604 const char *prop_name =
nullptr;
2605 const char *prop_getter_name =
nullptr;
2606 const char *prop_setter_name =
nullptr;
2608 uint32_t prop_attributes = 0;
2611struct DiscriminantValue {
2612 explicit DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp);
2614 uint32_t byte_offset;
2616 DWARFFormValue type_ref;
2619struct VariantMember {
2620 explicit VariantMember(DWARFDIE &die,
ModuleSP module_sp);
2621 bool IsDefault()
const;
2623 std::optional<uint32_t> discr_value;
2624 DWARFFormValue type_ref;
2625 ConstString variant_name;
2626 uint32_t byte_offset;
2631 explicit VariantPart(
const DWARFDIE &die,
const DWARFDIE &parent_die,
2634 std::vector<VariantMember> &members();
2636 DiscriminantValue &discriminant();
2639 std::vector<VariantMember> _members;
2640 DiscriminantValue _discriminant;
2645ConstString VariantMember::GetName()
const {
return this->variant_name; }
2647bool VariantMember::IsDefault()
const {
return !discr_value; }
2649VariantMember::VariantMember(DWARFDIE &die,
lldb::ModuleSP module_sp) {
2650 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant);
2654 for (
auto child_die : die.
children()) {
2655 switch (child_die.Tag()) {
2656 case llvm::dwarf::DW_TAG_member: {
2657 DWARFAttributes attributes = child_die.GetAttributes();
2658 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2659 DWARFFormValue form_value;
2664 variant_name = ConstString(form_value.
AsCString());
2667 type_ref = form_value;
2670 case DW_AT_data_member_location:
2671 if (
auto maybe_offset =
2673 byte_offset = *maybe_offset;
2690DiscriminantValue::DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp) {
2692 DWARFAttributes attributes = referenced_die.GetAttributes();
2693 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2695 DWARFFormValue form_value;
2699 type_ref = form_value;
2701 case DW_AT_data_member_location:
2702 if (
auto maybe_offset =
2704 byte_offset = *maybe_offset;
2713VariantPart::VariantPart(
const DWARFDIE &die,
const DWARFDIE &parent_die,
2715 : _members(), _discriminant(die, module_sp) {
2717 for (
auto child : die.
children()) {
2718 if (child.Tag() == llvm::dwarf::DW_TAG_variant) {
2719 _members.push_back(VariantMember(child, module_sp));
2724std::vector<VariantMember> &VariantPart::members() {
return this->_members; }
2726DiscriminantValue &VariantPart::discriminant() {
return this->_discriminant; }
2731 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2742 case DW_AT_bit_offset:
2745 case DW_AT_bit_size:
2748 case DW_AT_byte_size:
2751 case DW_AT_const_value:
2754 case DW_AT_data_bit_offset:
2757 case DW_AT_data_member_location:
2758 if (
auto maybe_offset =
2763 case DW_AT_accessibility:
2767 case DW_AT_artificial:
2770 case DW_AT_declaration:
2797PropertyAttributes::PropertyAttributes(
const DWARFDIE &die) {
2800 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2805 case DW_AT_APPLE_property_name:
2808 case DW_AT_APPLE_property_getter:
2809 prop_getter_name = form_value.
AsCString();
2811 case DW_AT_APPLE_property_setter:
2812 prop_setter_name = form_value.
AsCString();
2814 case DW_AT_APPLE_property_attribute:
2815 prop_attributes = form_value.
Unsigned();
2825 ConstString fixed_setter;
2829 if (prop_getter_name && prop_getter_name[0] ==
'-') {
2830 std::optional<const ObjCLanguage::ObjCMethodName> prop_getter_method =
2832 if (prop_getter_method)
2834 ConstString(prop_getter_method->GetSelector()).GetCString();
2837 if (prop_setter_name && prop_setter_name[0] ==
'-') {
2838 std::optional<const ObjCLanguage::ObjCMethodName> prop_setter_method =
2840 if (prop_setter_method)
2842 ConstString(prop_setter_method->GetSelector()).GetCString();
2846 if (!prop_getter_name)
2847 prop_getter_name = prop_name;
2848 if (!prop_setter_name && prop_name[0] &&
2849 !(prop_attributes & DW_APPLE_PROPERTY_readonly)) {
2852 ss.
Printf(
"set%c%s:", toupper(prop_name[0]), &prop_name[1]);
2855 prop_setter_name = fixed_setter.
GetCString();
2864 assert(die.
Tag() == DW_TAG_APPLE_property);
2869 const PropertyAttributes propAttrs(die);
2871 if (!propAttrs.prop_name) {
2872 module_sp->ReportError(
"{0:x8}: DW_TAG_APPLE_property has no name.",
2879 module_sp->ReportError(
2880 "{0:x8}: DW_TAG_APPLE_property '{1}' refers to type {2:x16}"
2881 " which was unable to be parsed",
2882 die.
GetID(), propAttrs.prop_name,
2889 delayed_properties.emplace_back(
2890 class_clang_type, propAttrs.prop_name,
2892 propAttrs.prop_getter_name, propAttrs.prop_attributes, metadata);
2898 assert(qt->isIntegralOrEnumerationType());
2901 return llvm::createStringError(llvm::inconvertibleErrorCode(),
2902 "TypeSystem not clang");
2906 const unsigned type_bits = ast.getIntWidth(qt);
2907 const bool is_unsigned = qt->isUnsignedIntegerType();
2911 constexpr std::size_t max_bit_size = 64;
2916 if (type_bits > max_bit_size) {
2917 auto msg = llvm::formatv(
"Can only parse integers with up to {0} bits, but "
2918 "given integer has {1} bits.",
2919 max_bit_size, type_bits);
2920 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2924 llvm::APInt result(max_bit_size, form_value.
Unsigned(), !is_unsigned);
2930 const unsigned required_bits =
2931 is_unsigned ? result.getActiveBits() : result.getSignificantBits();
2934 if (required_bits > type_bits) {
2935 std::string value_as_str = is_unsigned
2936 ? std::to_string(form_value.
Unsigned())
2937 : std::to_string(form_value.
Signed());
2938 auto msg = llvm::formatv(
"Can't store {0} value {1} in integer with {2} "
2940 (is_unsigned ?
"unsigned" :
"signed"),
2941 value_as_str, type_bits);
2942 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2946 if (result.getBitWidth() > type_bits)
2947 result = result.trunc(type_bits);
2955 assert(die.
Tag() == DW_TAG_member || die.
Tag() == DW_TAG_variable);
2962 auto accessibility =
2967 class_clang_type, attrs.
name, ct, accessibility);
2969 LLDB_LOG(log,
"Failed to add variable to the record type");
2978 llvm::Expected<llvm::APInt> const_value_or_err =
2980 if (!const_value_or_err) {
2982 "Failed to add const value to variable {1}: {0}",
2983 v->getQualifiedNameAsString());
2997 assert(die.
Tag() == DW_TAG_member);
3002 const uint64_t parent_byte_size =
3004 const uint64_t parent_bit_size =
3029 module_sp->ReportError(
3030 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
3031 " which was unable to be parsed",
3034 module_sp->ReportError(
"{0:x8}: DW_TAG_member refers to type {1:x16}"
3035 " which was unable to be parsed",
3041 const uint64_t character_width = 8;
3045 ? default_accessibility
3054 this_field_info.
bit_offset = field_bit_offset;
3062 byte_size = llvm::expectedToOptional(member_type->
GetByteSize(
nullptr));
3066 this_field_info.
bit_offset += byte_size.value_or(0) * 8;
3080 !(parent_die.
Tag() == DW_TAG_union_type &&
3082 ((this_field_info.
bit_offset >= parent_bit_size) ||
3088 "{0:x16}: {1} ({2}) bitfield named \"{3}\" has invalid "
3089 "bit offset ({4:x8}) member will be ignored. Please file a bug "
3091 "compiler and include the preprocessed output for {5}\n",
3098 field_bit_offset = this_field_info.
bit_offset;
3103 bool detect_unnamed_bitfields =
true;
3106 detect_unnamed_bitfields =
3109 if (detect_unnamed_bitfields)
3111 last_field_info, this_field_info);
3113 last_field_info = this_field_info;
3118 this_field_info.
bit_offset = field_bit_offset;
3122 if (std::optional<uint64_t> clang_type_size =
3123 llvm::expectedToOptional(member_type->
GetByteSize(
nullptr))) {
3124 this_field_info.
bit_size = *clang_type_size * character_width;
3131 last_field_info = this_field_info;
3151 class_clang_type, attrs.
name, member_clang_type, accessibility,
3154 m_ast.SetMetadataAsUserID(field_decl, die.
GetID());
3157 std::make_pair(field_decl, field_bit_offset));
3162 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
3163 std::vector<DWARFDIE> &member_function_dies,
3164 std::vector<DWARFDIE> &contained_type_dies,
3182 case DW_TAG_APPLE_property:
3186 case DW_TAG_variant_part:
3189 default_accessibility, layout_info);
3193 case DW_TAG_variable: {
3199 default_accessibility, layout_info, last_field_info);
3202 case DW_TAG_subprogram:
3204 member_function_dies.push_back(die);
3207 case DW_TAG_inheritance:
3209 module_sp, base_classes, layout_info);
3213 if (llvm::dwarf::isType(tag))
3214 contained_type_dies.push_back(die);
3223 clang::DeclContext *containing_decl_ctx,
const DWARFDIE &parent_die,
3224 bool &is_variadic,
bool &has_template_params,
3225 std::vector<CompilerType> &function_param_types,
3233 case DW_TAG_formal_parameter: {
3243 function_param_names.emplace_back(die.
GetName());
3247 case DW_TAG_unspecified_parameters:
3251 case DW_TAG_template_type_parameter:
3252 case DW_TAG_template_value_parameter:
3253 case DW_TAG_GNU_template_parameter_pack:
3259 has_template_params =
true;
3267 assert(function_param_names.size() == function_param_types.size());
3274 switch (die.
Tag()) {
3275 case DW_TAG_constant:
3276 case DW_TAG_formal_parameter:
3277 case DW_TAG_imported_declaration:
3278 case DW_TAG_imported_module:
3280 case DW_TAG_variable:
3294 return cache_pos->second;
3309 clang::Decl *decl =
nullptr;
3310 switch (die.
Tag()) {
3311 case DW_TAG_variable:
3312 case DW_TAG_constant:
3313 case DW_TAG_formal_parameter: {
3316 if (
dwarf && type) {
3317 const char *name = die.
GetName();
3318 clang::DeclContext *decl_context =
3320 dwarf->GetDeclContextContainingUID(die.
GetID()));
3321 decl =
m_ast.CreateVariableDeclaration(
3327 case DW_TAG_imported_declaration: {
3332 if (imported_decl) {
3333 clang::DeclContext *decl_context =
3335 dwarf->GetDeclContextContainingUID(die.
GetID()));
3336 if (clang::NamedDecl *clang_imported_decl =
3337 llvm::dyn_cast<clang::NamedDecl>(
3339 decl =
m_ast.CreateUsingDeclaration(
3345 case DW_TAG_imported_module: {
3352 if (imported_decl_ctx) {
3353 clang::DeclContext *decl_context =
3355 dwarf->GetDeclContextContainingUID(die.
GetID()));
3356 if (clang::NamespaceDecl *ns_decl =
3359 decl =
m_ast.CreateUsingDirectiveDeclaration(
3381 bool try_parsing_type =
true;
3382 switch (die.
Tag()) {
3383 case DW_TAG_compile_unit:
3384 case DW_TAG_partial_unit:
3385 decl_ctx =
m_ast.GetTranslationUnitDecl();
3386 try_parsing_type =
false;
3389 case DW_TAG_namespace:
3391 try_parsing_type =
false;
3394 case DW_TAG_imported_declaration:
3396 try_parsing_type =
false;
3399 case DW_TAG_lexical_block:
3401 try_parsing_type =
false;
3408 if (decl_ctx ==
nullptr && try_parsing_type) {
3428 parent = parent.GetParent()) {
3430 if (tag == DW_TAG_module) {
3450 switch (die.
Tag()) {
3451 case DW_TAG_subprogram:
3452 case DW_TAG_inlined_subroutine:
3462 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3469 assert(0 &&
"Shouldn't call GetContainingFunctionWithAbstractOrigin on "
3470 "something not in a function");
3476 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3498 assert(die.
Tag() == DW_TAG_lexical_block);
3499 DWARFDIE containing_function_with_abstract_origin =
3501 if (!containing_function_with_abstract_origin) {
3505 die, containing_function_with_abstract_origin);
3512 if (die && die.
Tag() == DW_TAG_lexical_block) {
3513 clang::BlockDecl *decl =
3518 clang::DeclContext *decl_context =
3532clang::NamespaceDecl *
3534 if (die && die.
Tag() == DW_TAG_namespace) {
3537 clang::NamespaceDecl *namespace_decl =
3540 return namespace_decl;
3542 const char *namespace_name = die.
GetName();
3543 clang::DeclContext *containing_decl_ctx =
3548 namespace_decl =
m_ast.GetUniqueNamespaceDeclaration(
3554 return namespace_decl;
3560clang::NamespaceDecl *
3562 assert(die && die.
Tag() == DW_TAG_imported_declaration);
3568 return static_cast<clang::NamespaceDecl *
>(it->getSecond());
3570 clang::NamespaceDecl *namespace_decl =
nullptr;
3577 switch (imported_uid.
Tag()) {
3578 case DW_TAG_imported_declaration:
3581 case DW_TAG_namespace:
3588 if (!namespace_decl)
3593 return namespace_decl;
3600 DWARFDIE decl_ctx_die =
dwarf->GetDeclContextDIEContainingDIE(die);
3602 if (decl_ctx_die_copy)
3603 *decl_ctx_die_copy = decl_ctx_die;
3606 clang::DeclContext *clang_decl_ctx =
3609 return clang_decl_ctx;
3611 return m_ast.GetTranslationUnitDecl();
3635 if (!class_type || !src_class_die || !dst_class_die)
3637 if (src_class_die.
Tag() != dst_class_die.
Tag())
3647 if (die.
Tag() != DW_TAG_subprogram)
3659 map_artificial.Append(const_name, die);
3661 map.Append(const_name, die);
3670 src_die = src_die.GetSibling()) {
3671 gather(src_die, src_name_to_die, src_name_to_die_artificial);
3674 dst_die = dst_die.GetSibling()) {
3675 gather(dst_die, dst_name_to_die, dst_name_to_die_artificial);
3677 const uint32_t src_size = src_name_to_die.
GetSize();
3678 const uint32_t dst_size = dst_name_to_die.
GetSize();
3681 bool fast_path =
true;
3683 if (src_size != dst_size)
3689 for (idx = 0; idx < src_size; ++idx) {
3693 if (src_die.
Tag() != dst_die.
Tag())
3700 if (src_name == dst_name || (strcmp(src_name, dst_name) == 0))
3715 clang::DeclContext *dst_decl_ctx =
3720 if (
Type *src_child_type = die_to_type.lookup(src.
GetDIE()))
3721 die_to_type[dst.GetDIE()] = src_child_type;
3728 for (idx = 0; idx < src_size; ++idx) {
3738 src_name_to_die.
Sort();
3740 for (idx = 0; idx < dst_size; ++idx) {
3745 if (src_die && (src_die.
Tag() == dst_die.
Tag()))
3746 link(src_die, dst_die);
3748 failures.push_back(dst_die);
3753 const uint32_t src_size_artificial = src_name_to_die_artificial.
GetSize();
3754 const uint32_t dst_size_artificial = dst_name_to_die_artificial.
GetSize();
3756 if (src_size_artificial && dst_size_artificial) {
3757 dst_name_to_die_artificial.
Sort();
3759 for (idx = 0; idx < src_size_artificial; ++idx) {
3765 dst_name_to_die_artificial.
Find(src_name_artificial,
DWARFDIE());
3769 link(src_die, dst_die);
3773 if (dst_size_artificial) {
3774 for (idx = 0; idx < dst_size_artificial; ++idx) {
3780 return !failures.empty();
3784 FieldInfo const &last_field_info, uint64_t last_field_end,
3789 if (this_field_info.
bit_offset <= last_field_end)
3803 const bool have_base = layout_info.
base_offsets.size() != 0;
3804 const bool this_is_first_field =
3806 const bool first_field_is_vptr =
3809 if (have_base && (this_is_first_field || first_field_is_vptr))
3820 const uint64_t word_width = 32;
3828 if (last_field_end != 0 && ((last_field_end % word_width) != 0))
3829 last_field_end += word_width - (last_field_end % word_width);
3834 current_field, class_layout_info))
3839 const uint64_t unnamed_bit_size = current_field.
bit_offset - last_field_end;
3840 const uint64_t unnamed_bit_offset = last_field_end;
3842 clang::FieldDecl *unnamed_bitfield_decl =
3844 class_clang_type, llvm::StringRef(),
3849 std::make_pair(unnamed_bitfield_decl, unnamed_bit_offset));
3857 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant_part);
3863 VariantPart variants(die, parent_die, module_sp);
3865 auto discriminant_type =
3866 die.
ResolveTypeUID(variants.discriminant().type_ref.Reference());
3868 auto decl_context =
m_ast.GetDeclContextForType(class_clang_type);
3870 auto inner_holder =
m_ast.CreateRecordType(
3873 llvm::formatv(
"{0}$Inner", class_clang_type.
GetTypeName(
false))),
3875 m_ast.StartTagDeclarationDefinition(inner_holder);
3876 m_ast.SetIsPacked(inner_holder);
3878 for (
auto member : variants.members()) {
3880 auto has_discriminant = !member.IsDefault();
3882 auto member_type = die.
ResolveTypeUID(member.type_ref.Reference());
3884 auto field_type =
m_ast.CreateRecordType(
3887 std::string(llvm::formatv(
"{0}$Variant", member.GetName())),
3888 llvm::to_underlying(clang::TagTypeKind::Struct),
3891 m_ast.StartTagDeclarationDefinition(field_type);
3892 auto offset = member.byte_offset;
3894 if (has_discriminant) {
3895 m_ast.AddFieldToRecordType(
3896 field_type,
"$discr$", discriminant_type->GetFullCompilerType(),
3899 llvm::expectedToOptional(discriminant_type->GetByteSize(
nullptr))
3903 m_ast.AddFieldToRecordType(field_type,
"value",
3904 member_type->GetFullCompilerType(),
3907 m_ast.CompleteTagDeclarationDefinition(field_type);
3909 auto name = has_discriminant
3910 ? llvm::formatv(
"$variant${0}", member.discr_value.value())
3911 : std::string(
"$variant$");
3914 m_ast.AddFieldToRecordType(inner_holder, llvm::StringRef(name),
3915 field_type, default_accesibility, 0);
3920 auto inner_field =
m_ast.AddFieldToRecordType(class_clang_type,
3921 llvm::StringRef(
"$variants$"),
3924 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.