Skip to content

[lldb][DWARFASTParserClang][NFCI] Simplify ParseChildParameters #123790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 13 additions & 56 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3084,50 +3084,10 @@ size_t DWARFASTParserClang::ParseChildParameters(
const dw_tag_t tag = die.Tag();
switch (tag) {
case DW_TAG_formal_parameter: {
DWARFAttributes attributes = die.GetAttributes();
if (attributes.Size() == 0) {
arg_idx++;
break;
}

const char *name = nullptr;
DWARFFormValue param_type_die_form;
bool is_artificial = false;
// one of None, Auto, Register, Extern, Static, PrivateExtern

clang::StorageClass storage = clang::SC_None;
uint32_t i;
for (i = 0; i < attributes.Size(); ++i) {
const dw_attr_t attr = attributes.AttributeAtIndex(i);
DWARFFormValue form_value;
if (attributes.ExtractFormValueAtIndex(i, form_value)) {
switch (attr) {
case DW_AT_name:
name = form_value.AsCString();
break;
case DW_AT_type:
param_type_die_form = form_value;
break;
case DW_AT_artificial:
is_artificial = form_value.Boolean();
break;
case DW_AT_location:
case DW_AT_const_value:
case DW_AT_default_value:
case DW_AT_description:
case DW_AT_endianity:
case DW_AT_is_optional:
case DW_AT_segment:
case DW_AT_variable_parameter:
default:
case DW_AT_abstract_origin:
case DW_AT_sibling:
break;
}
}
}
const char *name = die.GetName();
DWARFDIE param_type_die = die.GetAttributeValueAsReferenceDIE(DW_AT_type);

if (is_artificial) {
if (die.GetAttributeValueAsUnsigned(DW_AT_artificial, 0)) {
// In order to determine if a C++ member function is "const" we
// have to look at the const-ness of "this"...
if (arg_idx == 0 &&
Expand All @@ -3136,8 +3096,7 @@ size_t DWARFASTParserClang::ParseChildParameters(
// specification DIEs, so we can't rely upon the name being in
// the formal parameter DIE...
(name == nullptr || ::strcmp(name, "this") == 0)) {
Type *this_type = die.ResolveTypeUID(param_type_die_form.Reference());
if (this_type) {
if (Type *this_type = die.ResolveTypeUID(param_type_die)) {
uint32_t encoding_mask = this_type->GetEncodingMask();
if (encoding_mask & Type::eEncodingIsPointerUID) {
is_static = false;
Expand All @@ -3149,20 +3108,18 @@ size_t DWARFASTParserClang::ParseChildParameters(
}
}
}
} else {
Type *type = die.ResolveTypeUID(param_type_die_form.Reference());
if (type) {
function_param_types.push_back(type->GetForwardCompilerType());
} else if (Type *type = die.ResolveTypeUID(param_type_die)) {
function_param_types.push_back(type->GetForwardCompilerType());

clang::ParmVarDecl *param_var_decl = m_ast.CreateParameterDeclaration(
containing_decl_ctx, GetOwningClangModule(die), name,
type->GetForwardCompilerType(), storage);
assert(param_var_decl);
function_param_decls.push_back(param_var_decl);
clang::ParmVarDecl *param_var_decl = m_ast.CreateParameterDeclaration(
containing_decl_ctx, GetOwningClangModule(die), name,
type->GetForwardCompilerType(), clang::StorageClass::SC_None);
assert(param_var_decl);
function_param_decls.push_back(param_var_decl);

m_ast.SetMetadataAsUserID(param_var_decl, die.GetID());
}
m_ast.SetMetadataAsUserID(param_var_decl, die.GetID());
}

arg_idx++;
} break;

Expand Down
Loading