ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
procedureAnn Class Reference

Procedure annotation. More...

#include <procedure.h>

Inheritance diagram for procedureAnn:
Collaboration diagram for procedureAnn:

Public Member Functions

 procedureAnn (parserID *name, parserid_list *params, Annotations *anns, const int line)
 Build a new procedure annotation. More...
 
 ~procedureAnn ()
 Delete a procedure. More...
 
annVariablelookup (const std::string &variable, bool create, bool is_new=false)
 Lookup a variable. More...
 
void add_defs (parserid_list *variables)
 Add defs. More...
 
void add_one_def (annVariable *var)
 Add one def. More...
 
void add_uses (parserid_list *variables)
 Add uses. More...
 
void add_one_use (annVariable *var)
 Add one use. More...
 
void add_property_use (annVariable *var, enumPropertyAnn *enum_property)
 Def/use location. More...
 
const variable_property_mapproperty_uses () const
 Get the property uses. More...
 
void add_property_def (annVariable *var, enumPropertyAnn *enum_property)
 Add property def. More...
 
const variable_property_mapproperty_defs () const
 Get the property defs. More...
 
void add_property_weak_def (annVariable *var, enumPropertyAnn *enum_property)
 Add property weak def. More...
 
const variable_property_mapproperty_weak_defs () const
 Get the property weak defs. More...
 
void add_delete (parserID *id)
 Add a deleted variable. More...
 
void postprocess ()
 Postprocess procedure annotation. More...
 
void add_on_entry (structuretree_list *structures)
 Add an on_entry annation. More...
 
void add_on_exit (structuretree_list *structures)
 Add an on_exit annation. More...
 
void add_on_exit (pointerRuleAnn *pointer_rule)
 New add on_exit. More...
 
void add_global_structures (Annotations *annotations, annVariable *parent_var, structureTreeAnn *parent_node)
 Add structured globals. More...
 
void add_analysis (analyzeAnn *new_analysis)
 Add an analysis annotation. More...
 
void add_report (reportAnn *report)
 Add a calling context entry. More...
 
void add_action (actionAnn *action)
 Add a action annotation. More...
 
void process_reports (Analyzer *analyzer)
 Find a callsite. More...
 
void test_actions (Analyzer *analyzer)
 Test actions. More...
 
void clear ()
 Find applicable action. More...
 
void print (std::ostream &o) const
 
Accessors

Methods to get and set fields in the class.

const std::string & name () const
 
const var_mapvariables () const
 
const var_setuses () const
 
const var_setdefs () const
 
const var_listformal_params () const
 
const structure_liston_entry () const
 
const structure_liston_exit () const
 
const pointerrule_listpointer_rules () const
 
pointerRuleAnndefault_pointer_rule () const
 
const analyze_mapanalyses () const
 
const report_listreports () const
 
idnodeann_listnumeric_identifiers ()
 
bool pure_function () const
 
bool allocates_memory () const
 
bool deallocates_memory () const
 
bool modifies_globals () const
 
bool accesses_io () const
 
- Public Member Functions inherited from Ann
 Ann (int line)
 
int line () const
 

Static Public Attributes

static procedureAnnCurrent
 

Private Member Functions

void add_structures (bool is_on_entry, structure_list &the_list, annVariable *parent_var, structureTreeAnn *parent_node)
 
void postprocess_variables (parserid_list &uses_or_defs, bool is_defs)
 

Private Attributes

std::string _name
 the name of the procedure More...
 
TREE var_map _variables
 local variables More...
 
REF var_list _formal_params
 the list of formal parameters More...
 
REF var_set _uses
 Used variables. More...
 
REF var_set _defs
 Def'd variables. More...
 
REF var_set _global_uses
 Global variable uses. More...
 
REF var_set _global_defs
 Global variable defs. More...
 
REF variable_property_map _property_uses
 Property uses. More...
 
REF variable_property_map _property_defs
 Property defs. More...
 
REF variable_property_map _property_weak_defs
 Property weak defs. More...
 
TREE pointerrule_list _pointer_rules
 New implementation of on_exit. More...
 
REF pointerRuleAnn_default_pointer_rule
 Default pointer rule. More...
 
TREE analyze_map _analyses
 Analyze annotations. More...
 
TREE report_list _reports
 Report annotations. More...
 
REF idnodeann_list _numeric_identifiers
 Substitution annotations. More...
 
REF Annotations_annotations
 Annotations file. More...
 
TREE structure_list _on_entry
 on_entry and on_exit annotations More...
 
TREE structure_list _on_exit
 on_entry and on_exit annotations More...
 
Special properties

Callsites

Record all the places where this library routine is called. This will help us merge contexts for optimizations. They are stored according to the callsite that generated them.

This set of booleans records the special properties discovered about this procedure.

bool _pure_function
 
bool _allocates_memory
 
bool _deallocates_memory
 
bool _modifies_globals
 
bool _accesses_io
 
parserid_list_temp_defs
 Temporary variable lists. More...
 
parserid_list_temp_uses
 Temporary variable lists. More...
 
parserid_list_temp_deletes
 Temporary variable lists. More...
 

Friends

std::ostream & operator<< (std::ostream &o, const procedureAnn &pa)
 

Detailed Description

Procedure annotation.

Holds the annotations for one library procedure.

Definition at line 73 of file procedure.h.

Constructor & Destructor Documentation

procedureAnn::procedureAnn ( parserID name,
parserid_list params,
Annotations anns,
const int  line 
)

Build a new procedure annotation.

The new procedure annotation has the given name and list of input parameters. We also need a reference to the global Annotations object to allow proper variable lookup.

Parameters
namethe name of the procedure
paramsthe list of formal parameters
annsthe global Annotations object
linethe line number of the source annotation in the file
procedureAnn::~procedureAnn ( )

Delete a procedure.

Delete the procedure all all objects controlled by it. These include all of the procedure-specific annotations, as well as all the local variables.

Member Function Documentation

const std::string& procedureAnn::name ( ) const
inline

Definition at line 263 of file procedure.h.

References _name.

const var_map& procedureAnn::variables ( ) const
inline

Definition at line 265 of file procedure.h.

References _variables.

const var_set& procedureAnn::uses ( ) const
inline

Definition at line 267 of file procedure.h.

References _uses.

const var_set& procedureAnn::defs ( ) const
inline

Definition at line 268 of file procedure.h.

References _defs.

const var_list& procedureAnn::formal_params ( ) const
inline

Definition at line 270 of file procedure.h.

References _formal_params.

const structure_list& procedureAnn::on_entry ( ) const
inline

Definition at line 272 of file procedure.h.

References _on_entry.

const structure_list& procedureAnn::on_exit ( ) const
inline

Definition at line 273 of file procedure.h.

References _on_exit.

const pointerrule_list& procedureAnn::pointer_rules ( ) const
inline

Definition at line 275 of file procedure.h.

References _pointer_rules.

pointerRuleAnn* procedureAnn::default_pointer_rule ( ) const
inline

Definition at line 276 of file procedure.h.

References _default_pointer_rule.

const analyze_map& procedureAnn::analyses ( ) const
inline

Definition at line 278 of file procedure.h.

References _analyses.

const report_list& procedureAnn::reports ( ) const
inline

Definition at line 280 of file procedure.h.

References _reports.

idnodeann_list& procedureAnn::numeric_identifiers ( )
inline

Definition at line 289 of file procedure.h.

References _numeric_identifiers.

bool procedureAnn::pure_function ( ) const
inline

Definition at line 295 of file procedure.h.

References _pure_function.

bool procedureAnn::allocates_memory ( ) const
inline

Definition at line 296 of file procedure.h.

References _allocates_memory.

bool procedureAnn::deallocates_memory ( ) const
inline

Definition at line 297 of file procedure.h.

References _deallocates_memory.

bool procedureAnn::modifies_globals ( ) const
inline

Definition at line 298 of file procedure.h.

References _modifies_globals.

bool procedureAnn::accesses_io ( ) const
inline

Definition at line 299 of file procedure.h.

References _accesses_io.

annVariable* procedureAnn::lookup ( const std::string &  variable,
bool  create,
bool  is_new = false 
)

Lookup a variable.

This method looks up a local variable by name. The "create" flag indicates whether or not to create a new one if it doesn't already exist. The optional "is_new" flag should be set to true for local variables that represent newly allocated memory (i.e., are introduced with the "new" keyword in the on_exit annotations.

Parameters
variablethe name of the variable to look up
createpass true to create a new variable if one doesn't already exist
is_newpass true if the object is allocated in the annoation
void procedureAnn::add_defs ( parserid_list variables)

Add defs.

This method is used by the parser to process the "modify" annotations. At this point, the variable names are just temporarily stored.

Parameters
variablesthe list of variables from the "modify" annotation
void procedureAnn::add_one_def ( annVariable var)

Add one def.

Mark the variable as defined, and if it's global, add it to the list of global defs.

void procedureAnn::add_uses ( parserid_list variables)

Add uses.

This method is used by the parser to process the "access" annotations. At this point, the variable names are just temporarily stored.

Parameters
variablesthe list of variables from the "access" annotation
void procedureAnn::add_one_use ( annVariable var)

Add one use.

Mark the variable as used, and if it's global, add it to the list of global uses.

void procedureAnn::add_property_use ( annVariable var,
enumPropertyAnn enum_property 
)

Def/use location.

Given a procLocation corresponding to a call to this procedure, return the special synthetic stmtLocation that holds all of the defs and uses. Allocation/deallocation location

Given a procLocation corresponding to a call to this procedure, return the special synthetic stmtLocation to which we attach deallocation of heap objects. It needs to dominate the def/use location so that changes to the multiplicity of an object are properly reflected in assignments. Allocation location

Given a procLocation corresponding to a call to this procedure, return the special synthetic stmtLocation to which we attach allocation of heap objects. It needs to dominate the def/use location, but be dominated by the deallocation location so that changes to the multiplicity of an object are properly reflected in assignments. Add property use

Add this variable to the list of variables whose property value is tested. This does not actually mark the variable itself as used.

const variable_property_map& procedureAnn::property_uses ( ) const
inline

Get the property uses.

Definition at line 402 of file procedure.h.

References _property_uses.

void procedureAnn::add_property_def ( annVariable var,
enumPropertyAnn enum_property 
)

Add property def.

Add this variable to the list of variables whose property value is modified. This does not actually mark the variable itself as def'd.

const variable_property_map& procedureAnn::property_defs ( ) const
inline

Get the property defs.

Definition at line 415 of file procedure.h.

References _property_defs.

void procedureAnn::add_property_weak_def ( annVariable var,
enumPropertyAnn enum_property 
)

Add property weak def.

Add this variable to the list of variables whose property value is weakly updated. This should be a subset of the property defs.

const variable_property_map& procedureAnn::property_weak_defs ( ) const
inline

Get the property weak defs.

Definition at line 428 of file procedure.h.

References _property_weak_defs.

void procedureAnn::add_delete ( parserID id)

Add a deleted variable.

Record the given variable as deleted. We store it temporarily in the _deletes list, and then perform the actual lookup during the postprocess method.

void procedureAnn::postprocess ( )

Postprocess procedure annotation.

This method is called by Annotations::add_procedure() once parsing of the procedure annotation is complete. Take the temporary uses and defs sets and look up each annVariable. Set the 'used' or 'defined' flag appropriately.

void procedureAnn::add_on_entry ( structuretree_list structures)

Add an on_entry annation.

The given on_entry structure information is added to the procedure by processing it into a series of simpler operations. See structure.h for a discussion of this conversion.

Parameters
structuresthe on_entry structure information to add
See Also
structureTreeAnn
structureAnn
void procedureAnn::add_on_exit ( structuretree_list structures)

Add an on_exit annation.

The given on_exit structure information is added to the procedure by processing it into a series of simpler operations. See structure.h for a discussion of this conversion.

Parameters
structuresthe on_exit structure information to add
See Also
structureTreeAnn
structureAnn
void procedureAnn::add_on_exit ( pointerRuleAnn pointer_rule)

New add on_exit.

This uses the new conditional form of pointer annotations. This method handles compiling the structuretree_list into the form used by the analyzer.

void procedureAnn::add_global_structures ( Annotations annotations,
annVariable parent_var,
structureTreeAnn parent_node 
)

Add structured globals.

This method is only used to process the global structure annotations. It is similar to add structures with the following exceptions: (1) all the new variables that it discovers are added as globals, (2) all "dot" operators go into the on_entry annotations and (3) all "arrow" operators go into the on_exit annotations. This way we can just call Analyzer::process_on_entry() and Analyzer::process_on_exit() to set them up.

void procedureAnn::add_analysis ( analyzeAnn new_analysis)

Add an analysis annotation.

Parameters
new_analysisthe analysis object to add
void procedureAnn::add_report ( reportAnn report)

Add a calling context entry.

Create a new callsite entry if one doesn't yet exist Add a report annotation

void procedureAnn::add_action ( actionAnn action)

Add a action annotation.

void procedureAnn::process_reports ( Analyzer *  analyzer)

Find a callsite.

Return null if the procedure is not called at this statement. Process report annotations

void procedureAnn::test_actions ( Analyzer *  analyzer)

Test actions.

Evaluate the condition of each action annotation in each calling context of this procedure.

void procedureAnn::clear ( )

Find applicable action.

Given a particular statement, see if there is an applicable action for this procedure. It is not necessary to check if the statement is actually a call to the procedure. Only the first applicable aciton is returned, even if there is more than one. Clear

Re-initialize the callsite information in preparation for analysis.

void procedureAnn::print ( std::ostream &  o) const
void procedureAnn::add_structures ( bool  is_on_entry,
structure_list the_list,
annVariable parent_var,
structureTreeAnn parent_node 
)
private
void procedureAnn::postprocess_variables ( parserid_list uses_or_defs,
bool  is_defs 
)
private

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const procedureAnn pa 
)
friend

Definition at line 557 of file procedure.h.

Member Data Documentation

procedureAnn* procedureAnn::Current
static

Definition at line 77 of file procedure.h.

std::string procedureAnn::_name
private

the name of the procedure

Definition at line 83 of file procedure.h.

Referenced by name().

TREE var_map procedureAnn::_variables
private

local variables

This map contains an entry for each local variable (formal parameters, as well as names introduced by on_entry and on_exit annotations).

Definition at line 91 of file procedure.h.

Referenced by variables().

REF var_list procedureAnn::_formal_params
private

the list of formal parameters

Each entry is a reference into the _variables map.

Definition at line 97 of file procedure.h.

Referenced by formal_params().

REF var_set procedureAnn::_uses
private

Used variables.

The set of variables whose value is read.

Definition at line 103 of file procedure.h.

Referenced by uses().

REF var_set procedureAnn::_defs
private

Def'd variables.

The set of variables whose value is written.

Definition at line 109 of file procedure.h.

Referenced by defs().

REF var_set procedureAnn::_global_uses
private

Global variable uses.

These are also included in the _uses set.

Definition at line 115 of file procedure.h.

REF var_set procedureAnn::_global_defs
private

Global variable defs.

These are also included in the _defs set.

Definition at line 121 of file procedure.h.

REF variable_property_map procedureAnn::_property_uses
private

Property uses.

For each variable in the annotations, record which properties of that variable are tested.

Definition at line 128 of file procedure.h.

Referenced by property_uses().

REF variable_property_map procedureAnn::_property_defs
private

Property defs.

For each variable in the annotations, record which properties of that variable are modified.

Definition at line 135 of file procedure.h.

Referenced by property_defs().

REF variable_property_map procedureAnn::_property_weak_defs
private

Property weak defs.

This is a subset of the property defs. It holds the variables that have been forced by the user's annotations to be weakly updated.

Definition at line 142 of file procedure.h.

Referenced by property_weak_defs().

TREE structure_list procedureAnn::_on_entry
private

on_entry and on_exit annotations

Definition at line 149 of file procedure.h.

Referenced by on_entry().

TREE structure_list procedureAnn::_on_exit
private

on_entry and on_exit annotations

Definition at line 150 of file procedure.h.

Referenced by on_exit().

TREE pointerrule_list procedureAnn::_pointer_rules
private

New implementation of on_exit.

This contains a set of pointer rules: now we can have different pointer behavior based on the states of the inputs. NOTE: this doesn't change which objects get used/defd, so we need to be careful.

Definition at line 160 of file procedure.h.

Referenced by pointer_rules().

REF pointerRuleAnn* procedureAnn::_default_pointer_rule
private

Default pointer rule.

Keep a default (this is used in most cases).

Definition at line 166 of file procedure.h.

Referenced by default_pointer_rule().

TREE analyze_map procedureAnn::_analyses
private

Analyze annotations.

Definition at line 171 of file procedure.h.

Referenced by analyses().

TREE report_list procedureAnn::_reports
private

Report annotations.

Definition at line 176 of file procedure.h.

Referenced by reports().

REF idnodeann_list procedureAnn::_numeric_identifiers
private

Substitution annotations.

synthetic procNode

Build a synthetic procNode that can be used in various path-related functions. We should look up the actual function declaration in the library header. TBD. Numeric identifiers

This is a list of idNodeAnn objects which are used in numeric expressions. We keep this list so that when we enter a library procedure during analysis, we can assign the numeric values to these nodes. We can then use the regular exprNode::eval() function to get their values. This list is created during the lookup() phase.

Definition at line 201 of file procedure.h.

Referenced by numeric_identifiers().

REF Annotations* procedureAnn::_annotations
private

Annotations file.

This is a reference to the Annotations object that contains this procedure. We need it to look up global variables

Definition at line 208 of file procedure.h.

bool procedureAnn::_pure_function
private

Definition at line 226 of file procedure.h.

Referenced by pure_function().

bool procedureAnn::_allocates_memory
private

Definition at line 227 of file procedure.h.

Referenced by allocates_memory().

bool procedureAnn::_deallocates_memory
private

Definition at line 228 of file procedure.h.

Referenced by deallocates_memory().

bool procedureAnn::_modifies_globals
private

Definition at line 229 of file procedure.h.

Referenced by modifies_globals().

bool procedureAnn::_accesses_io
private

Definition at line 230 of file procedure.h.

Referenced by accesses_io().

parserid_list* procedureAnn::_temp_defs
private

Temporary variable lists.

Besides the obvious access and modifies annotations, we also augment these lists with any objects that are implicitly accessed or modified as a result of on_entry, on_exit or analyze annoations. After the structure annotations are processed, we go through this list and update the corresponding annVariable flags a reference into the _variables map. ALSO: store the list of deleted objects here.

Definition at line 581 of file procedure.h.

parserid_list* procedureAnn::_temp_uses
private

Temporary variable lists.

Besides the obvious access and modifies annotations, we also augment these lists with any objects that are implicitly accessed or modified as a result of on_entry, on_exit or analyze annoations. After the structure annotations are processed, we go through this list and update the corresponding annVariable flags a reference into the _variables map. ALSO: store the list of deleted objects here.

Definition at line 582 of file procedure.h.

parserid_list* procedureAnn::_temp_deletes
private

Temporary variable lists.

Besides the obvious access and modifies annotations, we also augment these lists with any objects that are implicitly accessed or modified as a result of on_entry, on_exit or analyze annoations. After the structure annotations are processed, we go through this list and update the corresponding annVariable flags a reference into the _variables map. ALSO: store the list of deleted objects here.

Definition at line 583 of file procedure.h.


The documentation for this class was generated from the following file: