bool remove_const_function_pointerst::try_resolve_typecast_function_call( const typecast_exprt &typecast_expr, functionst &out_functions) { // We simply ignore typecasts and assume they are valid // I thought simplify_expr would deal with this, but for example // a cast from a 32 bit width int to a 64bit width int it doesn't seem // to allow functionst typecast_values; bool resolved= try_resolve_function_call(typecast_expr.op(), typecast_values); if(resolved) { out_functions.insert(typecast_values.begin(), typecast_values.end()); return true; } else { LOG("Failed to squash typecast", typecast_expr); return false; } }
bool remove_const_function_pointerst::try_resolve_function_calls( const expressionst &exprs, functionst &out_functions) { for(const exprt &value : exprs) { functionst potential_out_functions; bool resolved_value= try_resolve_function_call(value, potential_out_functions); if(resolved_value) { out_functions.insert( potential_out_functions.begin(), potential_out_functions.end()); } else { LOG("Could not resolve expression in array", value); return false; } } return true; }
bool remove_const_function_pointerst::try_resolve_function_call( const exprt &expr, functionst &out_functions) { assert(out_functions.empty()); const exprt &simplified_expr=simplify_expr(expr, ns); bool resolved=false; functionst resolved_functions; if(simplified_expr.id()==ID_index) { const index_exprt &index_expr=to_index_expr(simplified_expr); resolved=try_resolve_index_of_function_call(index_expr, resolved_functions); } else if(simplified_expr.id()==ID_member) { const member_exprt &member_expr=to_member_expr(simplified_expr); resolved=try_resolve_member_function_call(member_expr, resolved_functions); } else if(simplified_expr.id()==ID_address_of) { address_of_exprt address_expr=to_address_of_expr(simplified_expr); resolved=try_resolve_address_of_function_call( address_expr, resolved_functions); } else if(simplified_expr.id()==ID_dereference) { const dereference_exprt &deref=to_dereference_expr(simplified_expr); resolved=try_resolve_dereference_function_call(deref, resolved_functions); } else if(simplified_expr.id()==ID_typecast) { typecast_exprt typecast_expr=to_typecast_expr(simplified_expr); resolved= try_resolve_typecast_function_call(typecast_expr, resolved_functions); } else if(simplified_expr.id()==ID_symbol) { if(simplified_expr.type().id()==ID_code) { resolved_functions.insert(simplified_expr); resolved=true; } else { LOG("Non const symbol wasn't squashed", simplified_expr); resolved=false; } } else { LOG("Unrecognised expression", simplified_expr); resolved=false; } if(resolved) { out_functions.insert(resolved_functions.begin(), resolved_functions.end()); return true; } else { return false; } }