return result;
}
+ // Let's create the type early and record it as being for the DIE
+ // 'die'. This way, when building the sub-type triggers the
+ // creation of a type matching the same 'die', then we'll reuse this
+ // one.
+ result.reset(is_method
+ ? new method_type(is_method,
+ tu->get_address_size(),
+ /*alignment=*/0)
+ : new function_type(tu->get_address_size(),
+ /*alignment=*/0));
+ tu->bind_function_type_life_time(result);
+ ctxt.associate_die_to_type(dwarf_dieoffset(die),
+ die_is_from_alt_di,
+ result);
+
decl_base_sptr return_type_decl;
Dwarf_Die ret_type_die;
bool ret_type_die_is_in_alternate_debug_info = false;
where_offset));
if (!return_type_decl)
return_type_decl = build_ir_node_for_void_type(ctxt);
+ result->set_return_type(is_type(return_type_decl));
Dwarf_Die child;
function_decl::parameters function_parms;
}
while (dwarf_siblingof(&child, &child) == 0);
- result.reset(is_method
- ? new method_type(is_type(return_type_decl),
- is_method,
- function_parms,
- tu->get_address_size(),
- /*alignment=*/0)
- : new function_type(is_type(return_type_decl),
- function_parms,
- tu->get_address_size(),
- /*alignment=*/0));
-
- tu->bind_function_type_life_time(result);
+ result->set_parameters(function_parms);
return result;
}
if (f)
{
result = f;
- ctxt.associate_die_to_type(dwarf_dieoffset(die),
- die_is_from_alt_di,
- f);
maybe_canonicalize_type(dwarf_dieoffset(die),
die_is_from_alt_di,
ctxt);
/// @param p the new vector of parameters to set.
void
function_type::set_parameters(const parameters &p)
-{priv_->parms_ = p;}
+{
+ priv_->parms_ = p;
+ for (parameters::size_type i = 0, j = 1;
+ i < priv_->parms_.size();
+ ++i, ++j)
+ {
+ if (i == 0 && priv_->parms_[i]->get_artificial())
+ // If the first parameter is artificial, then it certainly
+ // means that this is a member function, and the first
+ // parameter is the implicit this pointer. In that case, set
+ // the index of that implicit parameter to zero. Otherwise,
+ // the index of the first parameter starts at one.
+ j = 0;
+ priv_->parms_[i]->set_index(j);
+ }
+}
/// Append a new parameter to the vector of parameters of the current
/// instance of @ref function_type.