Skip to content

Commit c8e0230

Browse files
committed
Make link_to_library independent of the C front-end
Picking the library to load is now left to the tool front-end
1 parent d790f9f commit c8e0230

File tree

8 files changed

+37
-19
lines changed

8 files changed

+37
-19
lines changed

src/cbmc/cbmc_parse_options.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Author: Daniel Kroening, kroening@kroening.com
2424
#include <langapi/language.h>
2525

2626
#include <ansi-c/c_preprocess.h>
27+
#include <ansi-c/cprover_library.h>
2728

2829
#include <goto-programs/adjust_float_expressions.h>
2930
#include <goto-programs/initialize_goto_model.h>
@@ -713,7 +714,7 @@ bool cbmc_parse_optionst::process_goto_program(
713714
// add the library
714715
log.status() << "Adding CPROVER library (" << config.ansi_c.arch << ")"
715716
<< eom;
716-
link_to_library(goto_model, log.get_message_handler());
717+
link_to_library(goto_model, log.get_message_handler(), add_cprover_library);
717718

718719
if(options.get_bool_option("string-abstraction"))
719720
string_instrumentation(goto_model, log.get_message_handler());

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Author: Daniel Kroening, kroening@kroening.com
1717
#include <memory>
1818

1919
#include <ansi-c/ansi_c_language.h>
20+
#include <ansi-c/cprover_library.h>
21+
2022
#include <cpp/cpp_language.h>
2123
#include <jsil/jsil_language.h>
2224

@@ -725,7 +727,7 @@ bool goto_analyzer_parse_optionst::process_goto_program(
725727

726728
// add the library
727729
status() << "Adding CPROVER library (" << config.ansi_c.arch << ")" << eom;
728-
link_to_library(goto_model, ui_message_handler);
730+
link_to_library(goto_model, ui_message_handler, add_cprover_library);
729731
#endif
730732

731733
// remove function pointers

src/goto-diff/goto_diff_parse_options.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Author: Peter Schrammel
5252

5353
#include <langapi/mode.h>
5454

55+
#include <ansi-c/cprover_library.h>
56+
5557
#include <cbmc/version.h>
5658

5759
#include "goto_diff.h"
@@ -395,7 +397,7 @@ bool goto_diff_parse_optionst::process_goto_program(
395397

396398
// add the library
397399
status() << "Adding CPROVER library (" << config.ansi_c.arch << ")" << eom;
398-
link_to_library(goto_model, get_message_handler());
400+
link_to_library(goto_model, get_message_handler(), add_cprover_library);
399401

400402
// remove function pointers
401403
status() << "Removal of function pointers and virtual functions" << eom;

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Author: Daniel Kroening, kroening@kroening.com
6262
#include <analyses/constant_propagator.h>
6363
#include <analyses/is_threaded.h>
6464

65+
#include <ansi-c/cprover_library.h>
66+
6567
#include <cbmc/version.h>
6668

6769
#include "document_properties.h"
@@ -958,7 +960,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
958960

959961
// add the library
960962
status() << "Adding CPROVER library (" << config.ansi_c.arch << ")" << eom;
961-
link_to_library(goto_model, get_message_handler());
963+
link_to_library(goto_model, get_message_handler(), add_cprover_library);
962964
}
963965

964966
// now do full inlining, if requested

src/goto-programs/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ add_library(goto-programs ${sources})
33

44
generic_includes(goto-programs)
55

6-
target_link_libraries(
7-
goto-programs util assembler langapi analyses ansi-c)
6+
target_link_libraries(goto-programs util assembler langapi analyses)

src/goto-programs/link_to_library.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,30 @@ Author: Daniel Kroening, kroening@kroening.com
1111

1212
#include "link_to_library.h"
1313

14-
#include <util/config.h>
15-
16-
#include <ansi-c/cprover_library.h>
17-
1814
#include "compute_called_functions.h"
1915
#include "goto_convert_functions.h"
2016

2117
void link_to_library(
2218
goto_modelt &goto_model,
23-
message_handlert &message_handler)
19+
message_handlert &message_handler,
20+
const std::function<
21+
void(const std::set<irep_idt> &, symbol_tablet &, message_handlert &)>
22+
&library)
2423
{
2524
link_to_library(
2625
goto_model.symbol_table,
2726
goto_model.goto_functions,
28-
message_handler);
27+
message_handler,
28+
library);
2929
}
3030

3131
void link_to_library(
3232
symbol_tablet &symbol_table,
3333
goto_functionst &goto_functions,
34-
message_handlert &message_handler)
34+
message_handlert &message_handler,
35+
const std::function<
36+
void(const std::set<irep_idt> &, symbol_tablet &, message_handlert &)>
37+
&library)
3538
{
3639
// this needs a fixedpoint, as library functions
3740
// may depend on other library functions
@@ -69,7 +72,7 @@ void link_to_library(
6972
if(missing_functions.empty())
7073
break;
7174

72-
add_cprover_library(missing_functions, symbol_table, message_handler);
75+
library(missing_functions, symbol_table, message_handler);
7376

7477
// convert to CFG
7578
for(const auto &id : missing_functions)

src/goto-programs/link_to_library.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,27 @@ Author: Daniel Kroening, kroening@kroening.com
1212
#ifndef CPROVER_GOTO_PROGRAMS_LINK_TO_LIBRARY_H
1313
#define CPROVER_GOTO_PROGRAMS_LINK_TO_LIBRARY_H
1414

15-
#include <util/message.h>
15+
#include <functional>
16+
#include <set>
1617

17-
#include "goto_model.h"
18+
#include <util/irep.h>
19+
20+
class goto_functionst;
21+
class goto_modelt;
22+
class message_handlert;
23+
class symbol_tablet;
1824

1925
void link_to_library(
2026
symbol_tablet &,
2127
goto_functionst &,
22-
message_handlert &);
28+
message_handlert &,
29+
const std::function<
30+
void(const std::set<irep_idt> &, symbol_tablet &, message_handlert &)> &);
2331

2432
void link_to_library(
2533
goto_modelt &,
26-
message_handlert &);
34+
message_handlert &,
35+
const std::function<
36+
void(const std::set<irep_idt> &, symbol_tablet &, message_handlert &)> &);
2737

2838
#endif // CPROVER_GOTO_PROGRAMS_LINK_TO_LIBRARY_H

src/goto-programs/module_dependencies.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
analyses # dubious - concerns call_graph and does_remove_const
2-
ansi-c # should go away
32
assembler # should go away
43
goto-programs
54
goto-symex # dubious - spurious inclusion of symex_target_equation in graphml_witness

0 commit comments

Comments
 (0)