ROSE
0.9.6a
|
Procedure annotation. More...
#include <procedure.h>
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... | |
annVariable * | lookup (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_map & | property_uses () const |
Get the property uses. More... | |
void | add_property_def (annVariable *var, enumPropertyAnn *enum_property) |
Add property def. More... | |
const variable_property_map & | property_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_map & | property_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_map & | variables () const |
const var_set & | uses () const |
const var_set & | defs () const |
const var_list & | formal_params () const |
const structure_list & | on_entry () const |
const structure_list & | on_exit () const |
const pointerrule_list & | pointer_rules () const |
pointerRuleAnn * | default_pointer_rule () const |
const analyze_map & | analyses () const |
const report_list & | reports () const |
idnodeann_list & | numeric_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 procedureAnn * | Current |
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) |
Procedure annotation.
Holds the annotations for one library procedure.
Definition at line 73 of file procedure.h.
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.
name | the name of the procedure |
params | the list of formal parameters |
anns | the global Annotations object |
line | the 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.
|
inline |
Definition at line 263 of file procedure.h.
References _name.
|
inline |
Definition at line 265 of file procedure.h.
References _variables.
|
inline |
Definition at line 267 of file procedure.h.
References _uses.
|
inline |
Definition at line 268 of file procedure.h.
References _defs.
|
inline |
Definition at line 270 of file procedure.h.
References _formal_params.
|
inline |
Definition at line 272 of file procedure.h.
References _on_entry.
|
inline |
Definition at line 273 of file procedure.h.
References _on_exit.
|
inline |
Definition at line 275 of file procedure.h.
References _pointer_rules.
|
inline |
Definition at line 276 of file procedure.h.
References _default_pointer_rule.
|
inline |
Definition at line 278 of file procedure.h.
References _analyses.
|
inline |
Definition at line 280 of file procedure.h.
References _reports.
|
inline |
Definition at line 289 of file procedure.h.
References _numeric_identifiers.
|
inline |
Definition at line 295 of file procedure.h.
References _pure_function.
|
inline |
Definition at line 296 of file procedure.h.
References _allocates_memory.
|
inline |
Definition at line 297 of file procedure.h.
References _deallocates_memory.
|
inline |
Definition at line 298 of file procedure.h.
References _modifies_globals.
|
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.
variable | the name of the variable to look up |
create | pass true to create a new variable if one doesn't already exist |
is_new | pass 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.
variables | the 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.
variables | the 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.
|
inline |
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.
|
inline |
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.
|
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.
structures | the on_entry structure information to add |
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.
structures | the on_exit structure information to add |
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.
new_analysis | the 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 |
|
private |
|
private |
|
friend |
Definition at line 557 of file procedure.h.
|
static |
Definition at line 77 of file procedure.h.
|
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().
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().
Used variables.
The set of variables whose value is read.
Definition at line 103 of file procedure.h.
Referenced by uses().
Def'd variables.
The set of variables whose value is written.
Definition at line 109 of file procedure.h.
Referenced by defs().
Global variable uses.
These are also included in the _uses set.
Definition at line 115 of file procedure.h.
Global variable defs.
These are also included in the _defs set.
Definition at line 121 of file procedure.h.
|
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().
|
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().
|
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().
|
private |
on_entry and on_exit annotations
Definition at line 149 of file procedure.h.
Referenced by on_entry().
|
private |
on_entry and on_exit annotations
Definition at line 150 of file procedure.h.
Referenced by on_exit().
|
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().
|
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().
|
private |
|
private |
|
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().
|
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.
|
private |
Definition at line 226 of file procedure.h.
Referenced by pure_function().
|
private |
Definition at line 227 of file procedure.h.
Referenced by allocates_memory().
|
private |
Definition at line 228 of file procedure.h.
Referenced by deallocates_memory().
|
private |
Definition at line 229 of file procedure.h.
Referenced by modifies_globals().
|
private |
Definition at line 230 of file procedure.h.
Referenced by accesses_io().
|
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.
|
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.
|
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.