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"
62using namespace llvm::dwarf;
72 case clang::Decl::CXXRecord:
73 case clang::Decl::ClassTemplateSpecialization:
94 while (Parent.IsValid()) {
95 if (Parent.Tag() == DW_TAG_module)
97 Parent = Parent.GetParent();
108 parent = parent.GetParent()) {
110 if (tag == DW_TAG_module)
111 top_module_die = parent;
112 else if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
116 return top_module_die;
125 if (clang_module_die) {
126 const char *module_name = clang_module_die.
GetName();
138 return FieldName.starts_with(
"_vptr$")
140 || FieldName.starts_with(
"_vptr.");
146 case DW_TAG_class_type:
147 case DW_TAG_structure_type:
148 case DW_TAG_union_type:
159 assert(subprogram.
Tag() == DW_TAG_subprogram ||
160 subprogram.
Tag() == DW_TAG_inlined_subroutine ||
161 subprogram.
Tag() == DW_TAG_subroutine_type);
166 std::optional<size_t> object_pointer_index;
168 if (subprogram.
GetDIE()->GetAttributeValue(
169 subprogram.
GetCU(), DW_AT_object_pointer, form_value,
174 object_pointer_index = form_value.
Unsigned();
179 size_t param_index = 0;
180 for (
const auto &child : subprogram.
children()) {
181 if (child.Tag() != DW_TAG_formal_parameter)
184 if (param_index == object_pointer_index.value_or(0)) {
185 object_pointer = child;
199 if (object_pointer_index)
200 return object_pointer;
215 if (
const char *name = object_pointer.
GetName();
216 name && ::strcmp(name,
"this") != 0)
219 return object_pointer;
227 if (!subprogram || !object_parameter)
236 unsigned cv_quals = 0;
238 cv_quals |= clang::Qualifiers::Const;
240 cv_quals |= clang::Qualifiers::Volatile;
258 auto *obj = sym->GetMainObjectFile();
262 auto module_sp = obj->GetModule();
266 return module_sp->GetID();
271 module_id = get_module_id(
dwarf);
276 const auto die_id = die.
GetID();
292 if (!clang_module_sp)
298 std::vector<lldb_private::CompilerContext> die_context = die.
GetDeclContext();
299 TypeQuery query(die_context, TypeQueryOptions::e_module_search |
300 TypeQueryOptions::e_find_one);
305 clang_module_sp->FindTypes(query, results);
317 sym_file.ForEachExternalModule(
319 module.FindTypes(query, results);
320 pcm_type_sp = results.GetTypeMap().FirstType();
321 return (bool)pcm_type_sp;
351 auto type_sp =
dwarf->MakeType(
352 die.
GetID(), pcm_type_sp->GetName(),
353 llvm::expectedToOptional(pcm_type_sp->GetByteSize(
nullptr)),
nullptr,
375 clang::DeclContext *decl_ctx,
377 const char *type_name_cstr) {
378 auto *tag_decl_ctx = clang::dyn_cast<clang::TagDecl>(decl_ctx);
383 if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx->isBeingDefined())
391 if (type && ast_importer.
CanImport(type)) {
396 "Unable to complete the Decl context for DIE {0} at offset "
397 "{1:x16}.\nPlease file a bug report.",
398 type_name_cstr ? type_name_cstr :
"", die.
GetOffset());
407 if (!tag_decl_ctx->hasExternalLexicalStorage()) {
415 for (
size_t i = 0; i < attributes.
Size(); ++i) {
423 case DW_AT_abstract_origin:
427 case DW_AT_artificial:
431 case DW_AT_bit_stride:
435 case DW_AT_byte_size:
443 case DW_AT_alignment:
447 case DW_AT_byte_stride:
451 case DW_AT_calling_convention:
455 case DW_AT_containing_type:
459 case DW_AT_decl_file:
464 case DW_AT_decl_line:
467 case DW_AT_decl_column:
471 case DW_AT_declaration:
479 case DW_AT_enum_class:
496 case DW_AT_linkage_name:
497 case DW_AT_MIPS_linkage_name:
505 case DW_AT_signature:
509 case DW_AT_specification:
517 case DW_AT_virtuality:
521 case DW_AT_APPLE_objc_complete_type:
525 case DW_AT_APPLE_objc_direct:
529 case DW_AT_APPLE_runtime_class:
533 case DW_AT_GNU_vector:
536 case DW_AT_export_symbols:
539 case DW_AT_rvalue_reference:
542 case DW_AT_reference:
545 case DW_AT_APPLE_enum_kind:
546 enum_kind =
static_cast<clang::EnumExtensibilityAttr::Kind
>(
555 return unit->GetAbsolutePath().GetPath();
556 return "<missing DWARF unit path>";
561 bool *type_is_new_ptr) {
563 *type_is_new_ptr =
false;
573 clang::DeclContext *context =
576 dwarf->GetObjectFile()->GetModule()->LogMessage(
578 "DWARFASTParserClang::ParseTypeFromDWARF "
579 "(die = {0:x16}, decl_ctx = {1:p} (die "
580 "{2:x16})) {3} ({4}) name = '{5}')",
586 if (
auto [it, inserted] =
591 return it->getSecond()->shared_from_this();
600 if (clang::DeclContext *decl_ctx =
606 *type_is_new_ptr =
true;
612 case DW_TAG_template_alias:
613 case DW_TAG_base_type:
614 case DW_TAG_pointer_type:
615 case DW_TAG_reference_type:
616 case DW_TAG_rvalue_reference_type:
617 case DW_TAG_const_type:
618 case DW_TAG_restrict_type:
619 case DW_TAG_volatile_type:
620 case DW_TAG_LLVM_ptrauth_type:
621 case DW_TAG_atomic_type:
622 case DW_TAG_unspecified_type:
625 case DW_TAG_structure_type:
626 case DW_TAG_union_type:
627 case DW_TAG_class_type:
630 case DW_TAG_enumeration_type:
633 case DW_TAG_inlined_subroutine:
634 case DW_TAG_subprogram:
635 case DW_TAG_subroutine_type:
638 case DW_TAG_array_type:
641 case DW_TAG_ptr_to_member_type:
645 dwarf->GetObjectFile()->GetModule()->ReportError(
646 "[{0:x16}]: unhandled type tag {1:x4} ({2}), "
647 "please file a bug and "
648 "attach the file at the start of this error message",
655 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
660static std::optional<uint32_t>
671 Value initialValue(0);
673 uint32_t block_length = form_value.
Unsigned();
674 uint32_t block_offset =
684 "ExtractDataMemberLocation failed: {0}");
688 return memberOffset->ResolveValue(
nullptr).UInt();
692 auto getAttr = [&](llvm::dwarf::Attribute Attr,
unsigned defaultValue = 0) {
695 const unsigned key = getAttr(DW_AT_LLVM_ptrauth_key);
696 const bool addr_disc = getAttr(DW_AT_LLVM_ptrauth_address_discriminated);
697 const unsigned extra = getAttr(DW_AT_LLVM_ptrauth_extra_discriminator);
698 const bool isapointer = getAttr(DW_AT_LLVM_ptrauth_isa_pointer);
699 const bool authenticates_null_values =
700 getAttr(DW_AT_LLVM_ptrauth_authenticates_null_values);
701 const unsigned authentication_mode_int = getAttr(
702 DW_AT_LLVM_ptrauth_authentication_mode,
703 static_cast<unsigned>(clang::PointerAuthenticationMode::SignAndAuth));
704 clang::PointerAuthenticationMode authentication_mode =
705 clang::PointerAuthenticationMode::SignAndAuth;
706 if (authentication_mode_int >=
707 static_cast<unsigned>(clang::PointerAuthenticationMode::None) &&
708 authentication_mode_int <=
709 static_cast<unsigned>(
710 clang::PointerAuthenticationMode::SignAndAuth)) {
711 authentication_mode =
712 static_cast<clang::PointerAuthenticationMode
>(authentication_mode_int);
715 "[{0:x16}]: invalid pointer authentication mode method {1:x4}",
716 die.
GetOffset(), authentication_mode_int);
718 auto ptr_auth = clang::PointerAuthQualifier::Create(
719 key, addr_disc, extra, authentication_mode, isapointer,
720 authenticates_null_values);
738 if (tag == DW_TAG_typedef || tag == DW_TAG_template_alias) {
790 case DW_TAG_unspecified_type:
791 if (attrs.
name ==
"nullptr_t" || attrs.
name ==
"decltype(nullptr)") {
800 case DW_TAG_base_type: {
808 clang_type =
m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
812 case DW_TAG_pointer_type:
815 case DW_TAG_reference_type:
818 case DW_TAG_rvalue_reference_type:
822 case DW_TAG_template_alias:
825 case DW_TAG_const_type:
828 case DW_TAG_restrict_type:
831 case DW_TAG_volatile_type:
834 case DW_TAG_LLVM_ptrauth_type:
838 case DW_TAG_atomic_type:
845 if (tag == DW_TAG_pointer_type) {
853 if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name,
""),
858 if (function_pointer_type) {
862 bool function_type_is_new_pointer;
864 sc, function_type, &function_type_is_new_pointer);
866 if (lldb_function_type_sp) {
867 clang_type =
m_ast.CreateBlockPointerType(
868 lldb_function_type_sp->GetForwardCompilerType());
884 if (attrs.
name ==
"id") {
886 dwarf->GetObjectFile()->GetModule()->LogMessage(
888 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
889 "is Objective-C 'id' built-in type.",
896 }
else if (attrs.
name ==
"Class") {
898 dwarf->GetObjectFile()->GetModule()->LogMessage(
900 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
901 "is Objective-C 'Class' built-in type.",
908 }
else if (attrs.
name ==
"SEL") {
910 dwarf->GetObjectFile()->GetModule()->LogMessage(
912 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
913 "is Objective-C 'selector' built-in type.",
928 if (encoding_die && encoding_die.
Tag() == DW_TAG_structure_type) {
929 llvm::StringRef struct_name = encoding_die.
GetName();
930 if (struct_name ==
"objc_object") {
932 dwarf->GetObjectFile()->GetModule()->LogMessage(
934 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
935 "is 'objc_object*', which we overrode to 'id'.",
950 &attrs.
decl, clang_type, resolve_state, payload);
957 if (llvm::StringRef(die.
GetName()).contains(
"<"))
961 llvm::raw_string_ostream os(name);
962 llvm::DWARFTypePrinter<DWARFDIE> type_printer(os);
963 type_printer.appendAndTerminateTemplateParameters(die);
978 unique_typename, decl_declaration);
980 dwarf->GetUniqueDWARFASTTypeMap().Find(
981 unique_typename, decl_die, decl_declaration,
984 unique_ast_entry_type->UpdateToDefDIE(def_die, def_attrs.
decl,
989 "Failed to find {0:x16} {1} ({2}) type \"{3}\" in "
990 "UniqueDWARFASTTypeMap",
1007 def_die =
dwarf->FindDefinitionDIE(decl_die);
1011 if (debug_map_symfile) {
1019 dwarf->GetObjectFile()->GetModule()->LogMessage(
1021 "SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a "
1022 "forward declaration, complete DIE is {5}",
1025 def_die ? llvm::utohexstr(def_die.
GetID()) :
"not found");
1029 if (
auto [it, inserted] =
dwarf->GetDIEToType().try_emplace(
1034 return it->getSecond()->shared_from_this();
1045 Type *enumerator_type =
1047 if (enumerator_type)
1051 if (!enumerator_clang_type) {
1053 enumerator_clang_type =
m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
1054 "", DW_ATE_signed, *attrs.
byte_size * 8);
1071 clang::DeclContext *type_decl_ctx =
1074 if (decl_die != def_die) {
1076 dwarf->GetDIEToType()[def_die.
GetDIE()] = type_sp.get();
1081 dwarf->GetObjectFile()->GetModule()->ReportError(
1082 "DWARF DIE at {0:x16} named \"{1}\" was not able to start its "
1083 "definition.\nPlease file a bug and attach the file at the "
1084 "start of this error message",
1090static clang::CallingConv
1093 case llvm::dwarf::DW_CC_normal:
1095 case llvm::dwarf::DW_CC_BORLAND_stdcall:
1096 return clang::CC_X86StdCall;
1097 case llvm::dwarf::DW_CC_BORLAND_msfastcall:
1098 return clang::CC_X86FastCall;
1099 case llvm::dwarf::DW_CC_LLVM_vectorcall:
1100 return clang::CC_X86VectorCall;
1101 case llvm::dwarf::DW_CC_BORLAND_pascal:
1102 return clang::CC_X86Pascal;
1103 case llvm::dwarf::DW_CC_LLVM_Win64:
1104 return clang::CC_Win64;
1105 case llvm::dwarf::DW_CC_LLVM_X86_64SysV:
1106 return clang::CC_X86_64SysV;
1107 case llvm::dwarf::DW_CC_LLVM_X86RegCall:
1108 return clang::CC_X86RegCall;
1114 LLDB_LOG(log,
"Unsupported DW_AT_calling_convention value: {0}",
1127 const auto tag = die.
Tag();
1132 TypeSP complete_objc_class_type_sp =
1133 dwarf->FindCompleteObjCDefinitionTypeForDIE(
DWARFDIE(), class_name,
1136 if (!complete_objc_class_type_sp)
1140 complete_objc_class_type_sp->GetForwardCompilerType();
1142 if (!type_clang_forward_type)
1148 clang::ObjCMethodDecl *objc_method_decl =
m_ast.AddMethodToObjCObjectType(
1152 if (!objc_method_decl) {
1153 dwarf->GetObjectFile()->GetModule()->ReportError(
1154 "[{0:x16}]: invalid Objective-C method {1:x4} ({2}), "
1155 "please file a bug and attach the file at the start of "
1156 "this error message",
1162 m_ast.SetMetadataAsUserID(objc_method_decl, die.
GetID());
1170 const DWARFDIE &object_parameter,
bool &ignore_containing_context) {
1175 Type *class_type =
dwarf->ResolveType(decl_ctx_die);
1179 if (class_type->
GetID() != decl_ctx_die.
GetID() ||
1186 std::vector<DWARFDIE> failures;
1198 return {
true, type_ptr->shared_from_this()};
1212 clang::DeclContext *spec_clang_decl_ctx =
1214 if (spec_clang_decl_ctx)
1217 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1218 "{0:x8}: DW_AT_specification({1:x16}"
1222 return {
true,
nullptr};
1234 if (abs_clang_decl_ctx)
1237 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1238 "{0:x8}: DW_AT_abstract_origin({1:x16}"
1242 return {
true,
nullptr};
1255 const bool is_static = !object_parameter.
IsValid();
1261 return {
true,
nullptr};
1263 const bool is_attr_used =
false;
1265 clang::CXXMethodDecl *cxx_method_decl =
m_ast.AddMethodToCXXRecordType(
1270 if (cxx_method_decl) {
1276 if (
char const *object_pointer_name = object_parameter.
GetName()) {
1278 LLDB_LOGF(log,
"Setting object pointer name: %s on method object %p.\n",
1279 object_pointer_name,
static_cast<void *
>(cxx_method_decl));
1281 m_ast.SetMetadata(cxx_method_decl, metadata);
1283 ignore_containing_context =
true;
1288 const bool type_handled = cxx_method_decl !=
nullptr || attrs.
is_artificial;
1290 return {type_handled,
nullptr};
1301 bool is_variadic =
false;
1302 bool has_template_params =
false;
1305 Type *func_type =
nullptr;
1315 std::vector<CompilerType> function_param_types;
1316 llvm::SmallVector<llvm::StringRef> function_param_names;
1321 clang::DeclContext *containing_decl_ctx =
1323 assert(containing_decl_ctx);
1327 has_template_params, function_param_types,
1328 function_param_names);
1332 bool ignore_containing_context =
false;
1343 if (is_cxx_method && has_template_params) {
1344 ignore_containing_context =
true;
1345 is_cxx_method =
false;
1348 clang::CallingConv calling_convention =
1356 return_clang_type, function_param_types, is_variadic,
1361 bool type_handled =
false;
1362 if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
1363 if (std::optional<const ObjCLanguage::ObjCMethodName> objc_method =
1368 }
else if (is_cxx_method) {
1369 auto [handled, type_sp] =
1371 object_parameter, ignore_containing_context);
1375 type_handled = handled;
1379 if (!type_handled) {
1380 clang::FunctionDecl *function_decl =
nullptr;
1381 clang::FunctionDecl *template_function_decl =
nullptr;
1386 if (
dwarf->ResolveType(abs_die)) {
1387 function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
1390 if (function_decl) {
1396 if (!function_decl) {
1397 char *name_buf =
nullptr;
1404 llvm::ItaniumPartialDemangler D;
1406 name_buf = D.getFunctionBaseName(
nullptr,
nullptr);
1412 function_decl =
m_ast.CreateFunctionDeclaration(
1413 ignore_containing_context ?
m_ast.GetTranslationUnitDecl()
1414 : containing_decl_ctx,
1417 std::free(name_buf);
1419 if (has_template_params) {
1422 template_function_decl =
m_ast.CreateFunctionDeclaration(
1423 ignore_containing_context ?
m_ast.GetTranslationUnitDecl()
1424 : containing_decl_ctx,
1427 clang::FunctionTemplateDecl *func_template_decl =
1428 m_ast.CreateFunctionTemplateDecl(
1430 template_function_decl, template_param_infos);
1431 m_ast.CreateFunctionTemplateSpecializationInfo(
1432 template_function_decl, func_template_decl, template_param_infos);
1437 if (function_decl) {
1440 const clang::FunctionProtoType *function_prototype(
1441 llvm::cast<clang::FunctionProtoType>(
1443 const auto params =
m_ast.CreateParameterDeclarations(
1444 function_decl, *function_prototype, function_param_names);
1445 function_decl->setParams(params);
1446 if (template_function_decl)
1447 template_function_decl->setParams(params);
1452 if (
char const *object_pointer_name = object_parameter.
GetName()) {
1455 "Setting object pointer name: %s on function "
1457 object_pointer_name,
static_cast<void *
>(function_decl));
1459 m_ast.SetMetadata(function_decl, metadata);
1464 return dwarf->MakeType(
1475 Type *element_type =
dwarf->ResolveTypeUID(type_die,
true);
1484 byte_stride = array_info->byte_stride;
1485 bit_stride = array_info->bit_stride;
1487 if (byte_stride == 0 && bit_stride == 0)
1488 byte_stride = llvm::expectedToOptional(element_type->
GetByteSize(
nullptr))
1493 uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
1495 if (array_info && array_info->element_orders.size() > 0) {
1496 auto end = array_info->element_orders.rend();
1497 for (
auto pos = array_info->element_orders.rbegin(); pos != end; ++pos) {
1498 clang_type =
m_ast.CreateArrayType(
1499 array_element_type, *pos, attrs.
is_vector);
1501 uint64_t num_elements = pos->value_or(0);
1502 array_element_type = clang_type;
1503 array_element_bit_stride = num_elements
1504 ? array_element_bit_stride * num_elements
1505 : array_element_bit_stride;
1508 clang_type =
m_ast.CreateArrayType(
1509 array_element_type, std::nullopt, attrs.
is_vector);
1513 dwarf->MakeType(die.
GetID(), empty_name, array_element_bit_stride / 8,
1516 type_sp->SetEncodingType(element_type);
1518 m_ast.SetMetadataAsUserID(type, die.
GetID());
1531 if ((class_type ==
nullptr) || (pointee_type ==
nullptr))
1538 class_clang_type, pointee_clang_type);
1540 if (std::optional<uint64_t> clang_type_size =
1541 llvm::expectedToOptional(clang_type.
GetByteSize(
nullptr))) {
1542 return dwarf->MakeType(die.
GetID(), attrs.
name, *clang_type_size,
nullptr,
1550 switch (die.
Tag()) {
1551 case DW_TAG_union_type:
1552 case DW_TAG_structure_type:
1554 case DW_TAG_class_type:
1564 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
1572 if (attributes.
Size() == 0)
1577 bool is_virtual =
false;
1578 bool is_base_of_class =
true;
1579 off_t member_byte_offset = 0;
1581 for (uint32_t i = 0; i < attributes.
Size(); ++i) {
1587 encoding_form = form_value;
1589 case DW_AT_data_member_location:
1590 if (
auto maybe_offset =
1592 member_byte_offset = *maybe_offset;
1594 case DW_AT_accessibility:
1598 case DW_AT_virtuality:
1599 is_virtual = form_value.
Boolean();
1609 if (base_class_type ==
nullptr) {
1610 module_sp->ReportError(
"{0:x16}: DW_TAG_inheritance failed to "
1611 "resolve the base class at {1:x16}"
1612 " from enclosing type {2:x16}. \nPlease file "
1613 "a bug and attach the file at the start of "
1614 "this error message",
1622 assert(base_class_clang_type);
1630 ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
1633 std::unique_ptr<clang::CXXBaseSpecifier> result =
1635 accessibility, is_virtual,
1640 base_classes.push_back(std::move(result));
1658 clang::CharUnits::fromQuantity(member_byte_offset)));
1671 if (sc_parent_tag == DW_TAG_compile_unit ||
1672 sc_parent_tag == DW_TAG_partial_unit) {
1674 }
else if (sc.
function !=
nullptr && sc_parent_die) {
1675 symbol_context_scope =
1677 if (symbol_context_scope ==
nullptr)
1678 symbol_context_scope = sc.
function;
1680 symbol_context_scope = sc.
module_sp.get();
1683 if (symbol_context_scope !=
nullptr)
1684 type_sp->SetSymbolContextScope(symbol_context_scope);
1701 decl_declaration.
Clear();
1702 std::string qualified_name;
1705 while (parent_decl_ctx_die) {
1709 const dw_tag_t parent_tag = parent_decl_ctx_die.
Tag();
1710 switch (parent_tag) {
1711 case DW_TAG_namespace: {
1712 if (
const char *namespace_name = parent_decl_ctx_die.
GetName()) {
1713 qualified_name.insert(0,
"::");
1714 qualified_name.insert(0, namespace_name);
1716 qualified_name.insert(0,
"(anonymous namespace)::");
1722 case DW_TAG_class_type:
1723 case DW_TAG_structure_type:
1724 case DW_TAG_union_type: {
1725 if (
const char *class_union_struct_name = parent_decl_ctx_die.
GetName()) {
1726 qualified_name.insert(0,
"::");
1727 qualified_name.insert(0,
1729 qualified_name.insert(0, class_union_struct_name);
1736 parent_decl_ctx_die.
Clear();
1741 if (qualified_name.empty())
1742 qualified_name.append(
"::");
1744 qualified_name.append(unique_typename.
GetCString());
1761 uint64_t byte_size = attrs.
byte_size.value_or(0);
1767 dwarf->GetObjectFile()->GetModule()->LogMessage(
1768 log,
"SymbolFileDWARF({0:p}) - {1:x16}: {2} has unique name: {3} ",
1773 dwarf->GetUniqueDWARFASTTypeMap().Find(
1774 unique_typename, die, unique_decl, byte_size,
1776 if (
TypeSP type_sp = unique_ast_entry_type->m_type_sp) {
1777 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1784 unique_ast_entry_type->m_is_forward_declaration) {
1785 unique_ast_entry_type->UpdateToDefDIE(die, unique_decl, byte_size);
1786 clang_type = type_sp->GetForwardCompilerType();
1790 dwarf->GetForwardDeclCompilerTypeToDIE().insert_or_assign(
1808 dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.
name,
true);
1812 if (debug_map_symfile) {
1816 die, attrs.
name,
true);
1822 dwarf->GetObjectFile()->GetModule()->LogMessage(
1824 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an "
1825 "incomplete objc type, complete type is {5:x8}",
1841 int tag_decl_kind = -1;
1842 if (tag == DW_TAG_structure_type)
1843 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Struct);
1844 else if (tag == DW_TAG_union_type)
1845 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Union);
1846 else if (tag == DW_TAG_class_type)
1847 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Class);
1849 assert(
false &&
"Unexpected tag kind.");
1851 clang::DeclContext *containing_decl_ctx =
1855 containing_decl_ctx, die,
1865 clang::ClassTemplateDecl *class_template_decl =
1866 m_ast.ParseClassTemplateDecl(
1869 if (!class_template_decl) {
1871 dwarf->GetObjectFile()->GetModule()->LogMessage(
1873 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" "
1874 "clang::ClassTemplateDecl failed to return a decl.",
1881 clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1882 m_ast.CreateClassTemplateSpecializationDecl(
1884 tag_decl_kind, template_param_infos);
1885 if (!class_specialization_decl) {
1887 dwarf->GetObjectFile()->GetModule()->LogMessage(
1889 "SymbolFileDWARF({0:p}) - Failed to create specialization for "
1890 "clang::ClassTemplateDecl({1}, {2:p}).",
1891 this, llvm::StringRef(attrs.
name), class_template_decl);
1897 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
1899 m_ast.SetMetadata(class_template_decl, metadata);
1900 m_ast.SetMetadata(class_specialization_decl, metadata);
1904 clang_type =
m_ast.CreateRecordType(
1918 clang::DeclContext *type_decl_ctx =
1926 auto unique_ast_entry_up = std::make_unique<UniqueDWARFASTType>();
1930 unique_ast_entry_up->m_type_sp = type_sp;
1931 unique_ast_entry_up->m_die = die;
1932 unique_ast_entry_up->m_declaration = unique_decl;
1933 unique_ast_entry_up->m_byte_size = byte_size;
1935 dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
1936 *unique_ast_entry_up);
1944 dwarf->GetForwardDeclCompilerTypeToDIE()
1949 assert(inserted &&
"Type already in the forward declaration map!");
1958 clang::CXXRecordDecl *record_decl =
1960 if (record_decl && record_decl->getDefinition()) {
1961 record_decl->setHasTrivialSpecialMemberForCall();
1966 clang::CXXRecordDecl *record_decl =
1969 record_decl->setArgPassingRestrictions(
1970 clang::RecordArgPassingKind::CannotPassInRegs);
1980 const CompilerType &class_opaque_type,
const char *property_name,
1984 const char *property_setter_name,
const char *property_getter_name,
2009static std::optional<clang::APValue>
MakeAPValue(
const clang::ASTContext &ast,
2012 std::optional<uint64_t> bit_width =
2013 llvm::expectedToOptional(clang_type.
GetBitSize(
nullptr));
2015 return std::nullopt;
2017 bool is_signed =
false;
2020 llvm::APSInt apint(*bit_width, !is_signed);
2024 return clang::APValue(apint);
2029 return std::nullopt;
2031 return clang::APValue(llvm::APFloat(
2039 bool is_template_template_argument =
false;
2042 case DW_TAG_GNU_template_parameter_pack: {
2044 std::make_unique<TypeSystemClang::TemplateParameterInfos>());
2049 if (
const char *name = die.
GetName()) {
2054 case DW_TAG_GNU_template_template_param:
2055 is_template_template_argument =
true;
2057 case DW_TAG_template_type_parameter:
2058 case DW_TAG_template_value_parameter: {
2060 if (attributes.
Size() == 0)
2063 const char *name =
nullptr;
2064 const char *template_name =
nullptr;
2066 uint64_t uval64 = 0;
2067 bool uval64_valid =
false;
2068 bool is_default_template_arg =
false;
2070 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2079 case DW_AT_GNU_template_name:
2092 case DW_AT_const_value:
2094 uval64_valid =
true;
2098 case DW_AT_default_value:
2100 is_default_template_arg = form_value.
Boolean();
2107 clang::ASTContext &ast =
m_ast.getASTContext();
2111 if (!is_template_template_argument) {
2113 if (name && !name[0])
2116 if (tag == DW_TAG_template_value_parameter && uval64_valid) {
2117 if (
auto value =
MakeAPValue(ast, clang_type, uval64)) {
2119 name, clang::TemplateArgument(
2121 std::move(*value), is_default_template_arg));
2131 is_default_template_arg));
2133 auto *tplt_type =
m_ast.CreateTemplateTemplateParmDecl(template_name);
2135 name, clang::TemplateArgument(clang::TemplateName(tplt_type),
2136 is_default_template_arg));
2158 case DW_TAG_template_type_parameter:
2159 case DW_TAG_template_value_parameter:
2160 case DW_TAG_GNU_template_parameter_pack:
2161 case DW_TAG_GNU_template_template_param:
2170 return !template_param_infos.
IsEmpty() ||
2179 std::vector<DWARFDIE> contained_type_dies;
2190 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
2192 std::vector<DWARFDIE> member_function_dies;
2196 contained_type_dies, delayed_properties, layout_info);
2199 for (
const DWARFDIE &die : member_function_dies)
2200 dwarf->ResolveType(die);
2205 dwarf->GetObjCMethods(class_name, [&](
DWARFDIE method_die) {
2211 property.Finalize();
2221 "WARNING: Type completion aborted because forward declaration for "
2222 "'{0}' is C++ while definition is Objective-C.",
2223 llvm::StringRef(die.
GetName()));
2239 clang::CXXRecordDecl *record_decl =
2247 if (
m_ast.getASTContext().getTargetInfo().getCXXABI().isMicrosoft()) {
2248 auto IM = record_decl->calculateInheritanceModel();
2249 record_decl->addAttr(clang::MSInheritanceAttr::CreateImplicit(
2250 m_ast.getASTContext(),
true, {},
2251 clang::MSInheritanceAttr::Spelling(IM)));
2258 for (
const DWARFDIE &die : contained_type_dies)
2259 dwarf->ResolveType(die);
2261 return (
bool)clang_type;
2273 llvm::expectedToOptional(type->
GetByteSize(
nullptr)).value_or(0),
2278 return (
bool)clang_type;
2286 std::lock_guard<std::recursive_mutex> guard(
2287 dwarf->GetObjectFile()->GetModule()->GetMutex());
2300 case DW_TAG_structure_type:
2301 case DW_TAG_union_type:
2302 case DW_TAG_class_type:
2305 case DW_TAG_enumeration_type:
2309 assert(
false &&
"not a forward clang type decl!");
2326 auto opaque_decl_ctx =
2337 if (clang_decl !=
nullptr)
2338 return m_ast.GetCompilerDecl(clang_decl);
2346 return m_ast.CreateDeclContext(clang_decl_ctx);
2352 clang::DeclContext *clang_decl_ctx =
2355 return m_ast.CreateDeclContext(clang_decl_ctx);
2361 uint32_t enumerator_byte_size,
const DWARFDIE &parent_die) {
2365 size_t enumerators_added = 0;
2369 if (tag != DW_TAG_enumerator)
2373 if (attributes.
Size() == 0)
2376 const char *name =
nullptr;
2377 std::optional<uint64_t> enum_value;
2380 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2385 case DW_AT_const_value:
2387 enum_value = form_value.
Signed();
2389 enum_value = form_value.
Unsigned();
2396 case DW_AT_description:
2398 case DW_AT_decl_file:
2402 case DW_AT_decl_line:
2405 case DW_AT_decl_column:
2414 if (name && name[0] && enum_value) {
2415 m_ast.AddEnumerationValueToEnumerationType(
2416 clang_type, decl, name, *enum_value, enumerator_byte_size * 8);
2417 ++enumerators_added;
2420 return enumerators_added;
2425 bool is_variadic =
false;
2426 bool has_template_params =
false;
2427 std::vector<CompilerType> param_types;
2428 llvm::SmallVector<llvm::StringRef> param_names;
2435 clang::DeclContext *containing_decl_ctx =
2437 assert(containing_decl_ctx);
2439 const unsigned cv_quals =
2443 has_template_params, param_types, param_names);
2445 for (
size_t i = 0; i < param_types.size(); i++) {
2448 sstr << param_types[i].GetTypeName();
2453 if (cv_quals & clang::Qualifiers::Const)
2461 llvm::DWARFAddressRangesVector unused_func_ranges;
2462 const char *name =
nullptr;
2463 const char *mangled =
nullptr;
2464 std::optional<int> decl_file;
2465 std::optional<int> decl_line;
2466 std::optional<int> decl_column;
2467 std::optional<int> call_file;
2468 std::optional<int> call_line;
2469 std::optional<int> call_column;
2474 if (tag != DW_TAG_subprogram)
2478 decl_line, decl_column, call_file, call_line,
2479 call_column, &frame_base)) {
2483 else if ((die.
GetParent().
Tag() == DW_TAG_compile_unit ||
2489 name && strcmp(name,
"main") != 0) {
2500 std::unique_ptr<Declaration> decl_up;
2501 if (decl_file || decl_line || decl_column)
2502 decl_up = std::make_unique<Declaration>(
2503 die.
GetCU()->
GetFile(decl_file.value_or(0)), decl_line.value_or(0),
2504 decl_column.value_or(0));
2529 Address func_addr = func_ranges[0].GetBaseAddress();
2531 func_sp = std::make_shared<Function>(
2534 func_user_id, func_name, func_type, std::move(func_addr),
2535 std::move(func_ranges));
2537 if (func_sp.get() !=
nullptr) {
2539 func_sp->GetFrameBaseExpression() = frame_base;
2541 return func_sp.get();
2550struct PropertyAttributes {
2551 explicit PropertyAttributes(
const DWARFDIE &die);
2552 const char *prop_name =
nullptr;
2553 const char *prop_getter_name =
nullptr;
2554 const char *prop_setter_name =
nullptr;
2556 uint32_t prop_attributes = 0;
2559struct DiscriminantValue {
2560 explicit DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp);
2562 uint32_t byte_offset;
2564 DWARFFormValue type_ref;
2567struct VariantMember {
2568 explicit VariantMember(DWARFDIE &die,
ModuleSP module_sp);
2569 bool IsDefault()
const;
2571 std::optional<uint32_t> discr_value;
2572 DWARFFormValue type_ref;
2573 ConstString variant_name;
2574 uint32_t byte_offset;
2579 explicit VariantPart(
const DWARFDIE &die,
const DWARFDIE &parent_die,
2582 std::vector<VariantMember> &members();
2584 DiscriminantValue &discriminant();
2587 std::vector<VariantMember> _members;
2588 DiscriminantValue _discriminant;
2593ConstString VariantMember::GetName()
const {
return this->variant_name; }
2595bool VariantMember::IsDefault()
const {
return !discr_value; }
2597VariantMember::VariantMember(DWARFDIE &die,
lldb::ModuleSP module_sp) {
2598 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant);
2602 for (
auto child_die : die.
children()) {
2603 switch (child_die.Tag()) {
2604 case llvm::dwarf::DW_TAG_member: {
2605 DWARFAttributes attributes = child_die.GetAttributes();
2606 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2607 DWARFFormValue form_value;
2612 variant_name = ConstString(form_value.
AsCString());
2615 type_ref = form_value;
2618 case DW_AT_data_member_location:
2619 if (
auto maybe_offset =
2621 byte_offset = *maybe_offset;
2638DiscriminantValue::DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp) {
2640 DWARFAttributes attributes = referenced_die.GetAttributes();
2641 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2643 DWARFFormValue form_value;
2647 type_ref = form_value;
2649 case DW_AT_data_member_location:
2650 if (
auto maybe_offset =
2652 byte_offset = *maybe_offset;
2661VariantPart::VariantPart(
const DWARFDIE &die,
const DWARFDIE &parent_die,
2663 : _members(), _discriminant(die, module_sp) {
2665 for (
auto child : die.
children()) {
2666 if (child.Tag() == llvm::dwarf::DW_TAG_variant) {
2667 _members.push_back(VariantMember(child, module_sp));
2672std::vector<VariantMember> &VariantPart::members() {
return this->_members; }
2674DiscriminantValue &VariantPart::discriminant() {
return this->_discriminant; }
2679 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2690 case DW_AT_bit_offset:
2693 case DW_AT_bit_size:
2696 case DW_AT_byte_size:
2699 case DW_AT_const_value:
2702 case DW_AT_data_bit_offset:
2705 case DW_AT_data_member_location:
2706 if (
auto maybe_offset =
2711 case DW_AT_artificial:
2714 case DW_AT_declaration:
2741PropertyAttributes::PropertyAttributes(
const DWARFDIE &die) {
2744 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2749 case DW_AT_APPLE_property_name:
2752 case DW_AT_APPLE_property_getter:
2753 prop_getter_name = form_value.
AsCString();
2755 case DW_AT_APPLE_property_setter:
2756 prop_setter_name = form_value.
AsCString();
2758 case DW_AT_APPLE_property_attribute:
2759 prop_attributes = form_value.
Unsigned();
2769 ConstString fixed_setter;
2773 if (prop_getter_name && prop_getter_name[0] ==
'-') {
2774 std::optional<const ObjCLanguage::ObjCMethodName> prop_getter_method =
2776 if (prop_getter_method)
2778 ConstString(prop_getter_method->GetSelector()).GetCString();
2781 if (prop_setter_name && prop_setter_name[0] ==
'-') {
2782 std::optional<const ObjCLanguage::ObjCMethodName> prop_setter_method =
2784 if (prop_setter_method)
2786 ConstString(prop_setter_method->GetSelector()).GetCString();
2790 if (!prop_getter_name)
2791 prop_getter_name = prop_name;
2792 if (!prop_setter_name && prop_name[0] &&
2793 !(prop_attributes & DW_APPLE_PROPERTY_readonly)) {
2796 ss.
Printf(
"set%c%s:", toupper(prop_name[0]), &prop_name[1]);
2799 prop_setter_name = fixed_setter.
GetCString();
2808 assert(die.
Tag() == DW_TAG_APPLE_property);
2813 const PropertyAttributes propAttrs(die);
2815 if (!propAttrs.prop_name) {
2816 module_sp->ReportError(
"{0:x8}: DW_TAG_APPLE_property has no name.",
2823 module_sp->ReportError(
2824 "{0:x8}: DW_TAG_APPLE_property '{1}' refers to type {2:x16}"
2825 " which was unable to be parsed",
2826 die.
GetID(), propAttrs.prop_name,
2833 delayed_properties.emplace_back(
2834 class_clang_type, propAttrs.prop_name,
2836 propAttrs.prop_getter_name, propAttrs.prop_attributes, metadata);
2842 assert(qt->isIntegralOrEnumerationType());
2845 return llvm::createStringError(llvm::inconvertibleErrorCode(),
2846 "TypeSystem not clang");
2850 const unsigned type_bits = ast.getIntWidth(qt);
2851 const bool is_unsigned = qt->isUnsignedIntegerType();
2855 constexpr std::size_t max_bit_size = 64;
2860 if (type_bits > max_bit_size) {
2861 auto msg = llvm::formatv(
"Can only parse integers with up to {0} bits, but "
2862 "given integer has {1} bits.",
2863 max_bit_size, type_bits);
2864 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2868 llvm::APInt result(max_bit_size, form_value.
Unsigned(), !is_unsigned);
2874 const unsigned required_bits =
2875 is_unsigned ? result.getActiveBits() : result.getSignificantBits();
2878 if (required_bits > type_bits) {
2879 std::string value_as_str = is_unsigned
2880 ? std::to_string(form_value.
Unsigned())
2881 : std::to_string(form_value.
Signed());
2882 auto msg = llvm::formatv(
"Can't store {0} value {1} in integer with {2} "
2884 (is_unsigned ?
"unsigned" :
"signed"),
2885 value_as_str, type_bits);
2886 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2890 if (result.getBitWidth() > type_bits)
2891 result = result.trunc(type_bits);
2899 assert(die.
Tag() == DW_TAG_member || die.
Tag() == DW_TAG_variable);
2910 LLDB_LOG(log,
"Failed to add variable to the record type");
2919 llvm::Expected<llvm::APInt> const_value_or_err =
2921 if (!const_value_or_err) {
2923 "Failed to add const value to variable {1}: {0}",
2924 v->getQualifiedNameAsString());
2937 assert(die.
Tag() == DW_TAG_member);
2942 const uint64_t parent_byte_size =
2944 const uint64_t parent_bit_size =
2969 module_sp->ReportError(
2970 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
2971 " which was unable to be parsed",
2974 module_sp->ReportError(
"{0:x8}: DW_TAG_member refers to type {1:x16}"
2975 " which was unable to be parsed",
2981 const uint64_t character_width = 8;
2990 this_field_info.
bit_offset = field_bit_offset;
2998 byte_size = llvm::expectedToOptional(member_type->
GetByteSize(
nullptr));
3002 this_field_info.
bit_offset += byte_size.value_or(0) * 8;
3016 !(parent_die.
Tag() == DW_TAG_union_type &&
3018 ((this_field_info.
bit_offset >= parent_bit_size) ||
3024 "{0:x16}: {1} ({2}) bitfield named \"{3}\" has invalid "
3025 "bit offset ({4:x8}) member will be ignored. Please file a bug "
3027 "compiler and include the preprocessed output for {5}\n",
3034 field_bit_offset = this_field_info.
bit_offset;
3039 bool detect_unnamed_bitfields =
true;
3042 detect_unnamed_bitfields =
3045 if (detect_unnamed_bitfields)
3047 last_field_info, this_field_info);
3049 last_field_info = this_field_info;
3054 this_field_info.
bit_offset = field_bit_offset;
3058 if (std::optional<uint64_t> clang_type_size =
3059 llvm::expectedToOptional(member_type->
GetByteSize(
nullptr))) {
3060 this_field_info.
bit_size = *clang_type_size * character_width;
3067 last_field_info = this_field_info;
3087 class_clang_type, attrs.
name, member_clang_type, attrs.
bit_size);
3089 m_ast.SetMetadataAsUserID(field_decl, die.
GetID());
3092 std::make_pair(field_decl, field_bit_offset));
3097 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
3098 std::vector<DWARFDIE> &member_function_dies,
3099 std::vector<DWARFDIE> &contained_type_dies,
3116 case DW_TAG_APPLE_property:
3120 case DW_TAG_variant_part:
3126 case DW_TAG_variable: {
3135 case DW_TAG_subprogram:
3137 member_function_dies.push_back(die);
3140 case DW_TAG_inheritance:
3142 base_classes, layout_info);
3146 if (llvm::dwarf::isType(tag))
3147 contained_type_dies.push_back(die);
3156 clang::DeclContext *containing_decl_ctx,
const DWARFDIE &parent_die,
3157 bool &is_variadic,
bool &has_template_params,
3158 std::vector<CompilerType> &function_param_types,
3166 case DW_TAG_formal_parameter: {
3176 function_param_names.emplace_back(die.
GetName());
3180 case DW_TAG_unspecified_parameters:
3184 case DW_TAG_template_type_parameter:
3185 case DW_TAG_template_value_parameter:
3186 case DW_TAG_GNU_template_parameter_pack:
3192 has_template_params =
true;
3200 assert(function_param_names.size() == function_param_types.size());
3207 switch (die.
Tag()) {
3208 case DW_TAG_constant:
3209 case DW_TAG_formal_parameter:
3210 case DW_TAG_imported_declaration:
3211 case DW_TAG_imported_module:
3213 case DW_TAG_variable:
3227 return cache_pos->second;
3242 clang::Decl *decl =
nullptr;
3243 switch (die.
Tag()) {
3244 case DW_TAG_variable:
3245 case DW_TAG_constant:
3246 case DW_TAG_formal_parameter: {
3249 if (
dwarf && type) {
3250 const char *name = die.
GetName();
3251 clang::DeclContext *decl_context =
3253 dwarf->GetDeclContextContainingUID(die.
GetID()));
3254 decl =
m_ast.CreateVariableDeclaration(
3260 case DW_TAG_imported_declaration: {
3265 if (imported_decl) {
3266 clang::DeclContext *decl_context =
3268 dwarf->GetDeclContextContainingUID(die.
GetID()));
3269 if (clang::NamedDecl *clang_imported_decl =
3270 llvm::dyn_cast<clang::NamedDecl>(
3272 decl =
m_ast.CreateUsingDeclaration(
3278 case DW_TAG_imported_module: {
3285 if (imported_decl_ctx) {
3286 clang::DeclContext *decl_context =
3288 dwarf->GetDeclContextContainingUID(die.
GetID()));
3289 if (clang::NamespaceDecl *ns_decl =
3292 decl =
m_ast.CreateUsingDirectiveDeclaration(
3314 bool try_parsing_type =
true;
3315 switch (die.
Tag()) {
3316 case DW_TAG_compile_unit:
3317 case DW_TAG_partial_unit:
3318 decl_ctx =
m_ast.GetTranslationUnitDecl();
3319 try_parsing_type =
false;
3322 case DW_TAG_namespace:
3324 try_parsing_type =
false;
3327 case DW_TAG_imported_declaration:
3329 try_parsing_type =
false;
3332 case DW_TAG_lexical_block:
3334 try_parsing_type =
false;
3341 if (decl_ctx ==
nullptr && try_parsing_type) {
3361 parent = parent.GetParent()) {
3363 if (tag == DW_TAG_module) {
3383 switch (die.
Tag()) {
3384 case DW_TAG_subprogram:
3385 case DW_TAG_inlined_subroutine:
3395 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3402 assert(0 &&
"Shouldn't call GetContainingFunctionWithAbstractOrigin on "
3403 "something not in a function");
3409 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3431 assert(die.
Tag() == DW_TAG_lexical_block);
3432 DWARFDIE containing_function_with_abstract_origin =
3434 if (!containing_function_with_abstract_origin) {
3438 die, containing_function_with_abstract_origin);
3445 if (die && die.
Tag() == DW_TAG_lexical_block) {
3446 clang::BlockDecl *decl =
3451 clang::DeclContext *decl_context =
3465clang::NamespaceDecl *
3467 if (die && die.
Tag() == DW_TAG_namespace) {
3470 clang::NamespaceDecl *namespace_decl =
3473 return namespace_decl;
3475 const char *namespace_name = die.
GetName();
3476 clang::DeclContext *containing_decl_ctx =
3481 namespace_decl =
m_ast.GetUniqueNamespaceDeclaration(
3487 return namespace_decl;
3493clang::NamespaceDecl *
3495 assert(die && die.
Tag() == DW_TAG_imported_declaration);
3501 return static_cast<clang::NamespaceDecl *
>(it->getSecond());
3503 clang::NamespaceDecl *namespace_decl =
nullptr;
3510 switch (imported_uid.
Tag()) {
3511 case DW_TAG_imported_declaration:
3514 case DW_TAG_namespace:
3521 if (!namespace_decl)
3526 return namespace_decl;
3533 DWARFDIE decl_ctx_die =
dwarf->GetDeclContextDIEContainingDIE(die);
3535 if (decl_ctx_die_copy)
3536 *decl_ctx_die_copy = decl_ctx_die;
3539 clang::DeclContext *clang_decl_ctx =
3542 return clang_decl_ctx;
3544 return m_ast.GetTranslationUnitDecl();
3568 if (!class_type || !src_class_die || !dst_class_die)
3570 if (src_class_die.
Tag() != dst_class_die.
Tag())
3580 if (die.
Tag() != DW_TAG_subprogram)
3592 map_artificial.Append(const_name, die);
3594 map.Append(const_name, die);
3603 src_die = src_die.GetSibling()) {
3604 gather(src_die, src_name_to_die, src_name_to_die_artificial);
3607 dst_die = dst_die.GetSibling()) {
3608 gather(dst_die, dst_name_to_die, dst_name_to_die_artificial);
3610 const uint32_t src_size = src_name_to_die.
GetSize();
3611 const uint32_t dst_size = dst_name_to_die.
GetSize();
3614 bool fast_path =
true;
3616 if (src_size != dst_size)
3622 for (idx = 0; idx < src_size; ++idx) {
3626 if (src_die.
Tag() != dst_die.
Tag())
3633 if (src_name == dst_name || (strcmp(src_name, dst_name) == 0))
3640 auto *src_dwarf_ast_parser = llvm::cast<DWARFASTParserClang>(
3642 auto *dst_dwarf_ast_parser = llvm::cast<DWARFASTParserClang>(
3646 clang::DeclContext *dst_decl_ctx =
3647 dst_dwarf_ast_parser->m_die_to_decl_ctx[dst.GetDIE()];
3649 src_dwarf_ast_parser->LinkDeclContextToDIE(dst_decl_ctx, src);
3651 if (
Type *src_child_type = die_to_type.lookup(src.
GetDIE()))
3652 die_to_type[dst.GetDIE()] = src_child_type;
3659 for (idx = 0; idx < src_size; ++idx) {
3669 src_name_to_die.
Sort();
3671 for (idx = 0; idx < dst_size; ++idx) {
3676 if (src_die && (src_die.
Tag() == dst_die.
Tag()))
3677 link(src_die, dst_die);
3679 failures.push_back(dst_die);
3684 const uint32_t src_size_artificial = src_name_to_die_artificial.
GetSize();
3685 const uint32_t dst_size_artificial = dst_name_to_die_artificial.
GetSize();
3687 if (src_size_artificial && dst_size_artificial) {
3688 dst_name_to_die_artificial.
Sort();
3690 for (idx = 0; idx < src_size_artificial; ++idx) {
3696 dst_name_to_die_artificial.
Find(src_name_artificial,
DWARFDIE());
3700 link(src_die, dst_die);
3704 if (dst_size_artificial) {
3705 for (idx = 0; idx < dst_size_artificial; ++idx) {
3711 return !failures.empty();
3715 FieldInfo const &last_field_info, uint64_t last_field_end,
3720 if (this_field_info.
bit_offset <= last_field_end)
3734 const bool have_base = layout_info.
base_offsets.size() != 0;
3735 const bool this_is_first_field =
3737 const bool first_field_is_vptr =
3740 if (have_base && (this_is_first_field || first_field_is_vptr))
3751 const uint64_t word_width = 32;
3759 if (last_field_end != 0 && ((last_field_end % word_width) != 0))
3760 last_field_end += word_width - (last_field_end % word_width);
3765 current_field, class_layout_info))
3770 const uint64_t unnamed_bit_size = current_field.
bit_offset - last_field_end;
3771 const uint64_t unnamed_bit_offset = last_field_end;
3773 clang::FieldDecl *unnamed_bitfield_decl =
3775 class_clang_type, llvm::StringRef(),
3780 std::make_pair(unnamed_bitfield_decl, unnamed_bit_offset));
3787 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant_part);
3793 VariantPart variants(die, parent_die, module_sp);
3795 auto discriminant_type =
3796 die.
ResolveTypeUID(variants.discriminant().type_ref.Reference());
3798 auto decl_context =
m_ast.GetDeclContextForType(class_clang_type);
3800 auto inner_holder =
m_ast.CreateRecordType(
3803 llvm::formatv(
"{0}$Inner", class_clang_type.
GetTypeName(
false))),
3805 m_ast.StartTagDeclarationDefinition(inner_holder);
3806 m_ast.SetIsPacked(inner_holder);
3808 for (
auto member : variants.members()) {
3810 auto has_discriminant = !member.IsDefault();
3812 auto member_type = die.
ResolveTypeUID(member.type_ref.Reference());
3814 auto field_type =
m_ast.CreateRecordType(
3816 std::string(llvm::formatv(
"{0}$Variant", member.GetName())),
3817 llvm::to_underlying(clang::TagTypeKind::Struct),
3820 m_ast.StartTagDeclarationDefinition(field_type);
3821 auto offset = member.byte_offset;
3823 if (has_discriminant) {
3824 m_ast.AddFieldToRecordType(field_type,
"$discr$",
3825 discriminant_type->GetFullCompilerType(),
3826 variants.discriminant().byte_offset);
3828 llvm::expectedToOptional(discriminant_type->GetByteSize(
nullptr))
3832 m_ast.AddFieldToRecordType(field_type,
"value",
3833 member_type->GetFullCompilerType(), offset * 8);
3835 m_ast.CompleteTagDeclarationDefinition(field_type);
3837 auto name = has_discriminant
3838 ? llvm::formatv(
"$variant${0}", member.discr_value.value())
3839 : std::string(
"$variant$");
3841 auto variant_decl =
m_ast.AddFieldToRecordType(
3842 inner_holder, llvm::StringRef(name), field_type, 0);
3847 auto inner_field =
m_ast.AddFieldToRecordType(
3848 class_clang_type, llvm::StringRef(
"$variants$"), inner_holder, 0);
3850 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 AccessType GetDefaultAccessibility(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 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)
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)
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.
lldb::TypeSP ParseStructureLikeDIE(const lldb_private::SymbolContext &sc, const lldb_private::plugin::dwarf::DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs)
Parse a structure, class, or union type DIE.
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
DIEToDeclMap m_die_to_decl
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::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.
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_private::ClangASTImporter::LayoutInfo &layout_info, FieldInfo &last_field_info)
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.
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, lldb_private::ClangASTImporter::LayoutInfo &layout_info)
clang::DeclContext * GetCachedClangDeclContextForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die)
DIEToModuleMap m_die_to_module
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)
void ParseRustVariantPart(lldb_private::plugin::dwarf::DWARFDIE &die, const lldb_private::plugin::dwarf::DWARFDIE &parent_die, const lldb_private::CompilerType &class_clang_type, 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::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.
bool IsRealFloatingPointType() const
Returns true for non-complex float types.
llvm::Expected< uint64_t > GetBitSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bits.
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.
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 clang::VarDecl * AddVariableToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &var_type)
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::FieldDecl * AddFieldToRecordType(const CompilerType &type, llvm::StringRef name, const CompilerType &field_type, uint32_t bitfield_bit_size)
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
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_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
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.