Skip to content

Commit 0ea6143

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 c8702ab commit 0ea6143

File tree

9 files changed

+54
-20
lines changed

9 files changed

+54
-20
lines changed

jbmc/src/java_bytecode/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ generic_includes(java_bytecode)
1212

1313
# if you link java_bytecode.a in, then you also need to link other .a libraries
1414
# in
15-
target_link_libraries(java_bytecode util goto-programs miniz json)
15+
target_link_libraries(java_bytecode util goto-programs miniz json ansi-c)

src/cbmc/cbmc_parse_options.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Author: Daniel Kroening, [email protected]
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

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Author: Daniel Kroening, [email protected]
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

+3-1
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

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Author: Daniel Kroening, [email protected]
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

+1-2
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 linking)

src/goto-programs/link_to_library.cpp

+27-8
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,46 @@ Author: Daniel Kroening, [email protected]
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

17+
/// Complete missing function definitions using the \p library.
18+
/// \param goto_model goto model that may contain function calls and symbols
19+
/// with missing function bodies
20+
/// \param message_handler message handler to report library processing
21+
/// problems
22+
/// \param library generator function that produces function definitions for a
23+
/// given set of symbol names that have no body.
2124
void link_to_library(
2225
goto_modelt &goto_model,
23-
message_handlert &message_handler)
26+
message_handlert &message_handler,
27+
const std::function<
28+
void(const std::set<irep_idt> &, symbol_tablet &, message_handlert &)>
29+
&library)
2430
{
2531
link_to_library(
2632
goto_model.symbol_table,
2733
goto_model.goto_functions,
28-
message_handler);
34+
message_handler,
35+
library);
2936
}
3037

38+
/// Complete missing function definitions using the \p library.
39+
/// \param symbol_table symbol table that may contain symbols with missing
40+
/// function bodies
41+
/// \param goto_functions goto functions that may contain function calls with
42+
/// missing function bodies
43+
/// \param message_handler message handler to report library processing
44+
/// problems
45+
/// \param library generator function that produces function definitions for a
46+
/// given set of symbol names that have no body.
3147
void link_to_library(
3248
symbol_tablet &symbol_table,
3349
goto_functionst &goto_functions,
34-
message_handlert &message_handler)
50+
message_handlert &message_handler,
51+
const std::function<
52+
void(const std::set<irep_idt> &, symbol_tablet &, message_handlert &)>
53+
&library)
3554
{
3655
// this needs a fixedpoint, as library functions
3756
// may depend on other library functions
@@ -69,7 +88,7 @@ void link_to_library(
6988
if(missing_functions.empty())
7089
break;
7190

72-
add_cprover_library(missing_functions, symbol_table, message_handler);
91+
library(missing_functions, symbol_table, message_handler);
7392

7493
// convert to CFG
7594
for(const auto &id : missing_functions)

src/goto-programs/link_to_library.h

+14-4
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,27 @@ Author: Daniel Kroening, [email protected]
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

-1
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)