15
15
#include < util/namespace.h>
16
16
#include < util/std_expr.h>
17
17
18
+ // / Get the name of the special symbol used to denote an unknown referee pointed
19
+ // / to by a given pointer-typed symbol.
20
+ // / \param id: base symbol id
21
+ // / \return id of the corresponding unknown-object ("failed") symbol.
18
22
irep_idt failed_symbol_id (const irep_idt &id)
19
23
{
20
24
return id2string (id)+" $object" ;
21
25
}
22
26
27
+ // / Create a failed-dereference symbol for the given base symbol if it is
28
+ // / pointer-typed; if not, do nothing.
29
+ // / \param symbol: symbol to created a failed symbol for
30
+ // / \param symbol_table: global symbol table
23
31
void add_failed_symbol (symbolt &symbol, symbol_table_baset &symbol_table)
24
32
{
25
33
if (symbol.type .id ()==ID_pointer)
@@ -43,6 +51,11 @@ void add_failed_symbol(symbolt &symbol, symbol_table_baset &symbol_table)
43
51
}
44
52
}
45
53
54
+ // / Create a failed-dereference symbol for the given base symbol if it is
55
+ // / pointer-typed, an lvalue, and doesn't already have one. If any of these
56
+ // / conditions are not met, do nothing.
57
+ // / \param symbol: symbol to created a failed symbol for
58
+ // / \param symbol_table: global symbol table
46
59
void add_failed_symbol_if_needed (
47
60
const symbolt &symbol, symbol_table_baset &symbol_table)
48
61
{
@@ -55,6 +68,9 @@ void add_failed_symbol_if_needed(
55
68
add_failed_symbol (*symbol_table.get_writeable (symbol.name ), symbol_table);
56
69
}
57
70
71
+ // / Create a failed-dereference symbol for all symbols in the given table that
72
+ // / need one (i.e. pointer-typed lvalues).
73
+ // / \param symbol_table: global symbol table
58
74
void add_failed_symbols (symbol_table_baset &symbol_table)
59
75
{
60
76
// the symbol table iterators are not stable, and
@@ -68,6 +84,11 @@ void add_failed_symbols(symbol_table_baset &symbol_table)
68
84
add_failed_symbol_if_needed (*symbol, symbol_table);
69
85
}
70
86
87
+ // / Get the failed-dereference symbol for the given symbol
88
+ // / \param expr: symbol expression to get a failed symbol for
89
+ // / \param ns: global namespace
90
+ // / \return symbol expression for the failed-dereference symbol, or nil_exprt
91
+ // / if none exists.
71
92
exprt get_failed_symbol (
72
93
const symbol_exprt &expr,
73
94
const namespacet &ns)
0 commit comments