2 #ifndef BDWY_ENUM_PROPERTY_H
3 #define BDWY_ENUM_PROPERTY_H
63 inline const std::string &
name()
const {
return _name; }
73 inline int id()
const {
return _id; }
74 inline void id(
int new_id) {
_id = new_id; }
90 #define MAX_ENUMVALUES 32
92 typedef std::bitset< MAX_ENUMVALUES >
bitset32;
128 return (temp != other);
158 #ifdef __MEMORYACCESS
159 typedef std::map< memoryAccess *, enumvalue_set> defuse_property_map;
160 typedef defuse_property_map::iterator defuse_property_map_p;
164 typedef std::map< memoryBlock *, enumvalue_set > block_propertyset_map;
165 typedef block_propertyset_map::iterator block_propertyset_map_p;
168 #ifdef __PROCLOCATION
169 typedef std::pair< int, double > count_accuracy_pair;
170 typedef map< procLocation *, count_accuracy_pair > accuracy_map;
171 typedef accuracy_map::iterator accuracy_map_p;
175 typedef std::map< Location *, memoryblock_set > tested_objects_map;
176 typedef tested_objects_map::iterator tested_objects_map_p;
180 typedef std::map< stmtNode *, count_accuracy_pair > stmt_accuracy_map;
181 typedef stmt_accuracy_map::iterator stmt_accuracy_map_p;
186 typedef std::pair< memoryBlock*, Location* > block_loc_pair;
187 typedef std::set< block_loc_pair > block_loc_set;
189 typedef std::pair< memoryBlock*, procNode* > block_proc_pair;
190 typedef std::set< block_proc_pair > block_proc_set;
235 #ifdef __MEMORYACCESS
236 defuse_property_map _now_values;
242 block_propertyset_map _ever_values;
248 typedef std::pair<procedureInfo*,memoryBlock*> Input_to_pair;
249 std::map<Input_to_pair,enumvalue_set> _input_to_values;
257 #ifdef __FLOW_SENSITIVE_SET
258 flow_sensitive_set _flow_sensitive_objects;
266 #ifdef __TESTED_OBJECTS
267 tested_objects_map _tested_objects;
276 #ifdef __PROCLOCATION
277 accuracy_map _accuracy;
286 stmt_set _error_statements;
299 procedureinfo_set _error_procedures;
390 memoryBlock * lookup_property_block(memoryBlock * real_block);
399 void add_property_block(memoryBlock * real_block, memoryBlock * property_block);
408 pointerValue & lhs, std::string & lhs_name,
409 pointerValue & rhs, std::string & rhs_name);
418 pointerValue & lhs, std::string & lhs_name,
432 #ifdef __MEMORYACCESS
434 memoryAccess * def_or_use);
442 #ifdef __MEMORYACCESS
443 bool update_now_value(Location * where,
444 memoryBlock * property_block,
445 memoryAccess * def_or_use,
447 bool & lost_information);
463 memoryBlock * property_block);
468 void update_input_to_value(procedureInfo *info, memoryBlock * property_block,
485 std::string & variable_name,
486 bool & lost_information,
487 memoryblock_set & complicit_property_blocks);
498 memoryBlock * property_block,
499 bool default_to_top);
516 enumvalue_set construct_after_value(memoryBlock * real_block);
549 pointerValue & right,
550 std::string & right_name,
551 bool & rhs_lost_information,
552 memoryblock_set & complicit_property_blocks,
564 void apply_next(Location * where,
565 stmtLocation * parameter_callsite,
569 std::string & left_name,
570 pointerValue & right,
572 bool rhs_lost_information,
574 memoryblock_set & complicit_property_blocks,
576 memoryblock_set & changes);
585 void apply_merge(Location * where,
586 memoryBlock * property_block, memoryuse_list & phi_uses,
587 memoryblock_set & changes);
597 void apply_assignment(Location * where,
598 stmtLocation * parameter_callsite,
599 pointerValue & left, pointerValue & right,
601 memoryblock_set & changes);
610 void self_assignment(Location * source,
612 memoryBlock * property_block,
613 memoryblock_set & changes,
623 void conservative_procedure_call(stmtLocation * current,
624 pointerValue & reachable,
625 memoryblock_set & changes);
633 void report(std::ostream & out,
635 procLocation * where,
637 pointerValue & lhs, std::string & lhs_name);
654 memoryblock_set & flow_sensitive);
674 void add_flow_sensitive_object(memoryBlock * property_block);
683 void set_flow_sensitivity(memoryBlock * real_block);
689 #ifdef __FLOW_SENSITIVE_SET
690 inline int count_flow_sensitive_objects() {
return _flow_sensitive_objects.size(); }
694 void print(std::ostream & o)
const;
722 #ifdef __PROCLOCATION
723 void diagnostic(std::ostream &out, procLocation *where, pointerValue &pv,
731 bool compare_now_value(Location *where, memoryBlock *property_block,
743 int & cur_index,
int height,
int & max_height);
750 void track_destructive_assignments(Analyzer * analyzer,
753 bool disallow_context_sensitivity,
754 block_loc_set & already_seen,
755 block_loc_set seen_stack,
756 memoryblock_set & made_flow_sensitive,
757 memoryblock_set & made_fs_destructive,
758 block_loc_set & made_context_sensitive,
759 block_proc_set & eval_cs_seen_destructive,
760 block_proc_set & eval_cs_seen_complicit,
761 block_proc_set & eval_made_cs,
762 bool & make_chain_flow_sensitive,
763 bool & make_chain_context_sensitive,
764 memoryblock_vector & chain,
765 std::string & indent);
774 void record_tested_objects(Location * where,
777 memoryblock_set & complicit_property_blocks);
784 void trace_object(std::ostream & out,
785 memoryBlock * property_block,
786 memoryblock_set & already_seen,
787 std::string & indent);
795 bool evaluate_context_sensitivity(Analyzer * analyzer,
798 procLocation * procloc,
800 block_proc_set & eval_cs_seen_destructive,
801 block_proc_set & eval_cs_seen_complicit,
802 block_proc_set & evaled_cs,
803 std::string & indent);
810 bool validate_property_cs(memoryBlock * block,
811 const callsite_objects_map & assignments,
812 procedureInfo *procedure,
813 std::string & indent);
820 bool validate_multiplicity_cs(memoryBlock * block,
821 const callsite_objects_map & assignments,
822 procedureInfo *procedure,
823 std::string & indent);
830 bool validate_pointer_cs(memoryBlock * block,
831 const callsite_objects_map & assignments,
832 procedureInfo *procedure,
833 std::string & indent);
841 bool validate_pointer_fs(memoryBlock * block,
842 stmtLocation * where,
843 std::string & indent);
851 bool is_location_reachable(Location * source, Location * target, memoryBlock * block);
860 const memoryblock_set & blocks,
861 procedureInfo *callee=NULL);
867 #ifdef __PROCEDUREINFO
868 bool add_context_sensitive_proc(procedureInfo * info,
869 procedureinfo_set & already_seen,
870 procedureinfo_set & make_cs);