cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
find_macros.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 "
find_macros.h
"
10
11
#include <stack>
12
13
#include "
namespace.h
"
14
#include "
std_expr.h
"
15
#include "
symbol.h
"
16
17
void
find_macros
(
18
const
exprt
&src,
19
const
namespacet
&ns,
20
find_macros_sett
&dest)
21
{
22
std::stack<const exprt *> stack;
23
24
// use stack, these may be nested deeply
25
stack.push(&src);
26
27
while
(!stack.empty())
28
{
29
const
exprt
&e=*stack.top();
30
stack.pop();
31
32
if
(e.
id
() == ID_symbol)
33
{
34
const
irep_idt
&identifier =
to_symbol_expr
(e).
get_identifier
();
35
36
const
symbolt
&symbol = ns.
lookup
(identifier);
37
38
if
(symbol.
is_macro
)
39
{
40
// inserted?
41
if
(dest.insert(identifier).second)
42
stack.push(&symbol.
value
);
43
}
44
}
45
else
46
{
47
for
(
const
auto
&op : e.
operands
())
48
stack.push(&op);
49
}
50
}
51
}
exprt
Base class for all expressions.
Definition
expr.h:57
exprt::operands
operandst & operands()
Definition
expr.h:95
irept::id
const irep_idt & id() const
Definition
irep.h:388
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition
namespace.h:91
namespacet::lookup
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Definition
namespace.cpp:134
symbol_exprt::get_identifier
const irep_idt & get_identifier() const
Definition
std_expr.h:161
symbolt
Symbol table entry.
Definition
symbol.h:28
symbolt::is_macro
bool is_macro
Definition
symbol.h:62
symbolt::value
exprt value
Initial value of symbol.
Definition
symbol.h:34
find_macros
void find_macros(const exprt &src, const namespacet &ns, find_macros_sett &dest)
Definition
find_macros.cpp:17
find_macros.h
find_macros_sett
std::unordered_set< irep_idt > find_macros_sett
Definition
find_macros.h:20
namespace.h
std_expr.h
API to expression classes.
to_symbol_expr
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition
std_expr.h:211
symbol.h
Symbol table entry.
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
util
find_macros.cpp
Generated by
1.17.0