PIPS
|
#include "c_parser_private.h"
Go to the source code of this file.
Macros | |
#define | get_label_prefix() "-" |
The labels in C have function scope... More... | |
#define | FIRST_C_LINE_NUMBER (1) |
Error handling. More... | |
#define | UNDEFINED_C_LINE_NUMBER (-1) |
#define | CParserError(m) c_parser_error(CURRENT_FUNCTION, m) |
#define | c_parser_user_warning(...) c_parser_user_warning_func(CURRENT_FUNCTION, __FILE__, __LINE__, __VA_ARGS__) |
Functions | |
int | c_lex () |
int | c_parse () |
entity | GetFunction (void) |
cproto workaround More... | |
void | reset_expression_comment (void) |
we don't want an expression comment with new lines, it is disgracefull More... | |
string | pop_block_scope (string) |
The scope is moved up the scope tree and a NULL is return when there are no more scope to explore. More... | |
string | scope_to_block_scope (string) |
Allocate a new string containing only block scope information. More... | |
c_parser_context | CreateDefaultContext (void) |
void | InitScope (void) |
int | ScopeStackSize (void) |
string | GetScope (void) |
string | GetParentScope (void) |
void | ExitScope (void) |
void | PushContext (c_parser_context) |
void | PopContext (void) |
c_parser_context | GetContext (void) |
c_parser_context | GetContextCopy (void) |
void | reset_declaration_counter (void) |
int | get_declaration_counter (void) |
void | init_c_parser_scope_stack (void) |
void | reset_c_parser_scope_stack (void) |
void | force_reset_c_parser_scope_stack (void) |
To be used by an error handler. More... | |
void | push_new_c_parser_scope (void) |
void | pop_c_parser_scope_stack (void) |
bool | c_parser_scope_stack_empty_p (void) |
string | get_c_parser_current_scope (void) |
string | get_c_parser_nth_scope (int) |
int | c_parser_number_of_scopes (void) |
int | get_previous_c_lineno (void) |
unsigned int | character_occurences_in_string (string, char) |
Use a stack to survive to file inclusions if any. More... | |
int | get_current_C_line_number (void) |
int | get_previous_C_line_number (void) |
Should be called just before get_current_C_line_number. More... | |
void | set_current_C_line_number (void) |
void | push_current_C_line_number (void) |
The line number stack, designed for structured control structure, is not used yet. More... | |
int | pop_current_C_line_number (void) |
void | reset_current_C_line_number (void) |
void | error_reset_current_C_line_number (void) |
void | reset_token_has_been_seen_p (void) |
string | get_current_C_comment (void) |
Return the current comment as a string to be freed by the caller and reset the current comment. More... | |
void | push_current_C_comment (void) |
Push the current C comment so that we can get it back when building the statement later. More... | |
string | pop_current_C_comment (void) |
Pop the current comment. More... | |
void | update_C_comment (string) |
Add a comment to the current one. More... | |
void | remove_LFs_from_C_comment (int) |
Remove "extra_LF" trailing LF from C_current_comment if they can be found at the end of the comment string. More... | |
void | discard_C_comment (void) |
Discard a C comment because we don't know how to deal with it. More... | |
void | reset_C_comment (bool) |
reset and reset_error should be handled differently More... | |
void | error_reset_C_comment (bool) |
void | clear_C_comment (void) |
void | init_C_comment (void) |
void | c_error (char *) |
void | c_reset_lex (void) |
int | c_wrap (void) |
string | get_c_parser_current_input_file_name (void) |
void | set_c_parser_current_input_file_name (string) |
void | reset_c_parser_current_input_file_name (void) |
void | error_reset_c_parser_current_input_file_name (void) |
string | get_c_parser_current_user_input_file_name (void) |
void | set_c_parser_current_user_input_file_name (string) |
void | reset_c_parser_current_user_input_file_name (void) |
void | error_reset_c_parser_current_user_input_file_name (void) |
void | init_entity_type_storage_table (void) |
void | put_to_entity_type_stack_table (entity, stack value) |
stack | get_from_entity_type_stack_table (entity) |
void | remove_entity_type_stack (entity) |
void | remove_entity_type_stacks (list) |
void | reset_entity_type_stack_table (void) |
void | parser_init_keyword_typedef_table (void) |
bool | c_parser_error (const char *, const char *) |
Output a parser message error. More... | |
void | make_predefined_C_entities (string) |
bool | c_parser (const char *) |
bool | compilation_unit_parser (const char *) |
void | MakeCurrentModule (entity) |
is used for switch statements also, because we do not distinguish a break in a loop or a switch More... | |
void | ResetCurrentModule (void) |
void | InitializeBlock (void) |
statement | MakeBlock (list) |
Create a block statement. More... | |
statement | FindStatementFromLabel (entity) |
statement | MakeLabeledStatement (string, statement, string) |
Construct a new statement from. More... | |
statement | MakeGotoStatement (string) |
entity | MakeCLabel (string) |
statement | MakeWhileLoop (list, statement, bool) |
statement | MakeForloop (expression, expression, expression, statement) |
Create a for-loop statement with some parser-specific characteristics. More... | |
statement | MakeForloopWithIndexDeclaration (list, expression, expression, statement) |
Create a C99 for-loop statement with a declaration as first parameter in the for clause, with some parser-specific characteristics. More... | |
statement | MakeSwitchStatement (statement) |
statement | MakeCaseStatement (expression) |
Transform. More... | |
statement | MakeDefaultStatement (void) |
statement | MakeBreakStatement (string) |
statement | MakeContinueStatement (string) |
statement | ExpressionToStatement (expression) |
e is now owned by returned statement More... | |
list | add_prettyprint_control_list_to_declaration_statement (statement, list) |
The control list is hidden as arguments to the call to CONTROL in the declaration statement s. More... | |
void | set_prettyprint_control_list_to_extern (void) |
bool | extern_prettyprint_control_list_p (void) |
void reset_prettyprint_control_list_to_extern(void) More... | |
void | set_prettyprint_control_list_to_dummy (void) |
bool | dummy_prettyprint_control_list_p (void) |
Provide the information only once. More... | |
void | c_parser_user_warning_alist (const char *, const char *, const int, const char *, va_list *) |
util.c More... | |
void | c_parser_user_warning_func (const char *, const char *, const int, const char *,...) |
void | reset_current_dummy_parameter_number (void) |
entity | get_top_level_entity (void) |
void | MakeTopLevelEntity (void) |
void | init_c_areas (void) |
In C we have 4 areas. More... | |
entity | make_C_constant_entity (string, tag, size_t) |
void | init_c_implicit_variables (entity) |
entity | get_current_compilation_unit_entity (void) |
void | MakeCurrentCompilationUnitEntity (const char *) |
A compilation unit is also considered as a module. More... | |
void | ResetCurrentCompilationUnitEntity (bool) |
expression | MakeFunctionExpression (expression, list) |
e is now owned by returned expression and must not be used any longer More... | |
expression | MemberDerivedIdentifierToExpression (type, string) |
expression | MemberIdentifierToExpression (expression, string) |
expression | IdentifierToExpression (string) |
expression | MakeArrayExpression (expression, list) |
FI: this function is called for a bracketed comma expression. More... | |
entity | FindEntityFromLocalName (string) |
entity | FindOrCreateEntityFromLocalNameAndPrefix (string, string, bool) |
entity | FindOrCreateEntityFromLocalNameAndPrefixAndScope (string, string, string, bool) |
entity | FindEntityFromLocalNameAndPrefixAndScope (string, string, string) |
The parameter "scope" is potentially destroyed. More... | |
entity | FindEntityFromLocalNameAndPrefix (string, string) |
entity | CreateEntityFromLocalNameAndPrefix (string, string, bool) |
bool | CheckExternList (void) |
void | c_parser_put_new_typedef (const char *) |
Store named type for the lexical analyzer, which has to decide if a character string is the name of a type or the name of a variable. More... | |
void | put_new_typedef (const char *) |
This function is used by libraries "step"* and "task_parallelization". More... | |
entity | FindOrCreateCurrentEntity (string, stack, stack, stack, bool) |
void | UpdateParenEntity (entity, list) |
dimension | MakeDimension (list, list) |
type | UpdateFinalPointer (type, type) |
void | UpdatePointerEntity (entity, type, list) |
void | UpdateArrayEntity (entity, list, list) |
entity | RenameFunctionEntity (entity) |
Rename function oe if necessary. More... | |
void | UpdateFunctionEntity (entity, list) |
The parser has found out that an entity is a function and partially sets its type. More... | |
type | UpdateType (type, type) |
This function replaces the undefined field in t1 by t2. More... | |
void | CCompilationUnitMemoryAllocations (entity, bool) |
This function allocates the memory to the Current Compilation Unit. More... | |
void | CCompilationUnitMemoryAllocation (entity) |
void | CCompilationUnitMemoryReallocation (entity) |
void | CModuleMemoryAllocation (entity) |
This function is for MemoryAllocation for Module of C programs. More... | |
void | UseDummyArguments (entity) |
If f has regular formal parameters, destroy them. More... | |
void | UseFormalArguments (entity) |
If f has dummy formal parameters, replace them by standard formal parameters. More... | |
void | RemoveDummyArguments (entity, list) |
To chase formals in type declarations. More... | |
void | SubstituteDummyParameters (entity, list) |
void | CreateReturnEntity (entity) |
If necessary, create the return entity, which is a hidden variable used in PIPS internal representation to carry the value returned by a function. More... | |
void | UpdateEntity2 (entity, stack, stack) |
void | UpdateEntity (entity, stack, stack, stack, stack, bool, bool) |
Update the entity with final type, storage and initial value; and also (sometimes?) declare it at the module level. More... | |
void | UpdateEntities (list, stack, stack, stack, stack, bool, bool) |
void | CleanUpEntities (list) |
void | UpdateAbstractEntity (entity, stack) |
void | RemoveFromExterns (entity) |
void | AddToExterns (entity, entity) |
void | AddToDeclarations (entity, entity) |
FI: check the difference with AddEntityToDeclarations() More... | |
void | UpdateDerivedEntity (list, entity, stack) |
list | TakeDerivedEntities (list) |
void | UpdateDerivedEntities (list, list, stack) |
void | InitializeEnumMemberValues (list) |
entity | MakeDerivedEntity (string, list, bool, int) |
storage | MakeStorageRam (entity, bool, bool) |
The storage part should not be called twice when reparsing compilation unit. More... | |
string | CreateMemberScope (string, bool) |
value | MakeEnumeratorInitialValue (list, int) |
int | ComputeAreaOffset (entity, entity) |
list | MakeParameterList (list, list, stack) |
parameter | FindParameterEntity (string, int, list) |
void | AddToCalledModules (entity) |
void | NStackPop (stack, int) |
Pop n times the stack s. More... | |
void | StackPop (stack) |
The OffsetStack is poped n times, where n is the number of formal arguments of the actual function. More... | |
void | StackPush (stack) |
The OffsetStack is pushed incrementally. More... | |
void | set_entity_initial (entity, expression) |
Be careful if the initial value has already been set. More... | |
bool | check_declaration_uniqueness_p (statement) |
This is designed for standard C functions, not for compilation units. More... | |
list | insert_qualifier (list, qualifier) |
if qualifier "nq" does not already belong to qualifier list "ql", add it in front of the list. More... | |
void | reset_preprocessor_line_analysis (void) |
int | analyze_preprocessor_line (string, int) |
Analyze information about user line number provided by the C preprocessor and by PIPS file splitter and return the C line number in the source file. More... | |
entity | Generate_C_ReturnLabel (entity) |
return.c More... | |
statement | Generate_C_ReturnStatement (void) |
void | Reset_C_ReturnStatement (void) |
The return statement must be reset when it is used by the parser to add the return statement to the function body or when a parser error is encountered. More... | |
statement | Get_C_ReturnStatement (void) |
This function is used to generate all goto's towards the unique return used to C replace return statement and to insert this unique return at the end of the current function's body. More... | |
statement | C_MakeReturnStatement (list, int, string) |
This function creates a goto instruction to label end_label. More... | |
int | GetReturnNumber (void) |
void | FixCReturnStatements (statement) |
When return statements have been encountered, each of them has been replaced by a goto to a unique return statement. More... | |
void | c_restart (FILE *) |
void | c_pop_buffer_state (void) |
int | c_get_lineno (void) |
FILE * | c_get_in (void) |
FILE * | c_get_out (void) |
int | c_get_leng (void) |
char * | c_get_text (void) |
void | c_set_lineno (int) |
void | c_set_in (FILE *) |
void | c_set_out (FILE *) |
int | c_get_debug (void) |
void | c_set_debug (int) |
int | c_lex_destroy (void) |
void * | c_alloc (yy_size_t) |
void * | c_realloc (void *, yy_size_t) |
void | c_free (void *) |
#define c_parser_user_warning | ( | ... | ) | c_parser_user_warning_func(CURRENT_FUNCTION, __FILE__, __LINE__, __VA_ARGS__) |
Definition at line 63 of file c_syntax.h.
#define CParserError | ( | m | ) | c_parser_error(CURRENT_FUNCTION, m) |
Definition at line 62 of file c_syntax.h.
#define FIRST_C_LINE_NUMBER (1) |
Error handling.
Definition at line 59 of file c_syntax.h.
#define get_label_prefix | ( | ) | "-" |
The labels in C have function scope...
but beware of inlining... and conflict with user labels To disambiguate labels, in case inlining is performed later and to suppress the potential for conflicts with user labels.
Temporary entities have to be generated to be replaced later by the final labels. The temporary entities should be eliminated from the symbol table...
Definition at line 49 of file c_syntax.h.
#define UNDEFINED_C_LINE_NUMBER (-1) |
Definition at line 60 of file c_syntax.h.
list add_prettyprint_control_list_to_declaration_statement | ( | statement | s, |
list | initialization_expressions | ||
) |
The control list is hidden as arguments to the call to CONTROL in the declaration statement s.
It is made of 0 and 1 constant expressions.
The first element tells the prettyprinter if the "extern" keyword must be printed out.
The next expressions tells the prettyprinter which variables should be initialized by this statement.
The control list for the initializations is built by the C parser, cyacc.y.
This is only useful for global variables which can be declared multiple times in multiple files and in multiple ways. See Prettyprint/double_declaration01-14.c.
The parser generated the initialization control list backwards
Try to patch the initialization list for derived entities assuming that derived entities are located anywhere in the declaration list. See decl64-65 and struct14-15.c
Place holder variables have been removed. Even if a compilation unit is being parsed, initialization_expressions should have no impact.
The initialization list is OK
We could assert here than in = dn, but this is asserted below with more explanations. However, only in debug mode 8.
Preserve the "extern" information right away before the C parser updates it each time it encounters a global declaration.
An extern declaration?
Provide debugging information
Build the prettyprint control list: extern first and the initializations
Update the declaration statement
initialization_expressions | nitialization_expressions |
Definition at line 919 of file statement.c.
References add_initialization_information_to_declaration_statement(), CAR, CDR, CONS, derived_entity_p(), dummy_prettyprint_control_list_p(), ENDP, ENTITY, entity_user_name(), EXPRESSION, extern_declaration_p, extern_prettyprint_control_list_p(), FOREACH, fprintf(), gen_free_list(), gen_full_free_list(), gen_length(), gen_nreverse(), ifdebug, initialization_expressions, int, int_to_expression(), NIL, pips_assert, pips_internal_error, POP, print_entities(), print_expressions(), statement_declarations, and typedef_entity_p().
void AddToCalledModules | ( | entity | e | ) |
Definition at line 3413 of file util.c.
References CalledModules, CONS, entity_local_name(), intrinsic_entity_p(), MAP, pips_debug, strdup(), and STRING.
Referenced by MakeFunctionExpression().
FI: check the difference with AddEntityToDeclarations()
Here, the declared entity is added to the module declarations only.
mod | od |
Definition at line 2924 of file util.c.
References code_declarations, CONS, ENTITY, entity_initial, entity_name, entity_user_name(), gen_in_list_p(), gen_nconc(), NIL, pips_debug, and value_code.
Referenced by CreateReturnEntity(), MakeFunctionExpression(), MakeParameterList(), and UpdateEntity().
mod | od |
Definition at line 2898 of file util.c.
References code_externs, CONS, ENTITY, entity_domain, entity_domain_number, entity_initial, entity_list_p(), entity_user_name(), gen_in_list_p(), gen_nconc(), NIL, pips_assert, pips_debug, and value_code.
Referenced by FindOrCreateCurrentEntity(), and UpdateEntity().
Analyze information about user line number provided by the C preprocessor and by PIPS file splitter and return the C line number in the source file.
We do not have specs and must evolve with C preprocessors such as cpp.
We assume that information about the lines in the included files is only provided for compilation unit.
We assume that information about user line in a module is always related to the user source file, and that the first line has been generated by PIPS file splitter with syntax "x nnn", with no information about the user source file name.
See examples line00.c, line01.c, line02.c and line03.c. And do not forget cominc02 for the compilation unit case. And missing01.c for synthesized code.
More examples needed for include lines placed within a function body, with C code or preprocessor definitions: line04 and line05.
the C preprocessors, such as cpp, and PIPS file splitter provide line information in pragmas which are not line pragmas.
Not too sure about C source code generated by PIPS by passes initializer, clone, outlining, inlinging...
strstr(line, "#line")==line &&
Not to sure about this case
The next lines have been imported from an included file. Ignore information about include files, preserve the current C_line_number.
Not to sure about this case: internal error?
line | ine |
C_line_number | _line_number |
Definition at line 3617 of file util.c.
References buffer, buffer_initialized_p, C_line_increment, C_line_number, compilation_unit_parser_is_running_p, CParserError(), line, pips_debug, pips_user_warning, remove_LFs_from_C_comment(), and same_string_p.
void* c_alloc | ( | yy_size_t | ) |
void c_error | ( | char * | ) |
void c_free | ( | void * | ) |
int c_get_debug | ( | void | ) |
FILE* c_get_in | ( | void | ) |
int c_get_leng | ( | void | ) |
int c_get_lineno | ( | void | ) |
FILE* c_get_out | ( | void | ) |
char* c_get_text | ( | void | ) |
int c_lex | ( | ) |
int c_lex_destroy | ( | void | ) |
This function creates a goto instruction to label end_label.
This is done to eliminate return statements.
Note: I was afraid the mouse trap would not work to analyze multiple procedures but there is no problem. I guess that MakeGotoInst() generates the proper label entity regardless of end_label. FI. Generates the internal representation of a C return statement. If e is an undefined expression, a goto returnlabel is generated. Else, e is assigned to the return value of the current function, a goto is generated and both are returned within a block.
Assign the expression to the return value of the current function
el | l |
ln | n |
Definition at line 155 of file return.c.
References CAR, CDR, CONS, empty_extensions(), ENDP, entity_empty_label(), entity_to_expression(), EXPRESSION, f(), function_to_return_value(), Get_C_ReturnStatement(), get_current_module_entity(), instruction_consistent_p(), instruction_to_statement(), instruction_undefined, instruction_undefined_p, last_return_value_assignment, last_returned_value, make_assign_instruction(), make_instruction_block(), make_instruction_goto(), make_statement(), make_synchronization_none(), NIL, pips_assert, pips_internal_error, STATEMENT, statement_consistent_p(), STATEMENT_ORDERING_UNDEFINED, statement_undefined, and string_undefined.
int c_parse | ( | ) |
bool c_parser | ( | const char * | module_name | ) |
When the compilation_unit is parsed, it is parsed a second time and multiple declarations are certain to happen.
module_name | odule_name |
Definition at line 739 of file c_parser.c.
References actual_c_parser(), and module_name().
bool c_parser_error | ( | const char * | func, |
const char * | msg | ||
) |
Output a parser message error.
At the end there is a pips_user_error that launch an exception so that this function may not really exit but may be caught at a higher level...
This function is called by macro CParserError()
Since many information are lost by the various resetting, first save them for later display:
Reset the parser global variables ?
The error may occur before the current module entity is defined
Stacks are not allocated yet when dealing with external declarations. I assume that all stacks are declared simultaneously, hence a single test before freeing.
Reset them to stack_undefined_p instead of STACK_NULL
get rid of all collected comments
ffective_line_number,
func | unc |
msg | sg |
Definition at line 266 of file c_parser.c.
References BlockStack, c_reset_lex(), CleanLocalEntities(), code_declarations, code_decls_text, ContextStack, entity_initial, entity_undefined, entity_undefined_p, entity_user_name(), error_reset_c_parser_current_input_file_name(), error_reset_c_parser_current_user_input_file_name(), error_reset_current_C_line_number(), error_reset_current_module_entity(), force_reset_c_parser_scope_stack(), FormalStack, FunctionStack, get_c_parser_current_user_input_file_name(), get_current_C_line_number(), get_current_module_entity(), LoopStack, NIL, OffsetStack, pips_debug, pips_user_error, pips_user_warning, reset_C_comment(), Reset_C_ReturnStatement(), reset_current_dummy_parameter_number(), reset_declaration_counter(), reset_entity_type_stack_table(), reset_expression_comment(), stack_free(), stack_undefined, stack_undefined_p, string_undefined, StructNameStack, SwitchControllerStack, SwitchGotoStack, user_line_number, and value_code.
Referenced by make_C_constant_entity().
int c_parser_number_of_scopes | ( | void | ) |
Definition at line 587 of file cyacc.tab.c.
void c_parser_put_new_typedef | ( | const char * | name | ) |
Store named type for the lexical analyzer, which has to decide if a character string is the name of a type or the name of a variable.
See is_c_parser_keyword_typedef() in clex.l
name | ame |
Definition at line 1060 of file util.c.
References concatenate(), get_c_parser_current_scope(), hash_put(), keyword_typedef_table, pips_debug, same_string_p, strdup(), string_undefined, and TK_NAMED_TYPE.
Referenced by FindOrCreateCurrentEntity().
bool c_parser_scope_stack_empty_p | ( | void | ) |
Definition at line 564 of file cyacc.tab.c.
Referenced by get_c_parser_current_scope().
void c_parser_user_warning_alist | ( | const char * | pips_func, |
const char * | pips_file, | ||
const int | pips_line, | ||
const char * | format, | ||
va_list * | args | ||
) |
util.c
util.c
Parser warning on C code synthesized by PIPS
pips_func | ips_func |
pips_file | ips_file |
pips_line | ips_line |
format | ormat |
args | rgs |
Definition at line 60 of file util.c.
References asprintf, c_lineno, free(), get_bool_property(), get_c_parser_current_input_file_name(), get_c_parser_current_user_input_file_name(), get_current_C_line_number(), get_pips_current_module(), get_pips_current_pass_name(), get_previous_C_line_number(), get_previous_c_lineno(), pips_assert, pips_log_alist(), safe_get_line_interval(), and warning_log.
Referenced by c_parser_user_warning_func().
void c_parser_user_warning_func | ( | const char * | pips_func, |
const char * | pips_file, | ||
const int | pips_line, | ||
const char * | format, | ||
... | |||
) |
pips_func | ips_func |
pips_file | ips_file |
pips_line | ips_line |
format | ormat |
Definition at line 112 of file util.c.
References c_parser_user_warning_alist().
void c_pop_buffer_state | ( | void | ) |
void* c_realloc | ( | void * | , |
yy_size_t | |||
) |
void c_reset_lex | ( | void | ) |
void c_restart | ( | FILE * | ) |
void c_set_debug | ( | int | ) |
void c_set_in | ( | FILE * | ) |
void c_set_lineno | ( | int | ) |
void c_set_out | ( | FILE * | ) |
int c_wrap | ( | void | ) |
void CCompilationUnitMemoryAllocation | ( | entity | module | ) |
module | odule |
Definition at line 1967 of file util.c.
References CCompilationUnitMemoryAllocations(), and module.
Referenced by ResetCurrentCompilationUnitEntity().
This function allocates the memory to the Current Compilation Unit.
Check that all variables used or defined are declared
Allocate variables
We are in trouble
check the type of variable here to avoid conflicting declarations
The C parser is no longer active when this warning is emitted. It is not possible to rely on its line numbers.
No way to know if a pointer is initialized or not
This may happen with variables such as "__morecore" which is a functional pointer to a malloc like function and which is declared in a header file.
It may or not be an error, depending on conflicting initializations or not. It seems better to leave this for gcc or clang to decide before running PIPS.
Do not modify the initial allocation
Do not allocate the memory for external variables: Set the offset of ram -2 which signifies UNKNOWN offset
module | odule |
first_p | irst_p |
Definition at line 1881 of file util.c.
References add_C_variable_to_area(), area_size, CAR, CDR, code_externs, DYNAMIC_RAM_OFFSET, ENDP, ENTITY, entity_declarations, entity_initial, entity_local_name(), entity_storage, entity_type, entity_undefined, entity_user_name(), gen_in_list_p(), module, ModuleStatement, nodecl_p(), pips_debug, pips_internal_error, pips_user_warning, place_holder_variable_p(), ram_offset, ram_section, storage_ram, storage_ram_p, top_level_entity_p(), type_area, type_variable_p, ultimate_type(), UNDEFINED_RAM_OFFSET, UNKNOWN_RAM_OFFSET, value_code, value_code_p, and value_unknown_p.
Referenced by CCompilationUnitMemoryAllocation(), and CCompilationUnitMemoryReallocation().
void CCompilationUnitMemoryReallocation | ( | entity | module | ) |
module | odule |
Definition at line 1972 of file util.c.
References CCompilationUnitMemoryAllocations(), and module.
Referenced by ResetCurrentCompilationUnitEntity().
Use a stack to survive to file inclusions if any.
I guess that it is currently not used since file inclusion is already done by the preprocessor... RK To track the absolute line number in the file that is parsed use the default flex yylineno that is renamed c_lineno here Use a stack to survive to file inclusions if any Count the number of c in s.
Definition at line 1133 of file clexer.c.
Referenced by discard_C_comment().
This is designed for standard C functions, not for compilation units.
e must be a function: they can be declared several times
Definition at line 3540 of file util.c.
References ENTITY, entity_name, entity_type, FOREACH, gen_occurences(), pips_debug, pips_internal_error, statement_declarations, type_functional_p, and ultimate_type().
Referenced by actual_c_parser().
bool CheckExternList | ( | void | ) |
Definition at line 1025 of file util.c.
References cons::car, CAR, cons::cdr, code_externs, code_undefined_p, ENTITY, entity_initial, entity_list_p(), entity_name, entity_undefined_p, f(), gen_last(), gen_length(), get_current_module_entity(), pips_assert, pips_debug, value_code, and value_undefined_p.
void CleanUpEntities | ( | list | le | ) |
update entity in module declarations
Update storage area
Update entity in current entity list
Remove entity from potentially removable externs and add it the new entity
Apparently, formal parameters may have been declared for such an entity and PIPS code dumps when the symbol table is written.
See decl62.c and decl63.c
le | e |
Definition at line 2772 of file util.c.
References area_layout, CAR, CleanUpEntity(), code_declarations, CONS, ENDP, ENTITY, entity_initial, entity_storage, entity_type, gen_remove(), get_current_module_entity(), list_undefined, pips_internal_error, POP, ram_section, removable_extern_entities, storage_ram, storage_ram_p, type_area, and value_code.
void clear_C_comment | ( | void | ) |
Comments in the compilation unit and outside of function bodies are lost because they are related only to declarations and because comments on declarations are lost.
Definition at line 1489 of file clexer.c.
Referenced by error_reset_C_comment(), and reset_C_comment().
void CModuleMemoryAllocation | ( | entity | module | ) |
This function is for MemoryAllocation for Module of C programs.
module | odule |
Definition at line 1979 of file util.c.
References add_C_variable_to_area(), area_size, CAR, CDR, code_externs, DYNAMIC_RAM_OFFSET, ENDP, ENTITY, entity_declarations, entity_initial, entity_storage, entity_type, entity_undefined, gen_in_list_p(), module, ModuleStatement, nodecl_p(), pips_debug, place_holder_variable_p(), ram_offset, ram_section, StackArea, storage_formal_p, storage_ram, storage_ram_p, type_area, type_variable_p, UNDEFINED_RAM_OFFSET, UNKNOWN_RAM_OFFSET, and value_code.
Referenced by ResetCurrentModule().
bool compilation_unit_parser | ( | const char * | module_name | ) |
module_name | odule_name |
Definition at line 746 of file c_parser.c.
References actual_c_parser(), module_name(), and STUB_ERROR.
Referenced by AddEntityToCompilationUnit(), and outliner_independent().
Update the size and layout of the area aa. This function is called too earlier, we may not have the size of v. To be changed !!!
FI: who wrote this? when should the offsets be computed? how do we deal with scoping?
area_size(aa) = offset + 0;
Definition at line 3324 of file util.c.
References area_layout, area_size, CONS, CSafeSizeOfArray(), ENTITY, entity_type, gen_nconc(), NIL, offset, pips_assert, and type_area.
c_parser_context CreateDefaultContext | ( | void | ) |
Definition at line 292 of file cyacc.tab.c.
Referenced by EnterScope().
We have to know the context:
The entity is created local to the file. For instance, derived and user-named types. This makes type checking more difficult as types such as FILE * vary from C file to C file, but this is consistent with the C standard and the behavior of production compilers: the same local name can be used for two different types in two different files.
These types are created globally, which makes type checking much easier but forbid homonym types in different files.
name | ame |
prefix | refix |
is_external | s_external |
Definition at line 962 of file util.c.
References asprintf, compilation_unit_name, entity_name, entity_undefined, FILE_LOCAL_USER_DEFINED_TYPES_P, FindOrCreateEntity(), free(), get_current_module_entity(), get_current_module_name(), GetScope(), is_external, local_name(), pips_assert, pips_debug, prefix, scope_to_block_scope(), static_module_p(), string_block_scope_p(), and TOP_LEVEL_MODULE_NAME.
Referenced by FindOrCreateCurrentEntity(), FindOrCreateEntityFromLocalNameAndPrefix(), FindOrCreateEntityFromLocalNameAndPrefixAndScope(), and MakeDerivedEntity().
We have to know the context :
The name of the struct/union is then added to the field entity name, with the MEMBER_SEP_STRING
ompilation_unit_name,
derived | erived |
is_external | s_external |
Definition at line 3261 of file util.c.
References compilation_unit_name, concatenate(), get_current_module_entity(), get_current_module_name(), GetScope(), is_external, MEMBER_SEP_STRING, MODULE_SEP_STRING, pips_assert, pips_debug, scope_to_block_scope(), static_module_p(), strdup(), string_block_scope_p(), and string_undefined.
void CreateReturnEntity | ( | entity | f | ) |
If necessary, create the return entity, which is a hidden variable used in PIPS internal representation to carry the value returned by a function.
c_parser_user_warning() should not be called as it may be some times too late to get significant line numbers.
Create the return value
set the language
Definition at line 2382 of file util.c.
References AddToDeclarations(), c_parser_user_warning, copy_type(), entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, entity_user_name(), f(), FindOrCreateEntity(), functional_result, make_storage_return(), make_value_unknown(), pips_debug, pips_internal_error, type_functional, type_functional_p, type_undefined_p, type_void_p, and ultimate_type().
Referenced by UpdateEntity(), and UpdateEntity2().
void discard_C_comment | ( | void | ) |
Discard a C comment because we don't know how to deal with it.
The comments are only made of '
', just silently discarding them
Definition at line 1426 of file clexer.c.
bool dummy_prettyprint_control_list_p | ( | void | ) |
Provide the information only once.
Definition at line 1090 of file statement.c.
References dummy_declaration_p.
Referenced by add_prettyprint_control_list_to_declaration_statement().
void error_reset_C_comment | ( | bool | ) |
void error_reset_c_parser_current_input_file_name | ( | void | ) |
Definition at line 81 of file c_parser.c.
References c_parser_current_file_name, and string_undefined.
Referenced by c_parser_error().
void error_reset_c_parser_current_user_input_file_name | ( | void | ) |
Definition at line 112 of file c_parser.c.
References c_parser_current_user_input_file_name, and string_undefined.
Referenced by c_parser_error().
void error_reset_current_C_line_number | ( | void | ) |
Definition at line 1224 of file clexer.c.
void ExitScope | ( | void | ) |
Definition at line 400 of file cyacc.tab.c.
statement ExpressionToStatement | ( | expression | e | ) |
e is now owned by returned statement
Definition at line 880 of file statement.c.
References call_to_statement, call_undefined, expression_syntax, free_expression(), get_current_C_comment(), get_current_C_line_number(), instruction_to_statement(), make_instruction_expression(), statement_comments, statement_number, statement_undefined, string_undefined_p, syntax_call, and syntax_call_p.
bool extern_prettyprint_control_list_p | ( | void | ) |
void reset_prettyprint_control_list_to_extern(void)
{ extern_declaration_p = false; } Provide the information only once
Definition at line 1053 of file statement.c.
References extern_declaration_p.
Referenced by add_prettyprint_control_list_to_declaration_statement().
Find an entity from its local name. We have to look for all possible prefixes, which are: blank, STRUCT_PREFIX, UNION_PREFIX, ENUM_PREFIX, TYPEDEF_PREFIX
How about multiple results ? The order of prefixes ?
Is it a static function? It must have been parsed in the compilation unit
name | ame |
Definition at line 778 of file util.c.
References c_parser_user_warning, compilation_unit_name, concatenate(), entity_undefined, entity_undefined_p, ENUM_PREFIX, FindEntity(), FindEntityFromLocalNameAndPrefix(), free(), prefixes, strdup(), STRUCT_PREFIX, TYPEDEF_PREFIX, and UNION_PREFIX.
Referenced by IdentifierToExpression().
Find an entity from its local name and prefix. We have to look from the most enclosing scope.
Possible name combinations and the looking order:
PREFIXname or MODULE:BLOCK
PREFIXnamewith 5 possible prefixes: blank, STRUCT_PREFIX, UNION_PREFIX, ENUM_PREFIX, TYPEDEF_PREFIX
"!" is FILE_SEP_STRING and ":" is MODULE_SEP_STRING and "`" is BLOCK_SEP_STRING
First, look up the surrounding scopes
Is it a formal parameter not yet converted in the function frame?
Should we change the current dummy parameter number?
Is it a static variable declared in the compilation unit?
we have an issue there : a static function will be declared FILE!MODULE:FILE!name, but a static variable will be declared FILE!MODULE:name so try both ... CleanupEntity has been fixed to remove buggy situations ...
Is it a global variable declared in the compilation unit?
Is it a local type used within a function declaration?
It may be a parser error or a normal behavior when an entity is used before it is defined as, for example, a struct in a typedef: typedef struct foo foo;
CParserError("Variable appears to be undefined\n");
name | ame |
prefix | refix |
Definition at line 877 of file util.c.
References compilation_unit_name, concatenate(), DUMMY_PARAMETER_PREFIX, entity_domain, entity_name, entity_undefined, entity_undefined_p, FindEntityFromLocalNameAndPrefixAndScope(), free(), gen_find_tabulated(), get_current_C_line_number(), get_current_dummy_parameter_number(), GetParentScope(), GetScope(), int2a(), MODULE_SEP_STRING, pips_assert, pips_debug, prefix, scope_to_block_scope(), ScopeStackSize(), strdup(), string_block_scope_p(), string_undefined, and TOP_LEVEL_MODULE_NAME.
Referenced by FindEntityFromLocalName(), FindOrCreateEntityFromLocalNameAndPrefix(), and FindOrCreateEntityFromLocalNameAndPrefixAndScope().
The parameter "scope" is potentially destroyed.
Add block scope case here
ompilation_unit_name,
return values are not C variables... but they are entities.
name | ame |
prefix | refix |
scope | cope |
Definition at line 850 of file util.c.
References concatenate(), entity_domain, entity_storage, entity_undefined, entity_undefined_p, gen_find_tabulated(), get_current_module_entity(), get_current_module_name(), MODULE_SEP_STRING, pop_block_scope(), prefix, static_module_p(), storage_return_p, storage_undefined_p, and string_undefined.
Referenced by FindEntityFromLocalNameAndPrefix().
name | ame |
prefix | refix |
is_external | s_external |
Definition at line 811 of file util.c.
References CreateEntityFromLocalNameAndPrefix(), entity_undefined, FindEntityFromLocalNameAndPrefix(), is_external, and prefix.
entity FindOrCreateEntityFromLocalNameAndPrefixAndScope | ( | string | name, |
string | prefix, | ||
string | scope, | ||
bool | is_external | ||
) |
The current scope will be automatically added
name | ame |
prefix | refix |
scope | cope |
is_external | s_external |
Definition at line 820 of file util.c.
References concatenate(), CreateEntityFromLocalNameAndPrefix(), entity_name, entity_undefined, entity_undefined_p, FindEntityFromLocalNameAndPrefix(), free(), is_external, pips_assert, pips_debug, pop_block_scope(), prefix, strdup(), and string_block_scope_p().
to be verified in C, when by reference, when by value
offset | ffset |
Definition at line 3384 of file util.c.
References ENTITY, entity_storage, entity_type, entity_user_name(), f(), FOREACH, formal_offset, make_dummy_identifier(), make_mode_value(), make_parameter(), offset, parameter_undefined, storage_formal, and storage_formal_p.
Referenced by MakeParameterList().
Definition at line 189 of file statement.c.
References LabeledStatements, MAP, STATEMENT, statement_label, and statement_undefined.
Referenced by MakeForloop(), MakeGotoStatement(), MakeLabeledStatement(), MakeSwitchStatement(), and MakeWhileLoop().
void FixCReturnStatements | ( | statement | ms | ) |
When return statements have been encountered, each of them has been replaced by a goto to a unique return statement.
This unique return statement may have to be added to the function body.
How many return statements have been encountered?
nothing to be done
If the return statement is the last statement of the module statement, the goto and the assignment can be replaced by a call to return. Otherwise, a return statement with the proper label must be added at the end of the module statement ms
The goto instruction and, possibly, the return value assignment can be removed: just remove the label?
Do not forget to declare the return variable...
ms | s |
Definition at line 223 of file return.c.
References AddLocalEntityToDeclarations(), C_RETURN_FUNCTION_NAME, C_return_statement, call_to_instruction, CreateIntrinsic(), entity_undefined_p, free_instruction(), get_bool_property(), GetReturnNumber(), insert_statement(), instruction_goto, instruction_goto_p, last_return_value_assignment, last_returned_value, last_statement(), make_call(), make_continue_instruction(), pips_assert, pips_internal_error, Reset_C_ReturnStatement(), reset_current_module_entity(), return_current_module, return_value_entity, set_current_module_entity(), statement_block_p, statement_instruction, and statement_undefined_p.
Referenced by actual_c_parser().
void force_reset_c_parser_scope_stack | ( | void | ) |
To be used by an error handler.
Definition at line 539 of file cyacc.tab.c.
return.c
return.c
Unlike Fortran return statements, C return statements carry the value returned by functions. In some sense, they have a continuation since they return to the caller, but there is no local continuation. So C return cannot be simply replaced by goto statements. This only preserves the control semantics. An additional variable, the return value, must be declared and used to collect information about the different values that are returned. This translation can be removed when there is only one return at the end of the function body. Note that pass restructure_control may be useful for procedure with several returns because unspaghettify, called by the controlizer, is not strong enough.
Francois Irigoin
Definition at line 58 of file return.c.
References entity_module_name(), LABEL_PREFIX, make_label(), and RETURN_LABEL_NAME.
Referenced by Generate_C_ReturnStatement().
statement Generate_C_ReturnStatement | ( | void | ) |
Definition at line 84 of file return.c.
References C_RETURN_FUNCTION_NAME, CONS, entity_intrinsic(), entity_to_expression(), entity_type, EXPRESSION, f(), function_to_return_value(), functional_result, Generate_C_ReturnLabel(), get_current_module_entity(), instruction_to_statement(), instruction_undefined, make_call_instruction(), NIL, return_current_module, return_value_entity, statement_label, statement_undefined, type_functional, and type_void_p.
Referenced by Get_C_ReturnStatement().
string get_c_parser_current_input_file_name | ( | void | ) |
Definition at line 58 of file c_parser.c.
References c_parser_current_file_name, pips_internal_error, and string_undefined_p.
Referenced by c_parser_user_warning_alist(), and UpdateEntity().
string get_c_parser_current_scope | ( | void | ) |
Definition at line 569 of file cyacc.tab.c.
string get_c_parser_current_user_input_file_name | ( | void | ) |
Definition at line 89 of file c_parser.c.
References c_parser_current_user_input_file_name, pips_internal_error, and string_undefined_p.
Referenced by c_parser_error(), and c_parser_user_warning_alist().
Definition at line 581 of file cyacc.tab.c.
statement Get_C_ReturnStatement | ( | void | ) |
This function is used to generate all goto's towards the unique return used to C replace return statement and to insert this unique return at the end of the current function's body.
Definition at line 130 of file return.c.
References C_return_statement, Generate_C_ReturnStatement(), number_of_return_statements, pips_assert, and statement_undefined_p.
Referenced by C_MakeReturnStatement().
string get_current_C_comment | ( | void | ) |
Return the current comment as a string to be freed by the caller and reset the current comment.
If the current comment is undefined, returns a copy of the empty string, "".
Reset also the current comment.
If the comment begins with a new-line, it is indeed the new-line that ends the previous statement, so skip it. Quicker than strlen()
Note there won't be a memory leak since the orginal '\0' is in the malloc() bloc to be free()ed anyway...
If the comment is only an empty one, do not retain it:
Do retain it to keep the statement data structure easy to use, allowing strdup() on its text fields
Remove the trailing new-line if any since the RI is already line-oriented at the comment level: This is already done above.
It is a trailing new-line: just get rid of it:
pips_debug(3, "get_current_C_comment comment \"s"
", cc);
Definition at line 1282 of file clexer.c.
Referenced by push_current_C_comment().
int get_current_C_line_number | ( | void | ) |
FI: I assume that get_current_C_line_number is called only by some kind of make_statement()
The PIPS preprocessed C function files contain a specific first line to convert the line number in the workspace unto a line number in the user source file.
Definition at line 1146 of file clexer.c.
Referenced by pop_current_C_comment(), push_current_C_comment(), and push_current_C_line_number().
entity get_current_compilation_unit_entity | ( | void | ) |
Definition at line 320 of file util.c.
References compilation_unit_name, FindOrCreateEntity(), and TOP_LEVEL_MODULE_NAME.
Referenced by callnodeclfilter(), FindOrCreateCurrentEntity(), MakeFunctionExpression(), MakeStorageRam(), and referencenodeclfilter().
int get_declaration_counter | ( | void | ) |
Definition at line 497 of file cyacc.tab.c.
key | ey |
Definition at line 146 of file c_parser.c.
References entity_name, entity_to_type_stack_table, hash_get(), HASH_UNDEFINED_VALUE, and stack_undefined.
Referenced by FindOrCreateCurrentEntity(), RenameFunctionEntity(), SubstituteDummyParameters(), UpdateAbstractEntity(), UpdateDerivedEntity(), UpdateEntity(), and UseFormalArguments().
int get_previous_C_line_number | ( | void | ) |
Should be called just before get_current_C_line_number.
int get_previous_c_lineno | ( | void | ) |
entity get_top_level_entity | ( | void | ) |
Definition at line 152 of file util.c.
References FindOrCreateEntity(), and TOP_LEVEL_MODULE_NAME.
Referenced by MakeStorageRam(), and step_parameter().
c_parser_context GetContext | ( | void | ) |
Definition at line 458 of file cyacc.tab.c.
c_parser_context GetContextCopy | ( | void | ) |
Definition at line 476 of file cyacc.tab.c.
entity GetFunction | ( | void | ) |
string GetParentScope | ( | void | ) |
Definition at line 387 of file cyacc.tab.c.
int GetReturnNumber | ( | void | ) |
Definition at line 214 of file return.c.
References number_of_return_statements.
Referenced by FixCReturnStatements().
string GetScope | ( | void | ) |
FI: I do not know if it wouldn't be better to initialize the ContextStack with a default context before calling the C parser
Definition at line 371 of file cyacc.tab.c.
expression IdentifierToExpression | ( | string | s | ) |
Could this be non declared variables ?
This identifier has not been passed by the parser. It is probably a function call => try this case now and complete others later. The scope of this function is global
This may be a call or a reference in case a functional pointer is initialized
eturn MakeNullaryCall(ent);
FI: This may happen when a variable is used to initialize another variable within the same declaration statement: see decl29.c. This might not be a general fix as the type could be functional: to be checked. But setting up type earlier would require a huge change in the parser rules. Unless FindOrCreateCurrentEntity() could do a better job? But the information added is later destroyed by the parser.
Generate a call to an enum member
Definition at line 650 of file util.c.
References CParserError(), entity_initial, entity_storage, entity_type, entity_undefined_p, exp, expression_undefined, FindEntityFromLocalName(), FindOrCreateEntity(), is_type_functional, is_type_variable, is_value_code, make_call(), make_code(), make_expression(), make_functional(), make_language_c(), make_reference(), make_sequence(), make_storage_rom(), make_syntax_call(), make_syntax_reference(), make_type_functional(), make_type_unknown(), make_value(), NIL, normalized_undefined, pips_debug, safe_entity_name(), strdup(), TOP_LEVEL_MODULE_NAME, type_tag, type_undefined_p, value_symbolic_p, and value_undefined_p.
Referenced by MemberDerivedIdentifierToExpression().
void init_c_areas | ( | void | ) |
In C we have 4 areas.
Create a hidden pointer in the heap area to modelize malloc and free effects and to keep track of the corresponding abstract state.
FI: I use a complex type to avoid seeing this variable in the transformers and preconditions... OK, it's not a clean way to do it. Should we create another area to allocate this abstract heap state?
FI: I keep the code below, because it may turn useful again if context-insensitive address values must be generated.
This is because of the reparsing of the compilation unit The area is set to zero and all the declarations are overrided and the memory is reallocated The area is reset to only when it is called by same compilation unit twice. The code is dangerous hence it is commented. Please have a look
if( get_current_compilation_unit_entity() == get_current_module_entity() && (get_current_compilation_unit_entity() == previouscompilationunit)) area_size(type_area(entity_type(msae))) = 0;
if( get_current_compilation_unit_entity() == get_current_module_entity() && (get_current_compilation_unit_entity() == previouscompilationunit)) area_size(type_area(entity_type(gsae))) = previoussizeofGlobalArea ;
Definition at line 186 of file util.c.
References ABSTRACT_LOCATION, AddEntityToDeclarations(), compilation_unit_name, DYNAMIC_AREA_LOCAL_NAME, DynamicArea, ENTITY_DYNAMIC_AREA, ENTITY_HEAP_AREA, entity_initial, entity_kind, ENTITY_STACK_AREA, ENTITY_STATIC_AREA, entity_storage, entity_type, FindOrCreateEntity(), get_current_module_entity(), get_current_module_name(), HEAP_AREA_LOCAL_NAME, HeapArea, is_type_area, make_area(), make_storage_rom(), make_type(), make_value_unknown(), NIL, STACK_AREA_LOCAL_NAME, StackArea, STATIC_AREA_LOCAL_NAME, StaticArea, and TOP_LEVEL_MODULE_NAME.
Referenced by MakeCurrentCompilationUnitEntity(), and MakeCurrentModule().
void init_C_comment | ( | void | ) |
Definition at line 1513 of file clexer.c.
void init_c_implicit_variables | ( | entity | m | ) |
Function name variable function and FUNCTION
Should be static, but not compatible with FREIA inlining.
It is not clear if the encoding is correct or not. It may also be correct but not supported. This could be checked by computing the preconditions for strings and/or by adding initial values to the symbol table display.
Since the declarations are not added to a statement_declarations field, they are not going to be prettyprinted.
Definition at line 277 of file util.c.
References AddEntityToDeclarations(), concatenate(), DynamicArea, entity_initial, entity_local_name(), entity_storage, entity_type, entity_user_name(), FindOrCreateEntity(), free(), IMPLICIT_VARIABLE_NAME_1, IMPLICIT_VARIABLE_NAME_2, is_basic_string, make_C_constant_entity(), make_call_expression(), make_char_array_type(), make_ram(), make_storage_ram(), make_value_expression(), NIL, strdup(), and UNKNOWN_RAM_OFFSET.
Referenced by MakeCurrentModule().
void init_c_parser_scope_stack | ( | void | ) |
Definition at line 514 of file cyacc.tab.c.
void init_entity_type_storage_table | ( | void | ) |
Definition at line 131 of file c_parser.c.
References entity_to_type_stack_table, hash_string, hash_table_make(), hash_table_undefined_p, and reset_entity_type_stack_table().
Referenced by actual_c_parser().
void InitializeBlock | ( | void | ) |
Definition at line 143 of file statement.c.
References BlockStack, stack_make(), and statement_domain.
void InitializeEnumMemberValues | ( | list | lem | ) |
The expression evaluation may have been delayed
lem | em |
Definition at line 3104 of file util.c.
References CAR, constant_int, constant_int_p, constant_unknown_p, ENDP, ENTITY, entity_initial, EvalExpression(), expression_undefined_p, int_to_expression(), is_constant_int, list_undefined, make_constant(), make_symbolic(), make_value_symbolic(), pips_assert, POP, symbolic_consistent_p(), symbolic_constant, symbolic_expression, value_constant, value_constant_p, value_symbolic, and value_undefined_p.
void InitScope | ( | void | ) |
Definition at line 306 of file cyacc.tab.c.
if qualifier "nq" does not already belong to qualifier list "ql", add it in front of the list.
The list is probably reversed somewhere else... for instance by the parsing grammar rules
FI: either the context was not stacked or it was not used and emptied...
ql | l |
nq | q |
Definition at line 3567 of file util.c.
References c_parser_user_warning, CONS, FOREACH, QUALIFIER, qualifier_equal_p(), and qualifier_to_string().
name | ame |
bt | t |
size | ize |
Definition at line 269 of file util.c.
References c_parser_error(), and make_C_or_Fortran_constant_entity().
Referenced by init_c_implicit_variables().
void make_predefined_C_entities | ( | string | compilation_unit_name | ) |
Predefined type(s): __builtin_va_list
Let's lie about the real type
Predefined functions(s): __builtin_va_end (va_arg() is parsed directly)
Let's lie about the real type...
Let's lie about the real type
Let's lie about the real type
compilation_unit_name | ompilation_unit_name |
Definition at line 425 of file c_parser.c.
References BUILTIN_VA_COPY, BUILTIN_VA_END, BUILTIN_VA_START, compilation_unit_name, CONS, copy_parameter(), DEFAULT_COMPLEX_TYPE_SIZE, DEFAULT_INTEGER_TYPE_SIZE, DEFAULT_LOGICAL_TYPE_SIZE, entity_initial, entity_storage, entity_type, entity_undefined, FindOrCreateEntity(), is_basic_pointer, is_basic_typedef, is_mode_value, is_type_functional, is_type_variable, is_type_void, make_basic(), make_basic_complex(), make_basic_int(), make_basic_logical(), make_dummy_unknown(), make_functional(), make_mode(), make_mode_value(), make_parameter(), make_storage_rom(), make_type(), make_type_void(), make_value_intrinsic(), make_value_unknown(), make_variable(), NIL, PARAMETER, storage_undefined_p, TYPEDEF_PREFIX, and UU.
Referenced by actual_c_parser().
expression MakeArrayExpression | ( | expression | exp, |
list | lexp | ||
) |
FI: this function is called for a bracketed comma expression.
The two arguments are (should be) reused within the returned expression
There are two cases:
FI: Memory leak with exp?
FI: we might have preexisting subscript? No, in this context, only one index due to lack of type information?
exp | xp |
lexp | exp |
Definition at line 713 of file util.c.
References CDR, CONS, ENDP, exp, EXPRESSION, expression_syntax, expression_undefined, gen_nconc(), is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, lexp, make_expression(), make_reference(), make_subscript(), make_syntax_subscript(), MakeCommaExpression(), NIL, normalized_undefined, pips_debug, pips_internal_error, reference_indices, reference_to_expression(), reference_variable, syntax_reference, and syntax_tag.
Create a block statement.
It also gather all the declarations in the statements and declare them in the block sequence.
To please to current RI choices about Fortran, blocks cannot carry line numbers nor comments
Anyway, it might be much too late to retrieve the comment associated to the beginning of the block. The lost comment appears after the last statement of the block. To save it, as is done in Fortran, an empty statement should be added at the end of the sequence.
stmts | tmts |
Definition at line 153 of file statement.c.
References discard_C_comment(), empty_comments, empty_extensions(), ENDP, entity_empty_label(), fprintf(), ifdebug, make_instruction_sequence(), make_sequence(), make_statement(), make_synchronization_none(), pips_assert, print_entities(), statement_consistent_p(), statement_declarations, STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, statements_to_direct_declarations(), and string_undefined.
NN : I did not add a bool variable to distinguish between loop and switch statements :-( FI: Also, there is no protection in case the same label has been used by the programmer...
cmt | mt |
Definition at line 849 of file statement.c.
References asprintf, basic_int, free(), get_label_prefix, LoopStack, MakeGotoStatement(), stack_head(), and statement_comments.
Referenced by MakeSwitchStatement().
statement MakeCaseStatement | ( | expression | e | ) |
Transform.
case e:
to
switch_xxx_case_e: ;
and generate
if (c == e) goto switch_xxx_case_e
where c is retrieved from SwitchControllerStack xxx is unique from LoopStack
Before the code can be generated, expression e must be statically evaluated, transformer into a character string, and this character string must be made compatible with C constraints for labels.
It might be easier to evaluate e since e must be evaluable at compile time... And it is necessary if e contains operators whose name cannot be part of a label: see switch04
We chose to ignore the impact of casts
You must evaluate the constant expression. Hopefully it is an integer expression...
The expression may be a character
remove the quotes
Make sure "restr" only contains C characters valid for a label if a character constant is used: is_letter || is_digit || '_'.
illegal characters such as '?' or ',' or '.' must be converted as well as octal constant such as '\001' and special characters such as '
'
Must be an illegal character for a label
FI: not too safe to make it octal among decimal because it can generate a label conflict.
octal character
hexadecimal character, unicode character
FI: let's deal with special cases such as
, \r, \t,... The initialization to zero is meaningless but avoids a warning.
Definition at line 712 of file statement.c.
References asprintf, basic_int, c_parser_user_warning, call_to_expression(), cast_expression, CONS, CParserError(), entity_empty_label(), entity_intrinsic(), entity_undefined, EXPRESSION, expression_cast(), expression_cast_p(), expression_constant_p(), expression_integer_value(), expression_to_string(), free(), gen_nconc(), get_current_C_comment(), get_label_prefix, intptr_t, is_language_c, LoopStack, make_call(), make_continue_statement(), make_test(), MakeGotoStatement(), MakeLabeledStatement(), NIL, pips_internal_error, sequence_statements, set_prettyprint_language_tag(), stack_head(), STATEMENT, string_undefined, SwitchControllerStack, SwitchGotoStack, and test_to_statement.
Definition at line 278 of file statement.c.
References concatenate(), entity_initial, entity_storage, entity_type, FindOrCreateEntity(), free(), get_current_module_name(), is_value_constant, LABEL_PREFIX, make_constant_litteral(), make_storage_rom(), make_value(), MakeTypeStatement(), pips_debug, strdup(), and type_undefined.
Referenced by MakeForloop(), MakeGotoStatement(), MakeLabeledStatement(), MakeSwitchStatement(), and MakeWhileLoop().
Unique label with the LoopStack
cmt | mt |
Definition at line 865 of file statement.c.
References asprintf, basic_int, free(), get_label_prefix, LoopStack, MakeGotoStatement(), stack_head(), and statement_comments.
void MakeCurrentCompilationUnitEntity | ( | const char * | name | ) |
A compilation unit is also considered as a module.
value v = entity_initial(e);
if(value_code_p(v)) {
code c = value_code(v);
language l = code_language(c);
if(language_unknown_p(l))
code_language(c) = make_language_c();
else if(language_fortran_p(l) || language_fortran95_p(l))
pips_internal_error("A compilation unit should have language \"C".
");
}
else
pips_internal_error("A compilation unit should have value \"code".
");
name | ame |
Definition at line 328 of file util.c.
References init_c_areas(), MakeCompilationUnitEntity(), pips_debug, and set_current_module_entity().
Referenced by actual_c_parser().
void MakeCurrentModule | ( | entity | e | ) |
is used for switch statements also, because we do not distinguish a break in a loop or a switch
This must be changed later, the storage is of type return and we have to create a new entity
make_storage_return(e)
code_declaration to be updated : only need formal parameters, because the others are added in block statement declaration ?
The next two tests are replicated from the Fortran parser, Syntax/procedure.c, MakeCurrentFunction()
In case the module is parsed a second time, clean up the symbol table to avoid variable redefinition warnings and errors
Clean up existing local entities in case of a recompilation.
Let's hope cf is not an intrinsic: name conflict (the problem may have been detected earlier in UpdateEntity() if there are arguments)
Unfortunately, an intrinsics cannot be redefined, just like a user function or subroutine after editing because intrinsics are not handled like user functions or subroutines. They are not added to the called_modules list of other modules, unless the redefining module is parsed FIRST. There is not mechanism in PIPS to control the parsing order.
Definition at line 67 of file statement.c.
References basic_domain, CCleanLocalEntities(), code_declarations, code_undefined_p, CParserError(), ENDP, entity_initial, entity_local_name(), entity_storage, entity_type, entity_user_name(), expression_domain, init_c_areas(), init_c_implicit_variables(), intrinsic_entity_p(), is_value_code, LabeledStatements, LoopStack, make_code(), make_language_c(), make_sequence(), make_storage_rom(), make_value(), NIL, pips_debug, pips_user_warning, sequence_domain, set_current_module_entity(), stack_make(), strdup(), SwitchControllerStack, SwitchGotoStack, type_undefined, value_code, value_code_p, and value_undefined_p.
statement MakeDefaultStatement | ( | void | ) |
Return the labeled statement switch_xxx_default: ; and add goto switch_xxx_default; to the switch header
If the default case is not last, it must be moved later in the sequence_statements(CurrentSwitchGoto)
Definition at line 827 of file statement.c.
References asprintf, basic_int, CONS, entity_empty_label(), free(), gen_nconc(), get_current_C_comment(), get_label_prefix, LoopStack, make_continue_statement(), MakeGotoStatement(), MakeLabeledStatement(), sequence_statements, stack_head(), STATEMENT, and SwitchGotoStack.
FI: What should the initial value be?
name | ame |
members | embers |
is_external | s_external |
Definition at line 3140 of file util.c.
References AddEntityToDeclarations(), CreateEntityFromLocalNameAndPrefix(), entity_initial, entity_storage, entity_type, entity_undefined, ENUM_PREFIX, get_current_module_entity(), is_external, is_type_enum, is_type_struct, is_type_union, make_storage_rom(), make_type_enum(), make_type_struct(), make_type_union(), make_value_unknown(), STRUCT_PREFIX, UNION_PREFIX, and value_undefined_p.
Take only the first expression of le, do not know why it can be a list ?
use the integer value
If we do this, we cannot restitute the source code
Build a new expression e' == e-1
le | e |
ql | l |
Definition at line 1389 of file util.c.
References CAR, CreateIntrinsic(), dimension_lower, dimension_upper, EXPRESSION, expression_integer_value(), ifdebug, int_to_expression(), intptr_t, make_dimension(), make_unbounded_expression(), MakeBinaryCall(), MINUS_C_OPERATOR_NAME, NIL, pips_debug, and print_expression().
Referenced by UpdateArrayEntity().
The initial value = 0 if this is the first member in the enumerator list else, it is equal to : intial_value(predecessor) + 1
Find the predecessor of the counter-th member
enum_list | num_list |
counter | ounter |
Definition at line 3299 of file util.c.
References constant_int, constant_int_p, ENTITY, entity_initial, gen_nth(), make_constant_int(), make_value_constant(), value_constant, value_constant_p, and value_undefined.
statement MakeForloop | ( | expression | e1, |
expression | e2, | ||
expression | e3, | ||
statement | body | ||
) |
Create a for-loop statement with some parser-specific characteristics.
A more generic implementation would have been in ri-util instead.
There are assumptions that 2 comments have been pushed in the parser before.
[in] | e1 | is the init part of the for |
[in] | e2 | is the conditional part of the for |
[in] | e3 | is the increment part of the for |
[in] | body | is the loop body statement |
Beware that a block is returned instead of a forloop when a break has been processed. The forloop is somewhere in there...
A bool C constant cannot be used because stdbool.h may not be included
cond = make_call_expression(MakeConstant(TRUE_OPERATOR_NAME,
is_basic_logical),
NIL);
Create some land-pad labels to deal with break and continue.
Looks like some memory leaks if no break or continue...
What happens if this label is already used by the programmer? If I increment i, the label may not be retrieved when needed... unless LoopStack is updated...
This loop has a continue statement which has been transformed to goto.
Add the labeled statement at the end of loop body
The for clause may contain declarations
This loop has a break statement which has been transformed to goto Add the labeled statement after the loop
printf("For loop statement: \n");
print_statement(smt);
}
e1 | 1 |
e2 | 2 |
e3 | 3 |
body | ody |
Definition at line 358 of file statement.c.
References add_comment_and_line_number(), asprintf, basic_int, concatenate(), CONTINUE_FUNCTION_NAME, empty_extensions(), entity_empty_label(), entity_intrinsic(), expression_undefined_p, f(), FindStatementFromLabel(), forloop_consistent_p(), free(), get_current_C_line_number(), get_label_prefix, init, insert_statement(), int_to_expression(), LoopStack, make_call_expression(), make_forloop(), make_instruction_forloop(), make_statement(), make_synchronization_none(), MakeCLabel(), NIL, pips_assert, pop_current_C_comment(), pop_current_C_line_number(), s1, simplify_C_expression(), stack_head(), stack_pop(), statement_consistent_p(), STATEMENT_ORDERING_UNDEFINED, statement_undefined_p, strdup(), and string_undefined.
Referenced by MakeForloopWithIndexDeclaration().
statement MakeForloopWithIndexDeclaration | ( | list | decls, |
expression | e2, | ||
expression | e3, | ||
statement | body | ||
) |
Create a C99 for-loop statement with a declaration as first parameter in the for clause, with some parser-specific characteristics.
To represent for(int i = a;...;...) we generate instead: { int i; for(int i = a;...;...) }
The for could be generated back into the original form by the prettyprinter. To differentiate between such a C99 for loop or a for-loop that was really written with the i declaration just before, west may mark the for loop with an extension here so that the prettyprinter could use this hint to know if it has to do some resugaring or not.
[in,out] | decls | is the init part of the for. It is a declaration statement list |
[in] | e2 | is the conditional part of the for |
[in] | e3 | is the increment part of the for |
[in] | body | is the loop body statement |
printf("For loop statement declarations: \n");
print_statements(decls);
}
First generate naive but more robust version in the RI, such as:
{ int i = a; for(;...;...) }
We inject the for in its declaration statement to have the naive representation:
We try to refine to inject back an initialization in the for-clause.
Note split_initializations_in_statemen() works only on a block
We are interested in solving the simple case when there are 3 statements because we should be in the form of: int i; i = a; for(;...;...)
We need to remove the decl block statement and move the index declaration directly in the for statement.
Not yet implemented because it needs to extend declaration_statement_p for any kind of loops, the loop restructurers...
decls | ecls |
e2 | 2 |
e3 | 3 |
body | ody |
Definition at line 508 of file statement.c.
References append_statement_to_block_statement(), call_to_expression(), call_undefined, expression_undefined, f(), find_forloop_in_statement(), forloop_initialization, free_expression(), free_statement(), gen_length(), gen_nth(), gen_remove(), get_bool_property(), ifdebug, init, instruction_call, make_block_statement(), MakeForloop(), printf(), split_initializations_in_statement(), STATEMENT, statement_block(), statement_call(), statement_declarations, statement_instruction, and statements_to_direct_declarations().
expression MakeFunctionExpression | ( | expression | e, |
list | le | ||
) |
e is now owned by returned expression and must not be used any longer
There are 2 cases:
The first argument corresponds to a function name (an entity).
In this case, we create a normal call expression and the corresponding entity is added to the list of callees.
Must be a pointer to a function
Undeclared functions return int by default
This cannot be checked unless bootstrap typing is improved for varargs intrinsics, mostly IOs.
le | e |
Definition at line 368 of file util.c.
References AddToCalledModules(), AddToDeclarations(), c_parser_user_warning, call_compatible_type_p(), check_C_function_type(), code_declarations, CParserError(), entity_initial, entity_name, entity_type, entity_user_name(), exp, expression_syntax, expression_undefined, f(), free_expression(), functional_result, gen_in_list_p(), gen_length(), get_current_compilation_unit_entity(), get_current_module_entity(), ifdebug, intrinsic_entity_p(), is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, make_application(), make_call_expression(), make_expression(), make_syntax_application(), MakeIntegerResult(), normalized_undefined, pips_assert, pips_debug, pips_internal_error, print_expressions(), reference_variable, syntax_reference, syntax_tag, type_functional, type_functional_p, type_unknown_p, ultimate_type(), and value_code.
Find the corresponding statement from its label, if not found, create a pseudo one, which will be replaced lately when we see the statement (label: statement)
label | abel |
Definition at line 254 of file statement.c.
References CONS, empty_extensions(), entity_empty_label(), FindStatementFromLabel(), get_current_C_comment(), get_current_C_line_number(), is_instruction_goto, LabeledStatements, make_continue_statement(), make_instruction(), make_statement(), make_synchronization_none(), MakeCLabel(), NIL, STATEMENT, STATEMENT_ORDERING_UNDEFINED, and statement_undefined.
Referenced by MakeBreakStatement(), MakeCaseStatement(), MakeContinueStatement(), and MakeDefaultStatement().
Construct a new statement from.
s | by adding a |
label | and a |
comment. | If it is possible to do it without creating a new statement, retun the old one modified according to. |
There is no other statement already associated with this label...
Add a label and deal all the gory details about the PIPS internal representation:
There is already a statement stub smt associated to this label with some gotos pointing to it, so keep it as the labeled target.
The statement does not have a label and can accept one, so patch in place smt:
The statement can not accept a label or another one, just keep the previous label in front:
label | abel |
comment | omment |
Definition at line 204 of file statement.c.
References add_label_to_statement(), comment(), CONS, FindStatementFromLabel(), free(), free_statement(), gen_statement_cons(), insert_comments_to_statement(), instruction_sequence_p, instruction_undefined, LabeledStatements, make_block_statement(), MakeCLabel(), NIL, STATEMENT, statement_comments, statement_instruction, statement_undefined, string_undefined, and unlabelled_statement_p().
Referenced by MakeCaseStatement(), and MakeDefaultStatement().
l1 is a list of parameter names and it represents the exact order in the parameter list l2 is a list of entities with their type, storage,... and the order can be different from l1 In addition, l2 can be incomplete wrt l1, so other entities must be created from l1, with default type : scalar integer variable.
We create the list of parameters with the order of l1, and the parameter type and mode are retrieved from l2.
Since the offset of formal argument in l2 can be false, we have to update it here by using l1
s is not declared in l2, create the corresponding entity/ formal variable and add it to the declaration list, because it cannot be added with par_def in l2
l1 | 1 |
l2 | 2 |
FunctionStack | unctionStack |
Definition at line 3348 of file util.c.
References AddToDeclarations(), CONS, DEFAULT_INTEGER_TYPE_SIZE, entity_storage, entity_type, entity_user_name(), FindOrCreateEntity(), FindParameterEntity(), FOREACH, FunctionStack, gen_nconc(), make_basic_int(), make_dummy_identifier(), make_formal(), make_mode_value(), make_parameter(), make_storage_formal(), make_type_variable(), make_variable(), NIL, offset, PARAMETER, parameter_undefined_p, stack_head(), and STRING.
The storage part should not be called twice when reparsing compilation unit.
We assume that double declarations are dealt with someone else
ComputeAreaOffset(StaticArea,e)
he offset must be recomputed lately, when we know for sure the size of the variables
This must be a variable, not a function/typedef/struct/union/enum. The variable is declared outside any function, and hence is global
ComputeAreaOffset(get_top_level_entity(),e)
the offset must be recomputed lately, when we know for sure the size of the variable
Global variable can be declared in many different file
ADD BLOCK SCOPE
ComputeAreaOffset(StaticArea,e)
he offset must be recomputed lately, when we know for sure the size of the variable
ComputeAreaOffset(DynamicArea,e)
the offset must be recomputed lately, when we know for sure the size of the variable
is_external | s_external |
is_static | s_static |
Definition at line 3177 of file util.c.
References area_layout, compilation_unit_name, CONS, DYNAMIC_RAM_OFFSET, DynamicArea, ENTITY, entity_type, FindOrCreateEntity(), gen_in_list_p(), gen_nconc(), get_current_compilation_unit_entity(), get_current_module_entity(), get_top_level_entity(), is_external, make_ram(), make_storage_ram(), NIL, pips_assert, ram_undefined, SizeOfArray(), StackArea, STATIC_AREA_LOCAL_NAME, StaticArea, TOP_LEVEL_MODULE_NAME, type_area, type_variable_p, and UNKNOWN_RAM_OFFSET.
Referenced by UpdateEntity().
Transform a switch statement to if - else - goto. Example:
switch (c) { case 1: s1; case 2: s2; default: sd; }
if (c==1) goto switch_xxx_case_1; if (c==2) goto switch_xxx_case_2; goto switch_xxx_default; switch_xxx_case_1: ; s1; switch_xxx_case_2: ; s2; switch_xxx_default: ; sd;
In si, we can have goto break_xxx; (which was a break)
and break_xxx: ; is inserted at the end of the switch statement
The statement s corresponds to the body
switch_xxx_case_1: ; s1; switch_xxx_case_2: ; s2; switch_xxx_default: ; sd;
we have to insert
if (c==1) goto switch_xxx_case_1; if (c==2) goto switch_xxx_case_2; goto switch_xxx_default;
before s and return the inserted statement.
For the time being, the switch comment is lost. It should already be included in the argument,s
Make sure the default case is the last one in the test sequence
Keep the cases in the user order. Tobe checked at the pARSED_PRINTED_FILE level.
no default case, jump out of the switch control structure
trdup("")
This switch has a break statement which has been transformed to goto Add the labeled statement after the switch
{
printf("Switch statement: \n");
print_statement(s);
}
Definition at line 586 of file statement.c.
References asprintf, basic_int, CAR, CONS, ENDP, FindStatementFromLabel(), free(), free_sequence(), gen_free_list(), gen_nconc(), get_label_prefix, ifdebug, insert_statement(), instruction_goto_p, instruction_to_statement(), list_undefined, LoopStack, make_instruction_sequence(), make_sequence(), MakeBreakStatement(), MakeCLabel(), NIL, pips_assert, pips_debug, POP, sequence_statements, stack_head(), STATEMENT, statement_consistent_p(), statement_instruction, statement_undefined, statement_undefined_p, string_undefined, and SwitchGotoStack.
void MakeTopLevelEntity | ( | void | ) |
To be economic, group this top-level entity to it areas
FI: this is not convenient if top-level:top-level is a module. All global variables should be declared there. I need also to generate stubs for global variables... Do I? Yes, because the points-to information is computed bottom-up.
Definition at line 157 of file util.c.
References entity_initial, entity_storage, entity_type, FindOrCreateEntity(), make_code(), make_functional(), make_language_c(), make_sequence(), make_storage_rom(), make_type_functional(), make_type_void(), make_value_code(), NIL, strdup(), and TOP_LEVEL_MODULE_NAME.
Referenced by actual_c_parser().
This loop has a continue statement which has been transformed to goto Add the labeled statement at the end of loop body
This loop has a break statement which has been transformed to goto Add the labeled statement after the loop
{
printf("While loop statement: \n");
print_statement(smt);
}
lexp | exp |
before | efore |
Definition at line 297 of file statement.c.
References asprintf, basic_int, FindStatementFromLabel(), free(), get_current_C_line_number(), get_label_prefix, insert_statement(), lexp, LoopStack, make_whileloop_statement(), MakeCLabel(), MakeCommaExpression(), pips_assert, s1, stack_head(), statement_consistent_p(), and statement_undefined_p.
expression MemberDerivedIdentifierToExpression | ( | type | t, |
string | m | ||
) |
Definition at line 463 of file util.c.
References basic_derived, basic_pointer, basic_tag, basic_typedef, concatenate(), CParserError(), entity_type, entity_user_name(), exp, expression_undefined, free(), IdentifierToExpression(), is_basic_derived, is_basic_pointer, is_basic_typedef, MEMBER_SEP_STRING, MemberDerivedIdentifierToExpression(), pips_debug, strdup(), type_variable, type_variable_p, and variable_basic.
Referenced by MemberDerivedIdentifierToExpression(), and MemberIdentifierToExpression().
expression MemberIdentifierToExpression | ( | expression | e, |
string | m | ||
) |
Find the name of struct/union of m from the type of expression e
The first expression must be a pointer
standard integer arithmetic: why bother? why take the CDR?
FI: seems too simple. No need to remember if you sarted with "." or "->"?
Let use the second argument
More types of call must be taken into account: typedef and pointer to functions
User defined call and intrinsics not processed above
A call must have occured somewhere...
An apply must have occured somewhere...
expression exp = subscript_array(syntax_subscript(s));
pips_debug(6,"Subscripting array expression\n");
return MemberIdentifierToExpression(exp, m);
Definition at line 498 of file util.c.
References application_function, b1, b2, basic_bit_p, basic_int_p, basic_of_expression(), basic_pointer, basic_pointer_p, call_arguments, call_function, call_to_functional_type(), CAR, cast_type, CDR, CParserError(), ENTITY_ADDRESS_OF_P, ENTITY_ASSIGN_P, ENTITY_CONDITIONAL_P, ENTITY_DEREFERENCING_P, ENTITY_FIELD_P, ENTITY_MINUS_C_P, entity_name, ENTITY_PLUS_C_P, ENTITY_PLUS_P, ENTITY_POINT_TO_P, ENTITY_POST_DECREMENT_P, ENTITY_POST_INCREMENT_P, ENTITY_PRE_DECREMENT_P, ENTITY_PRE_INCREMENT_P, entity_type, exp, EXPRESSION, expression_syntax, expression_to_type(), expression_undefined, f(), free_basic(), functional_result, ifdebug, is_syntax_application, is_syntax_call, is_syntax_cast, is_syntax_range, is_syntax_reference, is_syntax_sizeofexpression, is_syntax_subscript, MemberDerivedIdentifierToExpression(), MemberIdentifierToExpression(), overloaded_type_p(), pips_debug, pips_internal_error, print_expression(), reference_variable, syntax_application, syntax_call, syntax_cast, syntax_reference, syntax_tag, type_functional, type_functional_p, type_variable, type_variable_p, ultimate_type(), and variable_basic.
Referenced by MemberIdentifierToExpression().
Pop n times the stack s.
Definition at line 3442 of file util.c.
References gen_free(), and stack_pop().
Referenced by StackPop().
void parser_init_keyword_typedef_table | ( | void | ) |
FI: keyword_typedef_table is also a global variable. I am trying to move towards some kind of functional wrapping around the global variable, which I would like to declare static in ri-util/static.c.
GNU predefined type(s), expecting no conflict with user named type
AM: en attendant mieux...
typedef names are added later when encoutered.
Definition at line 193 of file c_parser.c.
References hash_put(), keyword_typedef_table, make_keyword_typedef_table(), TK_ASM, TK_AUTO, TK_BREAK, TK_BUILTIN_VA_ARG, TK_CASE, TK_CHAR, TK_COMPLEX, TK_CONST, TK_CONTINUE, TK_DEFAULT, TK_DO, TK_DOUBLE, TK_ELSE, TK_ENUM, TK_EXTERN, TK_FLOAT, TK_FOR, TK_GOTO, TK_IF, TK_INLINE, TK_INT, TK_INT128, TK_LONG, TK_NAMED_TYPE, TK_REGISTER, TK_RESTRICT, TK_RETURN, TK_SHORT, TK_SIGNED, TK_SIZEOF, TK_STATIC, TK_STRUCT, TK_SWITCH, TK_THREAD, TK_TYPEDEF, TK_UINT128, TK_UNION, TK_UNSIGNED, TK_VOID, TK_VOLATILE, and TK_WHILE.
Referenced by actual_c_parser().
The scope is moved up the scope tree and a NULL is return when there are no more scope to explore.
get rid of last block separator
old_scope | ld_scope |
Definition at line 235 of file cyacc.tab.c.
void pop_c_parser_scope_stack | ( | void | ) |
Definition at line 558 of file cyacc.tab.c.
Referenced by ExitScope().
string pop_current_C_comment | ( | void | ) |
int pop_current_C_line_number | ( | void | ) |
void PopContext | ( | void | ) |
Definition at line 441 of file cyacc.tab.c.
void push_current_C_comment | ( | void | ) |
Push the current C comment so that we can get it back when building the statement later.
This reset the current comment through get_current_C_comment()
Definition at line 1331 of file clexer.c.
void push_current_C_line_number | ( | void | ) |
void push_new_c_parser_scope | ( | void | ) |
Definition at line 549 of file cyacc.tab.c.
Referenced by EnterScope().
void PushContext | ( | c_parser_context | c | ) |
Definition at line 434 of file cyacc.tab.c.
void put_new_typedef | ( | const char * | name | ) |
This function is used by libraries "step"* and "task_parallelization".
FI: I have no idea why it works although the keyword_typedef_table should not be initialized... It could not be made static, because it might be used by any file in the c_syntax library.
name | ame |
Definition at line 1078 of file util.c.
References hash_put(), keyword_typedef_table, pips_debug, strdup(), and TK_NAMED_TYPE.
Referenced by cast_STEP_ARG(), mpi_initialize(), mpi_type_mpi_comm(), mpi_type_mpi_request(), and mpi_type_mpi_status().
key | ey |
Definition at line 139 of file c_parser.c.
References entity_name, entity_to_type_stack_table, hash_put(), pips_internal_error, and stack_undefined_p.
Referenced by RenameFunctionEntity(), and SubstituteDummyParameters().
void remove_entity_type_stack | ( | entity | e | ) |
Definition at line 156 of file c_parser.c.
References entity_name, entity_to_type_stack_table, fprintf(), hash_del(), hash_get(), HASH_UNDEFINED_VALUE, ifdebug, pips_debug, stack_free(), and stack_undefined_p.
Referenced by remove_entity_type_stacks(), and SubstituteDummyParameters().
void remove_entity_type_stacks | ( | list | el | ) |
el | l |
Definition at line 179 of file c_parser.c.
References ENTITY, FOREACH, and remove_entity_type_stack().
Referenced by RemoveDummyArguments(), and UseFormalArguments().
void remove_LFs_from_C_comment | ( | int | extra_LF | ) |
To chase formals in type declarations.
If f has dummy formal parameters, replace them by standard formal parameters
make a list of formal dummy parameters
Since the compilation order is not known, the standard formal parameters may already exist and they should not be removed.
Update the "dummy" field of the "parameter" data structure
This special case could be ignored and handled like the next one to avoid cut-and-past and/or the definition of a new function.
no dummy naming information available as in foo(int);
FI: just in case?
Remore the dummy formals from f's declaration list (and from the symbol table?) but keep all pointers towards them in the declarations as in "void foo(n,a[n])"
FI: The storage might point to another dummy argument (although it should not)
Let's hope there are no other pointers towards dummy formal parameters
No, there may be occurences due to dependent types.
refs | efs |
Definition at line 2224 of file util.c.
References CAR, code_declarations, CONS, dummy_identifier, dummy_identifier_p, dummy_parameter_entity_p(), ENDP, ENTITY, entity_formal_p(), entity_initial, entity_name, entity_type, entity_undefined_p, f(), find_ith_parameter(), functional_parameters, gen_free_list(), gen_length(), gen_nconc(), gen_remove(), list_undefined, MAP, NIL, PARAMETER, parameter_dummy, pips_assert, pips_debug, POP, REFERENCE, reference_variable, remove_entity_type_stacks(), type_functional, type_functional_p, typedef_entity_p(), update_dummy_parameter(), value_code, value_code_p, value_intrinsic_p, and value_undefined_p.
Referenced by UpdateEntity().
void RemoveFromExterns | ( | entity | e | ) |
This may happen when functional arguments are dealt with
Definition at line 2884 of file util.c.
References c_parser_user_warning, code_externs, entity_initial, entity_undefined_p, f(), gen_remove(), get_current_module_entity(), and value_code.
Referenced by actual_c_parser(), and FindOrCreateCurrentEntity().
Rename function oe if necessary.
The function name may be wrong because not enough information was available when it was created by FindOrCreateCurrentEntity().
oe must be a function and not a pointer to a function
oe should be added to the declarations of the current block
A C function or intrinsics name should include no scope information. But a functional typedef should.
In fact, we'd like to know if it is found before we create it...
FI I do not understand how formal parameters could be declared before
We assume oe is not already part of a declaration list since its formal parameters have been taken care of
oe | e |
Definition at line 1556 of file util.c.
References code_declarations, copy_storage(), copy_type(), copy_value(), empty_string_p(), ENTITY, entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined_p, entity_user_name(), FindEntity(), FindOrCreateEntity(), FOREACH, formal_function, free(), gen_clear_tabulated_element(), get_from_entity_type_stack_table(), is_value_code, list_undefined, local_name_to_scope(), make_code(), make_language_c(), make_sequence(), make_value(), MODULE_SEP, NIL, pips_debug, put_to_entity_type_stack_table(), stack_copy(), storage_formal, storage_formal_p, strdup(), TOP_LEVEL_MODULE_NAME, typedef_entity_p(), value_code, value_undefined_p, and value_unknown_p.
void reset_C_comment | ( | bool | is_compilation_unit_p | ) |
reset and reset_error should be handled differently
Comments in the compilation unit are lost because they are related only to declarations and because comments on declarations are lost. Also, comments located at the end of a block are lost, as we do not generate an extra NOP to carry them.
pips_internal_error("Comments stack is not empty\n");
is_compilation_unit_p | s_compilation_unit_p |
Definition at line 1450 of file clexer.c.
void reset_c_parser_current_input_file_name | ( | void | ) |
Definition at line 73 of file c_parser.c.
References c_parser_current_file_name, pips_internal_error, string_undefined, and string_undefined_p.
Referenced by actual_c_parser().
void reset_c_parser_current_user_input_file_name | ( | void | ) |
Definition at line 104 of file c_parser.c.
References c_parser_current_user_input_file_name, pips_internal_error, string_undefined, and string_undefined_p.
Referenced by actual_c_parser().
void reset_c_parser_scope_stack | ( | void | ) |
Definition at line 522 of file cyacc.tab.c.
void Reset_C_ReturnStatement | ( | void | ) |
The return statement must be reset when it is used by the parser to add the return statement to the function body or when a parser error is encountered.
Definition at line 115 of file return.c.
References C_return_statement, entity_undefined, last_return_value_assignment, last_returned_value, list_undefined, number_of_return_statements, return_current_module, return_value_entity, and statement_undefined.
Referenced by c_parser_error(), and FixCReturnStatements().
void reset_current_dummy_parameter_number | ( | void | ) |
Definition at line 144 of file util.c.
References current_dummy_parameter_number.
Referenced by actual_c_parser(), and c_parser_error().
void reset_declaration_counter | ( | void | ) |
Definition at line 492 of file cyacc.tab.c.
void reset_entity_type_stack_table | ( | void | ) |
Definition at line 186 of file c_parser.c.
References entity_to_type_stack_table, HASH_MAP, hash_table_free(), hash_table_undefined, and stack_free().
Referenced by actual_c_parser(), c_parser_error(), and init_entity_type_storage_table().
void reset_expression_comment | ( | void | ) |
we don't want an expression comment with new lines, it is disgracefull
Too bad. This should not happen, but it happens with comma expressions in header files
Definition at line 169 of file cyacc.tab.c.
void reset_preprocessor_line_analysis | ( | void | ) |
Definition at line 3592 of file util.c.
References buffer_initialized_p.
Referenced by actual_c_parser().
void ResetCurrentCompilationUnitEntity | ( | bool | is_compilation_unit_parser | ) |
Let's redo the memory allocation for variables whose name has changed:-(
reset_entity_type_stack_table();
is_compilation_unit_parser | s_compilation_unit_parser |
Definition at line 349 of file util.c.
References CCompilationUnitMemoryAllocation(), CCompilationUnitMemoryReallocation(), fprint_C_environment(), get_bool_property(), get_current_module_entity(), get_current_module_name(), pips_debug, and reset_current_module_entity().
Referenced by actual_c_parser().
void ResetCurrentModule | ( | void | ) |
Reset them to stack_undefined_p instead of STACK_NULL
Definition at line 125 of file statement.c.
References BlockStack, CModuleMemoryAllocation(), fprint_C_environment(), get_bool_property(), get_current_module_entity(), get_current_module_name(), LoopStack, pips_debug, reset_current_module_entity(), stack_free(), stack_undefined, SwitchControllerStack, and SwitchGotoStack.
Allocate a new string containing only block scope information.
full_scope | ull_scope |
Definition at line 268 of file cyacc.tab.c.
int ScopeStackSize | ( | void | ) |
Definition at line 366 of file cyacc.tab.c.
void set_c_parser_current_input_file_name | ( | string | file_name | ) |
file_name | ile_name |
Definition at line 65 of file c_parser.c.
References c_parser_current_file_name, file_name, pips_internal_error, and string_undefined_p.
Referenced by actual_c_parser().
void set_c_parser_current_user_input_file_name | ( | string | file_name | ) |
file_name | ile_name |
Definition at line 96 of file c_parser.c.
References c_parser_current_user_input_file_name, file_name, pips_internal_error, and string_undefined_p.
Referenced by actual_c_parser().
void set_current_C_line_number | ( | void | ) |
Initialize the user line number...
... and the absolute line number in the current file
The first line is used to indicate the line number in the user source file
Some check on it first? It should have been disallocated by reset_current_C_line_number()
Definition at line 1166 of file clexer.c.
void set_entity_initial | ( | entity | v, |
expression | nie | ||
) |
Be careful if the initial value has already been set.
Detect double definitions when possible
Take care of the special case of pointers to functions.
The compilation unit has already been scanned once for declarations. Double definitions are no surprise...
Generate initializations for pointers to functions and arrays of pointers to functions
A pointer to a function already has value code as initial value. We may not even know yet it's a pointer...
nie | ie |
Definition at line 3469 of file util.c.
References asprintf, basic_pointer, c_parser_user_warning, code_initializations, compilation_unit_p(), CONS, entity_initial, entity_name, entity_type, expression_to_string(), free(), free_value(), get_current_module_name(), make_expression_statement(), make_sequence(), make_value_expression(), NIL, pips_internal_error, pips_user_warning, pointer_type_p(), STATEMENT, type_functional_p, type_undefined, type_undefined_p, type_variable, ultimate_type(), value_code, value_code_p, value_expression, value_expression_p, value_tag, value_undefined, value_undefined_p, value_unknown_p, and variable_basic.
Referenced by freia_is_transpose_call().
void set_prettyprint_control_list_to_dummy | ( | void | ) |
Definition at line 1084 of file statement.c.
References dummy_declaration_p.
void set_prettyprint_control_list_to_extern | ( | void | ) |
Definition at line 1042 of file statement.c.
References extern_declaration_p.
void StackPop | ( | stack | OffsetStack | ) |
The OffsetStack is poped n times, where n is the number of formal arguments of the actual function.
OffsetStack | ffsetStack |
Definition at line 3450 of file util.c.
References basic_int, NStackPop(), OffsetStack, and stack_head().
void StackPush | ( | stack | OffsetStack | ) |
The OffsetStack is pushed incrementally.
OffsetStack | ffsetStack |
Definition at line 3457 of file util.c.
References basic_int, make_basic_int(), OffsetStack, stack_head(), and stack_push().
The copy could be avoided by substituting v->s with nv->s
Store type information. Might be useless.
Inherit any attribute you can
el | l |
Definition at line 2351 of file util.c.
References CAR, copy_storage(), copy_type(), copy_value(), dummy_parameter_entity_p(), ENDP, ENTITY, ENTITY_, entity_initial, entity_local_name(), entity_storage, entity_type, entity_user_name(), f(), FindOrCreateEntity(), get_from_entity_type_stack_table(), POP, put_to_entity_type_stack_table(), remove_entity_type_stack(), stack_copy(), storage_undefined_p, type_undefined_p, and value_undefined_p.
To simplify debugging
The list is stored there at line 2087 of cyacc.y (5 August 2009)
e->type==entity_domain
lres = gen_nconc(lres,ltmp);
The ltmp lists seem to be somehow shared as shown in ngspice/main.tpips. The previous implementation of the current function generated cyclic lists. The new implementation is incompatible with a proper memory management.
I do not understand what's done in c_syntax/cyacc.y. The trace obtained from C_syntax/ngspice01.c shows that the same derived entities appear several times when dummy structs and unions are embedded as in ngspice01.c
le | e |
Definition at line 3020 of file util.c.
References check_entity(), CONS, ENDP, ENTITY, entity_domain, entity_initial, entity_name, FOREACH, fprintf(), gen_in_list_p(), gen_list_cyclic_p(), gen_nconc(), ifdebug, NIL, pips_assert, pips_debug, print_entities(), and value_undefined.
void update_C_comment | ( | string | a_comment | ) |
Update the entity with final type, storage
tc must have variable type, add lq to its qualifiers
lse const void, void is not of type variable, store const where ????????? CParserError("Entity has qualifier but no type or is not variable type in the context?\n");
Use the type stack in entity_storage to create the final type for the entity
ContextStack | ontextStack |
Definition at line 2842 of file util.c.
References c_parser_context_qualifiers, c_parser_context_type, ContextStack, entity_name, entity_storage, entity_type, get_from_entity_type_stack_table(), NIL, pips_debug, stack_head(), stack_pop(), stack_size(), storage_undefined, tc, type_undefined_p, type_variable, type_variable_p, UpdateType(), and variable_qualifiers.
lq is for what ? e or le ????: lq should be for le
lq | q |
le | e |
Definition at line 1514 of file util.c.
References basic_undefined, CONS, CParserError(), DIMENSION, entity_name, entity_type, gen_nconc(), make_type_variable(), make_variable(), MakeDimension(), NIL, pips_debug, type_undefined_p, type_variable, type_variable_p, variable_dimensions, and variable_qualifiers.
ld | d |
le | e |
ContextStack | ontextStack |
Definition at line 3097 of file util.c.
References ContextStack, ENTITY, FOREACH, and UpdateDerivedEntity().
Update the derived entity with final type and rom storage. If the entity has bit type, do not need to update its type
what about context qualifiers ?
What do we do for functional types for instance?
FI: I assume the qualifiers are carried by the result
What do we do for functional types for instance?
Although it should be popped from the stack, the current context seems to be used later in case of typedef, such as seen in decl24.c
Temporally put the list of struct/union entities defined in decl_psec_list to initial value of ent
ld | d |
ContextStack | ontextStack |
Definition at line 2942 of file util.c.
References basic_pointer, bit_type_p(), c_parser_context_qualifiers, c_parser_context_type, ContextStack, ENDP, entity_initial, entity_name, entity_storage, entity_type, f(), functional_result, get_from_entity_type_stack_table(), make_storage_rom(), NIL, pips_debug, pips_internal_error, pointer_type_p(), stack_head(), stack_pop(), stack_size(), tc, type_functional, type_functional_p, type_variable, type_variable_p, type_void, type_void_p, UpdateType(), variable_basic, and variable_qualifiers.
Referenced by UpdateDerivedEntities().
void UpdateEntities | ( | list | le, |
stack | ContextStack, | ||
stack | FormalStack, | ||
stack | FunctionStack, | ||
stack | OffsetStack, | ||
bool | is_external, | ||
bool | is_declaration | ||
) |
le | e |
ContextStack | ontextStack |
FormalStack | ormalStack |
FunctionStack | unctionStack |
OffsetStack | ffsetStack |
is_external | s_external |
is_declaration | s_declaration |
Definition at line 2733 of file util.c.
References ContextStack, derived_entity_p(), ENTITY, FOREACH, FormalStack, FunctionStack, is_external, OffsetStack, and UpdateEntity().
void UpdateEntity | ( | entity | e, |
stack | ContextStack, | ||
stack | FormalStack, | ||
stack | FunctionStack, | ||
stack | OffsetStack, | ||
bool | is_external, | ||
bool | is_declaration | ||
) |
Update the entity with final type, storage and initial value; and also (sometimes?) declare it at the module level.
Replace dummy arguments by formal arguments for functions
Generate the return variables for functions returning a result
And probably much more...
If e is an intrinsics, nothing should be done, unless you are in the compilation unit: but the intrinsic type has already been put aside in the type stack linked to the entity and destroyed
tc must have variable type, add lq to its qualifiers
lse const void, void is not of type variable, store const where ????????? CParserError("Entity has qualifier but no type or is not variable type in the context?\n");
Use the type stack in entity_storage to create the final type for the entity
The default type is int, or a function returning an int
FI: it might be a good idea to use the type "unknown" or a future type "default" to improve the prettyprinting by not adding implicit "int" declarations.
The default type is int
FI: This elseif branch is apparently useless because the probleme must be dealt with later in the parser
The default return type is int
FI: no longer true, I believe "this field is always pre-defined. It is temporarilly used to store a type. See cyacc.y rule direct-decl:"
FI: Intrinsic do not have formal named parameters in PIPS RI, however such parameters can be named in intrinsic declarations. Problem with Validation/C_syntax/memcof.c
|| type_variable_p(entity_type(function))
Storage does also matter for typedef (and function pointer)
How to access the information about the function type?
FI: This branch should never be executed
The entities for the type_variable is added to the current module and the declarations
It is too early to use extern_entity_p()
Keyword EXTERN has just been encountered
Yes, but this may have been already recognized in FindOrCreateCurrentEntity() and this may not imply the declaration as extern is another declaration of e has already been encountered.
To avoid multiple declarations
Too late to check that the first declaration did not include an initialization
The function should also added to the declarations
We are defining the current module entity
Test case C_syntax/function_name_conflict01.c
Unfortunately, an intrinsics cannot be redefined, just like a user function or subroutine after editing because intrinsics are not handled like user functions or subroutines. They are not added to the called_modules list of other modules, unless the redefining module is parsed FIRST. There is not mechanism in PIPS to control the parsing order.
Be careful if standard arguments are needed: replace the dummy parameters
FI: intrinsic may need to be processed here if they use dynamic typing, a.k.a. dependent types but they do not have a code value!
They cannot be removed in general because they may appear in declarations as in foo(int n, double a[n])
FI: I do not know if refs contains copies of references or just pointer to them
If e is a function pointer, check the storage of its formal parameters
ContextStack | ontextStack |
FormalStack | ormalStack |
FunctionStack | unctionStack |
OffsetStack | ffsetStack |
is_external | s_external |
is_declaration | s_declaration |
Definition at line 2473 of file util.c.
References AddToDeclarations(), AddToExterns(), basic_int, basic_pointer, c_parser_context_qualifiers, c_parser_context_scope, c_parser_context_static, c_parser_context_storage, c_parser_context_type, c_parser_user_warning, CAR, code_declarations, code_externs, code_undefined_p, compilation_unit_entity_p(), compilation_unit_p(), ContextStack, CParserError(), CreateReturnEntity(), DEFAULT_INTEGER_TYPE_SIZE, dummy_parameter_entity_p(), empty_scope_p(), ENDP, ENTITY, entity_consistent_p(), entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined_p, extract_references_from_declarations(), f(), formal_parameter_p(), FormalStack, free_storage(), functional_result, FunctionStack, gen_free_list(), gen_in_list_p(), get_c_parser_current_input_file_name(), get_current_module_entity(), get_current_module_name(), get_from_entity_type_stack_table(), intrinsic_entity_p(), is_external, list_to_string(), list_undefined, make_basic_int(), make_formal(), make_scalar_integer_type(), make_storage_formal(), make_storage_rom(), make_type_variable(), make_value_unknown(), make_variable(), MakeStorageRam(), NIL, offset, OffsetStack, pips_assert, pips_debug, pips_internal_error, pointer_type_p(), POP, RemoveDummyArguments(), safe_c_words_entity(), stack_empty_p(), stack_head(), stack_pop(), stack_size(), stack_undefined_p, storage_tag, storage_to_string(), storage_undefined_p, tc, TOP_LEVEL_MODULE_NAME, type_functional, type_functional_p, type_undefined_p, type_variable, type_variable_p, type_void, type_void_p, typedef_entity_p(), ultimate_type(), UpdateType(), UseFormalArguments(), user_log(), value_code, value_code_p, value_intrinsic_p, value_undefined_p, variable_basic, and variable_qualifiers.
Referenced by UpdateEntities().
This function replaces the type pointed by the pointer pt (this can be a pointer of pointer,... so we have to go until the last one) by the type t
pt | t |
Definition at line 1427 of file util.c.
References basic_pointer, basic_pointer_p, CParserError(), make_basic_pointer(), make_type_variable(), make_variable(), NIL, pips_debug, type_tag, type_undefined, type_undefined_p, type_variable, type_variable_p, UpdateFinalPointer(), variable_basic, and variable_qualifiers.
Referenced by UpdateFinalPointer().
The parser has found out that an entity is a function and partially sets its type.
The function may also be an intrinsics and be already fully defined.
If oe is an intrinsics, nothing should be done if we are compiling a function that redeclares intrinsics, because they are usually badly or at least only partly redeclared.
However, il should be updated if it's declared in a compilation unit as the header files may contain more up-to-date information than bootstrap. Or if its type has already been placed in the type stack and been undefined in the entity.
Note that a user function might have the same name as a C intrinsic. Then we are in trouble.
Is oe's name compatible with a function name? Well oe might be a pointer...
FI: We used never to bump into this case...
oe | e |
la | a |
Definition at line 1614 of file util.c.
References compilation_unit_p(), CParserError(), ENDP, entity_name, entity_type, entity_undefined_p, f(), fprintf(), functional_parameters, get_current_module_entity(), get_current_module_name(), ifdebug, intrinsic_entity_p(), list_to_string(), make_functional(), make_type_functional(), MAP, NIL, PARAMETER, parameter_type, pips_debug, pips_internal_error, safe_c_words_entity(), type_functional, type_functional_p, type_undefined, and type_undefined_p.
lq | q |
Definition at line 1368 of file util.c.
References basic_undefined, CParserError(), entity_name, entity_type, gen_nconc(), list_undefined, make_type_variable(), make_variable(), NIL, pips_debug, safe_type_to_string(), type_undefined_p, type_variable, type_variable_p, and variable_qualifiers.
Make e an array of pointers whose type is this of pt
Make e a function returns a pointer
pt | t |
lq | q |
Definition at line 1444 of file util.c.
References c_words_entity(), CParserError(), entity_name, entity_type, f(), functional_parameters, gen_free_list(), gen_nconc(), ifdebug, is_type_functional, is_type_variable, list_to_string(), make_functional(), make_type_functional(), make_type_variable(), make_variable(), NIL, pips_debug, type_functional, type_tag, type_undefined_p, type_variable, variable_basic, variable_dimensions, and variable_qualifiers.
This function replaces the undefined field in t1 by t2.
If t1 is an array type and the basic of t1 is undefined, it is replaced by the basic of t2.
If t1 is a pointer type, if the pointed type is undefined it is replaced by t2.
If t1 is a functional type, if the result type of t1 is undefined, it is replaced by t2.
If t1 is a void type, then either t2 also is a void type or an error is raised.
The function is recursive.
FI: This function used to create sharing between t1 and t2, which creates problems when t2 is later freed. t1 may be updated and returned or a new type may be created.
This may happen when a type is implicitly declared as in "extern m[3];"
We used to use type_unknown when the type was implicit, but type_unknown does not let us store dimension information. We need here a new kind of basic, basic unknown or basic implicit. This would let us be more respectful of the source code, but requires a modification of the internal representation. It is mostly a prettyprint issue. See ticket
Basic pointer
t1 is already fully defined
Redundant update
Could be a pips internal error...
t1 | 1 |
t2 | 2 |
Definition at line 1693 of file util.c.
References basic_pointer, basic_pointer_p, basic_undefined_p, copy_basic(), copy_type(), CParserError(), DEFAULT_INTEGER_TYPE_SIZE, f(), functional_parameters, functional_result, gen_full_copy_list(), gen_nconc(), is_type_functional, is_type_variable, is_type_void, make_basic_pointer(), make_functional(), make_scalar_integer_type(), make_type_functional(), make_type_unknown(), make_type_variable(), make_variable(), overloaded_type_p(), pips_assert, type_equal_p(), type_functional, type_tag, type_undefined, type_undefined_p, type_variable, type_variable_p, type_void_p, UpdateType(), variable_basic, variable_dimensions, and variable_qualifiers.
Referenced by UpdateAbstractEntity(), UpdateDerivedEntity(), UpdateEntity(), and UpdateType().
void UseDummyArguments | ( | entity | f | ) |
If f has regular formal parameters, destroy them.
make a list of formal parameters
Remove the formals from f's declaration list and from the symbol table
FI: The storage might point to another dummy argument (although it should not)
Let's hope there are no other pointers towards dummy formal parameters
Definition at line 2019 of file util.c.
References CAR, code_declarations, CONS, ENDP, ENTITY, entity_formal_p(), entity_initial, entity_name, entity_storage, entity_type, entity_undefined, f(), formal_function, gen_free_list(), gen_nconc(), gen_remove(), list_undefined, NIL, pips_assert, pips_debug, POP, storage_formal, type_functional_p, typedef_entity_p(), value_code, value_code_p, and value_undefined_p.
void UseFormalArguments | ( | entity | f | ) |
If f has dummy formal parameters, replace them by standard formal parameters.
make a list of formal dumy parameters; depending on the kind of function declaration, dummy formal parameters are used (new C function declaration style), or not (old C function declaration style).
FI: Maybe, it would be better to unify the use of summy formal parameter in the parser?
Is it a local function or global function?
mn = strdup(concatenate(entity_module_name(f),entity_local_name(f), NULL));
Remore the dummy formals from f's declaration list (and from the symbol table?) and replace them by equivalent regular formal parameters
Substitute p by new_p in the declaration references for cases such as "foo(n, double a[n])"
This only works if the refs list points to the actual references and not to copies...
sg: this test used to be if e == p, but it missed some cases because reference_variable may have been generated incorectly before using a TOP_LEVEL variable instead of the dummy
A substitution could be performed instead...
FI: The storage might point to another dummy argument (although it should not)
Let's hope there are no other pointers towards dummy formal parameters
Check substitution in formal parameter declarations
FI: just in case?
Do not free the dummy formal parameter variable as they are preserved in the dummy field for accurate prettyprinting
Definition at line 2063 of file util.c.
References CAR, code_declarations, CONS, copy_storage(), copy_type(), copy_value(), declaration_supporting_references(), dummy_parameter_entity_p(), ENDP, ENTITY, entity_formal_p(), entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined, entity_user_name(), f(), FindOrCreateEntity(), FOREACH, fprintf(), free(), gen_free_list(), gen_length(), gen_nconc(), gen_remove(), get_from_entity_type_stack_table(), ifdebug, list_undefined, MAP, module_all_declarations(), NIL, pips_assert, pips_debug, pips_internal_error, POP, print_entities(), print_references(), REFERENCE, reference_variable, remove_entity_type_stacks(), same_entity_lname_p(), stack_undefined_p, strdup(), string_undefined, top_level_entity_p(), type_functional_p, typedef_entity_p(), value_code, value_code_p, and value_undefined_p.
Referenced by UpdateEntity().
|
extern |
statement.c
statement.c
Definition at line 58 of file statement.c.
Referenced by c_parser_error(), InitializeBlock(), LinkInstToCurrentBlock(), MakeBlockIfInst(), MakeElseInst(), MakeEnddoInst(), MakeEndifInst(), PopBlock(), PushBlock(), and ResetCurrentModule().
|
extern |
|
extern |
|
extern |
|
extern |
Warning! Do not modify this file that is automatically generated!
Modify src/Libs/c_syntax/c_syntax-local.h instead, to add your own modifications. header file built by cproto c_syntax-local.h
Definition at line 291 of file c_syntax.h.
|
extern |
from "clex.l"
from "clex.l"
The goal is to reconstruct the line number in the user file and not the line number in the preprocessed file.
This is performed in analyze_preprocessor_line() (util.c)
Definition at line 296 of file c_syntax.h.
Referenced by set_current_C_line_number().
|
extern |
the file read in by the c_lexer
Definition at line 293 of file c_syntax.h.
|
extern |
|
extern |
Referenced by contrainte_copy(), contrainte_dup(), contraintes_copy(), and contraintes_dup().
|
extern |
|
extern |
Definition at line 51 of file c_parser.c.
Referenced by actual_c_parser(), and AddToCalledModules().
|
extern |
cproto-generated files
Definition at line 49 of file c_parser.c.
Referenced by actual_c_parser(), add_new_compilation_unit(), add_new_module_from_text(), build_real_resources(), compilation_unit_of_module(), CreateEntityFromLocalNameAndPrefix(), CreateMemberScope(), FindEntityFromLocalName(), FindEntityFromLocalNameAndPrefix(), FindOrCreateCurrentEntity(), get_current_compilation_unit_entity(), init_c_areas(), make_predefined_C_entities(), and MakeStorageRam().
|
extern |
To pass down the information to functions used by the syntactical analyzer.
Definition at line 541 of file c_parser.c.
Referenced by actual_c_parser(), and analyze_preprocessor_line().
|
extern |
Definition at line 117 of file c_parser.c.
Referenced by actual_c_parser(), c_parser_error(), EnterScope(), ExitScope(), GetContext(), GetContextCopy(), GetParentScope(), GetScope(), PopContext(), PushContext(), ScopeStackSize(), UpdateAbstractEntity(), UpdateDerivedEntities(), UpdateDerivedEntity(), UpdateEntities(), and UpdateEntity().
|
extern |
Definition at line 125 of file c_parser.c.
Referenced by actual_c_parser().
|
extern |
These global variables are declared in ri-util/util.c.
These global variables are declared in ri-util/util.c.
functions for areas Four areas used to allocate variables which are not stored in a Fortran common. These areas are just like Fortran commons, but the dynamic area is the only non-static area according to Fortran standard. The heap and the stack area are used to deal with Fortran ANSI extensions and C, pointers and allocatable arrays, and adjustable arrays (VLA in C). The dynamic area is stack allocated by most compilers but could be statically allocated since the array sizes are known.
Areas are declared for each module. These four global variables are managed by the Fortran and C parsers and used to allocate variables in the current module. Note that the C parser uses more areas at the same time to cope with global variables.
|
extern |
Definition at line 119 of file c_parser.c.
Referenced by actual_c_parser(), c_parser_error(), FindOrCreateCurrentEntity(), UpdateEntities(), and UpdateEntity().
|
extern |
Definition at line 118 of file c_parser.c.
Referenced by actual_c_parser(), c_parser_error(), FindOrCreateCurrentEntity(), GetFunction(), MakeParameterList(), PopFunction(), PushFunction(), UpdateEntities(), and UpdateEntity().
|
extern |
BlockStack is used to handle block scope.
Definition at line 60 of file statement.c.
Referenced by FindStatementFromLabel(), MakeCurrentModule(), MakeGotoStatement(), and MakeLabeledStatement().
|
extern |
|
extern |
Definition at line 64 of file statement.c.
Referenced by c_parser_error(), MakeBreakStatement(), MakeCaseStatement(), MakeContinueStatement(), MakeCurrentModule(), MakeDefaultStatement(), MakeForloop(), MakeSwitchStatement(), MakeWhileLoop(), and ResetCurrentModule().
|
extern |
Definition at line 53 of file c_parser.c.
Referenced by actual_c_parser(), CCompilationUnitMemoryAllocations(), and CModuleMemoryAllocation().
|
extern |
Definition at line 120 of file c_parser.c.
Referenced by actual_c_parser(), c_parser_error(), StackPop(), StackPush(), UpdateEntities(), and UpdateEntity().
|
extern |
Definition at line 542 of file c_parser.c.
Referenced by actual_c_parser(), and CleanUpEntities().
|
extern |
Definition at line 121 of file c_parser.c.
Referenced by actual_c_parser(), and c_parser_error().
|
extern |
Definition at line 63 of file statement.c.
Referenced by c_parser_error(), MakeCaseStatement(), MakeCurrentModule(), and ResetCurrentModule().
|
extern |
list of labeled statements of the current module
Definition at line 62 of file statement.c.
Referenced by c_parser_error(), MakeCaseStatement(), MakeCurrentModule(), MakeDefaultStatement(), MakeSwitchStatement(), and ResetCurrentModule().