43#include "clang/AST/CXXInheritance.h"
44#include "clang/AST/DeclBase.h"
45#include "clang/AST/DeclCXX.h"
46#include "clang/AST/DeclObjC.h"
47#include "clang/AST/DeclTemplate.h"
48#include "clang/AST/Type.h"
49#include "clang/Basic/Specifiers.h"
50#include "llvm/ADT/StringExtras.h"
51#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
52#include "llvm/DebugInfo/DWARF/DWARFTypePrinter.h"
53#include "llvm/Demangle/Demangle.h"
63using namespace llvm::dwarf;
73 case clang::Decl::CXXRecord:
74 case clang::Decl::ClassTemplateSpecialization:
95 while (Parent.IsValid()) {
96 if (Parent.Tag() == DW_TAG_module)
98 Parent = Parent.GetParent();
109 parent = parent.GetParent()) {
111 if (tag == DW_TAG_module)
112 top_module_die = parent;
113 else if (tag == DW_TAG_compile_unit || tag == DW_TAG_partial_unit)
117 return top_module_die;
126 if (clang_module_die) {
127 const char *module_name = clang_module_die.
GetName();
139 return FieldName.starts_with(
"_vptr$")
141 || FieldName.starts_with(
"_vptr.");
147 case DW_TAG_class_type:
148 case DW_TAG_structure_type:
149 case DW_TAG_union_type:
160 assert(subprogram.
Tag() == DW_TAG_subprogram ||
161 subprogram.
Tag() == DW_TAG_inlined_subroutine ||
162 subprogram.
Tag() == DW_TAG_subroutine_type);
167 std::optional<size_t> object_pointer_index;
169 if (subprogram.
GetDIE()->GetAttributeValue(
170 subprogram.
GetCU(), DW_AT_object_pointer, form_value,
175 object_pointer_index = form_value.
Unsigned();
180 size_t param_index = 0;
181 for (
const auto &child : subprogram.
children()) {
182 if (child.Tag() != DW_TAG_formal_parameter)
185 if (param_index == object_pointer_index.value_or(0)) {
186 object_pointer = child;
200 if (object_pointer_index)
201 return object_pointer;
216 if (
const char *name = object_pointer.
GetName();
217 name && ::strcmp(name,
"this") != 0)
220 return object_pointer;
228 if (!subprogram || !object_parameter)
237 unsigned cv_quals = 0;
239 cv_quals |= clang::Qualifiers::Const;
241 cv_quals |= clang::Qualifiers::Volatile;
259 auto *obj = sym->GetMainObjectFile();
263 auto module_sp = obj->GetModule();
267 return module_sp->GetID();
272 module_id = get_module_id(
dwarf);
277 const auto die_id = die.
GetID();
293 if (!clang_module_sp)
299 std::vector<lldb_private::CompilerContext> die_context = die.
GetDeclContext();
300 TypeQuery query(die_context, TypeQueryOptions::e_module_search |
301 TypeQueryOptions::e_find_one);
306 clang_module_sp->FindTypes(query, results);
318 sym_file.ForEachExternalModule(
320 module.FindTypes(query, results);
321 pcm_type_sp = results.GetTypeMap().FirstType();
322 return (bool)pcm_type_sp;
352 auto type_sp =
dwarf->MakeType(
353 die.
GetID(), pcm_type_sp->GetName(),
354 llvm::expectedToOptional(pcm_type_sp->GetByteSize(
nullptr)),
nullptr,
376 clang::DeclContext *decl_ctx,
378 const char *type_name_cstr) {
379 auto *tag_decl_ctx = clang::dyn_cast<clang::TagDecl>(decl_ctx);
384 if (tag_decl_ctx->isCompleteDefinition() || tag_decl_ctx->isBeingDefined())
392 if (type && ast_importer.
CanImport(type)) {
397 "Unable to complete the Decl context for DIE {0} at offset "
398 "{1:x16}.\nPlease file a bug report.",
399 type_name_cstr ? type_name_cstr :
"", die.
GetOffset());
408 if (!tag_decl_ctx->hasExternalLexicalStorage()) {
416 for (
size_t i = 0; i < attributes.
Size(); ++i) {
424 case DW_AT_abstract_origin:
428 case DW_AT_artificial:
432 case DW_AT_bit_stride:
436 case DW_AT_byte_size:
444 case DW_AT_alignment:
448 case DW_AT_byte_stride:
452 case DW_AT_calling_convention:
456 case DW_AT_containing_type:
460 case DW_AT_decl_file:
465 case DW_AT_decl_line:
468 case DW_AT_decl_column:
472 case DW_AT_declaration:
480 case DW_AT_enum_class:
497 case DW_AT_linkage_name:
498 case DW_AT_MIPS_linkage_name:
506 case DW_AT_signature:
510 case DW_AT_specification:
518 case DW_AT_virtuality:
522 case DW_AT_APPLE_objc_complete_type:
526 case DW_AT_APPLE_objc_direct:
530 case DW_AT_APPLE_runtime_class:
534 case DW_AT_GNU_vector:
537 case DW_AT_export_symbols:
540 case DW_AT_rvalue_reference:
543 case DW_AT_reference:
546 case DW_AT_APPLE_enum_kind:
547 enum_kind =
static_cast<clang::EnumExtensibilityAttr::Kind
>(
556 return unit->GetAbsolutePath().GetPath();
557 return "<missing DWARF unit path>";
562 bool *type_is_new_ptr) {
564 *type_is_new_ptr =
false;
574 clang::DeclContext *context =
577 dwarf->GetObjectFile()->GetModule()->LogMessage(
579 "DWARFASTParserClang::ParseTypeFromDWARF "
580 "(die = {0:x16}, decl_ctx = {1:p} (die "
581 "{2:x16})) {3} ({4}) name = '{5}')",
587 if (
auto [it, inserted] =
592 return it->getSecond()->shared_from_this();
601 if (clang::DeclContext *decl_ctx =
607 *type_is_new_ptr =
true;
613 case DW_TAG_template_alias:
614 case DW_TAG_base_type:
615 case DW_TAG_pointer_type:
616 case DW_TAG_reference_type:
617 case DW_TAG_rvalue_reference_type:
618 case DW_TAG_const_type:
619 case DW_TAG_restrict_type:
620 case DW_TAG_volatile_type:
621 case DW_TAG_LLVM_ptrauth_type:
622 case DW_TAG_atomic_type:
623 case DW_TAG_unspecified_type:
626 case DW_TAG_structure_type:
627 case DW_TAG_union_type:
628 case DW_TAG_class_type:
631 case DW_TAG_enumeration_type:
634 case DW_TAG_inlined_subroutine:
635 case DW_TAG_subprogram:
636 case DW_TAG_subroutine_type:
639 case DW_TAG_array_type:
642 case DW_TAG_ptr_to_member_type:
646 dwarf->GetObjectFile()->GetModule()->ReportError(
647 "[{0:x16}]: unhandled type tag {1:x4} ({2}), "
648 "please file a bug and "
649 "attach the file at the start of this error message",
656 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
661static std::optional<uint32_t>
672 Value initialValue(0);
674 uint32_t block_length = form_value.
Unsigned();
675 uint32_t block_offset =
685 "ExtractDataMemberLocation failed: {0}");
689 return memberOffset->GetScalar().UInt();
693 auto getAttr = [&](llvm::dwarf::Attribute Attr,
unsigned defaultValue = 0) {
696 const unsigned key = getAttr(DW_AT_LLVM_ptrauth_key);
697 const bool addr_disc = getAttr(DW_AT_LLVM_ptrauth_address_discriminated);
698 const unsigned extra = getAttr(DW_AT_LLVM_ptrauth_extra_discriminator);
699 const bool isapointer = getAttr(DW_AT_LLVM_ptrauth_isa_pointer);
700 const bool authenticates_null_values =
701 getAttr(DW_AT_LLVM_ptrauth_authenticates_null_values);
702 const unsigned authentication_mode_int = getAttr(
703 DW_AT_LLVM_ptrauth_authentication_mode,
704 static_cast<unsigned>(clang::PointerAuthenticationMode::SignAndAuth));
705 clang::PointerAuthenticationMode authentication_mode =
706 clang::PointerAuthenticationMode::SignAndAuth;
707 if (authentication_mode_int >=
708 static_cast<unsigned>(clang::PointerAuthenticationMode::None) &&
709 authentication_mode_int <=
710 static_cast<unsigned>(
711 clang::PointerAuthenticationMode::SignAndAuth)) {
712 authentication_mode =
713 static_cast<clang::PointerAuthenticationMode
>(authentication_mode_int);
716 "[{0:x16}]: invalid pointer authentication mode method {1:x4}",
717 die.
GetOffset(), authentication_mode_int);
719 auto ptr_auth = clang::PointerAuthQualifier::Create(
720 key, addr_disc, extra, authentication_mode, isapointer,
721 authenticates_null_values);
739 if (tag == DW_TAG_typedef || tag == DW_TAG_template_alias) {
791 case DW_TAG_unspecified_type:
792 if (attrs.
name ==
"nullptr_t" || attrs.
name ==
"decltype(nullptr)") {
801 case DW_TAG_base_type: {
809 clang_type =
m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
813 case DW_TAG_pointer_type:
816 case DW_TAG_reference_type:
819 case DW_TAG_rvalue_reference_type:
823 case DW_TAG_template_alias:
826 case DW_TAG_const_type:
829 case DW_TAG_restrict_type:
832 case DW_TAG_volatile_type:
835 case DW_TAG_LLVM_ptrauth_type:
839 case DW_TAG_atomic_type:
846 if (tag == DW_TAG_pointer_type) {
854 if (!strcmp(child_die.GetAttributeValueAsString(DW_AT_name,
""),
859 if (function_pointer_type) {
863 bool function_type_is_new_pointer;
865 sc, function_type, &function_type_is_new_pointer);
867 if (lldb_function_type_sp) {
868 clang_type =
m_ast.CreateBlockPointerType(
869 lldb_function_type_sp->GetForwardCompilerType());
885 if (attrs.
name ==
"id") {
887 dwarf->GetObjectFile()->GetModule()->LogMessage(
889 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
890 "is Objective-C 'id' built-in type.",
897 }
else if (attrs.
name ==
"Class") {
899 dwarf->GetObjectFile()->GetModule()->LogMessage(
901 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
902 "is Objective-C 'Class' built-in type.",
909 }
else if (attrs.
name ==
"SEL") {
911 dwarf->GetObjectFile()->GetModule()->LogMessage(
913 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
914 "is Objective-C 'selector' built-in type.",
929 if (encoding_die && encoding_die.
Tag() == DW_TAG_structure_type) {
930 llvm::StringRef struct_name = encoding_die.
GetName();
931 if (struct_name ==
"objc_object") {
933 dwarf->GetObjectFile()->GetModule()->LogMessage(
935 "SymbolFileDWARF::ParseType (die = {0:x16}) {1} ({2}) '{3}' "
936 "is 'objc_object*', which we overrode to 'id'.",
951 &attrs.
decl, clang_type, resolve_state, payload);
958 if (llvm::StringRef(die.
GetName()).contains(
"<"))
962 llvm::raw_string_ostream os(name);
963 llvm::DWARFTypePrinter<DWARFDIE> type_printer(os);
964 type_printer.appendAndTerminateTemplateParameters(die);
979 unique_typename, decl_declaration);
981 dwarf->GetUniqueDWARFASTTypeMap().Find(
982 unique_typename, decl_die, decl_declaration,
985 unique_ast_entry_type->UpdateToDefDIE(def_die, def_attrs.
decl,
990 "Failed to find {0:x16} {1} ({2}) type \"{3}\" in "
991 "UniqueDWARFASTTypeMap",
1008 def_die =
dwarf->FindDefinitionDIE(decl_die);
1012 if (debug_map_symfile) {
1020 dwarf->GetObjectFile()->GetModule()->LogMessage(
1022 "SymbolFileDWARF({0:p}) - {1:x16}}: {2} ({3}) type \"{4}\" is a "
1023 "forward declaration, complete DIE is {5}",
1026 def_die ? llvm::utohexstr(def_die.
GetID()) :
"not found");
1030 if (
auto [it, inserted] =
dwarf->GetDIEToType().try_emplace(
1035 return it->getSecond()->shared_from_this();
1046 Type *enumerator_type =
1048 if (enumerator_type)
1052 if (!enumerator_clang_type) {
1054 enumerator_clang_type =
m_ast.GetBuiltinTypeForDWARFEncodingAndBitSize(
1055 "", DW_ATE_signed, *attrs.
byte_size * 8);
1072 clang::DeclContext *type_decl_ctx =
1075 if (decl_die != def_die) {
1077 dwarf->GetDIEToType()[def_die.
GetDIE()] = type_sp.get();
1082 dwarf->GetObjectFile()->GetModule()->ReportError(
1083 "DWARF DIE at {0:x16} named \"{1}\" was not able to start its "
1084 "definition.\nPlease file a bug and attach the file at the "
1085 "start of this error message",
1091static clang::CallingConv
1094 case llvm::dwarf::DW_CC_normal:
1096 case llvm::dwarf::DW_CC_BORLAND_stdcall:
1097 return clang::CC_X86StdCall;
1098 case llvm::dwarf::DW_CC_BORLAND_msfastcall:
1099 return clang::CC_X86FastCall;
1100 case llvm::dwarf::DW_CC_LLVM_vectorcall:
1101 return clang::CC_X86VectorCall;
1102 case llvm::dwarf::DW_CC_BORLAND_pascal:
1103 return clang::CC_X86Pascal;
1104 case llvm::dwarf::DW_CC_LLVM_Win64:
1105 return clang::CC_Win64;
1106 case llvm::dwarf::DW_CC_LLVM_X86_64SysV:
1107 return clang::CC_X86_64SysV;
1108 case llvm::dwarf::DW_CC_LLVM_X86RegCall:
1109 return clang::CC_X86RegCall;
1115 LLDB_LOG(log,
"Unsupported DW_AT_calling_convention value: {0}",
1128 const auto tag = die.
Tag();
1133 TypeSP complete_objc_class_type_sp =
1134 dwarf->FindCompleteObjCDefinitionTypeForDIE(
DWARFDIE(), class_name,
1137 if (!complete_objc_class_type_sp)
1141 complete_objc_class_type_sp->GetForwardCompilerType();
1143 if (!type_clang_forward_type)
1149 clang::ObjCMethodDecl *objc_method_decl =
m_ast.AddMethodToObjCObjectType(
1153 if (!objc_method_decl) {
1154 dwarf->GetObjectFile()->GetModule()->ReportError(
1155 "[{0:x16}]: invalid Objective-C method {1:x4} ({2}), "
1156 "please file a bug and attach the file at the start of "
1157 "this error message",
1163 m_ast.SetMetadataAsUserID(objc_method_decl, die.
GetID());
1171 const DWARFDIE &object_parameter,
bool &ignore_containing_context) {
1176 Type *class_type =
dwarf->ResolveType(decl_ctx_die);
1180 if (class_type->
GetID() != decl_ctx_die.
GetID() ||
1187 std::vector<DWARFDIE> failures;
1199 return {
true, type_ptr->shared_from_this()};
1213 clang::DeclContext *spec_clang_decl_ctx =
1215 if (spec_clang_decl_ctx)
1218 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1219 "{0:x8}: DW_AT_specification({1:x16}"
1223 return {
true,
nullptr};
1235 if (abs_clang_decl_ctx)
1238 dwarf->GetObjectFile()->GetModule()->ReportWarning(
1239 "{0:x8}: DW_AT_abstract_origin({1:x16}"
1243 return {
true,
nullptr};
1256 const bool is_static = !object_parameter.
IsValid();
1262 return {
true,
nullptr};
1264 const bool is_attr_used =
false;
1266 clang::CXXMethodDecl *cxx_method_decl =
m_ast.AddMethodToCXXRecordType(
1271 if (cxx_method_decl) {
1277 if (
char const *object_pointer_name = object_parameter.
GetName()) {
1279 LLDB_LOGF(log,
"Setting object pointer name: %s on method object %p.\n",
1280 object_pointer_name,
static_cast<void *
>(cxx_method_decl));
1282 m_ast.SetMetadata(cxx_method_decl, metadata);
1284 ignore_containing_context =
true;
1289 const bool type_handled = cxx_method_decl !=
nullptr || attrs.
is_artificial;
1291 return {type_handled,
nullptr};
1302 bool is_variadic =
false;
1303 bool has_template_params =
false;
1306 Type *func_type =
nullptr;
1316 std::vector<CompilerType> function_param_types;
1317 llvm::SmallVector<llvm::StringRef> function_param_names;
1322 clang::DeclContext *containing_decl_ctx =
1324 assert(containing_decl_ctx);
1328 has_template_params, function_param_types,
1329 function_param_names);
1333 bool ignore_containing_context =
false;
1344 if (is_cxx_method && has_template_params) {
1345 ignore_containing_context =
true;
1346 is_cxx_method =
false;
1349 clang::CallingConv calling_convention =
1357 return_clang_type, function_param_types, is_variadic,
1362 bool type_handled =
false;
1363 if (tag == DW_TAG_subprogram || tag == DW_TAG_inlined_subroutine) {
1364 if (std::optional<const ObjCLanguage::ObjCMethodName> objc_method =
1369 }
else if (is_cxx_method) {
1370 auto [handled, type_sp] =
1372 object_parameter, ignore_containing_context);
1376 type_handled = handled;
1380 if (!type_handled) {
1381 clang::FunctionDecl *function_decl =
nullptr;
1382 clang::FunctionDecl *template_function_decl =
nullptr;
1387 if (
dwarf->ResolveType(abs_die)) {
1388 function_decl = llvm::dyn_cast_or_null<clang::FunctionDecl>(
1391 if (function_decl) {
1397 if (!function_decl) {
1398 char *name_buf =
nullptr;
1405 llvm::ItaniumPartialDemangler D;
1407 name_buf = D.getFunctionBaseName(
nullptr,
nullptr);
1413 function_decl =
m_ast.CreateFunctionDeclaration(
1414 ignore_containing_context ?
m_ast.GetTranslationUnitDecl()
1415 : containing_decl_ctx,
1418 std::free(name_buf);
1420 if (has_template_params) {
1423 template_function_decl =
m_ast.CreateFunctionDeclaration(
1424 ignore_containing_context ?
m_ast.GetTranslationUnitDecl()
1425 : containing_decl_ctx,
1428 clang::FunctionTemplateDecl *func_template_decl =
1429 m_ast.CreateFunctionTemplateDecl(
1431 template_function_decl, template_param_infos);
1432 m_ast.CreateFunctionTemplateSpecializationInfo(
1433 template_function_decl, func_template_decl, template_param_infos);
1438 if (function_decl) {
1441 const clang::FunctionProtoType *function_prototype(
1442 llvm::cast<clang::FunctionProtoType>(
1444 const auto params =
m_ast.CreateParameterDeclarations(
1445 function_decl, *function_prototype, function_param_names);
1446 function_decl->setParams(params);
1447 if (template_function_decl)
1448 template_function_decl->setParams(params);
1453 if (
char const *object_pointer_name = object_parameter.
GetName()) {
1456 "Setting object pointer name: %s on function "
1458 object_pointer_name,
static_cast<void *
>(function_decl));
1460 m_ast.SetMetadata(function_decl, metadata);
1465 return dwarf->MakeType(
1476 Type *element_type =
dwarf->ResolveTypeUID(type_die,
true);
1485 byte_stride = array_info->byte_stride;
1486 bit_stride = array_info->bit_stride;
1488 if (byte_stride == 0 && bit_stride == 0)
1489 byte_stride = llvm::expectedToOptional(element_type->
GetByteSize(
nullptr))
1494 uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
1496 if (array_info && array_info->element_orders.size() > 0) {
1497 auto end = array_info->element_orders.rend();
1498 for (
auto pos = array_info->element_orders.rbegin(); pos != end; ++pos) {
1499 clang_type =
m_ast.CreateArrayType(
1500 array_element_type, *pos, attrs.
is_vector);
1502 uint64_t num_elements = pos->value_or(0);
1503 array_element_type = clang_type;
1504 array_element_bit_stride = num_elements
1505 ? array_element_bit_stride * num_elements
1506 : array_element_bit_stride;
1509 clang_type =
m_ast.CreateArrayType(
1510 array_element_type, std::nullopt, attrs.
is_vector);
1514 dwarf->MakeType(die.
GetID(), empty_name, array_element_bit_stride / 8,
1517 type_sp->SetEncodingType(element_type);
1519 m_ast.SetMetadataAsUserID(type, die.
GetID());
1532 if ((class_type ==
nullptr) || (pointee_type ==
nullptr))
1539 class_clang_type, pointee_clang_type);
1541 if (std::optional<uint64_t> clang_type_size =
1542 llvm::expectedToOptional(clang_type.
GetByteSize(
nullptr))) {
1543 return dwarf->MakeType(die.
GetID(), attrs.
name, *clang_type_size,
nullptr,
1551 switch (die.
Tag()) {
1552 case DW_TAG_union_type:
1553 case DW_TAG_structure_type:
1555 case DW_TAG_class_type:
1565 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes,
1573 if (attributes.
Size() == 0)
1578 bool is_virtual =
false;
1579 bool is_base_of_class =
true;
1580 off_t member_byte_offset = 0;
1582 for (uint32_t i = 0; i < attributes.
Size(); ++i) {
1588 encoding_form = form_value;
1590 case DW_AT_data_member_location:
1591 if (
auto maybe_offset =
1593 member_byte_offset = *maybe_offset;
1595 case DW_AT_accessibility:
1599 case DW_AT_virtuality:
1600 is_virtual = form_value.
Boolean();
1610 if (base_class_type ==
nullptr) {
1611 module_sp->ReportError(
"{0:x16}: DW_TAG_inheritance failed to "
1612 "resolve the base class at {1:x16}"
1613 " from enclosing type {2:x16}. \nPlease file "
1614 "a bug and attach the file at the start of "
1615 "this error message",
1623 assert(base_class_clang_type);
1631 ast->SetObjCSuperClass(class_clang_type, base_class_clang_type);
1634 std::unique_ptr<clang::CXXBaseSpecifier> result =
1636 accessibility, is_virtual,
1641 base_classes.push_back(std::move(result));
1659 clang::CharUnits::fromQuantity(member_byte_offset)));
1672 if (sc_parent_tag == DW_TAG_compile_unit ||
1673 sc_parent_tag == DW_TAG_partial_unit) {
1675 }
else if (sc.
function !=
nullptr && sc_parent_die) {
1676 symbol_context_scope =
1678 if (symbol_context_scope ==
nullptr)
1679 symbol_context_scope = sc.
function;
1681 symbol_context_scope = sc.
module_sp.get();
1684 if (symbol_context_scope !=
nullptr)
1685 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());
1754 clang::ObjCInterfaceDecl *decl =
1758 if (
const char *runtime_name =
1760 .GetAttributeValueAsString(DW_AT_const_value,
nullptr))
1761 decl->addAttr(clang::ObjCRuntimeNameAttr::CreateImplicit(
1762 decl->getASTContext(), runtime_name));
1776 uint64_t byte_size = attrs.
byte_size.value_or(0);
1782 dwarf->GetObjectFile()->GetModule()->LogMessage(
1783 log,
"SymbolFileDWARF({0:p}) - {1:x16}: {2} has unique name: {3} ",
1788 dwarf->GetUniqueDWARFASTTypeMap().Find(
1789 unique_typename, die, unique_decl, byte_size,
1791 if (
TypeSP type_sp = unique_ast_entry_type->m_type_sp) {
1792 dwarf->GetDIEToType()[die.
GetDIE()] = type_sp.get();
1799 unique_ast_entry_type->m_is_forward_declaration) {
1800 unique_ast_entry_type->UpdateToDefDIE(die, unique_decl, byte_size);
1801 clang_type = type_sp->GetForwardCompilerType();
1805 dwarf->GetForwardDeclCompilerTypeToDIE().insert_or_assign(
1823 dwarf->FindCompleteObjCDefinitionTypeForDIE(die, attrs.
name,
true);
1827 if (debug_map_symfile) {
1831 die, attrs.
name,
true);
1837 dwarf->GetObjectFile()->GetModule()->LogMessage(
1839 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" is an "
1840 "incomplete objc type, complete type is {5:x8}",
1856 int tag_decl_kind = -1;
1857 if (tag == DW_TAG_structure_type)
1858 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Struct);
1859 else if (tag == DW_TAG_union_type)
1860 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Union);
1861 else if (tag == DW_TAG_class_type)
1862 tag_decl_kind = llvm::to_underlying(clang::TagTypeKind::Class);
1864 assert(
false &&
"Unexpected tag kind.");
1866 clang::DeclContext *containing_decl_ctx =
1870 containing_decl_ctx, die,
1880 clang::ClassTemplateDecl *class_template_decl =
1881 m_ast.ParseClassTemplateDecl(
1884 if (!class_template_decl) {
1886 dwarf->GetObjectFile()->GetModule()->LogMessage(
1888 "SymbolFileDWARF({0:p}) - {1:x16}: {2} ({3}) type \"{4}\" "
1889 "clang::ClassTemplateDecl failed to return a decl.",
1896 clang::ClassTemplateSpecializationDecl *class_specialization_decl =
1897 m_ast.CreateClassTemplateSpecializationDecl(
1899 tag_decl_kind, template_param_infos);
1900 if (!class_specialization_decl) {
1902 dwarf->GetObjectFile()->GetModule()->LogMessage(
1904 "SymbolFileDWARF({0:p}) - Failed to create specialization for "
1905 "clang::ClassTemplateDecl({1}, {2:p}).",
1906 this, llvm::StringRef(attrs.
name), class_template_decl);
1912 m_ast.CreateClassTemplateSpecializationType(class_specialization_decl);
1914 m_ast.SetMetadata(class_template_decl, metadata);
1915 m_ast.SetMetadata(class_specialization_decl, metadata);
1919 clang_type =
m_ast.CreateRecordType(
1934 clang::DeclContext *type_decl_ctx =
1942 auto unique_ast_entry_up = std::make_unique<UniqueDWARFASTType>();
1946 unique_ast_entry_up->m_type_sp = type_sp;
1947 unique_ast_entry_up->m_die = die;
1948 unique_ast_entry_up->m_declaration = unique_decl;
1949 unique_ast_entry_up->m_byte_size = byte_size;
1951 dwarf->GetUniqueDWARFASTTypeMap().Insert(unique_typename,
1952 *unique_ast_entry_up);
1960 dwarf->GetForwardDeclCompilerTypeToDIE()
1965 assert(inserted &&
"Type already in the forward declaration map!");
1974 clang::CXXRecordDecl *record_decl =
1976 if (record_decl && record_decl->getDefinition()) {
1977 record_decl->setHasTrivialSpecialMemberForCall();
1982 clang::CXXRecordDecl *record_decl =
1985 record_decl->setArgPassingRestrictions(
1986 clang::RecordArgPassingKind::CannotPassInRegs);
1996 const CompilerType &class_opaque_type,
const char *property_name,
2000 const char *property_setter_name,
const char *property_getter_name,
2025static std::optional<clang::APValue>
MakeAPValue(
const clang::ASTContext &ast,
2028 std::optional<uint64_t> bit_width =
2029 llvm::expectedToOptional(clang_type.
GetBitSize(
nullptr));
2031 return std::nullopt;
2033 bool is_signed =
false;
2036 llvm::APSInt apint(*bit_width, !is_signed);
2040 return clang::APValue(apint);
2045 return std::nullopt;
2047 return clang::APValue(llvm::APFloat(
2055 bool is_template_template_argument =
false;
2058 case DW_TAG_GNU_template_parameter_pack: {
2060 std::make_unique<TypeSystemClang::TemplateParameterInfos>());
2065 if (
const char *name = die.
GetName()) {
2070 case DW_TAG_GNU_template_template_param:
2071 is_template_template_argument =
true;
2073 case DW_TAG_template_type_parameter:
2074 case DW_TAG_template_value_parameter: {
2076 if (attributes.
Size() == 0)
2079 const char *name =
nullptr;
2080 const char *template_name =
nullptr;
2082 uint64_t uval64 = 0;
2083 bool uval64_valid =
false;
2084 bool is_default_template_arg =
false;
2086 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2095 case DW_AT_GNU_template_name:
2108 case DW_AT_const_value:
2110 uval64_valid =
true;
2114 case DW_AT_default_value:
2116 is_default_template_arg = form_value.
Boolean();
2123 clang::ASTContext &ast =
m_ast.getASTContext();
2127 if (!is_template_template_argument) {
2129 if (name && !name[0])
2132 if (tag == DW_TAG_template_value_parameter && uval64_valid) {
2133 if (
auto value =
MakeAPValue(ast, clang_type, uval64)) {
2135 name, clang::TemplateArgument(
2137 std::move(*value), is_default_template_arg));
2147 is_default_template_arg));
2149 auto *tplt_type =
m_ast.CreateTemplateTemplateParmDecl(template_name);
2151 name, clang::TemplateArgument(clang::TemplateName(tplt_type),
2152 is_default_template_arg));
2174 case DW_TAG_template_type_parameter:
2175 case DW_TAG_template_value_parameter:
2176 case DW_TAG_GNU_template_parameter_pack:
2177 case DW_TAG_GNU_template_template_param:
2186 return !template_param_infos.
IsEmpty() ||
2195 std::vector<DWARFDIE> contained_type_dies;
2206 std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> bases;
2208 std::vector<DWARFDIE> member_function_dies;
2212 contained_type_dies, delayed_properties, layout_info);
2215 for (
const DWARFDIE &die : member_function_dies)
2216 dwarf->ResolveType(die);
2221 dwarf->GetObjCMethods(class_name, [&](
DWARFDIE method_die) {
2227 property.Finalize();
2237 "WARNING: Type completion aborted because forward declaration for "
2238 "'{0}' is C++ while definition is Objective-C.",
2239 llvm::StringRef(die.
GetName()));
2255 clang::CXXRecordDecl *record_decl =
2263 if (
m_ast.getASTContext().getTargetInfo().getCXXABI().isMicrosoft()) {
2264 auto IM = record_decl->calculateInheritanceModel();
2265 record_decl->addAttr(clang::MSInheritanceAttr::CreateImplicit(
2266 m_ast.getASTContext(),
true, {},
2267 clang::MSInheritanceAttr::Spelling(IM)));
2274 for (
const DWARFDIE &die : contained_type_dies)
2275 dwarf->ResolveType(die);
2277 return (
bool)clang_type;
2289 llvm::expectedToOptional(type->
GetByteSize(
nullptr)).value_or(0),
2294 return (
bool)clang_type;
2302 std::lock_guard<std::recursive_mutex> guard(
2303 dwarf->GetObjectFile()->GetModule()->GetMutex());
2316 case DW_TAG_structure_type:
2317 case DW_TAG_union_type:
2318 case DW_TAG_class_type:
2321 case DW_TAG_enumeration_type:
2325 assert(
false &&
"not a forward clang type decl!");
2342 auto opaque_decl_ctx =
2353 if (clang_decl !=
nullptr)
2354 return m_ast.GetCompilerDecl(clang_decl);
2362 return m_ast.CreateDeclContext(clang_decl_ctx);
2368 clang::DeclContext *clang_decl_ctx =
2371 return m_ast.CreateDeclContext(clang_decl_ctx);
2377 uint32_t enumerator_byte_size,
const DWARFDIE &parent_die) {
2381 size_t enumerators_added = 0;
2385 if (tag != DW_TAG_enumerator)
2389 if (attributes.
Size() == 0)
2392 const char *name =
nullptr;
2393 std::optional<uint64_t> enum_value;
2396 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2401 case DW_AT_const_value:
2403 enum_value = form_value.
Signed();
2405 enum_value = form_value.
Unsigned();
2412 case DW_AT_description:
2414 case DW_AT_decl_file:
2418 case DW_AT_decl_line:
2421 case DW_AT_decl_column:
2430 if (name && name[0] && enum_value) {
2431 m_ast.AddEnumerationValueToEnumerationType(
2432 clang_type, decl, name, *enum_value, enumerator_byte_size * 8);
2433 ++enumerators_added;
2436 return enumerators_added;
2441 bool is_variadic =
false;
2442 bool has_template_params =
false;
2443 std::vector<CompilerType> param_types;
2444 llvm::SmallVector<llvm::StringRef> param_names;
2451 clang::DeclContext *containing_decl_ctx =
2453 assert(containing_decl_ctx);
2455 const unsigned cv_quals =
2459 has_template_params, param_types, param_names);
2461 for (
size_t i = 0; i < param_types.size(); i++) {
2464 sstr << param_types[i].GetTypeName();
2469 if (cv_quals & clang::Qualifiers::Const)
2477 llvm::DWARFAddressRangesVector unused_func_ranges;
2478 const char *name =
nullptr;
2479 const char *mangled =
nullptr;
2480 std::optional<int> decl_file;
2481 std::optional<int> decl_line;
2482 std::optional<int> decl_column;
2483 std::optional<int> call_file;
2484 std::optional<int> call_line;
2485 std::optional<int> call_column;
2490 if (tag != DW_TAG_subprogram)
2494 decl_line, decl_column, call_file, call_line,
2495 call_column, &frame_base)) {
2497 if (mangled && name &&
2505 }
else if (mangled) {
2507 }
else if ((die.
GetParent().
Tag() == DW_TAG_compile_unit ||
2513 name && strcmp(name,
"main") != 0) {
2549 Address func_addr = func_ranges[0].GetBaseAddress();
2551 func_sp = std::make_shared<Function>(
2554 func_user_id, func_name, func_type, std::move(func_addr),
2555 std::move(func_ranges));
2557 if (func_sp.get() !=
nullptr) {
2559 func_sp->GetFrameBaseExpression() = frame_base;
2561 return func_sp.get();
2570struct PropertyAttributes {
2571 explicit PropertyAttributes(
const DWARFDIE &die);
2572 const char *prop_name =
nullptr;
2573 const char *prop_getter_name =
nullptr;
2574 const char *prop_setter_name =
nullptr;
2576 uint32_t prop_attributes = 0;
2579struct DiscriminantValue {
2580 explicit DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp);
2582 uint32_t byte_offset;
2584 DWARFFormValue type_ref;
2587struct VariantMember {
2588 explicit VariantMember(DWARFDIE &die,
ModuleSP module_sp);
2589 bool IsDefault()
const;
2591 std::optional<llvm::APInt> discr_value;
2592 DWARFFormValue type_ref;
2593 ConstString variant_name;
2594 uint32_t byte_offset;
2599 explicit VariantPart(
const DWARFDIE &die,
const DWARFDIE &parent_die,
2602 std::vector<VariantMember> &members();
2604 DiscriminantValue &discriminant();
2607 std::vector<VariantMember> _members;
2608 DiscriminantValue _discriminant;
2613ConstString VariantMember::GetName()
const {
return this->variant_name; }
2615bool VariantMember::IsDefault()
const {
return !discr_value; }
2617VariantMember::VariantMember(DWARFDIE &die,
lldb::ModuleSP module_sp) {
2618 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant);
2620 DWARFFormValue discr_form;
2621 die.
GetDIE()->GetAttributeValue(die.
GetCU(), DW_AT_discr_value, discr_form);
2628 if ((form == DW_FORM_block1 && discr_form.
Unsigned() == 16) ||
2629 form == DW_FORM_data16) {
2630 const uint8_t *block_data = discr_form.
BlockData();
2635 uint64_t lo = extractor.GetU64(&offset);
2636 uint64_t hi = extractor.GetU64(&offset);
2637 uint64_t words[] = {lo, hi};
2638 this->discr_value = llvm::APInt(128, words);
2642 this->discr_value = llvm::APInt(
sizeof(uint64_t) * 8, result.value());
2644 this->discr_value = std::nullopt;
2648 for (
auto child_die : die.
children()) {
2649 switch (child_die.Tag()) {
2650 case llvm::dwarf::DW_TAG_member: {
2651 DWARFAttributes attributes = child_die.GetAttributes();
2652 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2653 DWARFFormValue form_value;
2658 variant_name = ConstString(form_value.
AsCString());
2661 type_ref = form_value;
2664 case DW_AT_data_member_location:
2665 if (
auto maybe_offset =
2667 byte_offset = *maybe_offset;
2684DiscriminantValue::DiscriminantValue(
const DWARFDIE &die,
ModuleSP module_sp) {
2686 DWARFAttributes attributes = referenced_die.GetAttributes();
2687 for (std::size_t i = 0; i < attributes.
Size(); ++i) {
2689 DWARFFormValue form_value;
2693 type_ref = form_value;
2695 case DW_AT_data_member_location:
2696 if (
auto maybe_offset =
2698 byte_offset = *maybe_offset;
2707VariantPart::VariantPart(
const DWARFDIE &die,
const DWARFDIE &parent_die,
2709 : _members(), _discriminant(die, module_sp) {
2711 for (
auto child : die.
children()) {
2712 if (child.Tag() == llvm::dwarf::DW_TAG_variant) {
2713 _members.push_back(VariantMember(child, module_sp));
2718std::vector<VariantMember> &VariantPart::members() {
return this->_members; }
2720DiscriminantValue &VariantPart::discriminant() {
return this->_discriminant; }
2725 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2736 case DW_AT_bit_offset:
2739 case DW_AT_bit_size:
2742 case DW_AT_byte_size:
2745 case DW_AT_const_value:
2748 case DW_AT_data_bit_offset:
2751 case DW_AT_data_member_location:
2752 if (
auto maybe_offset =
2757 case DW_AT_artificial:
2760 case DW_AT_declaration:
2787PropertyAttributes::PropertyAttributes(
const DWARFDIE &die) {
2790 for (
size_t i = 0; i < attributes.
Size(); ++i) {
2795 case DW_AT_APPLE_property_name:
2798 case DW_AT_APPLE_property_getter:
2799 prop_getter_name = form_value.
AsCString();
2801 case DW_AT_APPLE_property_setter:
2802 prop_setter_name = form_value.
AsCString();
2804 case DW_AT_APPLE_property_attribute:
2805 prop_attributes = form_value.
Unsigned();
2815 ConstString fixed_setter;
2819 if (prop_getter_name && prop_getter_name[0] ==
'-') {
2820 std::optional<const ObjCLanguage::ObjCMethodName> prop_getter_method =
2822 if (prop_getter_method)
2824 ConstString(prop_getter_method->GetSelector()).GetCString();
2827 if (prop_setter_name && prop_setter_name[0] ==
'-') {
2828 std::optional<const ObjCLanguage::ObjCMethodName> prop_setter_method =
2830 if (prop_setter_method)
2832 ConstString(prop_setter_method->GetSelector()).GetCString();
2836 if (!prop_getter_name)
2837 prop_getter_name = prop_name;
2838 if (!prop_setter_name && prop_name[0] &&
2839 !(prop_attributes & DW_APPLE_PROPERTY_readonly)) {
2842 ss.
Printf(
"set%c%s:", toupper(prop_name[0]), &prop_name[1]);
2845 prop_setter_name = fixed_setter.
GetCString();
2854 assert(die.
Tag() == DW_TAG_APPLE_property);
2859 const PropertyAttributes propAttrs(die);
2861 if (!propAttrs.prop_name) {
2862 module_sp->ReportError(
"{0:x8}: DW_TAG_APPLE_property has no name.",
2869 module_sp->ReportError(
2870 "{0:x8}: DW_TAG_APPLE_property '{1}' refers to type {2:x16}"
2871 " which was unable to be parsed",
2872 die.
GetID(), propAttrs.prop_name,
2879 delayed_properties.emplace_back(
2880 class_clang_type, propAttrs.prop_name,
2882 propAttrs.prop_getter_name, propAttrs.prop_attributes, metadata);
2888 assert(qt->isIntegralOrEnumerationType());
2891 return llvm::createStringError(llvm::inconvertibleErrorCode(),
2892 "TypeSystem not clang");
2896 const unsigned type_bits = ast.getIntWidth(qt);
2897 const bool is_unsigned = qt->isUnsignedIntegerType();
2901 constexpr std::size_t max_bit_size = 64;
2906 if (type_bits > max_bit_size) {
2907 auto msg = llvm::formatv(
"Can only parse integers with up to {0} bits, but "
2908 "given integer has {1} bits.",
2909 max_bit_size, type_bits);
2910 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2914 llvm::APInt result(max_bit_size, form_value.
Unsigned(), !is_unsigned);
2920 const unsigned required_bits =
2921 is_unsigned ? result.getActiveBits() : result.getSignificantBits();
2924 if (required_bits > type_bits) {
2925 std::string value_as_str = is_unsigned
2926 ? std::to_string(form_value.
Unsigned())
2927 : std::to_string(form_value.
Signed());
2928 auto msg = llvm::formatv(
"Can't store {0} value {1} in integer with {2} "
2930 (is_unsigned ?
"unsigned" :
"signed"),
2931 value_as_str, type_bits);
2932 return llvm::createStringError(llvm::inconvertibleErrorCode(), msg.str());
2936 if (result.getBitWidth() > type_bits)
2937 result = result.trunc(type_bits);
2945 assert(die.
Tag() == DW_TAG_member || die.
Tag() == DW_TAG_variable);
2956 LLDB_LOG(log,
"Failed to add variable to the record type");
2965 llvm::Expected<llvm::APInt> const_value_or_err =
2967 if (!const_value_or_err) {
2969 "Failed to add const value to variable {1}: {0}",
2970 v->getQualifiedNameAsString());
2983 assert(die.
Tag() == DW_TAG_member);
2988 const uint64_t parent_byte_size =
2990 const uint64_t parent_bit_size =
3015 module_sp->ReportError(
3016 "{0:x8}: DW_TAG_member '{1}' refers to type {2:x16}"
3017 " which was unable to be parsed",
3020 module_sp->ReportError(
"{0:x8}: DW_TAG_member refers to type {1:x16}"
3021 " which was unable to be parsed",
3027 const uint64_t character_width = 8;
3036 this_field_info.
bit_offset = field_bit_offset;
3044 byte_size = llvm::expectedToOptional(member_type->
GetByteSize(
nullptr));
3048 this_field_info.
bit_offset += byte_size.value_or(0) * 8;
3062 !(parent_die.
Tag() == DW_TAG_union_type &&
3064 ((this_field_info.
bit_offset >= parent_bit_size) ||
3070 "{0:x16}: {1} ({2}) bitfield named \"{3}\" has invalid "
3071 "bit offset ({4:x8}) member will be ignored. Please file a bug "
3073 "compiler and include the preprocessed output for {5}",
3080 field_bit_offset = this_field_info.
bit_offset;
3085 bool detect_unnamed_bitfields =
true;
3088 detect_unnamed_bitfields =
3091 if (detect_unnamed_bitfields)
3093 last_field_info, this_field_info);
3095 last_field_info = this_field_info;
3100 this_field_info.
bit_offset = field_bit_offset;
3104 if (std::optional<uint64_t> clang_type_size =
3105 llvm::expectedToOptional(member_type->
GetByteSize(
nullptr))) {
3106 this_field_info.
bit_size = *clang_type_size * character_width;
3113 last_field_info = this_field_info;
3133 class_clang_type, attrs.
name, member_clang_type, attrs.
bit_size);
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,
3162 case DW_TAG_APPLE_property:
3166 case DW_TAG_variant_part:
3172 case DW_TAG_variable: {
3181 case DW_TAG_subprogram:
3183 member_function_dies.push_back(die);
3186 case DW_TAG_inheritance:
3188 base_classes, layout_info);
3192 if (llvm::dwarf::isType(tag))
3193 contained_type_dies.push_back(die);
3202 clang::DeclContext *containing_decl_ctx,
const DWARFDIE &parent_die,
3203 bool &is_variadic,
bool &has_template_params,
3204 std::vector<CompilerType> &function_param_types,
3212 case DW_TAG_formal_parameter: {
3222 function_param_names.emplace_back(die.
GetName());
3226 case DW_TAG_unspecified_parameters:
3230 case DW_TAG_template_type_parameter:
3231 case DW_TAG_template_value_parameter:
3232 case DW_TAG_GNU_template_parameter_pack:
3238 has_template_params =
true;
3246 assert(function_param_names.size() == function_param_types.size());
3253 switch (die.
Tag()) {
3254 case DW_TAG_constant:
3255 case DW_TAG_formal_parameter:
3256 case DW_TAG_imported_declaration:
3257 case DW_TAG_imported_module:
3259 case DW_TAG_variable:
3273 return cache_pos->second;
3288 clang::Decl *decl =
nullptr;
3289 switch (die.
Tag()) {
3290 case DW_TAG_variable:
3291 case DW_TAG_constant:
3292 case DW_TAG_formal_parameter: {
3295 if (
dwarf && type) {
3296 const char *name = die.
GetName();
3297 clang::DeclContext *decl_context =
3299 dwarf->GetDeclContextContainingUID(die.
GetID()));
3300 decl =
m_ast.CreateVariableDeclaration(
3306 case DW_TAG_imported_declaration: {
3311 if (imported_decl) {
3312 clang::DeclContext *decl_context =
3314 dwarf->GetDeclContextContainingUID(die.
GetID()));
3315 if (clang::NamedDecl *clang_imported_decl =
3316 llvm::dyn_cast<clang::NamedDecl>(
3318 decl =
m_ast.CreateUsingDeclaration(
3324 case DW_TAG_imported_module: {
3331 if (imported_decl_ctx) {
3332 clang::DeclContext *decl_context =
3334 dwarf->GetDeclContextContainingUID(die.
GetID()));
3335 if (clang::NamespaceDecl *ns_decl =
3338 decl =
m_ast.CreateUsingDirectiveDeclaration(
3360 bool try_parsing_type =
true;
3361 switch (die.
Tag()) {
3362 case DW_TAG_compile_unit:
3363 case DW_TAG_partial_unit:
3364 decl_ctx =
m_ast.GetTranslationUnitDecl();
3365 try_parsing_type =
false;
3368 case DW_TAG_namespace:
3370 try_parsing_type =
false;
3373 case DW_TAG_imported_declaration:
3375 try_parsing_type =
false;
3378 case DW_TAG_lexical_block:
3380 try_parsing_type =
false;
3387 if (decl_ctx ==
nullptr && try_parsing_type) {
3407 parent = parent.GetParent()) {
3409 if (tag == DW_TAG_module) {
3429 switch (die.
Tag()) {
3430 case DW_TAG_subprogram:
3431 case DW_TAG_inlined_subroutine:
3441 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3448 assert(0 &&
"Shouldn't call GetContainingFunctionWithAbstractOrigin on "
3449 "something not in a function");
3455 if (candidate.GetReferencedDIE(DW_AT_abstract_origin)) {
3477 assert(die.
Tag() == DW_TAG_lexical_block);
3478 DWARFDIE containing_function_with_abstract_origin =
3480 if (!containing_function_with_abstract_origin) {
3484 die, containing_function_with_abstract_origin);
3491 if (die && die.
Tag() == DW_TAG_lexical_block) {
3492 clang::BlockDecl *decl =
3497 clang::DeclContext *decl_context =
3511clang::NamespaceDecl *
3513 if (die && die.
Tag() == DW_TAG_namespace) {
3516 clang::NamespaceDecl *namespace_decl =
3519 return namespace_decl;
3521 const char *namespace_name = die.
GetName();
3522 clang::DeclContext *containing_decl_ctx =
3527 namespace_decl =
m_ast.GetUniqueNamespaceDeclaration(
3533 return namespace_decl;
3539clang::NamespaceDecl *
3541 assert(die && die.
Tag() == DW_TAG_imported_declaration);
3547 return static_cast<clang::NamespaceDecl *
>(it->getSecond());
3549 clang::NamespaceDecl *namespace_decl =
nullptr;
3556 switch (imported_uid.
Tag()) {
3557 case DW_TAG_imported_declaration:
3560 case DW_TAG_namespace:
3567 if (!namespace_decl)
3572 return namespace_decl;
3579 DWARFDIE decl_ctx_die =
dwarf->GetDeclContextDIEContainingDIE(die);
3581 if (decl_ctx_die_copy)
3582 *decl_ctx_die_copy = decl_ctx_die;
3585 clang::DeclContext *clang_decl_ctx =
3588 return clang_decl_ctx;
3590 return m_ast.GetTranslationUnitDecl();
3614 if (!class_type || !src_class_die || !dst_class_die)
3616 if (src_class_die.
Tag() != dst_class_die.
Tag())
3626 if (die.
Tag() != DW_TAG_subprogram)
3638 map_artificial.Append(const_name, die);
3640 map.Append(const_name, die);
3649 src_die = src_die.GetSibling()) {
3650 gather(src_die, src_name_to_die, src_name_to_die_artificial);
3653 dst_die = dst_die.GetSibling()) {
3654 gather(dst_die, dst_name_to_die, dst_name_to_die_artificial);
3656 const uint32_t src_size = src_name_to_die.
GetSize();
3657 const uint32_t dst_size = dst_name_to_die.
GetSize();
3660 bool fast_path =
true;
3662 if (src_size != dst_size)
3668 for (idx = 0; idx < src_size; ++idx) {
3672 if (src_die.
Tag() != dst_die.
Tag())
3679 if (src_name == dst_name || (strcmp(src_name, dst_name) == 0))
3686 auto *src_dwarf_ast_parser = llvm::cast<DWARFASTParserClang>(
3688 auto *dst_dwarf_ast_parser = llvm::cast<DWARFASTParserClang>(
3692 clang::DeclContext *dst_decl_ctx =
3693 dst_dwarf_ast_parser->m_die_to_decl_ctx[dst.GetDIE()];
3695 src_dwarf_ast_parser->LinkDeclContextToDIE(dst_decl_ctx, src);
3697 if (
Type *src_child_type = die_to_type.lookup(src.
GetDIE()))
3698 die_to_type[dst.GetDIE()] = src_child_type;
3705 for (idx = 0; idx < src_size; ++idx) {
3715 src_name_to_die.
Sort();
3717 for (idx = 0; idx < dst_size; ++idx) {
3722 if (src_die && (src_die.
Tag() == dst_die.
Tag()))
3723 link(src_die, dst_die);
3725 failures.push_back(dst_die);
3730 const uint32_t src_size_artificial = src_name_to_die_artificial.
GetSize();
3731 const uint32_t dst_size_artificial = dst_name_to_die_artificial.
GetSize();
3733 if (src_size_artificial && dst_size_artificial) {
3734 dst_name_to_die_artificial.
Sort();
3736 for (idx = 0; idx < src_size_artificial; ++idx) {
3742 dst_name_to_die_artificial.
Find(src_name_artificial,
DWARFDIE());
3746 link(src_die, dst_die);
3750 if (dst_size_artificial) {
3751 for (idx = 0; idx < dst_size_artificial; ++idx) {
3757 return !failures.empty();
3761 FieldInfo const &last_field_info, uint64_t last_field_end,
3766 if (this_field_info.
bit_offset <= last_field_end)
3780 const bool have_base = layout_info.
base_offsets.size() != 0;
3781 const bool this_is_first_field =
3783 const bool first_field_is_vptr =
3786 if (have_base && (this_is_first_field || first_field_is_vptr))
3797 const uint64_t word_width = 32;
3805 if (last_field_end != 0 && ((last_field_end % word_width) != 0))
3806 last_field_end += word_width - (last_field_end % word_width);
3811 current_field, class_layout_info))
3816 const uint64_t unnamed_bit_size = current_field.
bit_offset - last_field_end;
3817 const uint64_t unnamed_bit_offset = last_field_end;
3819 clang::FieldDecl *unnamed_bitfield_decl =
3821 class_clang_type, llvm::StringRef(),
3826 std::make_pair(unnamed_bitfield_decl, unnamed_bit_offset));
3833 assert(die.
Tag() == llvm::dwarf::DW_TAG_variant_part);
3839 VariantPart variants(die, parent_die, module_sp);
3841 auto discriminant_type =
3842 die.
ResolveTypeUID(variants.discriminant().type_ref.Reference());
3844 auto decl_context =
m_ast.GetDeclContextForType(class_clang_type);
3846 auto inner_holder =
m_ast.CreateRecordType(
3849 llvm::formatv(
"{0}$Inner", class_clang_type.
GetTypeName(
false))),
3851 m_ast.StartTagDeclarationDefinition(inner_holder);
3852 m_ast.SetIsPacked(inner_holder);
3854 for (
auto member : variants.members()) {
3856 auto has_discriminant = !member.IsDefault();
3858 auto member_type = die.
ResolveTypeUID(member.type_ref.Reference());
3860 auto field_type =
m_ast.CreateRecordType(
3862 std::string(llvm::formatv(
"{0}$Variant", member.GetName())),
3863 llvm::to_underlying(clang::TagTypeKind::Struct),
3866 m_ast.StartTagDeclarationDefinition(field_type);
3867 auto offset = member.byte_offset;
3869 if (has_discriminant) {
3870 m_ast.AddFieldToRecordType(field_type,
"$discr$",
3871 discriminant_type->GetFullCompilerType(),
3872 variants.discriminant().byte_offset);
3874 llvm::expectedToOptional(discriminant_type->GetByteSize(
nullptr))
3878 m_ast.AddFieldToRecordType(field_type,
"value",
3879 member_type->GetFullCompilerType(), offset * 8);
3881 m_ast.CompleteTagDeclarationDefinition(field_type);
3883 auto name = std::string(
"$variant$");
3884 if (has_discriminant) {
3887 llvm::SmallString<40> discr_str;
3888 member.discr_value.value().toStringUnsigned(discr_str);
3889 name.append(discr_str.c_str());
3892 auto variant_decl =
m_ast.AddFieldToRecordType(
3893 inner_holder, llvm::StringRef(name), field_type, 0);
3898 auto inner_field =
m_ast.AddFieldToRecordType(
3899 class_clang_type, llvm::StringRef(
"$variants$"), inner_holder, 0);
3901 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 void ApplyObjCRuntimeName(const DWARFDIE &die, CompilerType type)
The ASTImporter copies attributes only when a decl is first imported, so this must run before the dec...
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.
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.
const char * AsCString(const char *value_if_empty) 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.
static Mangled::ManglingScheme GetManglingScheme(llvm::StringRef name)
Try to identify the mangling scheme used.
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::ObjCInterfaceDecl * GetAsObjCInterfaceDecl(const CompilerType &type)
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)
static DWARFDIE GetAnnotation(const DWARFDIE &die, llvm::StringRef name)
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
uint8_t GetAddressByteSize() const override
bool Supports_unnamed_objc_bitfields()
uint64_t GetDWARFLanguageType()
lldb::ByteOrder GetByteOrder() const
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::dwarf::Form dw_form_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.