cprover
Loading...
Searching...
No Matches
abstract_environment.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3 Module: analyses variable-sensitivity
4
5 Author: Thomas Kiley, thomas.kiley@diffblue.com
6
7\*******************************************************************/
8
9#include <util/expr_util.h>
10#include <util/namespace.h>
11#include <util/simplify_expr.h>
12#include <util/simplify_utils.h>
13#include <util/symbol_table.h>
14
17
18#include <algorithm>
19#include <map>
20#include <ostream>
21#include <stack>
22
23#ifdef DEBUG
24# include <iostream>
25#endif
26
30
31typedef exprt (
33
34static exprt
35assume_not(abstract_environmentt &env, const exprt &expr, const namespacet &ns);
36static exprt
37assume_or(abstract_environmentt &env, const exprt &expr, const namespacet &ns);
38static exprt
39assume_and(abstract_environmentt &env, const exprt &expr, const namespacet &ns);
40static exprt
41assume_eq(abstract_environmentt &env, const exprt &expr, const namespacet &ns);
42static exprt assume_noteq(
44 const exprt &expr,
45 const namespacet &ns);
48 const exprt &expr,
49 const namespacet &ns);
52 const exprt &expr,
53 const namespacet &ns);
54
56static bool is_value(const abstract_object_pointert &obj);
57
58std::vector<abstract_object_pointert> eval_operands(
59 const exprt &expr,
61 const namespacet &ns);
62
63bool is_ptr_diff(const exprt &expr)
64{
65 return (expr.id() == ID_minus) &&
66 (expr.operands()[0].type().id() == ID_pointer) &&
67 (expr.operands()[1].type().id() == ID_pointer);
68}
69
70bool is_ptr_comparison(const exprt &expr)
71{
72 auto const &id = expr.id();
73 bool is_comparison = id == ID_equal || id == ID_notequal || id == ID_lt ||
74 id == ID_le || id == ID_gt || id == ID_ge;
75
76 return is_comparison && (expr.operands()[0].type().id() == ID_pointer) &&
77 (expr.operands()[1].type().id() == ID_pointer);
78}
79
80static bool is_access_expr(const irep_idt &id)
81{
82 return id == ID_member || id == ID_index || id == ID_dereference;
83}
84
85static bool is_object_creation(const irep_idt &id)
86{
87 return id == ID_array || id == ID_struct || id == ID_constant ||
88 id == ID_address_of;
89}
90
91static bool is_dynamic_allocation(const exprt &expr)
92{
93 return expr.id() == ID_side_effect && expr.get(ID_statement) == ID_allocate;
94}
95
97abstract_environmentt::eval(const exprt &expr, const namespacet &ns) const
98{
99 if(bottom)
100 return abstract_object_factory(expr.type(), ns, false, true);
101
102 // first try to canonicalise, including constant folding
103 const exprt &simplified_expr = simplify_expr(expr, ns);
104
105 const irep_idt simplified_id = simplified_expr.id();
107 return resolve_symbol(simplified_expr, ns);
108
109 if(
110 is_access_expr(simplified_id) || is_ptr_diff(simplified_expr) ||
111 is_ptr_comparison(simplified_expr))
112 {
113 auto const operands = eval_operands(simplified_expr, *this, ns);
114 auto const &target = operands.front();
115
116 return target->expression_transform(simplified_expr, operands, *this, ns);
117 }
118
120 return abstract_object_factory(simplified_expr.type(), simplified_expr, ns);
121
122 if(is_dynamic_allocation(simplified_expr))
125 exprt(ID_dynamic_object, simplified_expr.type()),
126 ns);
127
128 // No special handling required by the abstract environment
129 // delegate to the abstract object
130 if(!simplified_expr.operands().empty())
131 return eval_expression(simplified_expr, ns);
132
133 // It is important that this is top as the abstract object may not know
134 // how to handle the expression
135 return abstract_object_factory(simplified_expr.type(), ns, true, false);
136}
137
139 const exprt &expr,
140 const namespacet &ns) const
141{
142 const symbol_exprt &symbol(to_symbol_expr(expr));
143 const auto symbol_entry = map.find(symbol.get_identifier());
144
145 if(symbol_entry.has_value())
146 return symbol_entry.value();
147 return abstract_object_factory(expr.type(), ns, true, false);
148}
149
151 const exprt &expr,
152 const abstract_object_pointert &value,
153 const namespacet &ns)
154{
155 PRECONDITION(value);
156
157 if(value->is_bottom())
158 {
159 bool bottom_at_start = this->is_bottom();
160 this->make_bottom();
161 return !bottom_at_start;
162 }
163
165 // Build a stack of index, member and dereference accesses which
166 // we will work through the relevant abstract objects
167 exprt s = expr;
168 std::stack<exprt> stactions; // I'm not a continuation, honest guv'
169 while(s.id() != ID_symbol)
170 {
171 if(s.id() == ID_index || s.id() == ID_member || s.id() == ID_dereference)
172 {
173 stactions.push(s);
174 s = s.operands()[0];
175 }
176 else
177 {
178 lhs_value = eval(s, ns);
179 break;
180 }
181 }
182
183 if(!lhs_value)
184 {
185 INVARIANT(s.id() == ID_symbol, "Have a symbol or a stack");
186 lhs_value = resolve_symbol(s, ns);
187 }
188
190
191 // This is the root abstract object that is in the map of abstract objects
192 // It might not have the same type as value if the above stack isn't empty
193
194 if(!stactions.empty())
195 {
196 // The symbol is not in the map - it is therefore top
197 final_value = write(lhs_value, value, stactions, ns, false);
198 }
199 else
200 {
201 // If we don't have a symbol on the LHS, then we must have some expression
202 // that we can write to (i.e. a pointer, an array, a struct) This appears
203 // to be none of that.
204 if(s.id() != ID_symbol)
205 {
206 throw std::runtime_error("invalid l-value");
207 }
208 // We can assign the AO directly to the symbol
209 final_value = value;
210 }
211
212 const typet &lhs_type = ns.follow(lhs_value->type());
213 const typet &rhs_type = ns.follow(final_value->type());
214
215 // Write the value for the root symbol back into the map
216 INVARIANT(
218 "Assignment types must match"
219 "\n"
220 "lhs_type :" +
221 lhs_type.pretty() +
222 "\n"
223 "rhs_type :" +
224 rhs_type.pretty());
225
226 // If LHS was directly the symbol
227 if(s.id() == ID_symbol)
228 {
229 symbol_exprt symbol_expr = to_symbol_expr(s);
230
232 {
233 CHECK_RETURN(!symbol_expr.get_identifier().empty());
234 map.insert_or_replace(symbol_expr.get_identifier(), final_value);
235 }
236 }
237 return true;
238}
239
241 const abstract_object_pointert &lhs,
242 const abstract_object_pointert &rhs,
243 std::stack<exprt> remaining_stack,
244 const namespacet &ns,
245 bool merge_write)
246{
248 const exprt &next_expr = remaining_stack.top();
249 remaining_stack.pop();
250
251 const irep_idt &stack_head_id = next_expr.id();
252 INVARIANT(
255 "Write stack expressions must be index, member, or dereference");
256
257 return lhs->write(*this, ns, remaining_stack, next_expr, rhs, merge_write);
258}
259
261{
262 // We should only attempt to assume Boolean things
263 // This should be enforced by the well-structured-ness of the
264 // goto-program and the way assume is used.
265 PRECONDITION(expr.is_boolean());
266
267 auto simplified = simplify_expr(expr, ns);
268 auto assumption = do_assume(simplified, ns);
269
270 if(assumption.id() != ID_nil) // I.E. actually a value
271 {
272 // Should be of the right type
273 INVARIANT(assumption.is_boolean(), "simplification preserves type");
274
275 if(assumption.is_false())
276 {
278 make_bottom();
279 return !currently_bottom;
280 }
281 }
282
283 return false;
284}
285
286static auto assume_functions =
287 std::map<irep_idt, assume_function>{{ID_not, assume_not},
289 {ID_or, assume_or},
296
297// do_assume attempts to reduce the expression
298// returns
299// true_exprt when the assumption does not hold
300// false_exprt if the assumption does not hold & the domain should go bottom
301// nil_exprt if the assumption can't be evaluated & we should give up
303{
304 auto expr_id = expr.id();
305
307
308 if(fn)
309 return fn(*this, expr, ns);
310
311 return eval(expr, ns)->to_constant();
312}
313
315 const typet &type,
316 const namespacet &ns,
317 bool top,
318 bool bttm) const
319{
322 type, top, bttm, empty_constant_expr, *this, ns);
323}
324
326 const typet &type,
327 const exprt &e,
328 const namespacet &ns) const
329{
330 return abstract_object_factory(type, false, false, e, *this, ns);
331}
332
334 const typet &type,
335 bool top,
336 bool bttm,
337 const exprt &e,
338 const abstract_environmentt &environment,
339 const namespacet &ns) const
340{
342 type, top, bttm, e, environment, ns);
343}
344
349
354{
355 // for each entry in the incoming environment we need to either add it
356 // if it is new, or merge with the existing key if it is not present
357 if(bottom)
358 {
359 *this = env;
360 return !env.bottom;
361 }
362
363 if(env.bottom)
364 return false;
365
366 // For each element in the intersection of map and env.map merge
367 // If the result of the merge is top, remove from the map
368 bool modified = false;
369 for(const auto &entry : env.map.get_delta_view(map))
370 {
372 entry.get_other_map_value(), entry.m, merge_location, widen_mode);
373
374 modified |= merge_result.modified;
375 map.replace(entry.k, merge_result.object);
376 }
377
378 return modified;
379}
380
382{
383 // TODO(tkiley): error reporting
384 make_top();
385}
386
388{
389 // since we assume anything is not in the map is top this is sufficient
390 map.clear();
391 bottom = false;
392}
393
395{
396 map.clear();
397 bottom = true;
398}
399
401{
402 return map.empty() && bottom;
403}
404
406{
407 return map.empty() && !bottom;
408}
409
411 std::ostream &out,
412 const ai_baset &ai,
413 const namespacet &ns) const
414{
415 out << "{\n";
416
417 for(const auto &entry : map.get_view())
418 {
419 out << entry.first << " () -> ";
420 entry.second->output(out, ai, ns);
421 out << "\n";
422 }
423
424 out << "}\n";
425}
426
428{
429 if(is_bottom())
430 return false_exprt();
431 if(is_top())
432 return true_exprt();
433
435 for(const auto &entry : map.get_view())
436 {
437 auto sym = entry.first;
438 auto val = entry.second;
439 auto pred = val->to_predicate(symbol_exprt(sym, val->type()));
440
441 predicates.push_back(pred);
442 }
443
444 if(predicates.size() == 1)
445 return predicates.front();
446
448 return and_exprt(predicates);
449}
450
452{
453 for(const auto &entry : map.get_view())
454 {
455 if(entry.second == nullptr)
456 {
457 return false;
458 }
459 }
460 return true;
461}
462
464 const exprt &e,
465 const namespacet &ns) const
466{
467 // We create a temporary top abstract object (according to the
468 // type of the expression), and call expression transform on it.
469 // The value of the temporary abstract object is ignored, its
470 // purpose is just to dispatch the expression transform call to
471 // a concrete subtype of abstract_objectt.
472 auto eval_obj = abstract_object_factory(e.type(), ns, true, false);
473 auto operands = eval_operands(e, *this, ns);
474
475 return eval_obj->expression_transform(e, operands, *this, ns);
476}
477
479{
480 map.erase_if_exists(expr.get_identifier());
481}
482
483std::vector<abstract_environmentt::map_keyt>
485 const abstract_environmentt &first,
486 const abstract_environmentt &second)
487{
488 // Find all symbols who have different write locations in each map
489 std::vector<abstract_environmentt::map_keyt> symbols_diff;
490 for(const auto &entry : first.map.get_view())
491 {
492 const auto &second_entry = second.map.find(entry.first);
493 if(second_entry.has_value())
494 {
495 if(second_entry.value().get()->has_been_modified(entry.second))
496 {
497 CHECK_RETURN(!entry.first.empty());
498 symbols_diff.push_back(entry.first);
499 }
500 }
501 }
502
503 // Add any symbols that are only in the second map
504 for(const auto &entry : second.map.get_view())
505 {
506 const auto &second_entry = first.map.find(entry.first);
507 if(!second_entry.has_value())
508 {
509 CHECK_RETURN(!entry.first.empty());
510 symbols_diff.push_back(entry.first);
511 }
512 }
513 return symbols_diff;
514}
515
516static std::size_t count_globals(const namespacet &ns)
517{
518 auto const &symtab = ns.get_symbol_table();
519 auto val = std::count_if(
520 symtab.begin(),
521 symtab.end(),
522 [](const symbol_tablet::const_iteratort::value_type &sym) {
523 return sym.second.is_lvalue && sym.second.is_static_lifetime;
524 });
525 return val;
526}
527
530{
531 abstract_object_statisticst statistics = {};
532 statistics.number_of_globals = count_globals(ns);
534 for(auto const &object : map.get_view())
535 {
536 if(visited.find(object.second) == visited.end())
537 {
538 object.second->get_statistics(statistics, visited, *this, ns);
539 }
540 }
541 return statistics;
542}
543
544std::vector<abstract_object_pointert> eval_operands(
545 const exprt &expr,
547 const namespacet &ns)
548{
549 std::vector<abstract_object_pointert> operands;
550
551 for(const auto &op : expr.operands())
552 operands.push_back(env.eval(op, ns));
553
554 return operands;
555}
556
559{
560 return std::dynamic_pointer_cast<const abstract_value_objectt>(
561 obj->unwrap_context());
562}
563
565{
566 return as_value(obj) != nullptr;
567}
568
570 std::map<irep_idt, irep_idt>{{ID_equal, ID_notequal},
572 {ID_le, ID_gt},
573 {ID_lt, ID_ge},
574 {ID_ge, ID_lt},
575 {ID_gt, ID_le}};
576
577static exprt invert_result(const exprt &result)
578{
579 if(!result.is_boolean())
580 return result;
581
582 if(result.is_true())
583 return false_exprt();
584 return true_exprt();
585}
586
587static exprt invert_expr(const exprt &expr)
588{
589 auto expr_id = expr.id();
590
593 return nil_exprt();
594
596 auto inverse_op = inverse_operation->second;
599}
600
603 const abstract_object_pointert &previous,
604 const exprt &destination,
606 const namespacet &ns)
607{
608 auto context =
609 std::dynamic_pointer_cast<const context_abstract_objectt>(previous);
610 if(context != nullptr)
611 obj = context->envelop(obj);
612 env.assign(destination, obj, ns);
613}
614
617 const exprt &expr,
618 const namespacet &ns)
619{
620 auto const &not_expr = to_not_expr(expr);
621
623 if(inverse_expression.is_not_nil())
624 return env.do_assume(inverse_expression, ns);
625
626 auto result = env.do_assume(not_expr.op(), ns);
627 return invert_result(result);
628}
629
632 const exprt &expr,
633 const namespacet &ns)
634{
635 auto and_expr = to_and_expr(expr);
636 bool nil = false;
637 for(auto const &operand : and_expr.operands())
638 {
639 auto result = env.do_assume(operand, ns);
640 if(result.is_false())
641 return result;
642 nil |= result.is_nil();
643 }
644 if(nil)
645 return nil_exprt();
646 return true_exprt();
647}
648
651 const exprt &expr,
652 const namespacet &ns)
653{
654 auto or_expr = to_or_expr(expr);
655
657 for(auto const &operand : or_expr.operands())
659
660 auto result = assume_and(env, and_exprt(negated_operands), ns);
661 return invert_result(result);
662}
663
665{
670
672 {
673 return as_value(left)->to_interval();
674 }
676 {
677 return as_value(right)->to_interval();
678 }
679
680 bool are_bad() const
681 {
682 return left == nullptr || right == nullptr ||
683 (left->is_top() && right->is_top()) || !is_value(left) ||
684 !is_value(right);
685 }
686
687 bool has_top() const
688 {
689 return left->is_top() || right->is_top();
690 }
691};
692
695 const exprt &expr,
696 const namespacet &ns)
697{
698 auto const &relationship_expr = to_binary_expr(expr);
699
700 auto lhs = relationship_expr.lhs();
701 auto rhs = relationship_expr.rhs();
702 auto left = env.eval(lhs, ns);
703 auto right = env.eval(rhs, ns);
704
705 if(left->is_top() && right->is_top())
706 return {};
707
708 return {lhs, rhs, left, right};
709}
710
713 const left_and_right_valuest &operands,
714 const namespacet &ns)
715{
716 if(operands.left->is_top() && is_assignable(operands.lhs))
717 {
718 // TOP == x
719 auto constrained = std::make_shared<interval_abstract_valuet>(
720 operands.right_interval(), env, ns);
721 prune_assign(env, operands.left, operands.lhs, constrained, ns);
722 }
723 if(operands.right->is_top() && is_assignable(operands.rhs))
724 {
725 // x == TOP
726 auto constrained = std::make_shared<interval_abstract_valuet>(
727 operands.left_interval(), env, ns);
728 prune_assign(env, operands.right, operands.rhs, constrained, ns);
729 }
730 return true_exprt();
731}
732
735 const exprt &expr,
736 const namespacet &ns)
737{
738 auto operands = eval_operands_as_values(env, expr, ns);
739
740 if(operands.are_bad())
741 return nil_exprt();
742
743 if(operands.has_top())
744 return assume_eq_unbounded(env, operands, ns);
745
746 auto meet = operands.left->meet(operands.right);
747
748 if(meet->is_bottom())
749 return false_exprt();
750
751 if(is_assignable(operands.lhs))
752 prune_assign(env, operands.left, operands.lhs, meet, ns);
753 if(is_assignable(operands.rhs))
754 prune_assign(env, operands.right, operands.rhs, meet, ns);
755 return true_exprt();
756}
757
760 const exprt &expr,
761 const namespacet &ns)
762{
763 auto const &notequal_expr = to_binary_expr(expr);
764
765 auto left = env.eval(notequal_expr.lhs(), ns);
766 auto right = env.eval(notequal_expr.rhs(), ns);
767
768 if(left->is_top() || right->is_top())
769 return nil_exprt();
770 if(!is_value(left) || !is_value(right))
771 return nil_exprt();
772
773 auto meet = left->meet(right);
774
775 if(meet->is_bottom())
776 return true_exprt();
777
778 return false_exprt();
779}
780
783 const left_and_right_valuest &operands,
784 const namespacet &ns)
785{
786 if(operands.left->is_top() && is_assignable(operands.lhs))
787 {
788 // TOP < x, so prune range is min->right.upper
790 min_value_exprt(operands.left->type()),
791 operands.right_interval().get_upper(),
792 operands.left->type());
793 auto constrained =
794 std::make_shared<interval_abstract_valuet>(pruned_expr, env, ns);
795 prune_assign(env, operands.left, operands.lhs, constrained, ns);
796 }
797 if(operands.right->is_top() && is_assignable(operands.rhs))
798 {
799 // x < TOP, so prune range is left.lower->max
801 operands.left_interval().get_lower(),
802 max_value_exprt(operands.right->type()),
803 operands.right->type());
804 auto constrained =
805 std::make_shared<interval_abstract_valuet>(pruned_expr, env, ns);
806 prune_assign(env, operands.right, operands.rhs, constrained, ns);
807 }
808
809 return true_exprt();
810}
811
814 const exprt &expr,
815 const namespacet &ns)
816{
817 auto operands = eval_operands_as_values(env, expr, ns);
818 if(operands.are_bad())
819 return nil_exprt();
820
821 if(operands.has_top())
822 return assume_less_than_unbounded(env, operands, ns);
823
824 auto left_interval = operands.left_interval();
825 auto right_interval = operands.right_interval();
826
827 const auto &left_lower = left_interval.get_lower();
828 const auto &right_upper = right_interval.get_upper();
829
830 auto reduced_le_expr =
832 auto result = env.eval(reduced_le_expr, ns)->to_constant();
833 if(result.is_true())
834 {
835 if(is_assignable(operands.lhs))
836 {
838 left_interval.get_upper(), right_upper);
839 auto constrained =
840 as_value(operands.left)->constrain(left_lower, pruned_upper);
841 prune_assign(env, operands.left, operands.lhs, constrained, ns);
842 }
843 if(is_assignable(operands.rhs))
844 {
846 left_lower, right_interval.get_lower());
847 auto constrained =
848 as_value(operands.right)->constrain(pruned_lower, right_upper);
849 prune_assign(env, operands.right, operands.rhs, constrained, ns);
850 }
851 }
852 return result;
853}
854
856 std::map<irep_idt, irep_idt>{{ID_ge, ID_le}, {ID_gt, ID_lt}};
857
860 const exprt &expr,
861 const namespacet &ns)
862{
863 auto const &gt_expr = to_binary_expr(expr);
864
866 auto symmetric_expr =
868
870}
std::vector< abstract_object_pointert > eval_operands(const exprt &expr, const abstract_environmentt &env, const namespacet &ns)
static auto assume_functions
static bool is_value(const abstract_object_pointert &obj)
static exprt assume_not(abstract_environmentt &env, const exprt &expr, const namespacet &ns)
static auto inverse_operations
static exprt invert_expr(const exprt &expr)
static abstract_value_pointert as_value(const abstract_object_pointert &obj)
static bool is_object_creation(const irep_idt &id)
static auto symmetric_operations
static bool is_access_expr(const irep_idt &id)
left_and_right_valuest eval_operands_as_values(abstract_environmentt &env, const exprt &expr, const namespacet &ns)
static exprt assume_eq(abstract_environmentt &env, const exprt &expr, const namespacet &ns)
static exprt assume_noteq(abstract_environmentt &env, const exprt &expr, const namespacet &ns)
static std::size_t count_globals(const namespacet &ns)
static exprt assume_or(abstract_environmentt &env, const exprt &expr, const namespacet &ns)
exprt(* assume_function)(abstract_environmentt &, const exprt &, const namespacet &)
static exprt assume_less_than(abstract_environmentt &env, const exprt &expr, const namespacet &ns)
static exprt invert_result(const exprt &result)
exprt assume_less_than_unbounded(abstract_environmentt &env, const left_and_right_valuest &operands, const namespacet &ns)
static exprt assume_and(abstract_environmentt &env, const exprt &expr, const namespacet &ns)
bool is_ptr_comparison(const exprt &expr)
void prune_assign(abstract_environmentt &env, const abstract_object_pointert &previous, const exprt &destination, abstract_object_pointert obj, const namespacet &ns)
static bool is_dynamic_allocation(const exprt &expr)
exprt assume_eq_unbounded(abstract_environmentt &env, const left_and_right_valuest &operands, const namespacet &ns)
static exprt assume_greater_than(abstract_environmentt &env, const exprt &expr, const namespacet &ns)
bool is_ptr_diff(const exprt &expr)
An abstract version of a program environment.
bool is_ptr_comparison(const exprt &expr)
bool is_ptr_diff(const exprt &expr)
std::set< abstract_object_pointert > abstract_object_visitedt
sharing_ptrt< class abstract_objectt > abstract_object_pointert
Statistics gathering for the variable senstivity domain.
virtual bool assume(const exprt &expr, const namespacet &ns)
Reduces the domain based on a condition.
void output(std::ostream &out, const class ai_baset &ai, const namespacet &ns) const
Print out all the values in the abstract object map.
bool is_bottom() const
Gets whether the domain is bottom.
abstract_object_pointert resolve_symbol(const exprt &e, const namespacet &ns) const
exprt to_predicate() const
Gives a boolean condition that is true for all values represented by the environment.
void make_top()
Set the domain to top (i.e. everything)
virtual abstract_object_pointert eval(const exprt &expr, const namespacet &ns) const
These three are really the heart of the method.
void erase(const symbol_exprt &expr)
Delete a symbol from the map.
static std::vector< abstract_environmentt::map_keyt > modified_symbols(const abstract_environmentt &first, const abstract_environmentt &second)
For our implementation of variable sensitivity domains, we need to be able to efficiently find symbol...
bool verify() const
Check the structural invariants are maintained.
virtual void havoc(const std::string &havoc_string)
This should be used as a default case / everything else has failed The string is so that I can easily...
exprt do_assume(const exprt &e, const namespacet &ns)
const vsd_configt & configuration() const
Exposes the environment configuration.
variable_sensitivity_object_factory_ptrt object_factory
virtual abstract_object_pointert write(const abstract_object_pointert &lhs, const abstract_object_pointert &rhs, std::stack< exprt > remaining_stack, const namespacet &ns, bool merge_write)
Used within assign to do the actual dispatch.
abstract_object_statisticst gather_statistics(const namespacet &ns) const
virtual bool merge(const abstract_environmentt &env, const goto_programt::const_targett &merge_location, widen_modet widen_mode)
Computes the join between "this" and "b".
void make_bottom()
Set the domain to top (i.e. no possible states / unreachable)
bool is_top() const
Gets whether the domain is top.
virtual abstract_object_pointert abstract_object_factory(const typet &type, const namespacet &ns, bool top, bool bottom) const
Look at the configuration for the sensitivity and create an appropriate abstract_object.
virtual abstract_object_pointert eval_expression(const exprt &e, const namespacet &ns) const
virtual bool assign(const exprt &expr, const abstract_object_pointert &value, const namespacet &ns)
Assign a value to an expression.
sharing_mapt< map_keyt, abstract_object_pointert > map
static combine_result merge(const abstract_object_pointert &op1, const abstract_object_pointert &op2, const locationt &merge_location, const widen_modet &widen_mode)
This is the basic interface of the abstract interpreter with default implementations of the core func...
Definition ai.h:118
virtual void clear()
Reset the abstract state.
Definition ai.h:266
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:563
Boolean AND.
Definition std_expr.h:2071
A base class for relations, i.e., binary predicates whose two operands have the same type.
Definition std_expr.h:707
Represents an interval of values.
Definition interval.h:52
static exprt get_max(const exprt &a, const exprt &b)
Definition interval.cpp:960
static exprt get_min(const exprt &a, const exprt &b)
Definition interval.cpp:965
const exprt & get_lower() const
Definition interval.cpp:27
const exprt & get_upper() const
Definition interval.cpp:32
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:39
Base class for all expressions.
Definition expr.h:56
std::vector< exprt > operandst
Definition expr.h:58
bool is_true() const
Return whether the expression is a constant representing true.
Definition expr.cpp:27
bool is_boolean() const
Return whether the expression represents a Boolean.
Definition expr.h:216
typet & type()
Return the type of the expression.
Definition expr.h:84
operandst & operands()
Definition expr.h:94
The Boolean constant false.
Definition std_expr.h:3017
instructionst::const_iterator const_targett
const irep_idt & get(const irep_idt &name) const
Definition irep.cpp:44
const irep_idt & id() const
Definition irep.h:396
+∞ upper bound for intervals
Definition interval.h:18
-∞ upper bound for intervals
Definition interval.h:33
const typet & follow(const typet &) const
Resolve type symbol to the type it points to.
Definition namespace.cpp:49
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
const symbol_table_baset & get_symbol_table() const
Return first symbol table registered with the namespace.
Definition namespace.h:123
The NIL expression.
Definition std_expr.h:3026
Expression to hold a symbol (variable)
Definition std_expr.h:113
const irep_idt & get_identifier() const
Definition std_expr.h:142
The Boolean constant true.
Definition std_expr.h:3008
The type of an expression, extends irept.
Definition type.h:29
abstract_object_pointert get_abstract_object(const typet &type, bool top, bool bottom, const exprt &e, const abstract_environmentt &environment, const namespacet &ns) const
Get the appropriate abstract object for the variable under consideration.
General implementation of a an abstract_objectt which can track side information in the form of a 'co...
bool is_assignable(const exprt &expr)
Returns true iff the argument is one of the following:
Definition expr_util.cpp:24
Deprecated expression utility functions.
An interval to represent a set of possible values.
exprt simplify_expr(exprt src, const namespacet &ns)
bool sort_operands(exprt::operandst &operands)
sort operands of an expression according to ordering defined by operator<
#define CHECK_RETURN(CONDITION)
Definition invariant.h:495
#define PRECONDITION(CONDITION)
Definition invariant.h:463
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition invariant.h:423
const binary_relation_exprt & to_binary_relation_expr(const exprt &expr)
Cast an exprt to a binary_relation_exprt.
Definition std_expr.h:840
const and_exprt & to_and_expr(const exprt &expr)
Cast an exprt to a and_exprt.
Definition std_expr.h:2118
const or_exprt & to_or_expr(const exprt &expr)
Cast an exprt to a or_exprt.
Definition std_expr.h:2226
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
Definition std_expr.h:660
const not_exprt & to_not_expr(const exprt &expr)
Cast an exprt to an not_exprt.
Definition std_expr.h:2303
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition std_expr.h:222
abstract_object_pointert right
constant_interval_exprt right_interval() const
constant_interval_exprt left_interval() const
abstract_object_pointert left
Author: Diffblue Ltd.
Tracks the user-supplied configuration for VSD and build the correct type of abstract object when nee...