89 if(old_symbol.
type != new_symbol.
type)
96 diag.warning(old_symbol, new_symbol,
"implicit function declaration");
108 "ignoring conflicting implicit function declaration");
111 else if(((
old_t.parameters().empty() &&
old_t.has_ellipsis() &&
113 (
new_t.parameters().empty() &&
new_t.has_ellipsis() &&
116 if(
old_t.parameters().empty() &&
117 old_t.has_ellipsis() &&
133 "function declaration conflicts with with weak definition");
148 "ignoring conflicting weak function declaration");
162 "ignoring conflicting function alias declaration");
169 old_symbol, new_symbol,
"ignoring conflicting function declarations");
171 if(
old_t.parameters().size()<
new_t.parameters().size())
179 else if((
old_t.parameters().size()<
new_t.parameters().size() &&
181 !
old_t.has_ellipsis()) ||
182 (
old_t.parameters().size()>
new_t.parameters().size() &&
184 !
new_t.has_ellipsis()))
189 "conflicting parameter counts of function declarations");
200 typedef std::deque<std::pair<typet, typet> >
conflictst;
203 if(
old_t.return_type() !=
new_t.return_type())
205 diag.warning(old_symbol, new_symbol,
"conflicting return types");
210 code_typet::parameterst::const_iterator
220 std::make_pair(
o_it->type(),
n_it->type()));
229 "conflicting parameter counts of function declarations");
244 "conflicting parameter counts of function declarations");
265 warn_msg=
"different pointer types in extern function";
276 warn_msg=
"pointer parameter types differ between "
277 "declaration and definition";
308 warn_msg=
"conflict on transparent union parameter in function";
322 warn_msg=
"non-pointer parameter types differ between "
323 "declaration and definition";
334 diag.detailed_conflict_report(
340 diag.error(old_symbol, new_symbol,
"conflicting function declarations");
384 else if(old_symbol.
type == new_symbol.
type)
389 log.debug() <<
"function '" << old_symbol.
name <<
"' in module '"
391 <<
"' is shadowed by a definition in module '"
396 diag.error(old_symbol, new_symbol,
"duplicate definition of function");
415 if(
info.o_symbols.insert(identifier).second)
419 info.o_symbols.erase(identifier);
432 if(
info.n_symbols.insert(identifier).second)
436 info.n_symbols.erase(identifier);
445 info.set_to_new=
true;
458 info.set_to_new=
true;
466 info.set_to_new =
true;
484 else if(
t1.id()!=
t2.id())
494 bool s=
info.set_to_new;
500 "conflicting pointer types for variable");
507 "conflicting pointer types for variable");
510 if(
info.old_symbol.is_extern && !
info.new_symbol.is_extern)
512 info.set_to_new =
true;
528 info.old_symbol.is_weak)
530 info.set_to_new=
true;
534 info.new_symbol.is_weak)
546 "conflicting array sizes for variable");
560 "conflicting array sizes for variable");
577 struct_union_typet::componentst::const_iterator
583 if(
it1->get_name()!=
it2->get_name() ||
606 set_to_new=
info.set_to_new;
616 bool set_to_new =
false;
618 if(old_symbol.
type != new_symbol.
type)
636 diag.detailed_conflict_report(
637 old_symbol, new_symbol, old_symbol.
type, new_symbol.
type);
640 diag.error(old_symbol, new_symbol,
"conflicting types for variable");
679 log.warning().source_location = new_symbol.
location;
681 log.warning() <<
"conflicting initializers for"
682 <<
" variable '" << old_symbol.
name <<
"'\n";
683 log.warning() <<
"using old value in module " << old_symbol.module
686 log.warning() <<
"ignoring new value in module " << new_symbol.module
710 old_symbol.
type != new_symbol.
type))
713 diag.error(old_symbol, new_symbol,
"conflict on code contract");
724 diag.error(old_symbol, new_symbol,
"conflicting definition for symbol");
753 diag.error(old_symbol, new_symbol,
"conflicting definition for symbol");
759 if(old_symbol.
type==new_symbol.
type)
827 diag.detailed_conflict_report(
828 old_symbol, new_symbol, old_symbol.
type, new_symbol.
type);
831 old_symbol, new_symbol,
"unexpected difference between type symbols");
843 if(old_symbol.
type==new_symbol.
type)
912 std::unordered_map<irep_idt, std::unordered_set<irep_idt>>
used_by;
929 std::deque<irep_idt> queue(
932 while(!queue.empty())
937 const std::unordered_set<irep_idt> &
u =
used_by[id];
939 for(
const auto &
dep :
u)
942 queue.push_back(
dep);
945 log.debug() <<
"LINKING: needs to be renamed (dependency): " <<
dep
1001 symbol.
name = it->second;
1045 !it->second.is_type && !it->second.is_macro &&
1046 it->second.value.is_not_nil())
1068 symbol_table_baset::symbolst::const_iterator
m_it =
1082 if(
m_it->second.is_type)
1095 log.debug() <<
"LINKING: needs to be renamed: " <<
symbol_pair.first
1137 return linking.link(new_symbol_table);
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
bool get_bool(const irep_idt &name) const
const irep_idt & id() const
std::unordered_map< irep_idt, irep_idt > rename_symbols(const symbol_table_baset &, const std::unordered_set< irep_idt > &needs_to_be_renamed)
void duplicate_non_type_symbol(symbolt &old_symbol, symbolt &new_symbol)
bool adjust_object_type(const symbolt &old_symbol, const symbolt &new_symbol, bool &set_to_new)
bool link(const symbol_table_baset &src_symbol_table)
Merges the symbol table src_symbol_table into main_symbol_table, renaming symbols from src_symbol_tab...
renamingt needs_renaming(const symbolt &old_symbol, const symbolt &new_symbol)
bool adjust_object_type_rec(const typet &type1, const typet &type2, adjust_type_infot &info)
rename_symbolt rename_main_symbol
void copy_symbols(const symbol_table_baset &, const std::unordered_map< irep_idt, irep_idt > &)
irep_idt rename(const symbol_table_baset &, const irep_idt &)
renamingt needs_renaming_type(const symbolt &old_symbol, const symbolt &new_symbol)
symbol_table_baset & main_symbol_table
renamingt needs_renaming_non_type(const symbolt &old_symbol, const symbolt &new_symbol)
void duplicate_object_symbol(symbolt &old_symbol, symbolt &new_symbol)
casting_replace_symbolt object_type_updates
std::unordered_set< irep_idt > renamed_ids
void duplicate_type_symbol(symbolt &old_symbol, const symbolt &new_symbol)
rename_symbolt rename_new_symbol
void duplicate_code_symbol(symbolt &old_symbol, symbolt &new_symbol)
message_handlert & message_handler
std::size_t get_message_count(unsigned level) const
Class that provides messages with a built-in verbosity 'level'.
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
void insert_type(const irep_idt &old_id, const irep_idt &new_id)
void insert_expr(const irep_idt &old_id, const irep_idt &new_id)
std::size_t erase(const irep_idt &id)
void insert(const class symbol_exprt &old_expr, const exprt &new_expr)
Sets old_expr to be replaced by new_expr if we don't already have a replacement; otherwise does nothi...
std::vector< componentt > componentst
The symbol table base class interface.
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
virtual std::pair< symbolt &, bool > insert(symbolt symbol)=0
Move or copy a new symbol to the symbol table.
virtual symbolt * get_writeable(const irep_idt &name)=0
Find a symbol in the symbol table for read-write access.
virtual void erase(const symbolst::const_iterator &entry)=0
Remove a symbol from the symbol table.
virtual iteratort begin()=0
const symbolst & symbols
Read-only field, used to look up symbols given their names.
virtual iteratort end()=0
bool has_symbol(const irep_idt &name) const
Check whether a symbol exists in the symbol table.
bool add(const symbolt &symbol)
Add a new symbol to the symbol table.
source_locationt location
Source code location of definition of symbol.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
typet type
Type of symbol.
irep_idt name
The unique identifier.
exprt value
Initial value of symbol.
Semantic type conversion.
The type of an expression, extends irept.
void find_type_and_expr_symbols(const exprt &src, find_symbols_sett &dest, const std::vector< irep_idt > &subs_to_find)
Find identifiers with id ID_symbol of the sub expressions and the subs with ID in subs_to_find consid...
std::unordered_set< irep_idt > find_symbols_sett
const std::string & id2string(const irep_idt &d)
std::string from_expr(const namespacet &ns, const irep_idt &identifier, const exprt &expr)
std::string type_to_name(const namespacet &ns, const irep_idt &identifier, const typet &type)
static void do_type_dependencies(const symbol_table_baset &src_symbol_table, std::unordered_set< irep_idt > &needs_to_be_renamed, message_handlert &message_handler)
static const typet & follow_tags_symbols(const namespacet &ns, const typet &type)
bool linking(symbol_table_baset &dest_symbol_table, const symbol_table_baset &new_symbol_table, message_handlert &message_handler)
Merges the symbol table new_symbol_table into dest_symbol_table, renaming symbols from new_symbol_tab...
bool is_true(const literalt &l)
std::optional< mp_integer > pointer_offset_bits(const typet &type, const namespacet &ns)
bool simplify(exprt &expr, const namespacet &ns)
exprt simplify_expr(exprt src, const namespacet &ns)
#define CHECK_RETURN(CONDITION)
#define PRECONDITION(CONDITION)
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
const tag_typet & to_tag_type(const typet &type)
Cast a typet to a tag_typet.
void replace(const union_find_replacet &replace_map, string_not_contains_constraintt &constraint)
static bool failed(bool error_indicator)