diff --git a/src/analyses/local_cfg.h b/src/analyses/local_cfg.h index d2e53cfdab0..a6734b31709 100644 --- a/src/analyses/local_cfg.h +++ b/src/analyses/local_cfg.h @@ -14,7 +14,7 @@ Author: Daniel Kroening, kroening@kroening.com #include -#include +#include class local_cfgt { diff --git a/src/analyses/locals.h b/src/analyses/locals.h index c9c59aaf340..281f0aa811d 100644 --- a/src/analyses/locals.h +++ b/src/analyses/locals.h @@ -14,13 +14,11 @@ Date: March 2013 #ifndef CPROVER_ANALYSES_LOCALS_H #define CPROVER_ANALYSES_LOCALS_H -#include +#include class localst { public: - typedef goto_functionst::goto_functiont goto_functiont; - explicit localst(const goto_functiont &goto_function) { build(goto_function); diff --git a/src/goto-instrument/alignment_checks.cpp b/src/goto-instrument/alignment_checks.cpp index 758539c68be..bb0ac407bc6 100644 --- a/src/goto-instrument/alignment_checks.cpp +++ b/src/goto-instrument/alignment_checks.cpp @@ -12,7 +12,11 @@ Module: Alignment Checks #include "alignment_checks.h" #include +#include #include +#include + +#include void print_struct_alignment_problems( const symbol_tablet &symbol_table, diff --git a/src/goto-instrument/alignment_checks.h b/src/goto-instrument/alignment_checks.h index 43362cb95f8..0e422d8b542 100644 --- a/src/goto-instrument/alignment_checks.h +++ b/src/goto-instrument/alignment_checks.h @@ -14,7 +14,7 @@ Module: Alignment Checks #include -#include +#include void print_struct_alignment_problems( const symbol_tablet &symbol_table, diff --git a/src/goto-programs/Makefile b/src/goto-programs/Makefile index c16ba9f9ae0..cefd43949ce 100644 --- a/src/goto-programs/Makefile +++ b/src/goto-programs/Makefile @@ -15,6 +15,7 @@ SRC = basic_blocks.cpp \ goto_convert_function_call.cpp \ goto_convert_functions.cpp \ goto_convert_side_effect.cpp \ + goto_function.cpp \ goto_functions.cpp \ goto_inline.cpp \ goto_inline_class.cpp \ diff --git a/src/goto-programs/generate_function_bodies.h b/src/goto-programs/generate_function_bodies.h index 7889b847bf3..4801b6cc508 100644 --- a/src/goto-programs/generate_function_bodies.h +++ b/src/goto-programs/generate_function_bodies.h @@ -12,7 +12,7 @@ Author: Diffblue Ltd. #include #include -#include +#include #include #include #include diff --git a/src/goto-programs/goto_function.cpp b/src/goto-programs/goto_function.cpp new file mode 100644 index 00000000000..1bab7d37e4c --- /dev/null +++ b/src/goto-programs/goto_function.cpp @@ -0,0 +1,28 @@ +/*******************************************************************\ + +Module: A GOTO Function + +Author: Daniel Kroening + +Date: May 2018 + +\*******************************************************************/ + +#include "goto_function.h" + +void get_local_identifiers( + const goto_functiont &goto_function, + std::set &dest) +{ + goto_function.body.get_decl_identifiers(dest); + + const code_typet::parameterst ¶meters = goto_function.type.parameters(); + + // add parameters + for(const auto ¶m : parameters) + { + const irep_idt &identifier = param.get_identifier(); + if(identifier != "") + dest.insert(identifier); + } +} diff --git a/src/goto-programs/goto_function.h b/src/goto-programs/goto_function.h new file mode 100644 index 00000000000..2db5fe04e17 --- /dev/null +++ b/src/goto-programs/goto_function.h @@ -0,0 +1,103 @@ +/*******************************************************************\ + +Module: A GOTO Function + +Author: Daniel Kroening + +Date: May 2018 + +\*******************************************************************/ + +#ifndef CPROVER_GOTO_PROGRAMS_GOTO_FUNCTION_H +#define CPROVER_GOTO_PROGRAMS_GOTO_FUNCTION_H + +#include + +#include + +#include "goto_program.h" + +class goto_functiont +{ +public: + goto_programt body; + code_typet type; + + typedef std::vector parameter_identifierst; + parameter_identifierst parameter_identifiers; + + bool body_available() const + { + return !body.instructions.empty(); + } + + bool is_inlined() const + { + return type.get_bool(ID_C_inlined); + } + + bool is_hidden() const + { + return type.get_bool(ID_C_hide); + } + + void make_hidden() + { + type.set(ID_C_hide, true); + } + + goto_functiont() + { + } + + void clear() + { + body.clear(); + type.clear(); + parameter_identifiers.clear(); + } + + /// update the function member in each instruction + /// \param function_id: the `function_id` used for assigning empty function + /// members + void update_instructions_function(const irep_idt &function_id) + { + body.update_instructions_function(function_id); + } + + void swap(goto_functiont &other) + { + body.swap(other.body); + type.swap(other.type); + parameter_identifiers.swap(other.parameter_identifiers); + } + + void copy_from(const goto_functiont &other) + { + body.copy_from(other.body); + type = other.type; + parameter_identifiers = other.parameter_identifiers; + } + + goto_functiont(const goto_functiont &) = delete; + goto_functiont &operator=(const goto_functiont &) = delete; + + goto_functiont(goto_functiont &&other) + : body(std::move(other.body)), + type(std::move(other.type)), + parameter_identifiers(std::move(other.parameter_identifiers)) + { + } + + goto_functiont &operator=(goto_functiont &&other) + { + body = std::move(other.body); + type = std::move(other.type); + parameter_identifiers = std::move(other.parameter_identifiers); + return *this; + } +}; + +void get_local_identifiers(const goto_functiont &, std::set &dest); + +#endif // CPROVER_GOTO_PROGRAMS_GOTO_FUNCTION_H diff --git a/src/goto-programs/goto_functions.cpp b/src/goto-programs/goto_functions.cpp index 44d9d31d6b7..1b604509632 100644 --- a/src/goto-programs/goto_functions.cpp +++ b/src/goto-programs/goto_functions.cpp @@ -73,22 +73,3 @@ void goto_functionst::compute_loop_numbers() func.second.body.compute_loop_numbers(); } } - - -void get_local_identifiers( - const goto_functiont &goto_function, - std::set &dest) -{ - goto_function.body.get_decl_identifiers(dest); - - const code_typet::parameterst ¶meters= - goto_function.type.parameters(); - - // add parameters - for(const auto ¶m : parameters) - { - const irep_idt &identifier=param.get_identifier(); - if(identifier!="") - dest.insert(identifier); - } -} diff --git a/src/goto-programs/goto_functions.h b/src/goto-programs/goto_functions.h index 0289fbdfcc2..a6fb01b53c2 100644 --- a/src/goto-programs/goto_functions.h +++ b/src/goto-programs/goto_functions.h @@ -14,93 +14,9 @@ Date: June 2003 #ifndef CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H #define CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H -#include +#include "goto_function.h" #include -#include - -#include "goto_program.h" - -class goto_functiont -{ -public: - goto_programt body; - code_typet type; - - typedef std::vector parameter_identifierst; - parameter_identifierst parameter_identifiers; - - bool body_available() const - { - return !body.instructions.empty(); - } - - bool is_inlined() const - { - return type.get_bool(ID_C_inlined); - } - - bool is_hidden() const - { - return type.get_bool(ID_C_hide); - } - - void make_hidden() - { - type.set(ID_C_hide, true); - } - - goto_functiont() - { - } - - void clear() - { - body.clear(); - type.clear(); - parameter_identifiers.clear(); - } - - /// update the function member in each instruction - /// \param function_id: the `function_id` used for assigning empty function - /// members - void update_instructions_function(const irep_idt &function_id) - { - body.update_instructions_function(function_id); - } - - void swap(goto_functiont &other) - { - body.swap(other.body); - type.swap(other.type); - parameter_identifiers.swap(other.parameter_identifiers); - } - - void copy_from(const goto_functiont &other) - { - body.copy_from(other.body); - type=other.type; - parameter_identifiers=other.parameter_identifiers; - } - - goto_functiont(const goto_functiont &)=delete; - goto_functiont &operator=(const goto_functiont &)=delete; - - goto_functiont(goto_functiont &&other): - body(std::move(other.body)), - type(std::move(other.type)), - parameter_identifiers(std::move(other.parameter_identifiers)) - { - } - - goto_functiont &operator=(goto_functiont &&other) - { - body=std::move(other.body); - type=std::move(other.type); - parameter_identifiers=std::move(other.parameter_identifiers); - return *this; - } -}; class goto_functionst { @@ -211,8 +127,4 @@ class goto_functionst it=(functions).function_map.begin(); \ it!=(functions).function_map.end(); it++) -void get_local_identifiers( - const goto_functiont &, - std::set &dest); - #endif // CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H diff --git a/src/goto-symex/goto_symex_state.h b/src/goto-symex/goto_symex_state.h index 8b00a1db968..b6c839c7659 100644 --- a/src/goto-symex/goto_symex_state.h +++ b/src/goto-symex/goto_symex_state.h @@ -24,7 +24,7 @@ Author: Daniel Kroening, kroening@kroening.com #include #include -#include +#include #include "symex_target_equation.h" @@ -365,7 +365,7 @@ class goto_symex_statet final bool l2_thread_write_encoding(const ssa_exprt &expr, const namespacet &ns); void populate_dirty_for_function( - const irep_idt &id, const goto_functionst::goto_functiont &); + const irep_idt &id, const goto_functiont &); void switch_to_thread(unsigned t); bool record_events;