Skip to content

Commit 3a31976

Browse files
authored
Merge pull request #6658 from diffblue/move_goto_check_c
move goto_check_ct to ansi-c/
2 parents de9fa65 + d3301c0 commit 3a31976

24 files changed

+88
-91
lines changed

jbmc/src/janalyzer/janalyzer_parse_options.cpp

+15-20
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "janalyzer_parse_options.h"
1313

14-
#include <cstdlib> // exit()
15-
#include <fstream>
16-
#include <iostream>
17-
#include <memory>
18-
19-
#include <ansi-c/ansi_c_language.h>
14+
#include <util/config.h>
15+
#include <util/exit_codes.h>
16+
#include <util/options.h>
17+
#include <util/version.h>
2018

19+
#include <goto-programs/goto_check.h>
2120
#include <goto-programs/remove_returns.h>
2221
#include <goto-programs/remove_skip.h>
2322
#include <goto-programs/remove_virtual_functions.h>
@@ -27,30 +26,26 @@ Author: Daniel Kroening, [email protected]
2726

2827
#include <analyses/constant_propagator.h>
2928
#include <analyses/dependence_graph.h>
30-
#include <analyses/goto_check.h>
3129
#include <analyses/interval_domain.h>
3230
#include <analyses/local_may_alias.h>
33-
31+
#include <ansi-c/ansi_c_language.h>
32+
#include <goto-analyzer/static_show_domain.h>
33+
#include <goto-analyzer/static_simplifier.h>
34+
#include <goto-analyzer/static_verifier.h>
35+
#include <goto-analyzer/taint_analysis.h>
36+
#include <goto-analyzer/unreachable_instructions.h>
3437
#include <java_bytecode/java_bytecode_language.h>
3538
#include <java_bytecode/lazy_goto_model.h>
3639
#include <java_bytecode/remove_exceptions.h>
3740
#include <java_bytecode/remove_instanceof.h>
38-
3941
#include <langapi/language.h>
4042
#include <langapi/mode.h>
41-
4243
#include <linking/static_lifetime_init.h>
4344

44-
#include <util/config.h>
45-
#include <util/exit_codes.h>
46-
#include <util/options.h>
47-
#include <util/version.h>
48-
49-
#include <goto-analyzer/static_show_domain.h>
50-
#include <goto-analyzer/static_simplifier.h>
51-
#include <goto-analyzer/static_verifier.h>
52-
#include <goto-analyzer/taint_analysis.h>
53-
#include <goto-analyzer/unreachable_instructions.h>
45+
#include <cstdlib> // exit()
46+
#include <fstream>
47+
#include <iostream>
48+
#include <memory>
5449

5550
janalyzer_parse_optionst::janalyzer_parse_optionst(int argc, const char **argv)
5651
: parse_options_baset(

jbmc/src/jbmc/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ add_library(jbmc-lib ${sources})
88
generic_includes(jbmc-lib)
99

1010
target_link_libraries(jbmc-lib
11-
analyses
1211
ansi-c
1312
big-int
1413
cbmc-lib

jbmc/src/jbmc/jbmc_parse_options.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Author: Daniel Kroening, [email protected]
1919
#include <util/xml.h>
2020

2121
#include <goto-programs/adjust_float_expressions.h>
22+
#include <goto-programs/goto_check.h>
2223
#include <goto-programs/goto_convert_functions.h>
2324
#include <goto-programs/instrument_preconditions.h>
2425
#include <goto-programs/loop_ids.h>
@@ -31,7 +32,6 @@ Author: Daniel Kroening, [email protected]
3132
#include <goto-programs/show_properties.h>
3233
#include <goto-programs/show_symbol_table.h>
3334

34-
#include <analyses/goto_check.h>
3535
#include <ansi-c/ansi_c_language.h>
3636
#include <goto-checker/all_properties_verifier.h>
3737
#include <goto-checker/all_properties_verifier_with_fault_localization.h>

jbmc/src/jbmc/module_dependencies.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
analyses
21
ansi-c # should go away
32
goto-checker
43
goto-instrument

jbmc/src/jdiff/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ target_link_libraries(jdiff-lib
1515
goto-diff-lib
1616
goto-instrument-lib
1717
goto-programs
18-
analyses
1918
java_bytecode
2019
langapi
2120
xml

jbmc/src/jdiff/jdiff_parse_options.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Author: Peter Schrammel
1717
#include <util/version.h>
1818

1919
#include <goto-programs/adjust_float_expressions.h>
20+
#include <goto-programs/goto_check.h>
2021
#include <goto-programs/initialize_goto_model.h>
2122
#include <goto-programs/instrument_preconditions.h>
2223
#include <goto-programs/loop_ids.h>
@@ -28,7 +29,6 @@ Author: Peter Schrammel
2829
#include <goto-programs/set_properties.h>
2930
#include <goto-programs/show_properties.h>
3031

31-
#include <analyses/goto_check.h>
3232
#include <goto-diff/change_impact.h>
3333
#include <goto-diff/unified_diff.h>
3434
#include <goto-instrument/cover.h>

jbmc/src/jdiff/module_dependencies.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
analyses
21
java_bytecode
32
jdiff
43
goto-diff

src/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ $(patsubst %, %.dir, $(filter-out big-int util, $(DIRS))): util.dir
5959
.PHONY: languages
6060
.PHONY: clean
6161

62+
ansi-c.dir: analyses.dir
63+
6264
cpp.dir: ansi-c.dir linking.dir
6365

6466
crangler.dir: util.dir json.dir

src/analyses/Makefile

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ SRC = ai.cpp \
1212
escape_analysis.cpp \
1313
flow_insensitive_analysis.cpp \
1414
global_may_alias.cpp \
15-
goto_check.cpp \
16-
goto_check_c.cpp \
1715
goto_rw.cpp \
1816
guard_bdd.cpp \
1917
guard_expr.cpp \

src/ansi-c/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,4 @@ set_source_files_properties(
127127

128128
generic_includes(ansi-c)
129129

130-
target_link_libraries(ansi-c util linking goto-programs assembler)
130+
target_link_libraries(ansi-c analyses util linking goto-programs assembler)

src/ansi-c/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ SRC = anonymous_member.cpp \
3131
expr2c.cpp \
3232
gcc_types.cpp \
3333
gcc_version.cpp \
34+
goto_check_c.cpp \
3435
literals/convert_character_literal.cpp \
3536
literals/convert_float_literal.cpp \
3637
literals/convert_integer_literal.cpp \

src/analyses/goto_check_c.cpp renamed to src/ansi-c/goto_check_c.cpp

+23-20
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include "goto_check_c.h"
1313

14-
#include <algorithm>
15-
#include <optional>
16-
1714
#include <util/arith_tools.h>
1815
#include <util/array_name.h>
1916
#include <util/bitvector_expr.h>
@@ -37,13 +34,15 @@ Author: Daniel Kroening, [email protected]
3734
#include <util/std_code.h>
3835
#include <util/std_expr.h>
3936

40-
#include <langapi/language.h>
41-
#include <langapi/mode.h>
42-
4337
#include <goto-programs/goto_model.h>
4438
#include <goto-programs/remove_skip.h>
4539

46-
#include "local_bitvector_analysis.h"
40+
#include <analyses/local_bitvector_analysis.h>
41+
#include <langapi/language.h>
42+
#include <langapi/mode.h>
43+
44+
#include <algorithm>
45+
#include <optional>
4746

4847
class goto_check_ct
4948
{
@@ -986,11 +985,12 @@ void goto_check_ct::integer_overflow_check(
986985
// a shift of zero isn't overflow;
987986
// else check the top bits
988987
add_guarded_property(
989-
disjunction({neg_value_shift,
990-
neg_dist_shift,
991-
dist_too_large,
992-
op_zero,
993-
top_bits_zero}),
988+
disjunction(
989+
{neg_value_shift,
990+
neg_dist_shift,
991+
dist_too_large,
992+
op_zero,
993+
top_bits_zero}),
994994
"arithmetic overflow on signed shl",
995995
"overflow",
996996
expr.find_source_location(),
@@ -1554,9 +1554,10 @@ void goto_check_ct::bounds_check_index(
15541554
exprt p_offset =
15551555
pointer_offset(to_dereference_expr(ode.root_object()).pointer());
15561556

1557-
effective_offset = plus_exprt{p_offset,
1558-
typecast_exprt::conditional_cast(
1559-
effective_offset, p_offset.type())};
1557+
effective_offset = plus_exprt{
1558+
p_offset,
1559+
typecast_exprt::conditional_cast(
1560+
effective_offset, p_offset.type())};
15601561
}
15611562

15621563
exprt zero = from_integer(0, ode.offset().type());
@@ -1825,9 +1826,10 @@ bool goto_check_ct::check_rec_member(
18251826
deref.pointer(), pointer_type(char_type()));
18261827

18271828
const exprt new_address_casted = typecast_exprt::conditional_cast(
1828-
plus_exprt{char_pointer,
1829-
typecast_exprt::conditional_cast(
1830-
member_offset_opt.value(), pointer_diff_type())},
1829+
plus_exprt{
1830+
char_pointer,
1831+
typecast_exprt::conditional_cast(
1832+
member_offset_opt.value(), pointer_diff_type())},
18311833
new_pointer_type);
18321834

18331835
dereference_exprt new_deref{new_address_casted};
@@ -2368,8 +2370,9 @@ goto_check_ct::get_pointer_is_null_condition(
23682370
if(flags.is_unknown() || flags.is_uninitialized() || flags.is_null())
23692371
{
23702372
return {conditiont{
2371-
or_exprt{is_in_bounds_of_some_explicit_allocation(address, size),
2372-
not_exprt(null_pointer(address))},
2373+
or_exprt{
2374+
is_in_bounds_of_some_explicit_allocation(address, size),
2375+
not_exprt(null_pointer(address))},
23732376
"pointer NULL"}};
23742377
}
23752378

src/analyses/goto_check_c.h renamed to src/ansi-c/goto_check_c.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ Author: Daniel Kroening, [email protected]
99
/// \file
1010
/// Program Transformation
1111

12-
#ifndef CPROVER_ANALYSES_GOTO_CHECK_C_H
13-
#define CPROVER_ANALYSES_GOTO_CHECK_C_H
12+
#ifndef CPROVER_ANSI_C_GOTO_CHECK_C_H
13+
#define CPROVER_ANSI_C_GOTO_CHECK_C_H
1414

1515
#include <goto-programs/goto_functions.h>
1616

src/ansi-c/module_dependencies.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
analyses
12
ansi-c
23
goto-programs
34
langapi # should go away

src/cbmc/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,19 @@ add_if_library(cbmc-lib jsil)
3333

3434
# Executable
3535
add_executable(cbmc cbmc_main.cpp)
36+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
37+
# There is a cyclic dependency between analyses and ansi-c, which the
38+
# Makefile-based build system resolves by using --start-group, --end-group.
39+
# CMake lacks direct support (cf.
40+
# https://gitlab.kitware.com/cmake/cmake/-/issues/21511), so we ensure all
41+
# object files from libanalyses.a remain present.
42+
target_link_libraries(cbmc
43+
cbmc-lib
44+
-Wl,--whole-archive -Wl,${CMAKE_BINARY_DIR}/lib/libanalyses.a -Wl,--no-whole-archive
45+
)
46+
else()
3647
target_link_libraries(cbmc cbmc-lib)
48+
endif()
3749
install(TARGETS cbmc DESTINATION ${CMAKE_INSTALL_BINDIR})
3850

3951
# Man page

src/cbmc/cbmc_parse_options.h

+6-12
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,23 @@ Author: Daniel Kroening, [email protected]
1212
#ifndef CPROVER_CBMC_CBMC_PARSE_OPTIONS_H
1313
#define CPROVER_CBMC_CBMC_PARSE_OPTIONS_H
1414

15-
#include <ansi-c/ansi_c_language.h>
16-
1715
#include <util/parse_options.h>
1816
#include <util/timestamper.h>
1917
#include <util/ui_message.h>
2018
#include <util/validation_interface.h>
2119

22-
#include <langapi/language.h>
23-
24-
#include <analyses/goto_check_c.h>
25-
26-
#include <goto-checker/bmc_util.h>
27-
2820
#include <goto-programs/goto_model.h>
2921
#include <goto-programs/goto_trace.h>
3022

31-
#include <solvers/strings/string_refinement.h>
32-
23+
#include <ansi-c/ansi_c_language.h>
24+
#include <ansi-c/goto_check_c.h>
25+
#include <goto-checker/bmc_util.h>
26+
#include <goto-instrument/cover.h>
3327
#include <json/json_interface.h>
28+
#include <langapi/language.h>
29+
#include <solvers/strings/string_refinement.h>
3430
#include <xmllang/xml_interface.h>
3531

36-
#include <goto-instrument/cover.h>
37-
3832
class optionst;
3933

4034
// clang-format off

src/goto-analyzer/goto_analyzer_parse_options.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,13 @@ Author: Daniel Kroening, [email protected]
9494
#include <util/ui_message.h>
9595
#include <util/validation_interface.h>
9696

97-
#include <langapi/language.h>
98-
9997
#include <goto-programs/goto_model.h>
10098
#include <goto-programs/show_goto_functions.h>
10199
#include <goto-programs/show_properties.h>
102100

103-
#include <analyses/goto_check_c.h>
104101
#include <analyses/variable-sensitivity/variable_sensitivity_domain.h>
102+
#include <ansi-c/goto_check_c.h>
103+
#include <langapi/language.h>
105104

106105
class optionst;
107106

src/goto-diff/goto_diff_parse_options.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ Author: Peter Schrammel
1212
#ifndef CPROVER_GOTO_DIFF_GOTO_DIFF_PARSE_OPTIONS_H
1313
#define CPROVER_GOTO_DIFF_GOTO_DIFF_PARSE_OPTIONS_H
1414

15-
#include <analyses/goto_check_c.h>
16-
17-
#include <util/ui_message.h>
1815
#include <util/parse_options.h>
1916
#include <util/timestamper.h>
17+
#include <util/ui_message.h>
2018

2119
#include <goto-programs/show_goto_functions.h>
2220
#include <goto-programs/show_properties.h>
2321

22+
#include <ansi-c/goto_check_c.h>
2423
#include <goto-instrument/cover.h>
2524

2625
class goto_modelt;

src/goto-instrument/goto_instrument_parse_options.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Author: Daniel Kroening, [email protected]
2828

2929
#include <goto-programs/class_hierarchy.h>
3030
#include <goto-programs/ensure_one_backedge_per_target.h>
31+
#include <goto-programs/goto_check.h>
3132
#include <goto-programs/goto_inline.h>
3233
#include <goto-programs/interpreter.h>
3334
#include <goto-programs/label_function_pointer_call_sites.h>
@@ -50,10 +51,6 @@ Author: Daniel Kroening, [email protected]
5051
#include <goto-programs/string_abstraction.h>
5152
#include <goto-programs/write_goto_binary.h>
5253

53-
#include <pointer-analysis/add_failed_symbols.h>
54-
#include <pointer-analysis/show_value_sets.h>
55-
#include <pointer-analysis/value_set_analysis.h>
56-
5754
#include <analyses/call_graph.h>
5855
#include <analyses/constant_propagator.h>
5956
#include <analyses/custom_bitvector_analysis.h>
@@ -69,16 +66,15 @@ Author: Daniel Kroening, [email protected]
6966
#include <analyses/natural_loops.h>
7067
#include <analyses/reaching_definitions.h>
7168
#include <analyses/sese_regions.h>
72-
7369
#include <ansi-c/ansi_c_language.h>
7470
#include <ansi-c/c_object_factory_parameters.h>
7571
#include <ansi-c/cprover_library.h>
76-
7772
#include <assembler/remove_asm.h>
78-
7973
#include <cpp/cprover_library.h>
74+
#include <pointer-analysis/add_failed_symbols.h>
75+
#include <pointer-analysis/show_value_sets.h>
76+
#include <pointer-analysis/value_set_analysis.h>
8077

81-
#include "accelerate/accelerate.h"
8278
#include "alignment_checks.h"
8379
#include "branch.h"
8480
#include "call_sequences.h"
@@ -109,6 +105,8 @@ Author: Daniel Kroening, [email protected]
109105
#include "unwind.h"
110106
#include "value_set_fi_fp_removal.h"
111107

108+
#include "accelerate/accelerate.h"
109+
112110
/// invoke main modules
113111
int goto_instrument_parse_optionst::doit()
114112
{

0 commit comments

Comments
 (0)