Skip to content

Commit aa5440b

Browse files
Moved call to final to lazy_goto_modelt::finalize
Explicitly load any functions added by call to final
1 parent a659bc0 commit aa5440b

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

src/goto-programs/lazy_goto_functions_map.h

+5
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ class lazy_goto_functions_mapt final
120120

121121
void unload(const key_type &name) const { goto_functions.erase(name); }
122122

123+
void ensure_function_loaded(const key_type &name) const
124+
{
125+
ensure_function_loaded_internal(name);
126+
}
127+
123128
private:
124129
// This returns a non-const reference, but if you use this method from a
125130
// const method then you should not return such a reference without making it

src/goto-programs/lazy_goto_model.cpp

+19-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <util/cmdline.h>
1313
#include <util/config.h>
14+
#include <util/journalling_symbol_table.h>
1415
#include <util/language.h>
1516
#include <util/unicode.h>
1617

@@ -184,12 +185,6 @@ void lazy_goto_modelt::initialize(const cmdlinet &cmdline)
184185
throw 0;
185186
}
186187

187-
if(language_files.final(symbol_table))
188-
{
189-
msg.error() << "FINAL STAGE CONVERSION ERROR" << messaget::eom;
190-
throw 0;
191-
}
192-
193188
// stupid hack
194189
config.set_object_bits_from_symbol_table(symbol_table);
195190
}
@@ -203,6 +198,24 @@ void lazy_goto_modelt::load_all_functions() const
203198

204199
bool lazy_goto_modelt::finalize()
205200
{
201+
messaget msg(message_handler);
202+
journalling_symbol_tablet symbol_table=
203+
journalling_symbol_tablet::wrap(this->symbol_table);
204+
if(language_files.final(symbol_table))
205+
{
206+
msg.error() << "CONVERSION ERROR" << messaget::eom;
207+
return true;
208+
}
209+
for(const irep_idt &updated_symbol_id : symbol_table.get_updated())
210+
{
211+
if(symbol_table.lookup_ref(updated_symbol_id).is_function())
212+
{
213+
// Re-convert any that already exist
214+
goto_functions.unload(updated_symbol_id);
215+
goto_functions.ensure_function_loaded(updated_symbol_id);
216+
}
217+
}
218+
206219
language_files.clear();
207220

208221
return post_process_functions(*goto_model);

src/util/symbol.h

+5
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ class symbolt
109109
{
110110
return !is_static_lifetime;
111111
}
112+
113+
bool is_function() const
114+
{
115+
return !is_type && !is_macro && type.id()==ID_code;
116+
}
112117
};
113118

114119
std::ostream &operator<<(std::ostream &out, const symbolt &symbol);

0 commit comments

Comments
 (0)