PIPS
static.c File Reference
#include <stdio.h>
#include <string.h>
#include "linear.h"
#include "genC.h"
#include "misc.h"
#include "ri.h"
#include "ri-util.h"
+ Include dependency graph for static.c:

Go to the source code of this file.

Functions

entity set_current_module_entity (entity e)
 Set the current module entity. More...
 
entity get_current_module_entity ()
 Get the entity of the current module. More...
 
void reset_current_module_entity ()
 Reset the current module entity. More...
 
void error_reset_current_module_entity ()
 To be called by an error management routine only. More...
 
const char * get_current_module_name ()
 Get the name of the current module. More...
 
void set_current_module_declarations (list l)
 
void reset_current_module_declarations ()
 
list get_current_module_declarations ()
 
statement set_current_module_statement (statement s)
 Set the current module statement. More...
 
void push_current_module_statement (statement s)
 Set the statement of the current module and push the statement of the previous one on a stack. More...
 
void pop_current_module_statement (void)
 Pop the current module statement stack and use it as the current module statement. More...
 
statement get_current_module_statement ()
 Get the current module statement. More...
 
void reset_current_module_statement ()
 Reset the current module statement. More...
 
void error_reset_current_module_statement ()
 To be called by an error management routine only. More...
 
hash_table make_keyword_typedef_table (int tk)
 
void set_keyword_typedef_table (hash_table h)
 
void reset_keyword_typedef_table ()
 
void free_keyword_typedef_table ()
 
void declare_new_typedef (const string tn)
 
_int is_c_keyword_typedef (char *s)
 This function checks if s is a C keyword or typedef name and returns the token number thanks to the hash-table keyword_typedef_table. More...
 
void make_statement_global_stack ()
 
void push_statement_on_statement_global_stack (statement st)
 
statement get_current_statement_from_statement_global_stack ()
 
statement pop_statement_global_stack (void)
 
void free_statement_global_stack ()
 
bool statement_global_stack_defined_p ()
 

Variables

static entity current_module_entity = entity_undefined
 static variables and related access functions concerning the current module More...
 
static list current_module_declaration_list =list_undefined
 
static statement current_module_statement = statement_undefined
 used to retrieve the intraprocedural effects of the current module More...
 
static statement stacked_current_module_statement = statement_undefined
 
hash_table keyword_typedef_table = hash_table_undefined
 Because of typedefs, the C lexers need help to decide if a character string such as toto is a type name or a keyword or an identifier. More...
 
static int token_named_type = -1
 
static stack statement_global_stack = stack_undefined
 

Function Documentation

◆ declare_new_typedef()

void declare_new_typedef ( const string  tn)
Parameters
tnn

Definition at line 283 of file static.c.

284 {
285  hash_put(keyword_typedef_table, strdup(tn), (const void *) ((long long int) token_named_type));
286 }
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
char * strdup()
static int token_named_type
Definition: static.c:254
hash_table keyword_typedef_table
Because of typedefs, the C lexers need help to decide if a character string such as toto is a type na...
Definition: static.c:253

References hash_put(), keyword_typedef_table, strdup(), and token_named_type.

Referenced by AddEntityToCompilationUnit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ error_reset_current_module_entity()

void error_reset_current_module_entity ( void  )

To be called by an error management routine only.

Definition at line 109 of file static.c.

110 {
113 }
void reset_current_module_declarations()
Definition: static.c:136
#define entity_undefined
Definition: ri.h:2761
static entity current_module_entity
static variables and related access functions concerning the current module
Definition: static.c:49

References current_module_entity, entity_undefined, and reset_current_module_declarations().

Referenced by c_parser_error(), ParserError(), and reset_static_phase_variables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ error_reset_current_module_statement()

void error_reset_current_module_statement ( void  )

To be called by an error management routine only.

Definition at line 234 of file static.c.

235 {
239 }
#define statement_undefined
Definition: ri.h:2419
static statement current_module_statement
used to retrieve the intraprocedural effects of the current module
Definition: static.c:153
static statement stacked_current_module_statement
Definition: static.c:154

References current_module_statement, reset_current_module_declarations(), stacked_current_module_statement, and statement_undefined.

Referenced by AbortEntries(), and reset_static_phase_variables().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_keyword_typedef_table()

void free_keyword_typedef_table ( void  )

Definition at line 275 of file static.c.

276 {
279  // No need to reset this value. It is a constant defined by Bison.
280  // token_named_type = -1;
281 }
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49

References hash_table_free(), hash_table_undefined, and keyword_typedef_table.

Referenced by csplit_error_handler(), and csplit_reset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ free_statement_global_stack()

void free_statement_global_stack ( void  )

Definition at line 358 of file static.c.

359 {
362 }
#define stack_undefined
Definition: newgen_stack.h:55
void stack_free(stack *)
type, bucket_size, policy
Definition: stack.c:292
static stack statement_global_stack
Definition: static.c:316

References stack_free(), stack_undefined, and statement_global_stack.

Referenced by generic_module_name_to_transformers(), generic_points_to_analysis(), generic_print_xml_application(), initial_precondition(), live_out_paths_from_caller_to_callee(), make_statement_global_stack(), module_name_to_preconditions(), partial_eval(), program_precondition(), and summary_precondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_current_statement_from_statement_global_stack()

statement get_current_statement_from_statement_global_stack ( void  )

Definition at line 344 of file static.c.

345 {
349  return st;
350 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
bool stack_empty_p(const stack)
void * stack_head(const stack)
returns the item on top of stack s
Definition: stack.c:420

References stack_empty_p(), stack_head(), statement_global_stack, and statement_undefined.

Referenced by c_user_call_to_transformer(), call_to_transformer(), points_to_context_statement_line_number(), semantics_expression_to_points_to_sinks(), semantics_expression_to_points_to_sources(), and semantics_user_warning_alist().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ is_c_keyword_typedef()

_int is_c_keyword_typedef ( char *  s)

This function checks if s is a C keyword or typedef name and returns the token number thanks to the hash-table keyword_typedef_table.

It returns an integer number corresponding to the keyword.

It returns 0 if s is not a keyword/typedef name

Definition at line 297 of file static.c.

298 {
300  return ((char *) i == HASH_UNDEFINED_VALUE) ? 0: i;
301 }
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
intptr_t _int
_INT
Definition: newgen_types.h:53

References hash_get(), HASH_UNDEFINED_VALUE, and keyword_typedef_table.

Referenced by is_c_parser_keyword_typedef(), and is_c_preprocessor_keyword_typedef().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_keyword_typedef_table()

hash_table make_keyword_typedef_table ( int  tk)
Parameters
tkk

Definition at line 256 of file static.c.

257 {
258  token_named_type = tk;
260  return keyword_typedef_table;
261 }
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
@ hash_string
Definition: newgen_hash.h:32

References hash_string, hash_table_make(), keyword_typedef_table, and token_named_type.

Referenced by parser_init_keyword_typedef_table(), and preprocessor_init_keyword_typedef_table().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_statement_global_stack()

void make_statement_global_stack ( void  )

This assert is too strong when user errors occur. Each pass should pprovide a "clean-up" function to be called by user_error() without creating a library cycle

This is an error recovery

Definition at line 318 of file static.c.

319 {
320  /* This assert is too strong when user errors occur. Each pass
321  * should pprovide a "clean-up" function to be called by
322  * user_error() without creating a library cycle
323  */
324  //pips_assert("statement_global_stack is undefined",
325  // stack_undefined_p(statement_global_stack));
327  /* This is an error recovery */
329  }
331 }
stack stack_make(int, int, int)
allocation
Definition: stack.c:246
#define stack_undefined_p(s)
Definition: newgen_stack.h:56
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
void free_statement_global_stack()
Definition: static.c:358

References free_statement_global_stack(), stack_make(), stack_undefined_p, statement_domain, and statement_global_stack.

Referenced by generic_module_name_to_transformers(), generic_points_to_analysis(), generic_print_xml_application(), initial_precondition(), live_out_paths_from_caller_to_callee(), module_name_to_preconditions(), partial_eval(), program_precondition(), and summary_precondition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pop_statement_global_stack()

statement pop_statement_global_stack ( void  )

Definition at line 352 of file static.c.

353 {
355  return st;
356 }
void * stack_pop(stack)
POPs one item from stack s.
Definition: stack.c:399

References stack_pop(), and statement_global_stack.

Referenced by partial_eval_statement(), statement_to_points_to(), statement_to_postcondition(), statement_to_transformer(), update_precondition_with_call_site_preconditions(), xml_Argument(), xml_Boxes(), xml_Call(), xml_Chain_Graph(), xml_Loop(), xml_Loops(), and xml_Task().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ push_statement_on_statement_global_stack()

void push_statement_on_statement_global_stack ( statement  st)
Parameters
stt

Definition at line 333 of file static.c.

334 {
335  stack_push((void *) st, statement_global_stack);
336 }
void stack_push(void *, stack)
stack use
Definition: stack.c:373

References stack_push(), and statement_global_stack.

Referenced by memorize_precondition_for_summary_precondition(), partial_eval_statement(), statement_to_points_to(), statement_to_postcondition(), statement_to_transformer(), xml_Argument(), xml_Boxes(), xml_Call(), xml_Chain_Graph(), xml_Loop(), xml_Loops(), and xml_Task().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset_keyword_typedef_table()

void reset_keyword_typedef_table ( void  )

Definition at line 268 of file static.c.

269 {
271  // No need to reset this value. It is a constant defined by Bison.
272  // token_named_type = -1;
273 }

References hash_table_undefined, and keyword_typedef_table.

◆ set_keyword_typedef_table()

void set_keyword_typedef_table ( hash_table  h)

Definition at line 263 of file static.c.

264 {
266 }

References keyword_typedef_table.

Referenced by AddEntityToCompilationUnit().

+ Here is the caller graph for this function:

◆ statement_global_stack_defined_p()

bool statement_global_stack_defined_p ( void  )

Definition at line 364 of file static.c.

365 {
367 }

References stack_undefined_p, and statement_global_stack.

Referenced by call_to_transformer(), and statement_to_transformer().

+ Here is the caller graph for this function:

Variable Documentation

◆ current_module_declaration_list

list current_module_declaration_list =list_undefined
static

◆ current_module_entity

entity current_module_entity = entity_undefined
static

static variables and related access functions concerning the current module

Be'atrice Apvrille, august 27, 1993 used to store the summary transformer ? to retrieve intraprocedural effects ?

Definition at line 49 of file static.c.

Referenced by error_reset_current_module_entity(), get_current_module_entity(), get_current_module_name(), reset_current_module_entity(), and set_current_module_entity().

◆ current_module_statement

statement current_module_statement = statement_undefined
static

◆ keyword_typedef_table

hash_table keyword_typedef_table = hash_table_undefined

Because of typedefs, the C lexers need help to decide if a character string such as toto is a type name or a keyword or an identifier.

Such a table is used by the C preprocessor and by the C parser. It is also updated for in- or outlining with new typedef names.

The table must be initialized with token values generated by bison. The token values could possibly be different for the PIPS preprocessor and syntactic analyzer. Each has its own initialization function, parser_init_keyword_typedef_table() and preprocessor_init_keyword_table().

Definition at line 253 of file static.c.

Referenced by actual_c_parser(), c_parser_put_new_typedef(), declare_new_typedef(), free_keyword_typedef_table(), is_c_keyword_typedef(), keep_track_of_typedef(), make_keyword_typedef_table(), parser_init_keyword_typedef_table(), preprocessor_init_keyword_typedef_table(), put_new_typedef(), reset_keyword_typedef_table(), and set_keyword_typedef_table().

◆ stacked_current_module_statement

statement stacked_current_module_statement = statement_undefined
static

◆ statement_global_stack

◆ token_named_type

int token_named_type = -1
static

Definition at line 254 of file static.c.

Referenced by declare_new_typedef(), and make_keyword_typedef_table().