1515#include < util/namespace.h>
1616#include < util/std_expr.h>
1717
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.
1822irep_idt failed_symbol_id (const irep_idt &id)
1923{
2024 return id2string (id)+" $object" ;
2125}
2226
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
2331void add_failed_symbol (symbolt &symbol, symbol_table_baset &symbol_table)
2432{
2533 if (symbol.type .id ()==ID_pointer)
@@ -43,6 +51,11 @@ void add_failed_symbol(symbolt &symbol, symbol_table_baset &symbol_table)
4351 }
4452}
4553
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
4659void add_failed_symbol_if_needed (
4760 const symbolt &symbol, symbol_table_baset &symbol_table)
4861{
@@ -55,6 +68,9 @@ void add_failed_symbol_if_needed(
5568 add_failed_symbol (*symbol_table.get_writeable (symbol.name ), symbol_table);
5669}
5770
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
5874void add_failed_symbols (symbol_table_baset &symbol_table)
5975{
6076 // the symbol table iterators are not stable, and
@@ -68,6 +84,11 @@ void add_failed_symbols(symbol_table_baset &symbol_table)
6884 add_failed_symbol_if_needed (*symbol, symbol_table);
6985}
7086
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.
7192exprt get_failed_symbol (
7293 const symbol_exprt &expr,
7394 const namespacet &ns)
0 commit comments