CBMC
replace_expr.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#include "
replace_expr.h
"
10
#include "
expr_iterator.h
"
11
12
bool
replace_expr
(
const
exprt
&what,
const
exprt
&by,
exprt
&dest)
13
{
14
bool
no_change =
true
;
15
16
for
(
auto
it = dest.
depth_begin
(), itend = dest.
depth_end
();
17
it != itend;)
// no ++it
18
{
19
if
(*it == what)
20
{
21
it.mutate() = by;
22
no_change =
false
;
23
it.next_sibling_or_parent();
24
}
25
else
26
++it;
27
}
28
29
return
no_change;
30
}
31
32
bool
replace_expr
(
const
replace_mapt
&what,
exprt
&dest)
33
{
34
bool
no_change =
true
;
35
36
for
(
auto
it = dest.
depth_begin
(), itend = dest.
depth_end
();
37
it != itend;)
// No ++it
38
{
39
replace_mapt::const_iterator findit = what.find(*it);
40
if
(findit != what.end())
41
{
42
it.mutate() = findit->second;
43
no_change =
false
;
44
it.next_sibling_or_parent();
45
}
46
else
47
++it;
48
}
49
50
return
no_change;
51
}
exprt::depth_end
depth_iteratort depth_end()
Definition:
expr.cpp:267
exprt
Base class for all expressions.
Definition:
expr.h:55
expr_iterator.h
exprt::depth_begin
depth_iteratort depth_begin()
Definition:
expr.cpp:265
replace_expr
bool replace_expr(const exprt &what, const exprt &by, exprt &dest)
Definition:
replace_expr.cpp:12
replace_mapt
std::unordered_map< exprt, exprt, irep_hash > replace_mapt
Definition:
replace_expr.h:22
replace_expr.h
src
util
replace_expr.cpp
Generated by
1.8.17