MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / set_function_parameters

Function set_function_parameters

src/backward.h:2999–3097  ·  view source on GitHub ↗

Resolve the function return type and parameters

Source from the content-addressed store, hash-verified

2997
2998 // Resolve the function return type and parameters
2999 static void set_function_parameters(
3000 std::string& function_name,
3001 std::vector<std::string>& ns,
3002 dwarf_fileobject& fobj,
3003 Dwarf_Die die)
3004 {
3005 Dwarf_Debug dwarf = fobj.dwarf_handle.get();
3006 Dwarf_Error error = DW_DLE_NE;
3007 Dwarf_Die current_die = 0;
3008 std::string parameters;
3009 bool has_spec = true;
3010 // Check if we have a spec DIE. If we do we use it as it contains
3011 // more information, like parameter names.
3012 Dwarf_Die spec_die = get_spec_die(fobj, die);
3013 if (!spec_die) {
3014 has_spec = false;
3015 spec_die = die;
3016 }
3017
3018 std::vector<std::string>::const_iterator it = ns.begin();
3019 std::string ns_name;
3020 for (it = ns.begin(); it < ns.end(); ++it) {
3021 ns_name.append(*it).append("::");
3022 }
3023
3024 if (!ns_name.empty()) {
3025 function_name.insert(0, ns_name);
3026 }
3027
3028 // See if we have a function return type. It can be either on the
3029 // current die or in its spec one (usually true for inlined functions)
3030 std::string return_type = get_referenced_die_name(dwarf, die, DW_AT_type, true);
3031 if (return_type.empty()) {
3032 return_type = get_referenced_die_name(dwarf, spec_die, DW_AT_type, true);
3033 }
3034 if (!return_type.empty()) {
3035 return_type.append(" ");
3036 function_name.insert(0, return_type);
3037 }
3038
3039 if (dwarf_child(spec_die, &current_die, &error) == DW_DLV_OK) {
3040 for (;;) {
3041 Dwarf_Die sibling_die = 0;
3042
3043 Dwarf_Half tag_value;
3044 dwarf_tag(current_die, &tag_value, &error);
3045
3046 if (tag_value == DW_TAG_formal_parameter) {
3047 // Ignore artificial (ie, compiler generated) parameters
3048 bool is_artificial = false;
3049 Dwarf_Attribute attr_mem;
3050 if (dwarf_attr(current_die, DW_AT_artificial, &attr_mem, &error) == DW_DLV_OK) {
3051 Dwarf_Bool flag = 0;
3052 if (dwarf_formflag(attr_mem, &flag, &error) == DW_DLV_OK) {
3053 is_artificial = flag != 0;
3054 }
3055 dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR);
3056 }

Callers 1

operator()Method · 0.85

Calls 6

get_spec_dieFunction · 0.85
get_referenced_die_nameFunction · 0.85
set_parameter_stringFunction · 0.85
getMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected