CBMC
Loading...
Searching...
No Matches
ai_domain.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Abstract Interpretation
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
11
12#include "ai_domain.h"
13
14#include <util/pointer_expr.h>
15#include <util/simplify_expr.h>
16
18 const
19{
20 std::ostringstream out;
21 output(out, ai, ns);
22 json_stringt json(out.str());
23 return std::move(json);
24}
25
27{
28 std::ostringstream out;
29 output(out, ai, ns);
30 xmlt xml("abstract_state");
31 xml.data = out.str();
32 return xml;
33}
34
44 const
45{
46 // Care must be taken here to give something that is still writable
47 if(condition.id() == ID_index)
48 {
49 index_exprt ie = to_index_expr(condition);
50 bool no_simplification = ai_simplify(ie.index(), ns);
52 condition = simplify_expr(std::move(ie), ns);
53
54 return no_simplification;
55 }
56 else if(condition.id() == ID_dereference)
57 {
59 bool no_simplification = ai_simplify(de.pointer(), ns);
61 condition = simplify_expr(std::move(de), ns); // So *(&x) -> x
62
63 return no_simplification;
64 }
65 else if(condition.id() == ID_member)
66 {
67 member_exprt me = to_member_expr(condition);
68 // Since simplify_ai_lhs is required to return an addressable object
69 // (so remains a valid left hand side), to simplify
70 // `(something_simplifiable).b` we require that `something_simplifiable`
71 // must also be addressable
72 bool no_simplification = ai_simplify_lhs(me.compound(), ns);
74 condition = simplify_expr(std::move(me), ns);
75
76 return no_simplification;
77 }
78 else
79 return true;
80}
Abstract Interpretation Domain.
This is the basic interface of the abstract interpreter with default implementations of the core func...
Definition ai.h:117
virtual xmlt output_xml(const ai_baset &ai, const namespacet &ns) const
Definition ai_domain.cpp:26
virtual jsont output_json(const ai_baset &ai, const namespacet &ns) const
Definition ai_domain.cpp:17
virtual bool ai_simplify_lhs(exprt &condition, const namespacet &ns) const
Simplifies the expression but keeps it as an l-value.
Definition ai_domain.cpp:43
virtual void output(std::ostream &, const ai_baset &, const namespacet &) const
Definition ai_domain.h:104
virtual bool ai_simplify(exprt &condition, const namespacet &) const
also add
Definition ai_domain.h:149
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
Operator to dereference a pointer.
Base class for all expressions.
Definition expr.h:56
Array index operator.
Definition std_expr.h:1470
const irep_idt & id() const
Definition irep.h:388
Definition json.h:27
Extract member of struct or union.
Definition std_expr.h:2972
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
Definition xml.h:21
std::string data
Definition xml.h:39
API to expression classes for Pointers.
const dereference_exprt & to_dereference_expr(const exprt &expr)
Cast an exprt to a dereference_exprt.
static void json(json_objectT &result, const irep_idt &property_id, const property_infot &property_info)
xmlt xml(const irep_idt &property_id, const property_infot &property_info)
exprt simplify_expr(exprt src, const namespacet &ns)
const index_exprt & to_index_expr(const exprt &expr)
Cast an exprt to an index_exprt.
Definition std_expr.h:1538
const member_exprt & to_member_expr(const exprt &expr)
Cast an exprt to a member_exprt.
Definition std_expr.h:3064