MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / set_function_parameters

Function set_function_parameters

external/include/backward/backward.hpp:2974–3069  ·  view source on GitHub ↗

Resolve the function return type and parameters

Source from the content-addressed store, hash-verified

2972
2973 // Resolve the function return type and parameters
2974 static void set_function_parameters(std::string &function_name,
2975 std::vector<std::string> &ns,
2976 dwarf_fileobject &fobj, Dwarf_Die die) {
2977 Dwarf_Debug dwarf = fobj.dwarf_handle.get();
2978 Dwarf_Error error = DW_DLE_NE;
2979 Dwarf_Die current_die = 0;
2980 std::string parameters;
2981 bool has_spec = true;
2982 // Check if we have a spec DIE. If we do we use it as it contains
2983 // more information, like parameter names.
2984 Dwarf_Die spec_die = get_spec_die(fobj, die);
2985 if (!spec_die) {
2986 has_spec = false;
2987 spec_die = die;
2988 }
2989
2990 std::vector<std::string>::const_iterator it = ns.begin();
2991 std::string ns_name;
2992 for (it = ns.begin(); it < ns.end(); ++it) {
2993 ns_name.append(*it).append("::");
2994 }
2995
2996 if (!ns_name.empty()) {
2997 function_name.insert(0, ns_name);
2998 }
2999
3000 // See if we have a function return type. It can be either on the
3001 // current die or in its spec one (usually true for inlined functions)
3002 std::string return_type =
3003 get_referenced_die_name(dwarf, die, DW_AT_type, true);
3004 if (return_type.empty()) {
3005 return_type = get_referenced_die_name(dwarf, spec_die, DW_AT_type, true);
3006 }
3007 if (!return_type.empty()) {
3008 return_type.append(" ");
3009 function_name.insert(0, return_type);
3010 }
3011
3012 if (dwarf_child(spec_die, &current_die, &error) == DW_DLV_OK) {
3013 for (;;) {
3014 Dwarf_Die sibling_die = 0;
3015
3016 Dwarf_Half tag_value;
3017 dwarf_tag(current_die, &tag_value, &error);
3018
3019 if (tag_value == DW_TAG_formal_parameter) {
3020 // Ignore artificial (ie, compiler generated) parameters
3021 bool is_artificial = false;
3022 Dwarf_Attribute attr_mem;
3023 if (dwarf_attr(current_die, DW_AT_artificial, &attr_mem, &error) ==
3024 DW_DLV_OK) {
3025 Dwarf_Bool flag = 0;
3026 if (dwarf_formflag(attr_mem, &flag, &error) == DW_DLV_OK) {
3027 is_artificial = flag != 0;
3028 }
3029 dwarf_dealloc(dwarf, attr_mem, DW_DLA_ATTR);
3030 }
3031

Callers 1

operator()Method · 0.85

Calls 9

get_spec_dieFunction · 0.85
get_referenced_die_nameFunction · 0.85
set_parameter_stringFunction · 0.85
getMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
appendMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected