PIPS
|
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects.h"
#include "effects-util.h"
#include "text-util.h"
#include "effects-simple.h"
#include "effects-generic.h"
#include "misc.h"
#include "pointer_values.h"
Go to the source code of this file.
Data Structures | |
struct | IntrinsicDescriptor |
The following data structure describes an intrinsic function: its name and its arity and its type, a function to type it (?) and a function to obtain its name if it is different from the entity user name, e.g. More... | |
Typedefs | |
typedef struct IntrinsicDescriptor | IntrinsicToPostPVDescriptor |
the following data structure describes an intrinsic function: its name and the function to apply on a call to this intrinsic to get the post pointer values of the call More... | |
Variables | |
static IntrinsicToPostPVDescriptor | IntrinsicToPostPVDescriptorTable [] |
typedef struct IntrinsicDescriptor IntrinsicToPostPVDescriptor |
the following data structure describes an intrinsic function: its name and the function to apply on a call to this intrinsic to get the post pointer values of the call
These intrinsics are arranged in the order of the standard ISO/IEC 9899:TC2. MB
|
static |
Definition at line 1485 of file pointer_values_intrinsics.c.
References CAR, CELL_INTERPRETATION, cell_interpretation_tag, EXPRESSION, expression_to_post_pv(), FOREACH, is_cell_interpretation_address_of, and pv_results::result_paths_interpretations.
|
static |
|
static |
Definition at line 1100 of file pointer_values_intrinsics.c.
References assignment_to_post_pv(), CAR, CDR, and EXPRESSION.
|
static |
|
static |
From ISO/IEC 9899:TC3 :
pointer arithmetic, the pointer is in the first expression
build new effects
Definition at line 1110 of file pointer_values_intrinsics.c.
References anywhere_effect_p(), array_type_p(), CAR, CDR, CELL_INTERPRETATION, CONS, copy_effect(), copy_expression(), EFFECT, effect_any_reference, ENDP, entity_domain, entity_local_name(), EXPRESSION, expression_to_post_pv(), expression_to_type(), expression_undefined, FOREACH, free_expression(), free_pv_results_paths(), free_type(), gen_find_tabulated(), gen_full_free_list(), gen_last(), gen_length(), gen_nreverse(), int, pv_results::l_out, make_cell_interpretation_address_of(), make_entity_fullname(), make_pv_results(), make_unbounded_expression(), MakeBinaryCall(), MakeUnaryCall(), MINUS_C_OPERATOR_NAME, NIL, pips_debug, pips_debug_pv_results, PLUS_C_OPERATOR_NAME, pointer_type_p(), reference_indices, pv_results::result_paths, pv_results::result_paths_interpretations, same_string_p, string_of_type(), TOP_LEVEL_MODULE_NAME, type_to_string(), type_variable, UNARY_MINUS_OPERATOR_NAME, and variable_dimensions.
|
static |
first argument is a FILE*
last argument is a FILE*
we assume that there is no effects on aliasing due to FILE* argument if any
Definition at line 1495 of file pointer_values_intrinsics.c.
References _IO_GETC_FUNCTION_NAME, _IO_PUTC_FUNCTION_NAME, C_REWIND_FUNCTION_NAME, CAR, CDR, CLEARERR_FUNCTION_NAME, CONS, ENDP, entity_local_name(), EXPRESSION, FCLOSE_FUNCTION_NAME, FEOF_FUNCTION_NAME, FERROR_FUNCTION_NAME, FGETC_FUNCTION_NAME, FGETPOS_FUNCTION_NAME, FGETS_FUNCTION_NAME, FPRINTF_FUNCTION_NAME, FPUTC_FUNCTION_NAME, FPUTS_FUNCTION_NAME, FREAD_FUNCTION_NAME, FSCANF_FUNCTION_NAME, FSEEK_FUNCTION_NAME, FSETPOS_FUNCTION_NAME, FTELL_FUNCTION_NAME, FWRITE_FUNCTION_NAME, gen_free_list(), GETC_FUNCTION_NAME, ISOC99_VFSCANF_FUNCTION_NAME, NIL, POP, PUTC_FUNCTION_NAME, safe_intrinsic_to_post_pv(), same_string_p, UNGETC_FUNCTION_NAME, VFPRINTF_FUNCTION_NAME, and VFSCANF_FUNCTION_NAME.
|
static |
but we have to evaluate the impact of the argument evaluation on pointer values eliminate local variables, retrieve the value of the returned pointer if any...
Definition at line 1853 of file pointer_values_intrinsics.c.
References CAR, ENDP, EXPRESSION, and expression_to_post_pv().
|
static |
|
static |
well, it should be a union, but there may not be such stupid things as (..)? a:a; I cannot use the effects test union operator because I must also merge interpretations
Definition at line 1382 of file pointer_values_intrinsics.c.
References CAR, effects_to_may_effects(), EXPRESSION, expression_to_post_pv(), gen_full_copy_list(), gen_full_free_list(), gen_nconc(), pv_results::l_out, make_pv_results(), pips_debug, pips_debug_pv_results, POP, pv_context::pvs_may_union_func, pv_results::result_paths, and pv_results::result_paths_interpretations.
|
static |
|
static |
free the result paths of the previous expression evaluation
Definition at line 1954 of file pointer_values_intrinsics.c.
References EXPRESSION, expression_to_post_pv(), FOREACH, free_pv_results_paths(), and pv_results::l_out.
|
static |
|
static |
Definition at line 1429 of file pointer_values_intrinsics.c.
References CAR, CELL_INTERPRETATION, cell_interpretation_tag, cell_interpretation_value_of_p, EFFECT, effect_add_dereferencing_dimension(), EXPRESSION, expression_to_post_pv(), FOREACH, is_cell_interpretation_value_of, POP, pv_results::result_paths, and pv_results::result_paths_interpretations.
|
static |
|
static |
Definition at line 1445 of file pointer_values_intrinsics.c.
References CAR, CDR, EFFECT, effect_add_field_dimension(), EXPRESSION, expression_syntax, expression_to_post_pv(), f(), FOREACH, pips_assert, pips_debug, reference_variable, pv_results::result_paths, syntax_reference, and syntax_reference_p.
|
static |
|
static |
for each freed pointer, find it's targets
try to find the heap location
try to find the heap target in remants
try first to find another target
try to find the heap location
assign an undefined_value to freed pointer
no flow or context sensitive variable found
FOREACH
Definition at line 1568 of file pointer_values_intrinsics.c.
References CELL_INTERPRETATION, cell_reference, CELL_RELATION, cell_relation_exact_p, cell_relation_first_cell, cell_relation_second_cell, cell_relation_undefined, cell_undefined, cell_undefined_p, CONS, copy_approximation(), copy_cell(), copy_cell_relation(), EFFECT, effect_any_reference, effect_approximation, effect_entity(), effect_find_equivalent_pointer_values(), effect_may_p, ENDP, entity_flow_or_context_sentitive_heap_location_p(), entity_name, FOREACH, free_pv_results_paths(), gen_free_list(), gen_full_free_list(), pv_results::l_out, make_action_write_memory(), make_approximation_exact(), make_approximation_may(), make_cell_interpretation_value_of(), make_descriptor_none(), make_effect(), make_undefined_pointer_value_cell(), NIL, pips_debug, pips_debug_effect, pips_debug_effects, pips_debug_pv, pips_debug_pvs, pointer_values_remove_var(), reference_variable, same_entity_p(), and single_pointer_assignment_to_post_pv().
Referenced by heap_intrinsic_to_post_pv().
|
static |
free the previously allocated path if need be
Then retrieve the allocated path if any
first, impact of argument evaluation on pointer values
Definition at line 1740 of file pointer_values_intrinsics.c.
References CALLOC_FUNCTION_NAME, CAR, CDR, CELL_INTERPRETATION, CONS, copy_expression(), EFFECT, effect_add_dereferencing_dimension(), effect_to_may_effect(), entity_all_heap_locations_p(), entity_all_module_heap_locations_p(), entity_intrinsic(), entity_local_name(), entity_scalar_p(), EXPRESSION, expression_to_post_pv(), expression_undefined, expression_undefined_p, free_expression(), FREE_FUNCTION_NAME, free_pv_results_paths(), free_to_post_pv(), gen_full_free_list(), get_current_module_entity(), int_to_expression(), pv_results::l_out, make_action_write_memory(), make_approximation_exact(), make_cell_interpretation_address_of(), make_cell_reference(), make_descriptor_none(), make_effect(), make_op_exp(), make_pv_results(), make_reference(), make_sensitivity_information(), MakeBinaryCall(), MakeUnaryCall(), MALLOC_FUNCTION_NAME, malloc_to_abstract_location(), NIL, PLUS_OPERATOR_NAME, pv_context_statement_head(), REALLOC_FUNCTION_NAME, pv_results::result_paths, pv_results::result_paths_interpretations, same_string_p, STRDUP_FUNCTION_NAME, and STRLEN_FUNCTION_NAME.
|
static |
Definition at line 1938 of file pointer_values_intrinsics.c.
References pv_results::l_out.
|
static |
void intrinsic_to_post_pv | ( | entity | func, |
list | func_args, | ||
list | l_in, | ||
pv_results * | pv_res, | ||
pv_context * | ctxt | ||
) |
func | unc |
func_args | unc_args |
l_in | _in |
pv_res | v_res |
ctxt | txt |
Definition at line 1969 of file pointer_values_intrinsics.c.
References entity_local_name(), IntrinsicToPostPVDescriptorTable, IntrinsicDescriptor::name, pips_debug, pips_debug_pv_results, pips_internal_error, and IntrinsicDescriptor::to_post_pv_function.
Referenced by call_to_post_pv().
|
static |
If it is a pure logical operator (&& or ||), there is a sequence point just after the evaluation of the first operand so we must evaluate the second operand in the memory store resulting from the evaluation of the first operand. If it's a relational operator, the evaluation order is not important, so let's do the same !
first operand
second operand
the resulting path of a relational expression is not a pointer value
Definition at line 1353 of file pointer_values_intrinsics.c.
References CAR, CDR, EXPRESSION, expression_to_post_pv(), free_pv_results_paths(), gen_full_free_list(), pv_results::l_out, make_pv_results(), NIL, pv_results::result_paths, and pv_results::result_paths_interpretations.
|
static |
|
static |
We add a dereferencing
we add the field dimension
Definition at line 1463 of file pointer_values_intrinsics.c.
References CAR, CDR, EFFECT, effect_add_dereferencing_dimension(), effect_add_field_dimension(), EXPRESSION, expression_syntax, expression_to_post_pv(), f(), FOREACH, pips_assert, pips_debug, reference_variable, pv_results::result_paths, syntax_reference, and syntax_reference_p.
|
static |
|
static |
first assume that all pointers reachable from arguments are written and set to anywhere
this should be quickly refined
well this is not safe in case of arguments with external function calls I should use the result paths of pv_res_arg, but there is a lot of work done in c_actual_argument_to_may_ summary_effect about arrays, and I'm not sure expression_to_post_pv does the same job
assume all pointers now point to anywhere
then retrieve the return value type to set pv_res->result_paths
if it is a pointer type, set it to anywhere for the moment specific work should be done for each intrinsic
Definition at line 1864 of file pointer_values_intrinsics.c.
References c_actual_argument_to_may_summary_effects(), CELL_INTERPRETATION, cell_to_type(), CONS, EFFECT, effect_cell, ENDP, EXPRESSION, expression_to_post_pv(), FOREACH, free_pv_results_paths(), free_type(), gen_full_free_list(), gen_nconc(), pv_results::l_out, make_action_write_memory(), make_anywhere_effect(), make_cell_interpretation_address_of(), make_pv_results(), NIL, pips_debug, pips_debug_effects, pips_debug_pv_results, pointer_type_p(), pv_results::result_paths, pv_results::result_paths_interpretations, and single_pointer_assignment_to_post_pv().
|
static |
Referenced by c_io_function_to_post_pv(), string_function_to_post_pv(), unix_io_function_to_post_pv(), and va_list_function_to_post_pv().
|
static |
Definition at line 1555 of file pointer_values_intrinsics.c.
References safe_intrinsic_to_post_pv().
|
static |
Definition at line 1279 of file pointer_values_intrinsics.c.
References CAR, EXPRESSION, expression_to_post_pv(), expression_to_type(), free_type(), ifdebug, pips_assert, and pointer_type_p().
|
static |
|
static |
Definition at line 1549 of file pointer_values_intrinsics.c.
References safe_intrinsic_to_post_pv().
|
static |
Definition at line 1945 of file pointer_values_intrinsics.c.
References pips_internal_error.
|
static |
|
static |
build rhs
_lhs_kind = CONS(CELL_INTERPRETATION, make_cell_interpretation_address_of(), NIL);
Definition at line 1295 of file pointer_values_intrinsics.c.
References anywhere_effect_p(), CAR, CELL_INTERPRETATION, CONS, copy_effect(), EFFECT, entity_local_name(), EXPRESSION, expression_to_post_pv(), expression_to_type(), expression_undefined, gen_full_free_list(), gen_length(), int_to_expression(), pv_results::l_out, make_cell_interpretation_address_of(), make_unbounded_expression(), NIL, pips_assert, pips_debug, pips_debug_pv_results, pointer_type_p(), POST_DECREMENT_OPERATOR_NAME, POST_INCREMENT_OPERATOR_NAME, PRE_DECREMENT_OPERATOR_NAME, PRE_INCREMENT_OPERATOR_NAME, pv_results::result_paths, same_string_p, and single_pointer_assignment_to_post_pv().
|
static |
Definition at line 1561 of file pointer_values_intrinsics.c.
References safe_intrinsic_to_post_pv().
|
static |
Definition at line 92 of file pointer_values_intrinsics.c.
Referenced by intrinsic_to_post_pv().