Skip to content

Commit bfd4f50

Browse files
authored
Merge pull request diffblue#1730 from smowton/smowton/feature/remove_returns_per_function
JBMC: Remove-returns per function
2 parents fd6e195 + 96569c3 commit bfd4f50

File tree

13 files changed

+221
-98
lines changed

13 files changed

+221
-98
lines changed

src/goto-programs/lazy_goto_functions_map.h

+10
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,16 @@ class lazy_goto_functions_mapt final
9999
return ensure_function_loaded_internal(name).second;
100100
}
101101

102+
/// Determines if this lazy GOTO functions map can produce a body for the
103+
/// given function
104+
/// \param name: function ID to query
105+
/// \return true if we can produce a function body, or false if we would leave
106+
/// it a bodyless stub.
107+
bool can_produce_function(const key_type &name) const
108+
{
109+
return language_files.can_convert_lazy_method(name);
110+
}
111+
102112
void unload(const key_type &name) const { goto_functions.erase(name); }
103113

104114
void ensure_function_loaded(const key_type &name) const

src/goto-programs/lazy_goto_model.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ lazy_goto_modelt::lazy_goto_modelt(
3131
[this] (goto_functionst::goto_functiont &function) -> void
3232
{
3333
goto_model_functiont model_function(*goto_model, function);
34-
this->post_process_function(model_function);
34+
this->post_process_function(model_function, *this);
3535
},
3636
message_handler),
3737
post_process_function(std::move(post_process_function)),
@@ -51,7 +51,7 @@ lazy_goto_modelt::lazy_goto_modelt(lazy_goto_modelt &&other)
5151
[this] (goto_functionst::goto_functiont &function) -> void
5252
{
5353
goto_model_functiont model_function(*goto_model, function);
54-
this->post_process_function(model_function);
54+
this->post_process_function(model_function, *this);
5555
},
5656
other.message_handler),
5757
language_files(std::move(other.language_files)),
@@ -239,3 +239,8 @@ bool lazy_goto_modelt::finalize()
239239

240240
return post_process_functions(*goto_model);
241241
}
242+
243+
bool lazy_goto_modelt::can_produce_function(const irep_idt &id) const
244+
{
245+
return goto_functions.can_produce_function(id);
246+
}

src/goto-programs/lazy_goto_model.h

+20-7
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,24 @@
1515
class cmdlinet;
1616
class optionst;
1717

18+
/// Interface for a provider of function definitions to report whether or not it
19+
/// can provide a definition (function body) for a given function ID.
20+
struct can_produce_functiont
21+
{
22+
/// Determines if this function provider can produce a body for the given
23+
/// function
24+
/// \param id: function ID to query
25+
/// \return true if we can produce a function body, or false if we would leave
26+
/// it a bodyless stub.
27+
virtual bool can_produce_function(const irep_idt &id) const = 0;
28+
};
29+
1830
/// Model that holds partially loaded map of functions
19-
class lazy_goto_modelt
31+
class lazy_goto_modelt : public can_produce_functiont
2032
{
2133
public:
22-
typedef std::function<void(goto_model_functiont &function)>
34+
typedef std::function<
35+
void(goto_model_functiont &function, const can_produce_functiont &)>
2336
post_process_functiont;
2437
typedef std::function<bool(goto_modelt &goto_model)> post_process_functionst;
2538

@@ -51,12 +64,10 @@ class lazy_goto_modelt
5164
message_handlert &message_handler)
5265
{
5366
return lazy_goto_modelt(
54-
[&handler] (goto_model_functiont &function)
55-
{
56-
handler.process_goto_function(function);
67+
[&handler] (goto_model_functiont &fun, const can_produce_functiont &cpf) { // NOLINT(*)
68+
handler.process_goto_function(fun, cpf);
5769
},
58-
[&handler, &options] (goto_modelt &goto_model) -> bool
59-
{
70+
[&handler, &options] (goto_modelt &goto_model) -> bool { // NOLINT(*)
6071
return handler.process_goto_functions(goto_model, options);
6172
},
6273
message_handler);
@@ -88,6 +99,8 @@ class lazy_goto_modelt
8899
return std::move(model.goto_model);
89100
}
90101

102+
virtual bool can_produce_function(const irep_idt &id) const;
103+
91104
private:
92105
std::unique_ptr<goto_modelt> goto_model;
93106

0 commit comments

Comments
 (0)