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:
453 case DW_AT_alignment:
457 case DW_AT_byte_stride:
461 case DW_AT_calling_convention:
465 case DW_AT_containing_type:
469 case DW_AT_decl_file:
474 case DW_AT_decl_line:
477 case DW_AT_decl_column:
481 case DW_AT_declaration:
489 case DW_AT_enum_class:
506 case DW_AT_linkage_name:
507 case DW_AT_MIPS_linkage_name:
515 case DW_AT_signature:
519 case DW_AT_specification:
527 case DW_AT_virtuality:
531 case DW_AT_APPLE_objc_complete_type:
535 case DW_AT_APPLE_objc_direct:
539 case DW_AT_APPLE_runtime_class:
543 case DW_AT_GNU_vector:
546 case DW_AT_export_symbols:
549 case DW_AT_rvalue_reference:
552 case DW_AT_reference:
555 case DW_AT_APPLE_enum_kind:
556 enum_kind =
static_cast<clang::EnumExtensibilityAttr::Kind
>(
565 return unit->GetAbsolutePath().GetPath();
566 return "<missing DWARF unit path>";
571 bool *type_is_new_ptr) {
573 *type_is_new_ptr =
false;
583 clang::DeclContext *context =
586 dwarf->GetObjectFile()->GetModule()->LogMessage(
588 "DWARFASTParserClang::ParseTypeFromDWARF "
589 "(die = {0:x16}, decl_ctx = {1:p} (die "
590 "{2:x16})) {3} ({4}) name = '{5}')",
596 if (
auto [it, inserted] =
601 return it->getSecond()->shared_from_this();
610 if (clang::DeclContext *decl_ctx =
616 *type_is_new_ptr =
true;
622 case DW_TAG_base_type:
623 case DW_TAG_pointer_type:
624 case DW_TAG_reference_type:
625 case DW_TAG_rvalue_reference_type:
626 case DW_TAG_const_type:
627 case DW_TAG_restrict_type:
628 case DW_TAG_volatile_type:
629 case DW_TAG_LLVM_ptrauth_type:
630 case DW_TAG_atomic_type:
631 case DW_TAG_unspecified_type:
634 case DW_TAG_structure_type:
635 case DW_TAG_union_type:
636 case DW_TAG_class_type:
639 case DW_TAG_enumeration_type:
642 case DW_TAG_inlined_subroutine:
643 case DW_TAG_subprogram:
644 case DW_TAG_subroutine_type:
647 case DW_TAG_array_type:
650 case DW_TAG_ptr_to_member_type:
654 dwarf->GetObjectFile()->GetModule()->ReportError(
655 "[{0:x16}]: unhandled type tag {1:x4} ({2}), "
656 "please file a bug and "
657 "attach the file at the start of this error message",
664 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
669static std::optional<uint32_t>
680 Value initialValue(0);
682 uint32_t block_length = form_value.
Unsigned();
683 uint32_t block_offset =
693 "ExtractDataMemberLocation failed: {0}");
697 return memberOffset->ResolveValue(
nullptr).UInt();
701 auto getAttr = [&](llvm::dwarf::Attribute Attr,
unsigned defaultValue = 0) {
704 const unsigned key = getAttr(DW_AT_LLVM_ptrauth_key);
705 const bool addr_disc = getAttr(DW_AT_LLVM_ptrauth_address_discriminated);
706 const unsigned extra = getAttr(DW_AT_LLVM_ptrauth_extra_discriminator);
707 const bool isapointer = getAttr(DW_AT_LLVM_ptrauth_isa_pointer);
708 const bool authenticates_null_values =
709 getAttr(DW_AT_LLVM_ptrauth_authenticates_null_values);
710 const unsigned authentication_mode_int = getAttr(
711 DW_AT_LLVM_ptrauth_authentication_mode,
712 static_cast<unsigned>(clang::PointerAuthenticationMode::SignAndAuth));
713 clang::PointerAuthenticationMode authentication_mode =
714 clang::PointerAuthenticationMode::SignAndAuth;
715 if (authentication_mode_int >=
716 static_cast<unsigned>(clang::PointerAuthenticationMode::None) &&
717 authentication_mode_int <=
718 static_cast<unsigned>(
719 clang::PointerAuthenticationMode::SignAndAuth)) {
720 authentication_mode =
721 static_cast<clang::PointerAuthenticationMode
>(authentication_mode_int);
724 "[{0:x16}]: invalid pointer authentication mode method {1:x4}",
725 die.
GetOffset(), authentication_mode_int);
727 auto ptr_auth = clang::PointerAuthQualifier::Create(
728 key, addr_disc, extra, authentication_mode, isapointer,
729 authenticates_null_values);
747 if (tag == DW_TAG_typedef) {
797 encoding_uid.Reference());
803 case DW_TAG_unspecified_type:
804 if (attrs.
name ==
"nullptr_t" || attrs.
name ==
"decltype(nullptr)") {
813 case DW_TAG_base_type:
815 clang_type =
m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
820 case DW_TAG_pointer_type:
823 case DW_TAG_reference_type:
826 case DW_TAG_rvalue_reference_type:
832 case DW_TAG_const_type:
835 case DW_TAG_restrict_type:
838 case DW_TAG_volatile_type:
841 case DW_TAG_LLVM_ptrauth_type:
845 case DW_TAG_atomic_type:
852 if (tag == DW_TAG_pointer_type) {
860 if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name,
""),
865 if (function_pointer_type) {
869 bool function_type_is_new_pointer;
871 sc, function_type, &function_type_is_new_pointer);
873 if (lldb_function_type_sp) {
874 clang_type =
m_ast.CreateBlockPointerType(
875 lldb_function_type_sp->GetForwardCompilerType());
891 if (attrs.
name ==
"id") {
893 dwarf->GetObjectFile()->GetModule()->LogMessage(
895 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
896 "is Objective-C 'id' built-in type.",
903 }
else if (attrs.
name ==
"Class") {
905 dwarf->GetObjectFile()->GetModule()->LogMessage(
907 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
908 "is Objective-C 'Class' built-in type.",
915 }
else if (attrs.
name ==
"SEL") {
917 dwarf->GetObjectFile()->GetModule()->LogMessage(
919 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
920 "is Objective-C 'selector' built-in type.",
935 if (encoding_die && encoding_die.
Tag() == DW_TAG_structure_type) {
936 llvm::StringRef struct_name = encoding_die.
GetName();
937 if (struct_name ==
"objc_object") {
939 dwarf->GetObjectFile()->GetModule()->LogMessage(
941 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
942 "is 'objc_object*', which we overrode to 'id'.",
957 &attrs.
decl, clang_type, resolve_state, payload);
964 if (llvm::StringRef(die.
GetName()).contains(
"<"))
968 llvm::raw_string_ostream os(name);
969 llvm::DWARFTypePrinter<DWARFDIE> type_printer(os);
970 type_printer.appendAndTerminateTemplateParameters(die);
985 unique_typename, decl_declaration);
987 dwarf->GetUniqueDWARFASTTypeMap().Find(
988 unique_typename, decl_die, decl_declaration,
991 unique_ast_entry_type->UpdateToDefDIE(def_die, def_attrs.
decl,
996 "Failed to find {0:x16} {1} ({2}) type \"{3}\" in "
997 "UniqueDWARFASTTypeMap",
1014 def_die =
dwarf->FindDefinitionDIE(decl_die);
1018 if (debug_map_symfile) {
1026 dwarf->GetObjectFile()->GetModule()->LogMessage(
1028 "SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a "
1029 "forward declaration, complete DIE is {5}",
1032 def_die ? llvm::utohexstr(def_die.
GetID()) :
"not found");
1036 if (
auto [it, inserted] =
dwarf->GetDIEToType().try_emplace(
1041 return it->getSecond()->shared_from_this();
1052 Type *enumerator_type =
1054 if (enumerator_type)
1058 if (!enumerator_clang_type) {
1060 enumerator_clang_type =
m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
1061 "", DW_ATE_signed, *attrs.
byte_size * 8);
1078 clang::DeclContext *type_decl_ctx =
1081 if (decl_die != def_die) {
1083 dwarf->GetDIEToType()[def_die.
GetDIE()] = type_sp.get();
1088 dwarf->GetObjectFile()->GetModule()->ReportError(
1089 "DWARF DIE at {0:x16} named \"{1}\" was not able to start its "
1090 "definition.\nPlease file a bug and attach the file at the "
1091 "start of this error message",
1097static clang::CallingConv
1100 case llvm::dwarf::DW_CC_normal:
1102 case llvm::dwarf::DW_CC_BORLAND_stdcall:
1103 return clang::CC_X86StdCall;
1104 case llvm::dwarf::DW_CC_BORLAND_msfastcall:
1105 return clang::CC_X86FastCall;
1106 case llvm::dwarf::DW_CC_LLVM_vectorcall:
1107 return clang::CC_X86VectorCall;
1108 case llvm::dwarf::DW_CC_BORLAND_pascal:
1109 return clang::CC_X86Pascal;
1110 case llvm::dwarf::DW_CC_LLVM_Win64:
1111 return clang::CC_Win64;
1112 case llvm::dwarf::DW_CC_LLVM_X86_64SysV:
1113 return clang::CC_X86_64SysV;
1114 case llvm::dwarf::DW_CC_LLVM_X86RegCall:
1115 return clang::CC_X86RegCall;
1121 LLDB_LOG(log,
"Unsupported DW_AT_calling_convention value: {0}",
1134 const auto tag = die.
Tag();
1139 TypeSP complete_objc_class_type_sp =
1140 dwarf->FindCompleteObjCDefinitionTypeForDIE(
DWARFDIE(), class_name,
1143 if (!complete_objc_class_type_sp)
1147 complete_objc_class_type_sp->GetForwardCompilerType();
1149 if (!type_clang_forward_type)
1155 clang::ObjCMethodDecl *objc_method_decl =
m_ast.AddMethodToObjCObjectType(
1159 if (!objc_method_decl) {
1160 dwarf->GetObjectFile()->GetModule()->ReportError(
1161 "[{0:x16}]: invalid Objective-C method {1:x4} ({2}), "
1162 "please file a bug and attach the file at the start of "
1163 "this error message",
1169 m_ast.SetMetadataAsUserID(objc_method_decl, die.
GetID());
1177 const DWARFDIE &object_parameter,
bool &ignore_containing_context) {
1182 Type *class_type =
dwarf->ResolveType(decl_ctx_die);
1186 if (class_type->
GetID() != decl_ctx_die.
GetID() ||
1193 std::vector<DWARFDIE> failures;
1205 return {
true, type_ptr->shared_from_this()};
1219 clang::DeclContext *spec_clang_decl_ctx =
1221 if (spec_clang_decl_ctx)
1224 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1225 "{0:x8}: DW_AT_specification({1:x16}"
1229 return {
true,
nullptr};
1241 if (abs_clang_decl_ctx)
1244 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1245 "{0:x8}: DW_AT_abstract_origin({1:x16}"
1249 return {
true,
nullptr};
1262 const bool is_static = !object_parameter.
IsValid();
1268 return {
true,
nullptr};
1270 const bool is_attr_used =
false;
1274 const auto accessibility =
1277 clang::CXXMethodDecl *cxx_method_decl =
m_ast.AddMethodToCXXRecordType(
1283 if (cxx_method_decl) {
1289 if (
char const *object_pointer_name = object_parameter.
GetName()) {
1291 LLDB_LOGF(log,
"Setting object pointer name: %s on method object %p.\n",
1292 object_pointer_name,
static_cast<void *
>(cxx_method_decl));
1294 m_ast.SetMetadata(cxx_method_decl, metadata);
1296 ignore_containing_context =
true;
1301 const bool type_handled = cxx_method_decl !=
nullptr || attrs.
is_artificial;
1303 return {type_handled,
nullptr};
1314 bool is_variadic =
false;
1315 bool has_template_params =
false;
1321 Type *func_type =
nullptr;
1331 std::vector<CompilerType> function_param_types;
1332 llvm::SmallVector<llvm::StringRef> function_param_names;
1337 clang::DeclContext *containing_decl_ctx =
1339 assert(containing_decl_ctx);
1343 has_template_params, function_param_types,
1344 function_param_names);
1348 bool ignore_containing_context =
false;
1359 if (is_cxx_method && has_template_params) {
1360 ignore_containing_context =
true;
1361 is_cxx_method =
false;
1364 clang::CallingConv calling_convention =
1372 return_clang_type, function_param_types, is_variadic,
1377 bool type_handled =
false;
1378 if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
1379 if (std::optional<const ObjCLanguage::ObjCMethodName> objc_method =
1384 }
else if (is_cxx_method) {
1385 auto [handled, type_sp] =
1387 object_parameter, ignore_containing_context);
1391 type_handled = handled;
1395 if (!type_handled) {
1396 clang::FunctionDecl *function_decl =
nullptr;
1397 clang::FunctionDecl *template_function_decl =
nullptr;
1402 if (
dwarf->ResolveType(abs_die)) {
1403 function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
1406 if (function_decl) {
1412 if (!function_decl) {
1413 char *name_buf =
nullptr;
1420 llvm::ItaniumPartialDemangler D;
1422 name_buf = D.getFunctionBaseName(
nullptr,
nullptr);
1428 function_decl =
m_ast.CreateFunctionDeclaration(
1429 ignore_containing_context ?
m_ast.GetTranslationUnitDecl()
1430 : containing_decl_ctx,
1433 std::free(name_buf);
1435 if (has_template_params) {
1438 template_function_decl =
m_ast.CreateFunctionDeclaration(
1439 ignore_containing_context ?
m_ast.GetTranslationUnitDecl()
1440 : containing_decl_ctx,
1443 clang::FunctionTemplateDecl *func_template_decl =
1444 m_ast.CreateFunctionTemplateDecl(
1446 template_function_decl, template_param_infos);
1447 m_ast.CreateFunctionTemplateSpecializationInfo(
1448 template_function_decl, func_template_decl, template_param_infos);
1453 if (function_decl) {
1456 const clang::FunctionProtoType *function_prototype(
1457 llvm::cast<clang::FunctionProtoType>(
1459 const auto params =
m_ast.CreateParameterDeclarations(
1460 function_decl, *function_prototype, function_param_names);
1461 function_decl->setParams(params);
1462 if (template_function_decl)
1463 template_function_decl->setParams(params);
1468 if (
char const *object_pointer_name = object_parameter.
GetName()) {
1471 "Setting object pointer name: %s on function "
1473 object_pointer_name,
static_cast<void *
>(function_decl));
1475 m_ast.SetMetadata(function_decl, metadata);
1480 return dwarf->MakeType(
1494 Type *element_type =
dwarf->ResolveTypeUID(type_die,
true);
1503 byte_stride = array_info->byte_stride;
1504 bit_stride = array_info->bit_stride;
1506 if (byte_stride == 0 && bit_stride == 0)
1507 byte_stride = llvm::expectedToOptional(element_type->
GetByteSize(
nullptr))
1512 uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
1514 if (array_info && array_info->element_orders.size() > 0) {
1515 auto end = array_info->element_orders.rend();
1516 for (
auto pos = array_info->element_orders.rbegin(); pos != end; ++pos) {
1517 clang_type =
m_ast.CreateArrayType(
1518 array_element_type, *pos, attrs.
is_vector);
1520 uint64_t num_elements = pos->value_or(0);
1521 array_element_type = clang_type;
1522 array_element_bit_stride = num_elements
1523 ? array_element_bit_stride * num_elements
1524 : array_element_bit_stride;
1527 clang_type =
m_ast.CreateArrayType(
1528 array_element_type, std::nullopt, attrs.
is_vector);
1532 dwarf->MakeType(die.
GetID(), empty_name, array_element_bit_stride / 8,
1535 type_sp->SetEncodingType(element_type);
1537 m_ast.SetMetadataAsUserID(type, die.
GetID());
1550 if ((class_type ==
nullptr) || (pointee_type ==
nullptr))
1557 class_clang_type, pointee_clang_type);
1559 if (std::optional<uint64_t> clang_type_size =
1560 llvm::expectedToOptional(clang_type.
GetByteSize(
nullptr))) {
1561 return dwarf->MakeType(die.
GetID(), attrs.
name, *clang_type_size,
nullptr,
1572 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
1580 if (attributes.
Size() == 0)
1584 AccessType accessibility = default_accessibility;
1585 bool is_virtual =
false;
1586 bool is_base_of_class =
true;
1587 off_t member_byte_offset = 0;
1589 for (uint32_t i = 0; i < attributes.
Size(); ++i) {
1595 encoding_form = form_value;
1597 case DW_AT_data_member_location:
1598 if (
auto maybe_offset =
1600 member_byte_offset = *maybe_offset;
1603 case DW_AT_accessibility:
1608 case DW_AT_virtuality:
1609 is_virtual = form_value.
Boolean();
1619 if (base_class_type ==
nullptr) {
1620 module_sp->ReportError(
"{0:x16}: DW_TAG_inheritance failed to "
1621 "resolve the base class at {1:x16}"
1622 " from enclosing type {2:x16}. \nPlease file "
1623 "a bug and attach the file at the start of "
1624 "this error message",
1632 assert(base_class_clang_type);
1634 ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
1637 std::unique_ptr<clang::CXXBaseSpecifier> result =
1639 accessibility, is_virtual,
1644 base_classes.push_back(std::move(result));
1662 clang::CharUnits::fromQuantity(member_byte_offset)));
1675 if (sc_parent_tag == DW_TAG_compile_unit ||
1676 sc_parent_tag == DW_TAG_partial_unit) {
1678 }
else if (sc.
function !=
nullptr && sc_parent_die) {
1679 symbol_context_scope =
1681 if (symbol_context_scope ==
nullptr)
1682 symbol_context_scope = sc.
function;
1684 symbol_context_scope = sc.
module_sp.get();
1687 if (symbol_context_scope !=
nullptr)
1688 type_sp->SetSymbolContextScope(symbol_context_scope);
1702 decl_declaration.
Clear();
1703 std::string qualified_name;
1706 while (parent_decl_ctx_die) {
1710 const dw_tag_t parent_tag = parent_decl_ctx_die.
Tag();
1711 switch (parent_tag) {
1712 case DW_TAG_namespace: {
1713 if (
const char *namespace_name = parent_decl_ctx_die.
GetName()) {
1714 qualified_name.insert(0,
"::");
1715 qualified_name.insert(0, namespace_name);
1717 qualified_name.insert(0,
"(anonymous namespace)::");
1723 case DW_TAG_class_type:
1724 case DW_TAG_structure_type:
1725 case DW_TAG_union_type: {
1726 if (
const char *class_union_struct_name = parent_decl_ctx_die.
GetName()) {
1727 qualified_name.insert(0,
"::");
1728 qualified_name.insert(0,
1730 qualified_name.insert(0, class_union_struct_name);
1737 parent_decl_ctx_die.
Clear();
1742 if (qualified_name.empty())
1743 qualified_name.append(
"::");
1745 qualified_name.append(unique_typename.
GetCString());
1763 uint64_t byte_size = attrs.
byte_size.value_or(0);
1769 dwarf->GetObjectFile()->GetModule()->LogMessage(
1770 log,
"SymbolFileDWARF({0:p}) - {1:x16}: {2} has unique name: {3} ",
1775 dwarf->GetUniqueDWARFASTTypeMap().Find(
1776 unique_typename, die, unique_decl, byte_size,
1778 if (
TypeSP type_sp = unique_ast_entry_type->m_type_sp) {
1779 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1786 unique_ast_entry_type->m_is_forward_declaration) {
1787 unique_ast_entry_type->UpdateToDefDIE(die, unique_decl, byte_size);
1788 clang_type = type_sp->GetForwardCompilerType();
1792 dwarf->GetForwardDeclCompilerTypeToDIE().insert_or_assign(
1804 int tag_decl_kind = -1;
1806 if (tag == DW_TAG_structure_type) {
1807 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Struct);
1809 }
else if (tag == DW_TAG_union_type) {
1810 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Union);
1812 }
else if (tag == DW_TAG_class_type) {
1813 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Class);
1826 dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.
name,
true);
1830 if (debug_map_symfile) {
1834 die, attrs.
name,
true);
1840 dwarf->GetObjectFile()->GetModule()->LogMessage(
1842 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an "
1843 "incomplete objc type, complete type is {5:x8}",
1859 assert(tag_decl_kind != -1);
1861 clang::DeclContext *containing_decl_ctx =
1865 containing_decl_ctx, die,
1871 const clang::Decl::Kind containing_decl_kind =
1872 containing_decl_ctx->getDeclKind();
1884 clang::ClassTemplateDecl *class_template_decl =
1885 m_ast.ParseClassTemplateDecl(
1888 if (!class_template_decl) {
1890 dwarf->GetObjectFile()->GetModule()->LogMessage(
1892 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" "
1893 "clang::ClassTemplateDecl failed to return a decl.",
1900 clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1901 m_ast.CreateClassTemplateSpecializationDecl(
1903 tag_decl_kind, template_param_infos);
1905 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
1907 m_ast.SetMetadata(class_template_decl, metadata);
1908 m_ast.SetMetadata(class_specialization_decl, metadata);
1912 clang_type =
m_ast.CreateRecordType(
1927 clang::DeclContext *type_decl_ctx =
1935 auto unique_ast_entry_up = std::make_unique<UniqueDWARFASTType>();
1939 unique_ast_entry_up->m_type_sp = type_sp;
1940 unique_ast_entry_up->m_die = die;
1941 unique_ast_entry_up->m_declaration = unique_decl;
1942 unique_ast_entry_up->m_byte_size = byte_size;
1944 dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
1945 *unique_ast_entry_up);
1953 dwarf->GetForwardDeclCompilerTypeToDIE()
1958 assert(inserted &&
"Type already in the forward declaration map!");
1967 clang::CXXRecordDecl *record_decl =
1969 if (record_decl && record_decl->getDefinition()) {
1970 record_decl->setHasTrivialSpecialMemberForCall();
1975 clang::CXXRecordDecl *record_decl =
1978 record_decl->setArgPassingRestrictions(
1979 clang::RecordArgPassingKind::CannotPassInRegs);
1989 const CompilerType &class_opaque_type,
const char *property_name,
1993 const char *property_setter_name,
const char *property_getter_name,
2018static std::optional<clang::APValue>
MakeAPValue(
const clang::ASTContext &ast,
2021 std::optional<uint64_t> bit_width =
2022 llvm::expectedToOptional(clang_type.
GetBitSize(
nullptr));
2024 return std::nullopt;
2026 bool is_signed =
false;
2029 llvm::APSInt apint(*bit_width, !is_signed);
2033 return clang::APValue(apint);
2040 return std::nullopt;
2042 return clang::APValue(llvm::APFloat(
2050 bool is_template_template_argument =
false;
2053 case DW_TAG_GNU_template_parameter_pack: {
2055 std::make_unique<TypeSystemClang::TemplateParameterInfos>());
2060 if (
const char *name = die.
GetName()) {
2065 case DW_TAG_GNU_template_template_param:
2066 is_template_template_argument =
true;
2068 case DW_TAG_template_type_parameter:
2069 case DW_TAG_template_value_parameter: {
2071 if (attributes.
Size() == 0)
2074 const char *name =
nullptr;
2075 const char *template_name =
nullptr;
2077 uint64_t uval64 = 0;
2078 bool uval64_valid =
false;
2079 bool is_default_template_arg =
false;
2081 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2090 case DW_AT_GNU_template_name:
2103 case DW_AT_const_value:
2105 uval64_valid =
true;
2109 case DW_AT_default_value:
2111 is_default_template_arg = form_value.
Boolean();
2118 clang::ASTContext &ast =
m_ast.getASTContext();
2122 if (!is_template_template_argument) {
2124 if (name && !name[0])
2127 if (tag == DW_TAG_template_value_parameter && uval64_valid) {
2128 if (
auto value =
MakeAPValue(ast, clang_type, uval64)) {
2130 name, clang::TemplateArgument(
2132 std::move(*value), is_default_template_arg));
2142 is_default_template_arg));
2144 auto *tplt_type =
m_ast.CreateTemplateTemplateParmDecl(template_name);
2146 name, clang::TemplateArgument(clang::TemplateName(tplt_type),
2147 is_default_template_arg));
2169 case DW_TAG_template_type_parameter:
2170 case DW_TAG_template_value_parameter:
2171 case DW_TAG_GNU_template_parameter_pack:
2172 case DW_TAG_GNU_template_template_param:
2181 return !template_param_infos.
IsEmpty() ||
2191 std::vector<DWARFDIE> contained_type_dies;
2203 if (tag == DW_TAG_structure_type) {
2205 }
else if (tag == DW_TAG_union_type) {
2207 }
else if (tag == DW_TAG_class_type) {
2211 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
2213 std::vector<DWARFDIE> member_function_dies;
2217 contained_type_dies, delayed_properties,
2218 default_accessibility, layout_info);
2221 for (
const DWARFDIE &die : member_function_dies)
2222 dwarf->ResolveType(die);
2227 dwarf->GetObjCMethods(class_name, [&](
DWARFDIE method_die) {
2233 property.Finalize();
2243 "WARNING: Type completion aborted because forward declaration for "
2244 "'{0}' is C++ while definition is Objective-C.",
2245 llvm::StringRef(die.
GetName()));
2249 if (!bases.empty()) {
2253 for (
const auto &base_class : bases) {
2254 clang::TypeSourceInfo *type_source_info = base_class->getTypeSourceInfo();
2255 if (type_source_info)
2257 m_ast.GetType(type_source_info->getType()));
2272 clang::CXXRecordDecl *record_decl =
2280 if (
m_ast.getASTContext().getTargetInfo().getCXXABI().isMicrosoft()) {
2281 auto IM = record_decl->calculateInheritanceModel();
2282 record_decl->addAttr(clang::MSInheritanceAttr::CreateImplicit(
2283 m_ast.getASTContext(),
true, {},
2284 clang::MSInheritanceAttr::Spelling(IM)));
2291 for (
const DWARFDIE &die : contained_type_dies)
2292 dwarf->ResolveType(die);
2294 return (
bool)clang_type;
2306 llvm::expectedToOptional(type->
GetByteSize(
nullptr)).value_or(0),
2311 return (
bool)clang_type;
2319 std::lock_guard<std::recursive_mutex> guard(
2320 dwarf->GetObjectFile()->GetModule()->GetMutex());
2333 case DW_TAG_structure_type:
2334 case DW_TAG_union_type:
2335 case DW_TAG_class_type:
2338 case DW_TAG_enumeration_type:
2342 assert(
false &&
"not a forward clang type decl!");
2359 auto opaque_decl_ctx =
2370 if (clang_decl !=
nullptr)
2371 return m_ast.GetCompilerDecl(clang_decl);
2379 return m_ast.CreateDeclContext(clang_decl_ctx);
2385 clang::DeclContext *clang_decl_ctx =
2388 return m_ast.CreateDeclContext(clang_decl_ctx);
2394 uint32_t enumerator_byte_size,
const DWARFDIE &parent_die) {
2398 size_t enumerators_added = 0;
2402 if (tag != DW_TAG_enumerator)
2406 if (attributes.
Size() == 0)
2409 const char *name =
nullptr;
2410 std::optional<uint64_t> enum_value;
2413 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2418 case DW_AT_const_value:
2420 enum_value = form_value.
Signed();
2422 enum_value = form_value.
Unsigned();
2429 case DW_AT_description:
2431 case DW_AT_decl_file:
2435 case DW_AT_decl_line:
2438 case DW_AT_decl_column:
2447 if (name && name[0] && enum_value) {
2448 m_ast.AddEnumerationValueToEnumerationType(
2449 clang_type, decl, name, *enum_value, enumerator_byte_size * 8);
2450 ++enumerators_added;
2453 return enumerators_added;
2458 bool is_variadic =
false;
2459 bool has_template_params =
false;
2460 std::vector<CompilerType> param_types;
2461 llvm::SmallVector<llvm::StringRef> param_names;
2468 clang::DeclContext *containing_decl_ctx =
2470 assert(containing_decl_ctx);
2472 const unsigned cv_quals =
2476 has_template_params, param_types, param_names);
2478 for (
size_t i = 0; i < param_types.size(); i++) {
2481 sstr << param_types[i].GetTypeName();
2486 if (cv_quals & clang::Qualifiers::Const)
2494 llvm::DWARFAddressRangesVector unused_func_ranges;
2495 const char *name =
nullptr;
2496 const char *mangled =
nullptr;
2497 std::optional<int> decl_file;
2498 std::optional<int> decl_line;
2499 std::optional<int> decl_column;
2500 std::optional<int> call_file;
2501 std::optional<int> call_line;
2502 std::optional<int> call_column;
2507 if (tag != DW_TAG_subprogram)
2511 decl_line, decl_column, call_file, call_line,
2512 call_column, &frame_base)) {
2516 else if ((die.
GetParent().
Tag() == DW_TAG_compile_unit ||
2522 name && strcmp(name,
"main") != 0) {
2533 std::unique_ptr<Declaration> decl_up;
2534 if (decl_file || decl_line || decl_column)
2535 decl_up = std::make_unique<Declaration>(
2536 die.
GetCU()->
GetFile(decl_file.value_or(0)), decl_line.value_or(0),
2537 decl_column.value_or(0));
2562 Address func_addr = func_ranges[0].GetBaseAddress();
2564 func_sp = std::make_shared<Function>(
2567 func_user_id, func_name, func_type, std::move(func_addr),
2568 std::move(func_ranges));
2570 if (func_sp.get() !=
nullptr) {
2572 func_sp->GetFrameBaseExpression() = frame_base;
2574 return func_sp.get();
2583struct PropertyAttributes {
2584 explicit PropertyAttributes(
const DWARFDIE &die);
2585 const char *prop_name =
nullptr;
2586 const char *prop_getter_name =
nullptr;
2587 const char *prop_setter_name =
nullptr;
2589 uint32_t prop_attributes = 0;
2592struct DiscriminantValue {
2593 explicit DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp);
2595 uint32_t byte_offset;
2597 DWARFFormValue type_ref;
2600struct VariantMember {
2601 explicit VariantMember(DWARFDIE &die,
ModuleSP module_sp);
2602 bool IsDefault()
const;
2604 std::optional<uint32_t> discr_value;
2605 DWARFFormValue type_ref;
2606 ConstString variant_name;
2607 uint32_t byte_offset;
2612 explicit VariantPart(
const DWARFDIE &die,
const DWARFDIE &parent_die,
2615 std::vector<VariantMember> &members();
2617 DiscriminantValue &discriminant();
2620 std::vector<VariantMember> _members;
2621 DiscriminantValue _discriminant;
2626ConstString VariantMember::GetName()
const {
return this->variant_name; }
2628bool VariantMember::IsDefault()
const {
return !discr_value; }
2630VariantMember::VariantMember(DWARFDIE &die,
lldb::ModuleSP module_sp) {
2631 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant);
2635 for (
auto child_die : die.
children()) {
2636 switch (child_die.Tag()) {
2637 case llvm::dwarf::DW_TAG_member: {
2638 DWARFAttributes attributes = child_die.GetAttributes();
2639 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2640 DWARFFormValue form_value;
2645 variant_name = ConstString(form_value.
AsCString());
2648 type_ref = form_value;
2651 case DW_AT_data_member_location:
2652 if (
auto maybe_offset =
2654 byte_offset = *maybe_offset;
2671DiscriminantValue::DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp) {
2673 DWARFAttributes attributes = referenced_die.GetAttributes();
2674 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2676 DWARFFormValue form_value;
2680 type_ref = form_value;
2682 case DW_AT_data_member_location:
2683 if (
auto maybe_offset =
2685 byte_offset = *maybe_offset;
2694VariantPart::VariantPart(
const DWARFDIE &die,
const DWARFDIE &parent_die,
2696 : _members(), _discriminant(die, module_sp) {
2698 for (
auto child : die.
children()) {
2699 if (child.Tag() == llvm::dwarf::DW_TAG_variant) {
2700 _members.push_back(VariantMember(child, module_sp));
2705std::vector<VariantMember> &VariantPart::members() {
return this->_members; }
2707DiscriminantValue &VariantPart::discriminant() {
return this->_discriminant; }
2712 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2723 case DW_AT_bit_offset:
2726 case DW_AT_bit_size:
2729 case DW_AT_byte_size:
2732 case DW_AT_const_value:
2735 case DW_AT_data_bit_offset:
2738 case DW_AT_data_member_location:
2739 if (
auto maybe_offset =
2744 case DW_AT_accessibility:
2748 case DW_AT_artificial:
2751 case DW_AT_declaration:
2778PropertyAttributes::PropertyAttributes(
const DWARFDIE &die) {
2781 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2786 case DW_AT_APPLE_property_name:
2789 case DW_AT_APPLE_property_getter:
2790 prop_getter_name = form_value.
AsCString();
2792 case DW_AT_APPLE_property_setter:
2793 prop_setter_name = form_value.
AsCString();
2795 case DW_AT_APPLE_property_attribute:
2796 prop_attributes = form_value.
Unsigned();
2806 ConstString fixed_setter;
2810 if (prop_getter_name && prop_getter_name[0] ==
'-') {
2811 std::optional<const ObjCLanguage::ObjCMethodName> prop_getter_method =
2813 if (prop_getter_method)
2815 ConstString(prop_getter_method->GetSelector()).GetCString();
2818 if (prop_setter_name && prop_setter_name[0] ==
'-') {
2819 std::optional<const ObjCLanguage::ObjCMethodName> prop_setter_method =
2821 if (prop_setter_method)
2823 ConstString(prop_setter_method->GetSelector()).GetCString();
2827 if (!prop_getter_name)
2828 prop_getter_name = prop_name;
2829 if (!prop_setter_name && prop_name[0] &&
2830 !(prop_attributes & DW_APPLE_PROPERTY_readonly)) {
2833 ss.
Printf(
"set%c%s:", toupper(prop_name[0]), &prop_name[1]);
2836 prop_setter_name = fixed_setter.
GetCString();
2845 assert(die.
Tag() == DW_TAG_APPLE_property);
2850 const PropertyAttributes propAttrs(die);
2852 if (!propAttrs.prop_name) {
2853 module_sp->ReportError(
"{0:x8}: DW_TAG_APPLE_property has no name.",
2860 module_sp->ReportError(
2861 "{0:x8}: DW_TAG_APPLE_property '{1}' refers to type {2:x16}"
2862 " which was unable to be parsed",
2863 die.
GetID(), propAttrs.prop_name,
2870 delayed_properties.emplace_back(
2871 class_clang_type, propAttrs.prop_name,
2873 propAttrs.prop_getter_name, propAttrs.prop_attributes, metadata);
2879 assert(qt->isIntegralOrEnumerationType());
2882 return llvm::createStringError(llvm::inconvertibleErrorCode(),
2883 "TypeSystem not clang");
2887 const unsigned type_bits = ast.getIntWidth(qt);
2888 const bool is_unsigned = qt->isUnsignedIntegerType();
2892 constexpr std::size_t max_bit_size = 64;
2897 if (type_bits > max_bit_size) {
2898 auto msg = llvm::formatv(
"Can only parse integers with up to {0} bits, but "
2899 "given integer has {1} bits.",
2900 max_bit_size, type_bits);
2901 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2905 llvm::APInt result(max_bit_size, form_value.
Unsigned(), !is_unsigned);
2911 const unsigned required_bits =
2912 is_unsigned ? result.getActiveBits() : result.getSignificantBits();
2915 if (required_bits > type_bits) {
2916 std::string value_as_str = is_unsigned
2917 ? std::to_string(form_value.
Unsigned())
2918 : std::to_string(form_value.
Signed());
2919 auto msg = llvm::formatv(
"Can't store {0} value {1} in integer with {2} "
2921 (is_unsigned ?
"unsigned" :
"signed"),
2922 value_as_str, type_bits);
2923 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2927 if (result.getBitWidth() > type_bits)
2928 result = result.trunc(type_bits);
2936 assert(die.
Tag() == DW_TAG_member || die.
Tag() == DW_TAG_variable);
2943 auto accessibility =
2948 class_clang_type, attrs.
name, ct, accessibility);
2950 LLDB_LOG(log,
"Failed to add variable to the record type");
2959 llvm::Expected<llvm::APInt> const_value_or_err =
2961 if (!const_value_or_err) {
2963 "Failed to add const value to variable {1}: {0}",
2964 v->getQualifiedNameAsString());
2978 assert(die.
Tag() == DW_TAG_member);
2983 const uint64_t parent_byte_size =
2985 const uint64_t parent_bit_size =
3010 module_sp->ReportError(
3011 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
3012 " which was unable to be parsed",
3015 module_sp->ReportError(
"{0:x8}: DW_TAG_member refers to type {1:x16}"
3016 " which was unable to be parsed",
3022 const uint64_t character_width = 8;
3026 ? default_accessibility
3035 this_field_info.
bit_offset = field_bit_offset;
3043 byte_size = llvm::expectedToOptional(member_type->
GetByteSize(
nullptr));
3047 this_field_info.
bit_offset += byte_size.value_or(0) * 8;
3061 !(parent_die.
Tag() == DW_TAG_union_type &&
3063 ((this_field_info.
bit_offset >= parent_bit_size) ||
3069 "{0:x16}: {1} ({2}) bitfield named \"{3}\" has invalid "
3070 "bit offset ({4:x8}) member will be ignored. Please file a bug "
3072 "compiler and include the preprocessed output for {5}\n",
3079 field_bit_offset = this_field_info.
bit_offset;
3084 bool detect_unnamed_bitfields =
true;
3087 detect_unnamed_bitfields =
3090 if (detect_unnamed_bitfields)
3092 last_field_info, this_field_info);
3094 last_field_info = this_field_info;
3099 this_field_info.
bit_offset = field_bit_offset;
3103 if (std::optional<uint64_t> clang_type_size =
3104 llvm::expectedToOptional(member_type->
GetByteSize(
nullptr))) {
3105 this_field_info.
bit_size = *clang_type_size * character_width;
3112 last_field_info = this_field_info;
3132 class_clang_type, attrs.
name, member_clang_type, accessibility,
3135 m_ast.SetMetadataAsUserID(field_decl, die.
GetID());
3138 std::make_pair(field_decl, field_bit_offset));
3143 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
3144 std::vector<DWARFDIE> &member_function_dies,
3145 std::vector<DWARFDIE> &contained_type_dies,
3163 case DW_TAG_APPLE_property:
3167 case DW_TAG_variant_part:
3170 default_accessibility, layout_info);
3174 case DW_TAG_variable: {
3180 default_accessibility, layout_info, last_field_info);
3183 case DW_TAG_subprogram:
3185 member_function_dies.push_back(die);
3188 case DW_TAG_inheritance:
3190 module_sp, base_classes, layout_info);
3194 if (llvm::dwarf::isType(tag))
3195 contained_type_dies.push_back(die);
3204 clang::DeclContext *containing_decl_ctx,
const DWARFDIE &parent_die,
3205 bool &is_variadic,
bool &has_template_params,
3206 std::vector<CompilerType> &function_param_types,
3214 case DW_TAG_formal_parameter: {
3224 function_param_names.emplace_back(die.
GetName());
3228 case DW_TAG_unspecified_parameters:
3232 case DW_TAG_template_type_parameter:
3233 case DW_TAG_template_value_parameter:
3234 case DW_TAG_GNU_template_parameter_pack:
3240 has_template_params =
true;
3248 assert(function_param_names.size() == function_param_types.size());
3255 switch (die.
Tag()) {
3256 case DW_TAG_constant:
3257 case DW_TAG_formal_parameter:
3258 case DW_TAG_imported_declaration:
3259 case DW_TAG_imported_module:
3261 case DW_TAG_variable:
3275 return cache_pos->second;
3290 clang::Decl *decl =
nullptr;
3291 switch (die.
Tag()) {
3292 case DW_TAG_variable:
3293 case DW_TAG_constant:
3294 case DW_TAG_formal_parameter: {
3297 if (
dwarf && type) {
3298 const char *name = die.
GetName();
3299 clang::DeclContext *decl_context =
3301 dwarf->GetDeclContextContainingUID(die.
GetID()));
3302 decl =
m_ast.CreateVariableDeclaration(
3308 case DW_TAG_imported_declaration: {
3313 if (imported_decl) {
3314 clang::DeclContext *decl_context =
3316 dwarf->GetDeclContextContainingUID(die.
GetID()));
3317 if (clang::NamedDecl *clang_imported_decl =
3318 llvm::dyn_cast<clang::NamedDecl>(
3320 decl =
m_ast.CreateUsingDeclaration(
3326 case DW_TAG_imported_module: {
3333 if (imported_decl_ctx) {
3334 clang::DeclContext *decl_context =
3336 dwarf->GetDeclContextContainingUID(die.
GetID()));
3337 if (clang::NamespaceDecl *ns_decl =
3340 decl =
m_ast.CreateUsingDirectiveDeclaration(
3362 bool try_parsing_type =
true;
3363 switch (die.
Tag()) {
3364 case DW_TAG_compile_unit:
3365 case DW_TAG_partial_unit:
3366 decl_ctx =
m_ast.GetTranslationUnitDecl();
3367 try_parsing_type =
false;
3370 case DW_TAG_namespace:
3372 try_parsing_type =
false;
3375 case DW_TAG_imported_declaration:
3377 try_parsing_type =
false;
3380 case DW_TAG_lexical_block:
3382 try_parsing_type =
false;
3389 if (decl_ctx ==
nullptr && try_parsing_type) {
3409 parent = parent.GetParent()) {
3411 if (tag == DW_TAG_module) {
3431 switch (die.
Tag()) {
3432 case DW_TAG_subprogram:
3433 case DW_TAG_inlined_subroutine:
3443 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3450 assert(0 &&
"Shouldn't call GetContainingFunctionWithAbstractOrigin on "
3451 "something not in a function");
3457 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3479 assert(die.
Tag() == DW_TAG_lexical_block);
3480 DWARFDIE containing_function_with_abstract_origin =
3482 if (!containing_function_with_abstract_origin) {
3486 die, containing_function_with_abstract_origin);
3493 if (die && die.
Tag() == DW_TAG_lexical_block) {
3494 clang::BlockDecl *decl =
3499 clang::DeclContext *decl_context =
3513clang::NamespaceDecl *
3515 if (die && die.
Tag() == DW_TAG_namespace) {
3518 clang::NamespaceDecl *namespace_decl =
3521 return namespace_decl;
3523 const char *namespace_name = die.
GetName();
3524 clang::DeclContext *containing_decl_ctx =
3529 namespace_decl =
m_ast.GetUniqueNamespaceDeclaration(
3535 return namespace_decl;
3541clang::NamespaceDecl *
3543 assert(die && die.
Tag() == DW_TAG_imported_declaration);
3549 return static_cast<clang::NamespaceDecl *
>(it->getSecond());
3551 clang::NamespaceDecl *namespace_decl =
nullptr;
3558 switch (imported_uid.
Tag()) {
3559 case DW_TAG_imported_declaration:
3562 case DW_TAG_namespace:
3569 if (!namespace_decl)
3574 return namespace_decl;
3581 DWARFDIE decl_ctx_die =
dwarf->GetDeclContextDIEContainingDIE(die);
3583 if (decl_ctx_die_copy)
3584 *decl_ctx_die_copy = decl_ctx_die;
3587 clang::DeclContext *clang_decl_ctx =
3590 return clang_decl_ctx;
3592 return m_ast.GetTranslationUnitDecl();
3616 if (!class_type || !src_class_die || !dst_class_die)
3618 if (src_class_die.
Tag() != dst_class_die.
Tag())
3628 if (die.
Tag() != DW_TAG_subprogram)
3640 map_artificial.Append(const_name, die);
3642 map.Append(const_name, die);
3651 src_die = src_die.GetSibling()) {
3652 gather(src_die, src_name_to_die, src_name_to_die_artificial);
3655 dst_die = dst_die.GetSibling()) {
3656 gather(dst_die, dst_name_to_die, dst_name_to_die_artificial);
3658 const uint32_t src_size = src_name_to_die.
GetSize();
3659 const uint32_t dst_size = dst_name_to_die.
GetSize();
3662 bool fast_path =
true;
3664 if (src_size != dst_size)
3670 for (idx = 0; idx < src_size; ++idx) {
3674 if (src_die.
Tag() != dst_die.
Tag())
3681 if (src_name == dst_name || (strcmp(src_name, dst_name) == 0))
3696 clang::DeclContext *dst_decl_ctx =
3701 if (
Type *src_child_type = die_to_type.lookup(src.
GetDIE()))
3702 die_to_type[dst.GetDIE()] = src_child_type;
3709 for (idx = 0; idx < src_size; ++idx) {
3719 src_name_to_die.
Sort();
3721 for (idx = 0; idx < dst_size; ++idx) {
3726 if (src_die && (src_die.
Tag() == dst_die.
Tag()))
3727 link(src_die, dst_die);
3729 failures.push_back(dst_die);
3734 const uint32_t src_size_artificial = src_name_to_die_artificial.
GetSize();
3735 const uint32_t dst_size_artificial = dst_name_to_die_artificial.
GetSize();
3737 if (src_size_artificial && dst_size_artificial) {
3738 dst_name_to_die_artificial.
Sort();
3740 for (idx = 0; idx < src_size_artificial; ++idx) {
3746 dst_name_to_die_artificial.
Find(src_name_artificial,
DWARFDIE());
3750 link(src_die, dst_die);
3754 if (dst_size_artificial) {
3755 for (idx = 0; idx < dst_size_artificial; ++idx) {
3761 return !failures.empty();
3765 FieldInfo const &last_field_info, uint64_t last_field_end,
3770 if (this_field_info.
bit_offset <= last_field_end)
3784 const bool have_base = layout_info.
base_offsets.size() != 0;
3785 const bool this_is_first_field =
3787 const bool first_field_is_vptr =
3790 if (have_base && (this_is_first_field || first_field_is_vptr))
3801 const uint64_t word_width = 32;
3809 if (last_field_end != 0 && ((last_field_end % word_width) != 0))
3810 last_field_end += word_width - (last_field_end % word_width);
3815 current_field, class_layout_info))
3820 const uint64_t unnamed_bit_size = current_field.
bit_offset - last_field_end;
3821 const uint64_t unnamed_bit_offset = last_field_end;
3823 clang::FieldDecl *unnamed_bitfield_decl =
3825 class_clang_type, llvm::StringRef(),
3830 std::make_pair(unnamed_bitfield_decl, unnamed_bit_offset));
3838 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant_part);
3844 VariantPart variants(die, parent_die, module_sp);
3846 auto discriminant_type =
3847 die.
ResolveTypeUID(variants.discriminant().type_ref.Reference());
3849 auto decl_context =
m_ast.GetDeclContextForType(class_clang_type);
3851 auto inner_holder =
m_ast.CreateRecordType(
3854 llvm::formatv(
"{0}$Inner", class_clang_type.
GetTypeName(
false))),
3856 m_ast.StartTagDeclarationDefinition(inner_holder);
3857 m_ast.SetIsPacked(inner_holder);
3859 for (
auto member : variants.members()) {
3861 auto has_discriminant = !member.IsDefault();
3863 auto member_type = die.
ResolveTypeUID(member.type_ref.Reference());
3865 auto field_type =
m_ast.CreateRecordType(
3868 std::string(llvm::formatv(
"{0}$Variant", member.GetName())),
3869 llvm::to_underlying(clang::TagTypeKind::Struct),
3872 m_ast.StartTagDeclarationDefinition(field_type);
3873 auto offset = member.byte_offset;
3875 if (has_discriminant) {
3876 m_ast.AddFieldToRecordType(
3877 field_type,
"$discr$", discriminant_type->GetFullCompilerType(),
3880 llvm::expectedToOptional(discriminant_type->GetByteSize(
nullptr))
3884 m_ast.AddFieldToRecordType(field_type,
"value",
3885 member_type->GetFullCompilerType(),
3888 m_ast.CompleteTagDeclarationDefinition(field_type);
3890 auto name = has_discriminant
3891 ? llvm::formatv(
"$variant${0}", member.discr_value.value())
3892 : std::string(
"$variant$");
3895 m_ast.AddFieldToRecordType(inner_holder, llvm::StringRef(name),
3896 field_type, default_accesibility, 0);
3901 auto inner_field =
m_ast.AddFieldToRecordType(class_clang_type,
3902 llvm::StringRef(
"$variants$"),
3905 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 IsFloatingPointType(uint32_t &count, bool &is_complex) 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.
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
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.