Skip to content

Commit 1d0cd01

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2175 from diffblue/extract-goto-functiont
split out goto_functiont from goto_functions.h into separate file
2 parents 784b6dd + 76d202a commit 1d0cd01

11 files changed

+143
-116
lines changed

src/analyses/local_cfg.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include <util/numbering.h>
1616

17-
#include <goto-programs/goto_functions.h>
17+
#include <goto-programs/goto_program.h>
1818

1919
class local_cfgt
2020
{

src/analyses/locals.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ Date: March 2013
1414
#ifndef CPROVER_ANALYSES_LOCALS_H
1515
#define CPROVER_ANALYSES_LOCALS_H
1616

17-
#include <goto-programs/goto_functions.h>
17+
#include <goto-programs/goto_function.h>
1818

1919
class localst
2020
{
2121
public:
22-
typedef goto_functionst::goto_functiont goto_functiont;
23-
2422
explicit localst(const goto_functiont &goto_function)
2523
{
2624
build(goto_function);

src/goto-instrument/alignment_checks.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ Module: Alignment Checks
1212
#include "alignment_checks.h"
1313

1414
#include <util/config.h>
15+
#include <util/namespace.h>
1516
#include <util/pointer_offset_size.h>
17+
#include <util/std_types.h>
18+
19+
#include <ostream>
1620

1721
void print_struct_alignment_problems(
1822
const symbol_tablet &symbol_table,

src/goto-instrument/alignment_checks.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Module: Alignment Checks
1414

1515
#include <iosfwd>
1616

17-
#include <goto-programs/goto_functions.h>
17+
#include <util/symbol_table.h>
1818

1919
void print_struct_alignment_problems(
2020
const symbol_tablet &symbol_table,

src/goto-programs/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ SRC = basic_blocks.cpp \
1515
goto_convert_function_call.cpp \
1616
goto_convert_functions.cpp \
1717
goto_convert_side_effect.cpp \
18+
goto_function.cpp \
1819
goto_functions.cpp \
1920
goto_inline.cpp \
2021
goto_inline_class.cpp \

src/goto-programs/generate_function_bodies.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Author: Diffblue Ltd.
1212
#include <memory>
1313
#include <regex>
1414

15-
#include <goto-programs/goto_functions.h>
15+
#include <goto-programs/goto_function.h>
1616
#include <goto-programs/goto_model.h>
1717
#include <util/cmdline.h>
1818
#include <util/message.h>

src/goto-programs/goto_function.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*******************************************************************\
2+
3+
Module: A GOTO Function
4+
5+
Author: Daniel Kroening
6+
7+
Date: May 2018
8+
9+
\*******************************************************************/
10+
11+
#include "goto_function.h"
12+
13+
void get_local_identifiers(
14+
const goto_functiont &goto_function,
15+
std::set<irep_idt> &dest)
16+
{
17+
goto_function.body.get_decl_identifiers(dest);
18+
19+
const code_typet::parameterst &parameters = goto_function.type.parameters();
20+
21+
// add parameters
22+
for(const auto &param : parameters)
23+
{
24+
const irep_idt &identifier = param.get_identifier();
25+
if(identifier != "")
26+
dest.insert(identifier);
27+
}
28+
}

src/goto-programs/goto_function.h

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*******************************************************************\
2+
3+
Module: A GOTO Function
4+
5+
Author: Daniel Kroening
6+
7+
Date: May 2018
8+
9+
\*******************************************************************/
10+
11+
#ifndef CPROVER_GOTO_PROGRAMS_GOTO_FUNCTION_H
12+
#define CPROVER_GOTO_PROGRAMS_GOTO_FUNCTION_H
13+
14+
#include <iosfwd>
15+
16+
#include <util/std_types.h>
17+
18+
#include "goto_program.h"
19+
20+
class goto_functiont
21+
{
22+
public:
23+
goto_programt body;
24+
code_typet type;
25+
26+
typedef std::vector<irep_idt> parameter_identifierst;
27+
parameter_identifierst parameter_identifiers;
28+
29+
bool body_available() const
30+
{
31+
return !body.instructions.empty();
32+
}
33+
34+
bool is_inlined() const
35+
{
36+
return type.get_bool(ID_C_inlined);
37+
}
38+
39+
bool is_hidden() const
40+
{
41+
return type.get_bool(ID_C_hide);
42+
}
43+
44+
void make_hidden()
45+
{
46+
type.set(ID_C_hide, true);
47+
}
48+
49+
goto_functiont()
50+
{
51+
}
52+
53+
void clear()
54+
{
55+
body.clear();
56+
type.clear();
57+
parameter_identifiers.clear();
58+
}
59+
60+
/// update the function member in each instruction
61+
/// \param function_id: the `function_id` used for assigning empty function
62+
/// members
63+
void update_instructions_function(const irep_idt &function_id)
64+
{
65+
body.update_instructions_function(function_id);
66+
}
67+
68+
void swap(goto_functiont &other)
69+
{
70+
body.swap(other.body);
71+
type.swap(other.type);
72+
parameter_identifiers.swap(other.parameter_identifiers);
73+
}
74+
75+
void copy_from(const goto_functiont &other)
76+
{
77+
body.copy_from(other.body);
78+
type = other.type;
79+
parameter_identifiers = other.parameter_identifiers;
80+
}
81+
82+
goto_functiont(const goto_functiont &) = delete;
83+
goto_functiont &operator=(const goto_functiont &) = delete;
84+
85+
goto_functiont(goto_functiont &&other)
86+
: body(std::move(other.body)),
87+
type(std::move(other.type)),
88+
parameter_identifiers(std::move(other.parameter_identifiers))
89+
{
90+
}
91+
92+
goto_functiont &operator=(goto_functiont &&other)
93+
{
94+
body = std::move(other.body);
95+
type = std::move(other.type);
96+
parameter_identifiers = std::move(other.parameter_identifiers);
97+
return *this;
98+
}
99+
};
100+
101+
void get_local_identifiers(const goto_functiont &, std::set<irep_idt> &dest);
102+
103+
#endif // CPROVER_GOTO_PROGRAMS_GOTO_FUNCTION_H

src/goto-programs/goto_functions.cpp

-19
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,3 @@ void goto_functionst::compute_loop_numbers()
7373
func.second.body.compute_loop_numbers();
7474
}
7575
}
76-
77-
78-
void get_local_identifiers(
79-
const goto_functiont &goto_function,
80-
std::set<irep_idt> &dest)
81-
{
82-
goto_function.body.get_decl_identifiers(dest);
83-
84-
const code_typet::parameterst &parameters=
85-
goto_function.type.parameters();
86-
87-
// add parameters
88-
for(const auto &param : parameters)
89-
{
90-
const irep_idt &identifier=param.get_identifier();
91-
if(identifier!="")
92-
dest.insert(identifier);
93-
}
94-
}

src/goto-programs/goto_functions.h

+1-89
Original file line numberDiff line numberDiff line change
@@ -14,93 +14,9 @@ Date: June 2003
1414
#ifndef CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H
1515
#define CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H
1616

17-
#include <iosfwd>
17+
#include "goto_function.h"
1818

1919
#include <util/cprover_prefix.h>
20-
#include <util/std_types.h>
21-
22-
#include "goto_program.h"
23-
24-
class goto_functiont
25-
{
26-
public:
27-
goto_programt body;
28-
code_typet type;
29-
30-
typedef std::vector<irep_idt> parameter_identifierst;
31-
parameter_identifierst parameter_identifiers;
32-
33-
bool body_available() const
34-
{
35-
return !body.instructions.empty();
36-
}
37-
38-
bool is_inlined() const
39-
{
40-
return type.get_bool(ID_C_inlined);
41-
}
42-
43-
bool is_hidden() const
44-
{
45-
return type.get_bool(ID_C_hide);
46-
}
47-
48-
void make_hidden()
49-
{
50-
type.set(ID_C_hide, true);
51-
}
52-
53-
goto_functiont()
54-
{
55-
}
56-
57-
void clear()
58-
{
59-
body.clear();
60-
type.clear();
61-
parameter_identifiers.clear();
62-
}
63-
64-
/// update the function member in each instruction
65-
/// \param function_id: the `function_id` used for assigning empty function
66-
/// members
67-
void update_instructions_function(const irep_idt &function_id)
68-
{
69-
body.update_instructions_function(function_id);
70-
}
71-
72-
void swap(goto_functiont &other)
73-
{
74-
body.swap(other.body);
75-
type.swap(other.type);
76-
parameter_identifiers.swap(other.parameter_identifiers);
77-
}
78-
79-
void copy_from(const goto_functiont &other)
80-
{
81-
body.copy_from(other.body);
82-
type=other.type;
83-
parameter_identifiers=other.parameter_identifiers;
84-
}
85-
86-
goto_functiont(const goto_functiont &)=delete;
87-
goto_functiont &operator=(const goto_functiont &)=delete;
88-
89-
goto_functiont(goto_functiont &&other):
90-
body(std::move(other.body)),
91-
type(std::move(other.type)),
92-
parameter_identifiers(std::move(other.parameter_identifiers))
93-
{
94-
}
95-
96-
goto_functiont &operator=(goto_functiont &&other)
97-
{
98-
body=std::move(other.body);
99-
type=std::move(other.type);
100-
parameter_identifiers=std::move(other.parameter_identifiers);
101-
return *this;
102-
}
103-
};
10420

10521
class goto_functionst
10622
{
@@ -211,8 +127,4 @@ class goto_functionst
211127
it=(functions).function_map.begin(); \
212128
it!=(functions).function_map.end(); it++)
213129

214-
void get_local_identifiers(
215-
const goto_functiont &,
216-
std::set<irep_idt> &dest);
217-
218130
#endif // CPROVER_GOTO_PROGRAMS_GOTO_FUNCTIONS_H

src/goto-symex/goto_symex_state.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Author: Daniel Kroening, [email protected]
2424
#include <util/make_unique.h>
2525

2626
#include <pointer-analysis/value_set.h>
27-
#include <goto-programs/goto_functions.h>
27+
#include <goto-programs/goto_function.h>
2828

2929
#include "symex_target_equation.h"
3030

@@ -365,7 +365,7 @@ class goto_symex_statet final
365365
bool l2_thread_write_encoding(const ssa_exprt &expr, const namespacet &ns);
366366

367367
void populate_dirty_for_function(
368-
const irep_idt &id, const goto_functionst::goto_functiont &);
368+
const irep_idt &id, const goto_functiont &);
369369

370370
void switch_to_thread(unsigned t);
371371
bool record_events;

0 commit comments

Comments
 (0)