Skip to content

Commit 3f7ed08

Browse files
author
martin
committed
Apply Peter Schrammel's review comments
1 parent dcb81e9 commit 3f7ed08

File tree

20 files changed

+32
-130
lines changed

20 files changed

+32
-130
lines changed

src/analyses/variable-sensitivity/abstract_enviroment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ abstract_environmentt::eval(const exprt &expr, const namespacet &ns) const
140140
/// what kind of array abstraction it is). So, as we find the variable
141141
/// ('a' in this case) we build a stack of which part of it is accessed.
142142
///
143-
/// As abstractions may split the assignment into multiple write (for
143+
/// As abstractions may split the assignment into multiple writes (for
144144
/// example pointers that could point to several locations, arrays with
145145
/// non-constant indexes), each of which has to handle the rest of the
146146
/// compound write, thus the stack is passed (to write, which does the

src/analyses/variable-sensitivity/abstract_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/// abstract_objectt is the top of the inheritance heirarchy of objects
1111
/// used to represent individual variables in the general non-relational
1212
/// domain. It is a two element abstraction (i.e. it is either top or
13-
/// bottom). Within the hierachy of objects under it, child classes are
13+
/// bottom). Within the hierarchy of objects under it, child classes are
1414
/// more precise abstractions (the converse doesn't hold to avoid
1515
/// diamonds and inheriting unnecessary fields). Thus the common parent
1616
/// of two classes is an abstraction capable of representing both. This

src/analyses/variable-sensitivity/array_abstract_object.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ abstract_object_pointert array_abstract_objectt::read_index(
131131
/// \param value: the value we are trying to assign to that value in the array
132132
/// \param merging_write: ?
133133
///
134-
/// \return The struct_abstract_objectt representing the result of writing
134+
/// \return The array_abstract_objectt representing the result of writing
135135
/// to a specific component. In this case this will always be top
136-
/// as we are not tracking the value of this struct.
136+
/// as we are not tracking the value in the array.
137137
///
138138
/// A helper function to evaluate writing to a component of a struct.
139139
/// More precise abstractions may override this to

src/analyses/variable-sensitivity/constant_array_abstract_object.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ void constant_array_abstract_objectt::get_statistics(
490490
array_abstract_objectt::get_statistics(statistics, visited, env, ns);
491491
shared_array_mapt::viewt view;
492492
map.get_view(view);
493-
for(auto const &object : view)
493+
for(const auto &object : view)
494494
{
495495
if(visited.find(object.second) == visited.end())
496496
{

src/analyses/variable-sensitivity/data_dependency_context.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ abstract_object_pointert data_dependency_contextt::write(
210210
* \param update_sub_elements if true, propogate the update operation to any
211211
* children of this abstract object
212212
*
213-
* \return a clone of this abstract object with it's location context
213+
* \return a clone of this abstract object with its location context
214214
* updated
215215
*/
216216
abstract_object_pointert data_dependency_contextt::update_location_context(
@@ -280,7 +280,7 @@ data_dependency_contextt::merge(abstract_object_pointert other) const
280280

281281
/**
282282
* Helper function for abstract_objectt::abstract_object_merge to perform any
283-
* additional actions after the base abstract_object_merge has completed it's
283+
* additional actions after the base abstract_object_merge has completed its
284284
* actions but immediately prior to it returning. As such, this function gives
285285
* the ability to perform additional work for a merge.
286286
*

src/analyses/variable-sensitivity/full_struct_abstract_object.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,12 @@ full_struct_abstract_objectt::full_struct_abstract_objectt(
7676
bool did_initialize_values = false;
7777
auto struct_type_it = struct_type_def.components().begin();
7878
for(auto param_it = e.operands().begin(); param_it != e.operands().end();
79-
++param_it)
79+
++param_it, ++struct_type_it)
8080
{
8181
map.insert_or_replace(
8282
struct_type_it->get_name(),
8383
environment.abstract_object_factory(param_it->type(), *param_it, ns));
8484
did_initialize_values = true;
85-
++struct_type_it;
8685
}
8786

8887
if(did_initialize_values)

src/analyses/variable-sensitivity/three_way_merge_abstract_interpreter.cpp

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ bool ai_three_way_merget::visit_edge_function_call(
132132
ns);
133133

134134
// TODO : this is probably needed to avoid three_way_merge modifying one of
135-
// it's arguments as it goes. A better solution would be to refactor
135+
// its arguments as it goes. A better solution would be to refactor
136136
// merge_three_way_function_return.
137137
const std::unique_ptr<statet> ptr_s_working_copy(
138138
make_temporary_state(s_working));
@@ -155,101 +155,3 @@ bool ai_three_way_merget::visit_edge_function_call(
155155

156156
return new_data;
157157
}
158-
159-
#if 0
160-
// This is the edge from function end to return site.
161-
162-
{
163-
if(end_state.is_bottom())
164-
return false; // function exit point not reachable
165-
166-
working_sett working_set; // Redundant; visit will add l_return
167-
168-
- return visit_edge(
169-
- f_it->first, l_end, calling_function_id, l_return, ns, working_set);
170-
+ const std::unique_ptr<statet> tmp_state(make_temporary_state(end_state));
171-
+ tmp_state->transform(f_it->first, l_end, f_it->first, l_return, *this, ns);
172-
+
173-
+ const std::unique_ptr<statet> pre_merge_state{
174-
+ make_temporary_state(*tmp_state)};
175-
+
176-
+ const locationt l_begin = goto_function.body.instructions.begin();
177-
+ tmp_state->merge_three_way_function_return(
178-
+ get_state(l_call), get_state(l_begin), *pre_merge_state, ns);
179-
+
180-
+ return merge(*tmp_state, l_end, l_return);
181-
}
182-
183-
#endif
184-
185-
#if 0
186-
bool ai_baset::visit_edge(
187-
const irep_idt &function_id,
188-
trace_ptrt p,
189-
const irep_idt &to_function_id,
190-
locationt to_l,
191-
trace_ptrt caller_history,
192-
const namespacet &ns,
193-
working_sett &working_set)
194-
{
195-
// We only care about the return cases
196-
if (caller_history == ai_history_baset::no_caller_history) {
197-
return ai_recursive_interproceduralt::visit_edge(function_id, p, to_function_id, to_l, caller_history, ns, working_set);
198-
}
199-
200-
// There are four histories / locations / domains we care about
201-
// In chronological order...
202-
203-
trace_ptr call_site_history = caller_history;
204-
statet &call_site_state = get_state(call_site_history);
205-
locationt call_site_location = call_site_history.current_location();
206-
INVARIANT(call_site_location->is_function_call(), "caller_history implies that is is a function call");
207-
208-
trace_ptr callee_start_history = TBD;
209-
statet &callee_start_state = get_state(callee_start_history);
210-
locationt callee_start_location = callee_start_history.current_location();
211-
212-
trace_ptr callee_end_history = p;
213-
statet &callee_end_state = get_state(callee_end_history);
214-
locationt callee_end_location = callee_end_history.current_location();
215-
INVARIANT(callee_end_location->is_end_function(), "TBD");
216-
217-
trace_ptr return_site_history = STEP;
218-
statet &return_site_state = get_state(return_site_history);
219-
locationt return_site_location = to_l;
220-
INVARIANT(std::next(call_site_location) == to_l, "TBD");
221-
222-
223-
224-
// Has history taught us not to step here...
225-
auto next =
226-
p->step(to_l, *(storage->abstract_traces_before(to_l)), caller_history);
227-
if(next.first == ai_history_baset::step_statust::BLOCKED)
228-
return false;
229-
trace_ptrt to_p = next.second;
230-
231-
// Abstract domains are mutable so we must copy before we transform
232-
statet &current = get_state(p);
233-
234-
std::unique_ptr<statet> tmp_state(make_temporary_state(current));
235-
statet &new_values = *tmp_state;
236-
237-
// Apply transformer
238-
new_values.transform(function_id, p, to_function_id, to_p, *this, ns);
239-
240-
// Expanding a domain means that it has to be analysed again
241-
// Likewise if the history insists that it is a new trace
242-
// (assuming it is actually reachable).
243-
if(
244-
merge(new_values, p, to_p) ||
245-
(next.first == ai_history_baset::step_statust::NEW &&
246-
!new_values.is_bottom()))
247-
{
248-
put_in_working_set(working_set, to_p);
249-
return true;
250-
}
251-
252-
return false;
253-
}
254-
255-
#endif

src/analyses/variable-sensitivity/variable_sensitivity_domain.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88

99
/// \file
1010
/// There are different ways of handling arrays, structures, unions and
11-
/// pointers. Our existing solution basically ignores them which is
12-
/// imprecise at best and out-right wrong at worst. For one project we
13-
/// needed to do better. We could have implemented a particular way of
14-
/// handling them in an existing domain, created a new one with it, etc.
15-
/// This would work but it means duplicate code and it is is inflexible when
16-
/// the same person / the next person comes along and says "actually, we
17-
/// really care about the pointer precision but less so the array so could
18-
/// you just ...". Thus the idea was to do this properly:
11+
/// pointers. interval_domaint and constant_propagator_domaint
12+
/// basically ignores them which is imprecise at best and out-right
13+
/// wrong at worst. For one project we needed to do better. We could
14+
/// have implemented a particular way of handling them in an existing
15+
/// domain, created a new one with it, etc. This would work but it
16+
/// means duplicate code and it is is inflexible when the same person
17+
/// / the next person comes along and says "actually, we really care
18+
/// about the pointer precision but less so the array so could you
19+
/// just ...". Thus the idea was to do this properly:
1920
///
2021
/// 1. Build a "non-relational domain" and allow the abstractions used for
2122
/// individual variables to be different.

src/analyses/variable-sensitivity/write_location_context.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515

1616
/**
1717
* Update the location context for an abstract object, potentially
18-
* propogating the update to any children of this abstract object.
18+
* propagating the update to any children of this abstract object.
1919
*
2020
* \param locations the set of locations to be updated
2121
* \param update_sub_elements if true, propogate the update operation to any
2222
* children of this abstract object
2323
*
24-
* \return a clone of this abstract object with it's location context
24+
* \return a clone of this abstract object with its location context
2525
* updated
2626
*/
2727
abstract_object_pointert write_location_contextt::update_location_context(
@@ -152,7 +152,7 @@ write_location_contextt::merge(abstract_object_pointert other) const
152152

153153
/**
154154
* Helper function for abstract_objectt::abstract_object_merge to perform any
155-
* additional actions after the base abstract_object_merge has completed it's
155+
* additional actions after the base abstract_object_merge has completed its
156156
* actions but immediately prior to it returning. As such, this function gives
157157
* the ability to perform additional work for a merge.
158158
*

src/analyses/variable-sensitivity/write_stack.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
Module: Variable Sensitivity Domain
44
5-
Author: DiffBlue Limited. All rights reserved.
5+
Author: DiffBlue Limited.
66
77
\*******************************************************************/
88

0 commit comments

Comments
 (0)