1717
1818static std::string get_cprover_library_text (
1919 const std::set<irep_idt> &functions,
20- const symbol_tablet &symbol_table)
20+ const symbol_tablet &symbol_table,
21+ const bool force_load)
2122{
2223 std::ostringstream library_text;
2324
@@ -52,14 +53,15 @@ static std::string get_cprover_library_text(
5253 // / \endcond
5354
5455 return get_cprover_library_text (
55- functions, symbol_table, cprover_library, library_text.str ());
56+ functions, symbol_table, cprover_library, library_text.str (), force_load );
5657}
5758
5859std::string get_cprover_library_text (
5960 const std::set<irep_idt> &functions,
6061 const symbol_tablet &symbol_table,
6162 const struct cprover_library_entryt cprover_library[],
62- const std::string &prologue)
63+ const std::string &prologue,
64+ const bool force_load)
6365{
6466 // the default mode is ios_base::out which means subsequent write to the
6567 // stream will overwrite the original content
@@ -77,8 +79,9 @@ std::string get_cprover_library_text(
7779 symbol_tablet::symbolst::const_iterator old=
7880 symbol_table.symbols .find (id);
7981
80- if (old!=symbol_table.symbols .end () &&
81- old->second .value .is_nil ())
82+ if (
83+ force_load ||
84+ (old != symbol_table.symbols .end () && old->second .value .is_nil ()))
8285 {
8386 count++;
8487 library_text << e->model << ' \n ' ;
@@ -100,17 +103,17 @@ void cprover_c_library_factory(
100103 if (config.ansi_c .lib ==configt::ansi_ct::libt::LIB_NONE)
101104 return ;
102105
103- std::string library_text;
104-
105- library_text=get_cprover_library_text (functions, symbol_table);
106+ std::string library_text =
107+ get_cprover_library_text (functions, symbol_table, false );
106108
107109 add_library (library_text, symbol_table, message_handler);
108110}
109111
110112void add_library (
111113 const std::string &src,
112114 symbol_tablet &symbol_table,
113- message_handlert &message_handler)
115+ message_handlert &message_handler,
116+ const std::set<irep_idt> &keep)
114117{
115118 if (src.empty ())
116119 return ;
@@ -121,5 +124,15 @@ void add_library(
121124 ansi_c_language.set_message_handler (message_handler);
122125 ansi_c_language.parse (in, " " );
123126
124- ansi_c_language.typecheck (symbol_table, " <built-in-library>" );
127+ ansi_c_language.typecheck (symbol_table, " <built-in-library>" , true , keep);
128+ }
129+
130+ void cprover_c_library_factory_force_load (
131+ const std::set<irep_idt> &functions,
132+ symbol_tablet &symbol_table,
133+ message_handlert &message_handler)
134+ {
135+ std::string library_text =
136+ get_cprover_library_text (functions, symbol_table, true );
137+ add_library (library_text, symbol_table, message_handler, functions);
125138}
0 commit comments