Main Page Modules Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages
constantAnalyzer Class Reference#include <constants.h>
List of all members.
|
Public Member Functions |
| constantAnalyzer () |
| Create a new constant analysis.
|
| ~constantAnalyzer () |
| Destructor.
|
void | clear () |
| Clear.
|
void | set_null_object (memoryBlock *null_object) |
| Set the null object.
|
const constant * | top () const |
| TOP value.
|
const constant * | bottom () const |
| BOTTOM value.
|
bool | has_value (const constant *val) |
| Has value.
|
bool | has_truth_value (const constant *val, bool &value) |
| Check for truth value.
|
const constant * | lookup (const constant &value) |
| Lookup a constant value.
|
const constant * | lookup_flowvalue (memoryDef *def) |
| Lookup a variable value.
|
bool | update_flowvalue (const constant *val, memoryDef *def) |
| Update a variable value.
|
const constant * | meet (const constant *one, const constant *two) |
| Meet function.
|
const constant * | rebuild_flowvalue (pointerValue &pointer) |
| Rebuild the flow value.
|
void | record_expression (exprNode *expr, const constant *val) |
| Record the value of an expression.
|
void | record_stmt (stmtNode *stmt, const constant *val) |
| Record the rhs value of an threeAddr.
|
const constant * | evaluate_points_to (const memoryblock_set &points_to) |
| Evaluate points-to set.
|
const constant * | lookup_expression (exprNode *expr) |
| Look up an expression.
|
const constant * | lookup_stmt (stmtNode *expr) |
void | at_id (stmtLocation *current, idNode *id, pointerValue &value) |
void | at_unary (stmtLocation *current, stmtNode *t, pointerValue &operand, pointerValue &result) |
void | at_sizeof (stmtLocation *current, threeAddrNode *t, pointerValue &operand, pointerValue &result) |
void | at_binary (stmtLocation *current, stmtNode *s, pointerValue &left, pointerValue &right, pointerValue &result) |
void | at_const (stmtLocation *current, constNode *cons, pointerValue &result) |
void | at_address (stmtLocation *current, operandNode *operand, pointerValue &result) |
void | at_cast (stmtLocation *current, operandNode *operand, pointerValue &operand_val, pointerValue &result) |
void | at_dereference (stmtLocation *current, operandNode *operand, pointerValue &result) |
void | at_field_access (stmtLocation *current, operandNode *operand, pointerValue &result) |
void | at_index (stmtLocation *current, operandNode *operand, pointerValue &result) |
void | at_assignment (stmtLocation *current, pointerValue &left, pointerValue &right, pointerValue &result, memoryblock_set &changes) |
void | at_parameter_pass (Location *current, pointerValue &left, pointerValue &right, memoryblock_set &changes) |
void | at_self_assignment (Location *source, Location *target, memoryBlock *block, memoryblock_set &changes) |
void | at_return (stmtLocation *stmt, returnNode *ret, pointerValue &result, pointerValue &return_val) |
void | at_merge (Location *where, memoryBlock *block, memoryuse_list &phi_uses, pointerValue &result, memoryblock_set &changes) |
void | at_basicblock_entry (basicblockLocation *block, procedureInfo *info, pointerValue &initial) |
void | at_stmt_entry (stmtLocation *stmt, pointerValue &result) |
void | at_conservative_procedure_call (stmtLocation *current, operandNode *call, operand_list &args, pointerValue &call_target, pointervalue_list &arguments, memoryblock_set &reachable_blocks, pointerValue &return_val, memoryblock_set &changes) |
void | print (ostream &o, const constant *val) |
string | to_string (const constant *val) |
Private Types |
typedef set< constant > | constant_set |
typedef constant_set::iterator | constant_set_p |
typedef map< exprNode *, const
constant * > | expr_value_map |
typedef expr_value_map::iterator | expr_value_map_p |
typedef map< stmtNode *, const
constant * > | stmt_value_map |
typedef stmt_value_map::iterator | stmt_value_map_p |
Private Member Functions |
void | record_change (memoryDef *def) |
| Obsolete: Record a value change.
|
Private Attributes |
TREE constant_set | _schar_constants |
| The set of all constants.
|
TREE constant_set | _uchar_constants |
TREE constant_set | _sshort_constants |
TREE constant_set | _ushort_constants |
TREE constant_set | _sint_constants |
TREE constant_set | _uint_constants |
TREE constant_set | _slong_constants |
TREE constant_set | _ulong_constants |
TREE constant_set | _float_constants |
TREE constant_set | _double_constants |
REF memoryBlock * | _null |
| Null object.
|
const constant * | _top |
| Unique lattice top element.
|
const constant * | _bottom |
| Unique lattice bottom element.
|
const constant * | _non_null |
| Special non-null element.
|
expr_value_map | _expr_values |
| Record the value of each expression.
|
stmt_value_map | _stmt_values |
Member Typedef Documentation
typedef set< constant > constantAnalyzer::constant_set [private]
|
|
typedef constant_set::iterator constantAnalyzer::constant_set_p [private]
|
|
typedef map< exprNode *, const constant * > constantAnalyzer::expr_value_map [private]
|
|
typedef expr_value_map::iterator constantAnalyzer::expr_value_map_p [private]
|
|
typedef map< stmtNode *, const constant * > constantAnalyzer::stmt_value_map [private]
|
|
typedef stmt_value_map::iterator constantAnalyzer::stmt_value_map_p [private]
|
|
Constructor & Destructor Documentation
constantAnalyzer::constantAnalyzer |
( |
|
) |
|
|
|
Create a new constant analysis.
Definition at line 44 of file constants.cc. |
constantAnalyzer::~constantAnalyzer |
( |
|
) |
|
|
Member Function Documentation
|
Definition at line 772 of file constants.cc.
References _bottom, _top, pointerValue::blocks, pointerValue::constant_value, memoryBlock::current_def(), memoryBlock::current_use(), def, vector_set< memoryBlock * >::insert(), lookup_flowvalue(), meet(), memoryblock_set_p, memoryUse::reaching_def(), update_flowvalue(), and memoryBlock::write_protected().
Referenced by Pointers::eval(), and Pointers::struct_union_assignment(). |
|
Definition at line 558 of file constants.cc.
References _bottom, _non_null, _top, Condition, pointerValue::constant_value, Operator::EQ, constant::eval(), Operator::id(), pointerValue::is_a_use, Operator::is_unary(), constant::is_zero(), lookup(), Operator::NE, record_stmt(), ThreeAddr, and Node::typ().
Referenced by Pointers::analyze_procedure(), and Pointers::eval(). |
|
Definition at line 683 of file constants.cc.
References _bottom, _non_null, _top, primNode::basic(), constant::cast(), operandNode::cast(), pointerValue::constant_value, pointerValue::is_a_use, lookup(), Prim, record_expression(), and Node::typ().
Referenced by Pointers::eval(). |
|
Definition at line 821 of file constants.cc.
References _top, memoryBlock::current_def(), memoryBlock::current_use(), def, vector_set< memoryBlock * >::insert(), lookup_flowvalue(), meet(), memoryUse::reaching_def(), rebuild_flowvalue(), update_flowvalue(), and memoryBlock::write_protected().
Referenced by Pointers::pass_one_external_input(), and Pointers::pass_one_external_output(). |
|
Definition at line 505 of file constants.cc.
References _bottom, _non_null, _top, Condition, pointerValue::constant_value, constant::eval(), Operator::id(), pointerValue::is_a_use, Operator::is_unary(), lookup(), record_stmt(), Operator::SIZEOF, ThreeAddr, and Node::typ().
Referenced by Pointers::analyze_procedure(), and Pointers::eval(). |
const constant* constantAnalyzer::bottom |
( |
|
) |
const [inline] |
|
void constantAnalyzer::clear |
( |
|
) |
|
|
|
Evaluate points-to set.
Determine the constant value of a pointer by looking at what it points to. There are basically three cases: (1) it only points to the NULL object, in which case it is zero, (2) it points to heap objects, which might fail to be allocated, so the value is bottom, or (3) it points to regular variables, whose addresses cannot be zero, so the value is non-null.
Definition at line 395 of file constants.cc.
References _bottom, _non_null, _null, memoryBlock::is_heap_object(), lookup(), and memoryblock_set_cp.
Referenced by lookup_flowvalue(), and rebuild_flowvalue(). |
bool constantAnalyzer::has_truth_value |
( |
const constant * |
val, |
|
|
bool & |
value |
|
) |
|
|
bool constantAnalyzer::has_value |
( |
const constant * |
val |
) |
[inline] |
|
|
Lookup a constant value.
All constants are stored in a set so that there is only one constant object for each unique value.
Definition at line 101 of file constants.cc.
References _bottom, _double_constants, _float_constants, _schar_constants, _sint_constants, _slong_constants, _sshort_constants, _uchar_constants, _uint_constants, _ulong_constants, _ushort_constants, constant::basic(), constant_set_p, basic_type::Double, basic_type::Float, basic_type::SChar, basic_type::SInt, basic_type::SLong, basic_type::SShort, basic_type::UChar, basic_type::UInt, basic_type::ULong, and basic_type::UShort.
Referenced by at_binary(), at_cast(), at_const(), at_sizeof(), at_unary(), evaluate_points_to(), and rebuild_flowvalue(). |
void constantAnalyzer::print |
( |
ostream & |
o, |
|
|
const constant * |
val |
|
) |
[inline] |
|
|
Rebuild the flow value.
Collect the current values of the given pointer using the meet function
Definition at line 276 of file constants.cc.
References _bottom, _top, pointerValue::blocks, bottom(), memoryBlock::current_use(), memoryBlock::decl(), declNode::decl_location(), def, declNode::ENUM, evaluate_points_to(), declNode::init(), pointerValue::is_address, lookup(), lookup_flowvalue(), meet(), memoryblock_set_p, memoryBlock::name(), to_string(), use, and exprNode::value().
Referenced by at_dereference(), at_field_access(), at_id(), at_index(), and at_self_assignment(). |
void constantAnalyzer::record_change |
( |
memoryDef * |
def |
) |
[private] |
|
|
Obsolete: Record a value change.
|
void constantAnalyzer::record_expression |
( |
exprNode * |
expr, |
|
|
const constant * |
val |
|
) |
|
|
void constantAnalyzer::set_null_object |
( |
memoryBlock * |
null_object |
) |
[inline] |
|
|
Set the null object.
The pointer analyzer needs to provide this so that we can properly handle null pointers as constants.
Definition at line 125 of file constants.h.
Referenced by Pointers::Pointers(). |
string constantAnalyzer::to_string |
( |
const constant * |
val |
) |
[inline] |
|
const constant* constantAnalyzer::top |
( |
|
) |
const [inline] |
|
Member Data Documentation
const constant* constantAnalyzer::_bottom [private]
|
|
|
Unique lattice bottom element.
Definition at line 91 of file constants.h.
Referenced by at_address(), at_assignment(), at_binary(), at_cast(), at_const(), at_sizeof(), at_unary(), evaluate_points_to(), has_truth_value(), lookup(), lookup_expression(), lookup_flowvalue(), lookup_stmt(), meet(), rebuild_flowvalue(), and ~constantAnalyzer(). |
TREE constant_set constantAnalyzer::_double_constants [private]
|
|
TREE constant_set constantAnalyzer::_float_constants [private]
|
|
const constant* constantAnalyzer::_non_null [private]
|
|
TREE constant_set constantAnalyzer::_schar_constants [private]
|
|
|
The set of all constants.
This set ensures that each unique constant value is represented by exactly one constant object. It "owns" all of the constant values. All other data structures refer to these.
Definition at line 68 of file constants.h.
Referenced by lookup(). |
TREE constant_set constantAnalyzer::_sint_constants [private]
|
|
TREE constant_set constantAnalyzer::_slong_constants [private]
|
|
TREE constant_set constantAnalyzer::_sshort_constants [private]
|
|
const constant* constantAnalyzer::_top [private]
|
|
|
Unique lattice top element.
Definition at line 87 of file constants.h.
Referenced by at_assignment(), at_basicblock_entry(), at_binary(), at_cast(), at_merge(), at_parameter_pass(), at_self_assignment(), at_stmt_entry(), at_unary(), has_truth_value(), meet(), rebuild_flowvalue(), record_expression(), record_stmt(), update_flowvalue(), and ~constantAnalyzer(). |
TREE constant_set constantAnalyzer::_uchar_constants [private]
|
|
TREE constant_set constantAnalyzer::_uint_constants [private]
|
|
TREE constant_set constantAnalyzer::_ulong_constants [private]
|
|
TREE constant_set constantAnalyzer::_ushort_constants [private]
|
|
The documentation for this class was generated from the following files:
|