static void print_function(const_tree caller, const_tree callee) { expanded_location xloc; const char *caller_name, *callee_name; gcc_assert(callee != NULL_TREE); if (DECL_ABSTRACT_ORIGIN(callee) != NULL_TREE) return; callee_name = DECL_NAME_POINTER(callee); gcc_assert(caller != NULL_TREE); caller_name = DECL_NAME_POINTER(caller); xloc = expand_location(DECL_SOURCE_LOCATION(caller)); fprintf(stderr, "DUMP_CFG:%s:%s:%s\n", caller_name, callee_name, xloc.file); }
const char *get_orig_decl_name(const_tree decl) { const char *name; unsigned int len; const void *end; const_tree orig_decl; if (TREE_CODE(decl) == FUNCTION_DECL) orig_decl = DECL_ORIGIN(decl); else orig_decl = decl; len = DECL_NAME_LENGTH(orig_decl); name = DECL_NAME_POINTER(orig_decl); /* Sometimes gcc loses the original cgraph node leaving only clones behind. * In such cases we will extract the name from the clone and use it in the hash table * without checking the parameter number on the original (unavailable) decl. */ if (made_by_compiler(orig_decl)) { end = memchr(name, '.', len); if (!end) return xstrndup(name, len); len = (long)end - (long)name; gcc_assert(len > 0); } return xstrndup(name, len); }
static void search_local_strs(bool initexit) { unsigned int i; tree var; FOR_EACH_LOCAL_DECL(cfun, i, var) { tree str, init_val = DECL_INITIAL(var); if (init_val == NULL_TREE) continue; if (strcmp(DECL_NAME_POINTER(var), "__func__")) continue; str = get_string_cst(init_val); gcc_assert(str); if (set_init_exit_section(var, initexit) && verbose) inform(DECL_SOURCE_LOCATION(var), "initified local var: %s: %s", DECL_NAME_POINTER(current_function_decl), TREE_STRING_POINTER(str)); }
unsigned int find_arg_number_tree(const_tree arg, const_tree func) { tree var; unsigned int argnum = 1; if (DECL_ARGUMENTS(func) == NULL_TREE) return CANNOT_FIND_ARG; if (TREE_CODE(arg) == SSA_NAME) arg = SSA_NAME_VAR(arg); for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) { if (!operand_equal_p(arg, var, 0) && strcmp(DECL_NAME_POINTER(var), DECL_NAME_POINTER(arg))) continue; if (!skip_types(var)) return argnum; } return CANNOT_FIND_ARG; }
static bool is_interesting_function(const_tree decl, unsigned int num) { const struct size_overflow_hash *so_hash; if (get_global_next_interesting_function_entry_with_hash(decl, DECL_NAME_POINTER(decl), num, YES_SO_MARK)) return true; if (made_by_compiler(decl)) return false; so_hash = get_size_overflow_hash_entry_tree(decl, num); return so_hash != NULL; }
static unsigned int cyc_complexity_execute(void) { int complexity; expanded_location xloc; /* M = E - N + 2P */ complexity = n_edges_for_fn(cfun) - n_basic_blocks_for_fn(cfun) + 2; xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl)); fprintf(log_file, "%s%s:%d:%d:%s\t%d\n", has_log_file ? "" : "Cyclomatic Complexity ", xloc.file, xloc.line, xloc.column, DECL_NAME_POINTER(current_function_decl), complexity); return 0; }