Skip to content

VSD: Simplifying abstract_objectt::write, collapsing inheritance hierarchy #5755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 49 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
5b4f40f
Fold ID_address_of into ID_array/ID_struct/ID_constant case. They are…
jezhiggins Jan 5, 2021
dbad4e5
Factored out abstract_environmentt::resolve_symbol
jezhiggins Jan 5, 2021
ef31be2
abstract_environmentt::eval unpicked if ladder
jezhiggins Jan 5, 2021
6e35c3b
Simplified abstract_environmentt::write - all cases were equivalent
jezhiggins Jan 6, 2021
bb0b1fe
collapse equivalent cases in abstract_environmentt::assign
jezhiggins Jan 6, 2021
ae9e6aa
call resolve_symbol from abstract_environmentt::assign
jezhiggins Jan 6, 2021
3d53ccd
Removed member functions that just call down to base class
jezhiggins Jan 6, 2021
8918a14
Removed abstract_valuet
jezhiggins Jan 6, 2021
363ed9f
Corrected abstract_environment.h/cpp filenames
jezhiggins Jan 9, 2021
bac4312
Pass shared pointers to assign & write by const-ref
jezhiggins Jan 9, 2021
1c64b91
Introduce abstract_aggregate_objectt
jezhiggins Jan 9, 2021
421d2ff
Implemented two_value_array_abstract_object
jezhiggins Jan 9, 2021
94cbfb6
Eliminate array_abstract_objectt as a base class
jezhiggins Jan 9, 2021
3e47f43
Rename union_abstract_objectt to two_value_union_abstract_objectt
jezhiggins Jan 10, 2021
fddf371
Reordered cases in variable_sensitivity_object_factoryt::get_abstract…
jezhiggins Jan 10, 2021
c09023d
Removed now empty source files
jezhiggins Jan 11, 2021
21af732
Renamed header files to reflect contents
jezhiggins Jan 11, 2021
b37e18b
clean up includes
jezhiggins Jan 11, 2021
ea76a7f
Update make build to match file changes
jezhiggins Jan 11, 2021
9b4acdd
Corrected base class template parameter
jezhiggins Jan 11, 2021
87706b3
Simplified interval_array_abstract_objectt::write_component
jezhiggins Jan 11, 2021
ff4aa07
Introduce abstract_value_objectt as base for constant/interval/value_…
jezhiggins Jan 12, 2021
e7f7239
Starting work on index_range, first step along that path a single arr…
jezhiggins Jan 12, 2021
402809c
input_range for interval_abstract_values
jezhiggins Jan 12, 2021
0585702
index_range needs namespacet passed in
jezhiggins Jan 13, 2021
ab30d0c
Rework interval_array_...::write_component to using index_range
jezhiggins Jan 13, 2021
ce3eb0b
Rework interval_array_...::read_component to use index_range
jezhiggins Jan 13, 2021
19b324e
If the expression is not constant that's an inderminate range not an …
jezhiggins Jan 14, 2021
8e317ba
Remove interval_array_abstract_object::eval_index override
jezhiggins Jan 14, 2021
703c97f
Implemented value_set_index_ranget
jezhiggins Jan 14, 2021
053df78
Refactoring index_ranget and its subclasses
jezhiggins Jan 16, 2021
fdd5712
Combine constant_array_ & interval_array_ implementations
jezhiggins Jan 16, 2021
5a5d4c1
full_array_abstract_object
jezhiggins Jan 16, 2021
aa9925f
Removed value_set_array_abstract_objectt
jezhiggins Jan 17, 2021
a439481
eval_index doesn't need to be a member function
jezhiggins Jan 16, 2021
55b477d
Factor common index loop out of full_array_abstract_object::write_/re…
jezhiggins Jan 16, 2021
058ffd7
get_top_entry instead big abstract_object_factory call
jezhiggins Jan 16, 2021
3168916
Use get_view()/get_sorted_view() instead of get_view(&view)
jezhiggins Jan 16, 2021
886829c
Hoist is_top check from read_element to read_component
jezhiggins Jan 16, 2021
2a3f4cd
Moved merged_sharing_maps into abstract_aggregate_object. Eliminated …
jezhiggins Jan 16, 2021
56370a7
use abstract_objectt::merge(op1, op2) when we're not interested in wh…
jezhiggins Jan 16, 2021
27543d8
Split full_array_::write_element into write_sub_element and write_lea…
jezhiggins Jan 16, 2021
33021a3
Removed redundant if guard
jezhiggins Jan 16, 2021
b04f5c8
Arrange write checks so everything if(not value) replace else insert
jezhiggins Jan 16, 2021
1c18b88
clang-format fixes
jezhiggins Jan 16, 2021
c5248bd
Updated expected doxygen warnings
jezhiggins Jan 17, 2021
f332df8
Fix doxygen warning
jezhiggins Jan 17, 2021
cc75d94
Add header block
jezhiggins Jan 27, 2021
d9f7b72
remove extraneous include
jezhiggins Jan 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions scripts/expected_doxygen_warnings.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/home/runner/work/cbmc/cbmc/src/solvers/sat/satcheck_glucose.cpp:232: warning: no matching class member found for
/home/runner/work/cbmc/cbmc/src/solvers/sat/satcheck_glucose.cpp:246: warning: no matching class member found for
template
satcheck_glucose_baset< Glucose::Solver >::~satcheck_glucose_baset()

/home/runner/work/cbmc/cbmc/src/solvers/sat/satcheck_glucose.cpp:238: warning: no matching class member found for
/home/runner/work/cbmc/cbmc/src/solvers/sat/satcheck_glucose.cpp:252: warning: no matching class member found for
template
satcheck_glucose_baset< Glucose::SimpSolver >::~satcheck_glucose_baset()

/home/runner/work/cbmc/cbmc/src/solvers/sat/satcheck_minisat2.cpp:312: warning: no matching class member found for
/home/runner/work/cbmc/cbmc/src/solvers/sat/satcheck_minisat2.cpp:313: warning: no matching class member found for
template
satcheck_minisat2_baset< Minisat::Solver >::~satcheck_minisat2_baset()

/home/runner/work/cbmc/cbmc/src/solvers/sat/satcheck_minisat2.cpp:318: warning: no matching class member found for
/home/runner/work/cbmc/cbmc/src/solvers/sat/satcheck_minisat2.cpp:319: warning: no matching class member found for
template
satcheck_minisat2_baset< Minisat::SimpSolver >::~satcheck_minisat2_baset()

Expand Down Expand Up @@ -87,16 +87,16 @@ warning: Included by graph for 'arith_tools.h' not generated, too many nodes (18
warning: Included by graph for 'c_types.h' not generated, too many nodes (111), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'config.h' not generated, too many nodes (85), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'exception_utils.h' not generated, too many nodes (61), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'expr.h' not generated, too many nodes (88), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'expr.h' not generated, too many nodes (87), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'expr_util.h' not generated, too many nodes (61), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'invariant.h' not generated, too many nodes (187), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'irep.h' not generated, too many nodes (62), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'message.h' not generated, too many nodes (116), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'namespace.h' not generated, too many nodes (113), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'namespace.h' not generated, too many nodes (110), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'pointer_expr.h' not generated, too many nodes (101), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'prefix.h' not generated, too many nodes (86), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'simplify_expr.h' not generated, too many nodes (77), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'std_code.h' not generated, too many nodes (78), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'std_expr.h' not generated, too many nodes (248), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'std_types.h' not generated, too many nodes (124), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'std_expr.h' not generated, too many nodes (245), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'std_types.h' not generated, too many nodes (122), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
warning: Included by graph for 'symbol_table.h' not generated, too many nodes (95), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
11 changes: 3 additions & 8 deletions src/analyses/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,26 @@ SRC = ai.cpp \
uncaught_exceptions_analysis.cpp \
uninitialized_domain.cpp \
variable-sensitivity/abstract_object.cpp \
variable-sensitivity/abstract_enviroment.cpp \
variable-sensitivity/abstract_value.cpp \
variable-sensitivity/array_abstract_object.cpp \
variable-sensitivity/abstract_environment.cpp \
variable-sensitivity/abstract_value_object.cpp \
variable-sensitivity/constant_abstract_value.cpp \
variable-sensitivity/constant_pointer_abstract_object.cpp \
variable-sensitivity/context_abstract_object.cpp \
variable-sensitivity/write_location_context.cpp \
variable-sensitivity/pointer_abstract_object.cpp \
variable-sensitivity/struct_abstract_object.cpp \
variable-sensitivity/variable_sensitivity_domain.cpp \
variable-sensitivity/variable_sensitivity_object_factory.cpp \
variable-sensitivity/full_struct_abstract_object.cpp \
variable-sensitivity/constant_array_abstract_object.cpp \
variable-sensitivity/union_abstract_object.cpp \
variable-sensitivity/full_array_abstract_object.cpp \
variable-sensitivity/write_stack.cpp \
variable-sensitivity/write_stack_entry.cpp \
variable-sensitivity/data_dependency_context.cpp \
variable-sensitivity/value_set_abstract_object.cpp \
variable-sensitivity/variable_sensitivity_dependence_graph.cpp \
variable-sensitivity/interval_abstract_value.cpp \
variable-sensitivity/interval_array_abstract_object.cpp \
variable-sensitivity/value_set_abstract_object.cpp \
variable-sensitivity/value_set_abstract_value.cpp \
variable-sensitivity/value_set_pointer_abstract_object.cpp \
variable-sensitivity/value_set_array_abstract_object.cpp \
variable-sensitivity/three_way_merge_abstract_interpreter.cpp \
variable-sensitivity/variable_sensitivity_configuration.cpp \
# Empty last line
Expand Down
227 changes: 227 additions & 0 deletions src/analyses/variable-sensitivity/abstract_aggregate_object.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
/*******************************************************************\

Module: analyses variable-sensitivity

Author: Jez Higgins, jez@jezuk.co.uk

\*******************************************************************/

/// \file
/// Common behaviour for abstract objects modelling aggregate values -
/// arrays, structs, etc.
#ifndef CBMC_ABSTRACT_AGGREGATE_OBJECT_H
#define CBMC_ABSTRACT_AGGREGATE_OBJECT_H

#include <analyses/variable-sensitivity/abstract_environment.h>
#include <analyses/variable-sensitivity/abstract_object.h>
#include <stack>

class abstract_aggregate_tag
{
};

template <class aggregate_typet, class aggregate_traitst>
class abstract_aggregate_objectt : public abstract_objectt,
public abstract_aggregate_tag
{
public:
explicit abstract_aggregate_objectt(const typet &type)
: abstract_objectt(type)
{
PRECONDITION(type.id() == aggregate_traitst::TYPE_ID());
}

abstract_aggregate_objectt(const typet &type, bool tp, bool bttm)
: abstract_objectt(type, tp, bttm)
{
PRECONDITION(type.id() == aggregate_traitst::TYPE_ID());
}

abstract_aggregate_objectt(
const exprt &expr,
const abstract_environmentt &environment,
const namespacet &ns)
: abstract_objectt(expr, environment, ns)
{
PRECONDITION(ns.follow(expr.type()).id() == aggregate_traitst::TYPE_ID());
}

abstract_object_pointert expression_transform(
const exprt &expr,
const std::vector<abstract_object_pointert> &operands,
const abstract_environmentt &environment,
const namespacet &ns) const override
{
if(expr.id() == aggregate_traitst::ACCESS_EXPR_ID())
return read_component(environment, expr, ns);

return abstract_objectt::expression_transform(
expr, operands, environment, ns);
}

abstract_object_pointert write(
abstract_environmentt &environment,
const namespacet &ns,
const std::stack<exprt> &stack,
const exprt &specifier,
const abstract_object_pointert &value,
bool merging_write) const override
{
return write_component(
environment, ns, stack, specifier, value, merging_write);
}

void get_statistics(
abstract_object_statisticst &statistics,
abstract_object_visitedt &visited,
const abstract_environmentt &env,
const namespacet &ns) const override
{
abstract_objectt::get_statistics(statistics, visited, env, ns);
aggregate_traitst::get_statistics(statistics, visited, env, ns);
this->statistics(statistics, visited, env, ns);
}

protected:
virtual abstract_object_pointert read_component(
const abstract_environmentt &environment,
const exprt &expr,
const namespacet &ns) const
{
// If we are bottom then so are the components
// otherwise the components could be anything
return environment.abstract_object_factory(
aggregate_traitst::read_type(expr.type(), type()),
ns,
!is_bottom(),
is_bottom());
}

virtual abstract_object_pointert write_component(
abstract_environmentt &environment,
const namespacet &ns,
const std::stack<exprt> &stack,
const exprt &expr,
const abstract_object_pointert &value,
bool merging_write) const
{
if(is_top() || is_bottom())
{
return shared_from_this();
}
else
{
return std::make_shared<aggregate_typet>(type(), true, false);
}
}

virtual void statistics(
abstract_object_statisticst &statistics,
abstract_object_visitedt &visited,
const abstract_environmentt &env,
const namespacet &ns) const = 0;

template <class keyt, typename hash>
static bool merge_shared_maps(
const sharing_mapt<keyt, abstract_object_pointert, false, hash> &map1,
const sharing_mapt<keyt, abstract_object_pointert, false, hash> &map2,
sharing_mapt<keyt, abstract_object_pointert, false, hash> &out_map)
{
bool modified = false;

typename sharing_mapt<keyt, abstract_object_pointert, false, hash>::
delta_viewt delta_view;
map1.get_delta_view(map2, delta_view, true);

for(auto &item : delta_view)
{
bool changes = false;
abstract_object_pointert v_new =
abstract_objectt::merge(item.m, item.get_other_map_value(), changes);
if(changes)
{
modified = true;
out_map.replace(item.k, v_new);
}
}

return modified;
}
};

struct array_aggregate_typet
{
static const irep_idt TYPE_ID()
{
return ID_array;
}
static const irep_idt ACCESS_EXPR_ID()
{
return ID_index;
}
static typet read_type(const typet &, const typet &object_type)
{
array_typet array_type(to_array_type(object_type));
return array_type.subtype();
}

static void get_statistics(
abstract_object_statisticst &statistics,
abstract_object_visitedt &visited,
const abstract_environmentt &env,
const namespacet &ns)
{
++statistics.number_of_arrays;
}
};

struct struct_aggregate_typet
{
static const irep_idt &TYPE_ID()
{
return ID_struct;
}
static const irep_idt &ACCESS_EXPR_ID()
{
return ID_member;
}
static const typet &read_type(const typet &expr_type, const typet &)
{
return expr_type;
}

static void get_statistics(
abstract_object_statisticst &statistics,
abstract_object_visitedt &visited,
const abstract_environmentt &env,
const namespacet &ns)
{
++statistics.number_of_structs;
}
};

struct union_aggregate_typet
{
static const irep_idt TYPE_ID()
{
return ID_union;
}
static const irep_idt ACCESS_EXPR_ID()
{
return ID_member;
}
static typet read_type(const typet &, const typet &object_type)
{
return object_type;
}

static void get_statistics(
abstract_object_statisticst &statistics,
abstract_object_visitedt &visited,
const abstract_environmentt &env,
const namespacet &ns)
{
}
};

#endif //CBMC_ABSTRACT_AGGREGATE_OBJECT_H
Loading