X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=ir%2Fana%2Fcgana.c;h=759e9af5721993645b50a99bdec077b519d9f05d;hb=d6822bc0573f5571a07ff7208114a4c7f0d6ceaa;hp=76c152cce9b8117511a529fbe6ed3b511af2592d;hpb=916caec9328586dd9922020233ae419aa29facea;p=libfirm diff --git a/ir/ana/cgana.c b/ir/ana/cgana.c index 76c152cce..759e9af57 100644 --- a/ir/ana/cgana.c +++ b/ir/ana/cgana.c @@ -119,9 +119,8 @@ static ir_entity **get_impl_methods(ir_entity *method) /* no overwriting methods found */ arr = NULL; } else { - ir_entity * ent; arr = NEW_ARR_F(ir_entity *, size); - foreach_pset(set, ir_entity*, ent) { + foreach_pset(set, ir_entity, ent) { arr[--size] = ent; } } @@ -250,14 +249,11 @@ static void sel_methods_init(void) static ir_entity ** get_Sel_arr(ir_node * sel) { static ir_entity ** NULL_ARRAY = NULL; - ir_entity * ent; - ir_entity ** arr; - - assert(is_Sel(sel)); - ent = get_Sel_entity(sel); + ir_entity *const ent = get_Sel_entity(sel); assert(is_Method_type(get_entity_type(ent))); /* what else? */ - arr = (ir_entity**) get_entity_link(ent); + + ir_entity **const arr = (ir_entity**)get_entity_link(ent); if (arr) { return arr; } else { @@ -511,19 +507,6 @@ static void add_method_address(ir_entity *ent, pset *set) if (ent->initializer != NULL) { add_method_address_inititializer(get_entity_initializer(ent), set); - } else if (entity_has_compound_ent_values(ent)) { - size_t i, n; - for (i = 0, n = get_compound_ent_n_values(ent); i < n; ++i) { - ir_node *irn = get_compound_ent_value(ent, i); - - /* let's check if it's the address of a function */ - if (is_SymConst_addr_ent(irn)) { - ir_entity *ent2 = get_SymConst_entity(irn); - - if (is_Method_type(get_entity_type(ent2))) - pset_insert_ptr(set, ent2); - } - } } } @@ -542,7 +525,6 @@ static size_t get_free_methods(ir_entity ***free_methods) pset *free_set = pset_new_ptr_default(); size_t i, n, j, m; ir_entity **arr; - ir_entity *ent; ir_graph *irg; ir_type *tp; size_t length; @@ -550,7 +532,7 @@ static size_t get_free_methods(ir_entity ***free_methods) for (i = 0, n = get_irp_n_irgs(); i < n; ++i) { ir_linkage linkage; irg = get_irp_irg(i); - ent = get_irg_entity(irg); + ir_entity *const ent = get_irg_entity(irg); linkage = get_entity_linkage(ent); if ((linkage & IR_LINKAGE_HIDDEN_USER) || entity_is_externally_visible(ent)) { @@ -567,12 +549,12 @@ static size_t get_free_methods(ir_entity ***free_methods) /* insert all methods that are used in global variables initializers */ tp = get_glob_type(); for (j = 0, m = get_class_n_members(tp); j < m; ++j) { - ent = get_class_member(tp, j); + ir_entity *const ent = get_class_member(tp, j); add_method_address(ent, free_set); } tp = get_tls_type(); for (j = 0, m = get_compound_n_members(tp); j < m; ++j) { - ent = get_compound_member(tp, j); + ir_entity *const ent = get_compound_member(tp, j); add_method_address(ent, free_set); } @@ -585,7 +567,7 @@ static size_t get_free_methods(ir_entity ***free_methods) length = pset_count(free_set); arr = XMALLOCN(ir_entity*, length); i = 0; - foreach_pset(free_set, ir_entity*, ent) { + foreach_pset(free_set, ir_entity, ent) { arr[i++] = ent; } del_pset(free_set); @@ -619,7 +601,7 @@ static void callee_ana_proj(ir_node *node, long n, pset *methods) if (is_Tuple(pred)) { callee_ana_proj(get_Tuple_pred(pred, get_Proj_proj(node)), n, methods); } else { - pset_insert_ptr(methods, unknown_entity); /* free method -> unknown */ + pset_insert_ptr(methods, get_unknown_entity()); /* free method -> unknown */ } } break; @@ -630,7 +612,7 @@ static void callee_ana_proj(ir_node *node, long n, pset *methods) break; default: - pset_insert_ptr(methods, unknown_entity); /* free method -> unknown */ + pset_insert_ptr(methods, get_unknown_entity()); /* free method -> unknown */ break; } } @@ -655,7 +637,7 @@ static void callee_ana_node(ir_node *node, pset *methods) case iro_Const: /* A direct address call. We tread this as an external call and ignore it completely. */ - pset_insert_ptr(methods, unknown_entity); /* free method -> unknown */ + pset_insert_ptr(methods, get_unknown_entity()); /* free method -> unknown */ break; case iro_SymConst: { @@ -673,7 +655,7 @@ static void callee_ana_node(ir_node *node, pset *methods) if (ent != NULL) { pset_insert_ptr(methods, ent); } else { - pset_insert_ptr(methods, unknown_entity); + pset_insert_ptr(methods, get_unknown_entity()); } } break; @@ -708,7 +690,7 @@ static void callee_ana_node(ir_node *node, pset *methods) case iro_Sub: case iro_Conv: /* extern */ - pset_insert_ptr(methods, unknown_entity); /* free method -> unknown */ + pset_insert_ptr(methods, get_unknown_entity()); /* free method -> unknown */ break; default: @@ -726,19 +708,18 @@ static void callee_walker(ir_node *call, void *env) (void) env; if (is_Call(call)) { pset *methods = pset_new_ptr_default(); - ir_entity *ent; ir_entity **arr; size_t i; callee_ana_node(get_Call_ptr(call), methods); arr = NEW_ARR_F(ir_entity*, pset_count(methods)); i = 0; - foreach_pset(methods, ir_entity*, ent) { + foreach_pset(methods, ir_entity, ent) { arr[i] = ent; /* we want the unknown_entity on the zero position for easy tests later */ - if (ent == unknown_entity) { + if (is_unknown_entity(ent)) { arr[i] = arr[0]; - arr[0] = unknown_entity; + arr[0] = get_unknown_entity(); } ++i; } @@ -786,9 +767,8 @@ static void callee_ana(void) /** Frees intermediate data structures. */ static void sel_methods_dispose(void) { - ir_entity * ent; assert(entities); - foreach_pset(entities, ir_entity*, ent) { + foreach_pset(entities, ir_entity, ent) { ir_entity **arr = (ir_entity**) get_entity_link(ent); if (arr != NULL) { DEL_ARR_F(arr);