Go to the documentation of this file.
24 typedef std::unordered_map<irep_idt, std::pair<size_t, bool>>
symbol_numbert;
40 if(ns.
lookup(identifier, symbol))
43 assert(symbol && symbol->
is_type);
45 if(symbol->
type.
id()!=ID_struct &&
46 symbol->
type.
id()!=ID_union)
50 std::pair<symbol_numbert::iterator, bool> entry=
51 symbol_number.insert(std::make_pair(
53 std::make_pair(symbol_number.size(),
true)));
55 std::string
result =
"SYM" +
66 entry.first->second.second=
false;
98 if(type.
get_bool(ID_C_transparent_union))
110 throw "empty type encountered";
111 else if(type.
id()==ID_empty)
113 else if(type.
id()==ID_signedbv)
115 else if(type.
id()==ID_unsignedbv)
117 else if(type.
id()==ID_bool ||
118 type.
id()==ID_c_bool)
120 else if(type.
id()==ID_integer)
122 else if(type.
id()==ID_real)
124 else if(type.
id()==ID_complex)
126 else if(type.
id()==ID_floatbv)
128 else if(type.
id()==ID_fixedbv)
130 else if(type.
id()==ID_natural)
132 else if(type.
id()==ID_pointer)
139 else if(type.
id()==ID_code)
145 for(code_typet::parameterst::const_iterator
146 it=parameters.begin();
147 it!=parameters.end();
150 if(it!=parameters.begin())
157 if(!parameters.empty())
165 else if(type.
id()==ID_array)
169 if(size.
id() == ID_symbol)
173 const auto size_int = numeric_cast<mp_integer>(size);
175 if(!size_int.has_value())
182 type.
id() == ID_c_enum_tag || type.
id() == ID_struct_tag ||
183 type.
id() == ID_union_tag)
187 else if(type.
id()==ID_struct ||
192 if(struct_union_type.is_incomplete())
194 if(type.
id() == ID_struct)
196 else if(type.
id() == ID_union)
201 if(type.
id() == ID_struct)
203 if(type.
id() == ID_union)
207 for(
const auto &c : struct_union_type.components())
215 const irep_idt &component_name = c.get_name();
222 else if(type.
id()==ID_c_enum)
233 for(c_enum_typet::memberst::const_iterator it = members.begin();
237 if(it != members.begin())
244 else if(type.
id()==ID_c_bit_field)
246 else if(type.
id()==ID_vector)
249 throw "unknown type '"+type.
id_string()+
"' encountered";
276 return type2name(type, ns, symbol_number);
285 const auto replace_special_characters = [](
const std::string &name) {
307 const auto replace_invalid_characters_with_underscore =
308 [](
const std::string &identifier) {
309 static const std::regex non_alpha_numeric{
"[^A-Za-z0-9\x80-\xff]+"};
310 return std::regex_replace(identifier, non_alpha_numeric,
"_");
312 const auto strip_leading_digits = [](
const std::string &identifier) {
313 static const std::regex identifier_regex{
314 "[A-Za-z\x80-\xff_][A-Za-z0-9_\x80-\xff]*"};
315 std::smatch match_results;
316 bool found = std::regex_search(identifier, match_results, identifier_regex);
318 return match_results.str(0);
320 return strip_leading_digits(replace_invalid_characters_with_underscore(
321 replace_special_characters(name)));
const irep_idt & get_identifier() const
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
const irep_idt & get_function() const
bool has_ellipsis() const
std::unordered_map< irep_idt, std::pair< size_t, bool > > symbol_numbert
bool is_incomplete() const
enum types may be incomplete
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
#define CHECK_RETURN(CONDITION)
The type of an expression, extends irept.
std::vector< parametert > parameterst
typet type
Type of symbol.
std::vector< c_enum_membert > memberst
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a typet to a c_enum_typet.
bool has_subtypes() const
const type_with_subtypet & to_type_with_subtype(const typet &type)
const type_with_subtypest & to_type_with_subtypes(const typet &type)
Base class for all expressions.
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
std::string type_name2type_identifier(const std::string &name)
type2name generates strings that aren't valid C identifiers If we want utilities like dump_c to work ...
static std::string pointer_offset_bits_as_string(const typet &type, const namespacet &ns)
const exprt & size() const
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
mstreamt & result() const
const tag_typet & to_tag_type(const typet &type)
Cast a typet to a tag_typet.
const std::string & id2string(const irep_idt &d)
static optionalt< smt_termt > get_identifier(const exprt &expr, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_handle_identifiers, const std::unordered_map< exprt, smt_identifier_termt, irep_hash > &expression_identifiers)
static std::string type2name(const typet &type, const namespacet &ns, symbol_numbert &symbol_number)
const source_locationt & source_location() const
optionalt< mp_integer > pointer_offset_bits(const typet &type, const namespacet &ns)
const std::string & id_string() const
const std::string & get_string(const irep_idt &name) const
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
A tag-based type, i.e., typet with an identifier.
const parameterst & parameters() const
static std::string type2name_tag(const tag_typet &type, const namespacet &ns, symbol_numbert &symbol_number)
#define POSTCONDITION(CONDITION)
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
std::string type_to_partial_identifier(const typet &type, const namespacet &ns)
Constructs a string describing the given type, which can be used as part of a C identifier.
const typet & return_type() const
bool get_bool(const irep_idt &name) const
const memberst & members() const
const std::string integer2string(const mp_integer &n, unsigned base)