cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
undefined_functions.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Handling of functions without body
4
5
Author: Michael Tautschnig
6
7
Date: July 2016
8
9
\*******************************************************************/
10
13
14
#include "
undefined_functions.h
"
15
16
#include <ostream>
17
18
#include <
util/invariant.h
>
19
20
#include <
goto-programs/goto_model.h
>
21
22
void
list_undefined_functions
(
23
const
goto_modelt
&goto_model,
24
std::ostream &os)
25
{
26
const
namespacet
ns(goto_model.
symbol_table
);
27
28
for
(
const
auto
&gf_entry : goto_model.
goto_functions
.
function_map
)
29
{
30
if
(!ns.
lookup
(gf_entry.first).is_macro && !gf_entry.second.body_available())
31
os << gf_entry.first <<
'\n'
;
32
}
33
}
34
35
void
undefined_function_abort_path
(
goto_modelt
&goto_model)
36
{
37
for
(
auto
&gf_entry : goto_model.
goto_functions
.
function_map
)
38
{
39
for
(
auto
&ins : gf_entry.second.body.instructions)
40
{
41
if
(!ins.is_function_call())
42
continue
;
43
44
const
auto
&function = ins.call_function();
45
46
if
(function.id() != ID_symbol)
47
continue
;
48
49
const
irep_idt
&function_identifier =
50
to_symbol_expr
(function).
get_identifier
();
51
52
goto_functionst::function_mapt::const_iterator entry =
53
goto_model.
goto_functions
.
function_map
.find(function_identifier);
54
DATA_INVARIANT
(
55
entry!=goto_model.
goto_functions
.
function_map
.end(),
56
"called function must be in function_map"
);
57
58
if
(entry->second.body_available())
59
continue
;
60
61
source_locationt
annotated_location = ins.source_location();
62
annotated_location.
set_comment
(
63
"'"
+
id2string
(function_identifier) +
"' is undefined"
);
64
ins =
goto_programt::make_assumption
(
false_exprt
(), annotated_location);
65
}
66
}
67
}
false_exprt
The Boolean constant false.
Definition
std_expr.h:3125
goto_functionst::function_map
function_mapt function_map
Definition
goto_functions.h:29
goto_modelt
Definition
goto_model.h:27
goto_modelt::symbol_table
symbol_tablet symbol_table
Symbol table.
Definition
goto_model.h:31
goto_modelt::goto_functions
goto_functionst goto_functions
GOTO functions.
Definition
goto_model.h:34
goto_programt::make_assumption
static instructiont make_assumption(const exprt &g, const source_locationt &l=source_locationt::nil())
Definition
goto_program.h:944
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
source_locationt
Definition
source_location.h:20
source_locationt::set_comment
void set_comment(const irep_idt &comment)
Definition
source_location.h:156
symbol_exprt::get_identifier
const irep_idt & get_identifier() const
Definition
std_expr.h:161
goto_model.h
Symbol Table + CFG.
id2string
const std::string & id2string(const irep_idt &d)
Definition
irep.h:44
invariant.h
DATA_INVARIANT
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
Definition
invariant.h:534
to_symbol_expr
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
Definition
std_expr.h:211
list_undefined_functions
void list_undefined_functions(const goto_modelt &goto_model, std::ostream &os)
Definition
undefined_functions.cpp:22
undefined_function_abort_path
void undefined_function_abort_path(goto_modelt &goto_model)
Definition
undefined_functions.cpp:35
undefined_functions.h
Handling of functions without body.
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
goto-instrument
undefined_functions.cpp
Generated by
1.17.0