30 return expr2c(expr, *
this);
35 return type2c(type, *
this);
46 error() <<
"failed to move symbol '" << symbol.
name <<
"' into symbol table"
81 <<
"' should not have an initializer" <<
eom;
87 error() <<
"only functions can have a function body" <<
eom;
112 error() <<
"void-typed symbol not permitted" <<
eom;
117 symbol_table_baset::symbolst::const_iterator
old_it =
134 <<
"' as a different kind of symbol" <<
eom;
149 <<
"' with no linkage" <<
eom;
223 error() <<
"conflicting definition of type symbol '"
247 error() <<
"conflicting definition of tag symbol '"
270 if(new_symbol.
type != old_symbol.
type)
274 <<
"' defined twice:\n"
361 error() <<
"function type not allowed for K&R function parameter"
377 <<
"' redefined with a different type:\n"
402 "' redefined with a different type:\n" +
408 const bool inlined =
old_ct.get_inlined() ||
new_ct.get_inlined();
412 else if(!
old_ct.has_ellipsis() &&
new_ct.has_ellipsis())
417 error() <<
"code contract on incomplete function re-declaration" <<
eom;
454 symbol_table_baset::symbolst::const_iterator
p_s_it =
464 <<
"' defined twice" <<
eom;
499 for(
auto &p :
old_ct.parameters())
560 <<
"' redefined with a different type:\n"
587 <<
"' already has an initial value" <<
eom;
614 error() <<
"function '" << symbol.
name <<
"' is initialized with "
649 error() <<
"branching label '" << label.first
650 <<
"' is not defined in function" <<
eom;
665 if(!asm_label.
empty() &&
669 symbol.
name=asm_label;
676 std::make_pair(
orig_name, asm_label)).second)
682 <<
" by " << asm_label <<
eom;
687 else if(asm_label.
empty())
689 asm_label_mapt::const_iterator entry=
693 symbol.
name=entry->second;
704 for(
const auto &p :
code_type.parameters())
816 error() <<
"alias attribute cannot be used with a body"
872 declarator.set_name(identifier);
897 std::size_t anon_counter = 0;
901 if(p.get_base_name().empty())
902 p.set_base_name(
"#anon" + std::to_string(anon_counter++));
905 const irep_idt &base_name = p.get_base_name();
918 for(
auto &c_requires :
code_type.c_requires())
926 lambda.add_source_location() = c_requires.source_location();
931 for(
auto &assigns :
code_type.c_assigns())
936 lambda.add_source_location() = assigns.source_location();
944 lambda.add_source_location() =
frees.source_location();
980 <<
"' already set at " << entry.first.location.as_string()
1002 unsigned anon_counter = 0;
1008 if(p.get_base_name().empty())
1010 irep_idt base_name =
"#anon" + std::to_string(anon_counter++);
1011 p.set_base_name(base_name);
1015 irep_idt base_name = p.get_base_name();
1018 p.set_identifier(identifier);
1025 p_symbol.location = p.source_location();
ANSI-CC Language Type Checking.
static bool is_instantiation_of_flexible_array(const struct_typet &old_type, const struct_typet &new_type)
ANSI-C Language Type Checking.
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a typet to a c_enum_typet.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
const code_with_contract_typet & to_code_with_contract_type(const typet &type)
Cast a typet to a code_with_contract_typet.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
static void make_already_typechecked(typet &type)
void set_is_thread_local(bool is_thread_local)
void set_is_weak(bool is_weak)
symbolt to_symbol(const ansi_c_declaratort &) const
const declaratorst & declarators() const
void set_is_register(bool is_register)
void set_is_inline(bool is_inline)
typet full_type(const ansi_c_declaratort &) const
void set_is_extern(bool is_extern)
void set_is_typedef(bool is_typedef)
bool get_is_static_assert() const
void set_is_static(bool is_static)
std::vector< symbol_exprt > variablest
symbol_table_baset & symbol_table
virtual void check_history_expr_return_value(const exprt &expr, std::string &clause_type)
Checks that no history expr or return_value exists in expr.
void typecheck_function_body(symbolt &symbol)
std::map< irep_idt, source_locationt > labels_used
virtual void typecheck_expr(exprt &expr)
virtual void do_initializer(exprt &initializer, const typet &type, bool force_constant)
virtual void typecheck_code(codet &code)
virtual void check_was_freed(const exprt &expr, std::string &clause_type)
Checks that no occurence of the CPROVER_PREFIX was_freed predicate is found in expr.
void move_symbol(symbolt &symbol, symbolt *&new_symbol)
void disallow_subexpr_by_id(const exprt &, const irep_idt &, const std::string &) const
void apply_asm_label(const irep_idt &asm_label, symbolt &symbol)
virtual std::string to_string(const exprt &expr)
void typecheck_declaration(ansi_c_declarationt &)
void typecheck_new_symbol(symbolt &symbol)
asm_label_mapt asm_label_map
virtual void adjust_function_parameter(typet &type) const
void typecheck_redefinition_type(symbolt &old_symbol, symbolt &new_symbol)
void add_parameters_to_symbol_table(symbolt &symbol)
Create symbols for parameter of the code-typed symbol symbol.
void typecheck_redefinition_non_type(symbolt &old_symbol, symbolt &new_symbol)
virtual void typecheck_spec_frees(exprt::operandst &targets)
const irep_idt const irep_idt mode
virtual void typecheck_spec_assigns(exprt::operandst &targets)
id_type_mapt parameter_map
virtual void implicit_typecast_bool(exprt &expr)
virtual void typecheck_type(typet &type)
void typecheck_symbol(symbolt &symbol)
std::map< irep_idt, source_locationt > labels_defined
Data structure for representing an arbitrary statement in a program.
struct configt::ansi_ct ansi_c
Mangle identifiers by hashing their working directory with djb2 hash.
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 is_constant() const
Return whether the expression is a constant.
typet & type()
Return the type of the expression.
const source_locationt & source_location() const
source_locationt & add_source_location()
Thrown when we can't handle something in an input source file.
const irep_idt & get(const irep_idt &name) const
void remove(const irep_idt &name)
const irep_idt & id() const
A (mathematical) lambda expression.
source_locationt source_location
mstreamt & warning() const
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
Symbol table entry of function parameterThis is a symbol generated as part of type checking.
Structure type, corresponds to C style structs.
std::vector< componentt > componentst
static symbol_exprt typeless(const irep_idt &id)
Generate a symbol_exprt without a proper type.
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
virtual bool move(symbolt &symbol, symbolt *&new_symbol)=0
virtual std::pair< symbolt &, bool > insert(symbolt symbol)=0
Move or copy a new symbol to the symbol table.
virtual void erase(const symbolst::const_iterator &entry)=0
Remove a symbol from the symbol table.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
source_locationt location
Source code location of definition of symbol.
typet type
Type of symbol.
irep_idt name
The unique identifier.
irep_idt pretty_name
Language-specific display name.
irep_idt irep_idt base_name
Name of module the symbol belongs to.
const irep_idt & display_name() const
Return language specific display name if present.
exprt value
Initial value of symbol.
irep_idt mode
Language mode.
The type of an expression, extends irept.
std::string expr2c(const exprt &expr, const namespacet &ns, const expr2c_configurationt &configuration)
std::string type2c(const typet &type, const namespacet &ns, const expr2c_configurationt &configuration)
bool has_subexpr(const exprt &expr, const std::function< bool(const exprt &)> &pred)
returns true if the expression has a subexpression that satisfies pred
Deprecated expression utility functions.
bool has_contract(const irep_idt &function_identifier, const namespacet &ns)
const std::string & id2string(const irep_idt &d)
API to expression classes for 'mathematical' expressions.
Mangle names of file-local functions to make them unique.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
#define CHECK_RETURN(CONDITION)
#define PRECONDITION(CONDITION)
const codet & to_code(const exprt &expr)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
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.