Skip to content

Commit 17fa8a7

Browse files
authored
Merge pull request diffblue#493 from diffblue/merge-cbmc-develop-2018-07-06
Merge cbmc develop 2018 07 06
2 parents aa7734d + d896ea3 commit 17fa8a7

File tree

81 files changed

+941
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+941
-230
lines changed

cbmc/CMakeLists.txt

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -42,48 +42,6 @@ if(${enable_cbmc_tests})
4242
enable_testing()
4343
endif()
4444

45-
# based on https://cmake.org/pipermail/cmake/2010-July/038015.html
46-
find_package(Git)
47-
if(GIT_FOUND)
48-
file(WRITE ${CMAKE_BINARY_DIR}/version.cmake
49-
"
50-
file(STRINGS \${CBMC_SOURCE_DIR}/config.inc
51-
config_inc_v REGEX \"CBMC_VERSION *= *[0-9\.]+\")
52-
string(REGEX REPLACE \"^CBMC_VERSION *= *\" \"\" CBMC_RELEASE \${config_inc_v})
53-
execute_process(
54-
COMMAND \"${GIT_EXECUTABLE}\" \"describe\" \"--tags\" \"--always\" \"--dirty\"
55-
OUTPUT_VARIABLE GIT_INFO
56-
OUTPUT_STRIP_TRAILING_WHITESPACE
57-
)
58-
configure_file(\${CUR}/version.h.in version.h)
59-
"
60-
)
61-
else()
62-
file(WRITE ${CMAKE_BINARY_DIR}/version.cmake
63-
"
64-
file(STRINGS \${CBMC_SOURCE_DIR}/config.inc
65-
config_inc_v REGEX \"CBMC_VERSION *= *[0-9\.]+\")
66-
string(REGEX REPLACE \"^CBMC_VERSION *= *\" \"\" CBMC_RELEASE \${config_inc_v})
67-
set(GIT_INFO \"n/a\")
68-
configure_file(\${CUR}/version.h.in version.h)
69-
"
70-
)
71-
endif()
72-
73-
macro(git_revision target)
74-
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.h.in
75-
"\#define CBMC_VERSION \"@CBMC_RELEASE@ (@GIT_INFO@)\"\n")
76-
add_custom_target(
77-
${target}-version.h
78-
COMMAND ${CMAKE_COMMAND}
79-
-D CBMC_SOURCE_DIR=${CBMC_SOURCE_DIR}
80-
-D CUR=${CMAKE_CURRENT_BINARY_DIR}
81-
-P ${CMAKE_BINARY_DIR}/version.cmake
82-
)
83-
add_dependencies(${target} ${target}-version.h)
84-
endmacro()
85-
include_directories(${CMAKE_CURRENT_BINARY_DIR})
86-
8745
add_subdirectory(src)
8846
add_subdirectory(regression)
8947
add_subdirectory(unit)

cbmc/appveyor.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ version: 1.0.{build}
22
image: Visual Studio 2013
33
clone_depth: 50
44
environment:
5-
BUILD_ENV: MSVC
65
PATH: C:\projects\cbmc\deps\bin;%PATH%
76
INCLUDE: C:\projects\cbmc\deps\include
87
install:
@@ -57,9 +56,8 @@ build_script:
5756
cp -r deps/minisat2-2.2.1 minisat-2.2.1
5857
patch -d minisat-2.2.1 -p1 < scripts/minisat-2.2.1-patch
5958
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64
60-
sed -i "s/BUILD_ENV[ ]*=.*/BUILD_ENV = MSVC/" src/config.inc
61-
make -C src -j2
62-
make -C jbmc/src -j2
59+
make -C src -j2 BUILD_ENV=MSVC
60+
make -C jbmc/src -j2 BUILD_ENV=MSVC
6361
6462
test_script:
6563
- cmd: |
@@ -81,10 +79,10 @@ test_script:
8179
rmdir /s /q goto-instrument\slice08
8280
cd ..
8381
84-
make -C regression test
82+
make -C regression test BUILD_ENV=MSVC
8583
86-
make -C unit all -j2
87-
make -C unit test
84+
make -C unit all -j2 BUILD_ENV=MSVC
85+
make -C unit test BUILD_ENV=MSVC
8886
8987
cd jbmc/regression
9088
rmdir /s /q jbmc\VarLengthArrayTrace1
@@ -93,7 +91,7 @@ test_script:
9391
rmdir /s /q jbmc\tableswitch2
9492
cd ../..
9593
96-
make -C jbmc/regression test
94+
make -C jbmc/regression test BUILD_ENV=MSVC
9795
98-
make -C jbmc/unit all -j2
99-
make -C jbmc/unit test
96+
make -C jbmc/unit all -j2 BUILD_ENV=MSVC
97+
make -C jbmc/unit test BUILD_ENV=MSVC

cbmc/buildspec-windows.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ phases:
88

99
build:
1010
commands:
11-
- 'C:\tools\cygwin\bin\sed -i "s/BUILD_ENV[ ]*=.*/BUILD_ENV = MSVC/" src/config.inc'
1211
- |
1312
$env:Path = "C:\tools\cygwin\bin;$env:Path"
1413
C:\tools\cygwin\bin\bash -c "make -C src minisat2-download DOWNLOADER=wget"
1514
1615
- |
1716
$env:Path = "C:\tools\cygwin\bin;$env:Path"
18-
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C src" '
19-
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C unit all" '
17+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C src BUILD_ENV=MSVC" '
18+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C unit all BUILD_ENV=MSVC" '
2019
2120
- |
2221
$env:Path = "C:\tools\cygwin\bin;$env:Path"
23-
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C jbmc/src" '
24-
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C jbmc/unit all ; exit 0" '
22+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C jbmc/src BUILD_ENV=MSVC" '
23+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -j4 -C jbmc/unit all BUILD_ENV=MSVC ; exit 0" '
2524
2625
post_build:
2726
commands:
@@ -49,19 +48,19 @@ phases:
4948
5049
- |
5150
$env:Path = "C:\tools\cygwin\bin;$env:Path"
52-
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C regression test" '
51+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C regression test BUILD_ENV=MSVC" '
5352
5453
- |
5554
$env:Path = "C:\tools\cygwin\bin;$env:Path"
56-
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C unit test" '
55+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C unit test BUILD_ENV=MSVC" '
5756
5857
- |
5958
$env:Path = "C:\tools\cygwin\bin;$env:Path"
60-
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C jbmc/regression test ; exit 0" '
59+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C jbmc/regression test BUILD_ENV=MSVC ; exit 0" '
6160
6261
- |
6362
$env:Path = "C:\tools\cygwin\bin;$env:Path"
64-
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C jbmc/unit test ; exit 0" '
63+
cmd /c 'call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 && bash -c "make -C jbmc/unit test BUILD_ENV=MSVC ; exit 0" '
6564
6665
artifacts:
6766
files:

cbmc/jbmc/src/janalyzer/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,3 @@ target_link_libraries(janalyzer-lib
2424
# Executable
2525
add_executable(janalyzer janalyzer_main.cpp)
2626
target_link_libraries(janalyzer janalyzer-lib)
27-
28-
git_revision(janalyzer-lib)

cbmc/jbmc/src/janalyzer/janalyzer_parse_options.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,14 @@ Author: Daniel Kroening, [email protected]
4949
#include <util/exit_codes.h>
5050
#include <util/options.h>
5151
#include <util/unicode.h>
52+
#include <util/version.h>
5253

5354
#include <goto-analyzer/static_show_domain.h>
5455
#include <goto-analyzer/static_simplifier.h>
5556
#include <goto-analyzer/static_verifier.h>
5657
#include <goto-analyzer/taint_analysis.h>
5758
#include <goto-analyzer/unreachable_instructions.h>
5859

59-
#include "version.h"
60-
6160
janalyzer_parse_optionst::janalyzer_parse_optionst(int argc, const char **argv)
6261
: parse_options_baset(JANALYZER_OPTIONS, argc, argv),
6362
messaget(ui_message_handler),

cbmc/jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ void java_bytecode_convert_classt::convert(
276276
class_type.set(ID_interface, c.is_interface);
277277
class_type.set(ID_synthetic, c.is_synthetic);
278278
class_type.set_final(c.is_final);
279+
class_type.set_is_inner_class(c.is_inner_class);
279280
if(c.is_enum)
280281
{
281282
if(max_array_length != 0 && c.enum_elements > max_array_length)

cbmc/jbmc/src/java_bytecode/java_bytecode_parse_tree.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ class java_bytecode_parse_treet
217217
bool is_interface = false;
218218
bool is_synthetic = false;
219219
bool is_annotation = false;
220+
bool is_inner_class = false;
220221
bool attribute_bootstrapmethods_read = false;
221222
size_t enum_elements=0;
222223

cbmc/jbmc/src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ class java_bytecode_parsert:public parsert
119119
void rfields(classt &parsed_class);
120120
void rmethods(classt &parsed_class);
121121
void rmethod(classt &parsed_class);
122+
void
123+
rinner_classes_attribute(classt &parsed_class, const u4 &attribute_length);
122124
void rclass_attribute(classt &parsed_class);
123125
void rRuntimeAnnotation_attribute(annotationst &);
124126
void rRuntimeAnnotation(annotationt &);
@@ -1576,6 +1578,77 @@ void java_bytecode_parsert::relement_value_pair(
15761578
}
15771579
}
15781580

1581+
/// Corresponds to the element_value structure
1582+
/// Described in Java 8 specification 4.7.6
1583+
/// https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.6
1584+
/// Parses the InnerClasses attribute for the current parsed class,
1585+
/// which contains an array of information about its inner classes. We are
1586+
/// interested in getting information only for inner classes, which is
1587+
/// determined by checking if the parsed class matches any of the inner classes
1588+
/// in its inner class array. If the parsed class is not an inner class, then it
1589+
/// is ignored. When a parsed class is an inner class, the accessibility
1590+
/// information for the parsed class is overwritten, and the parsed class is
1591+
/// marked as an inner class.
1592+
void java_bytecode_parsert::rinner_classes_attribute(
1593+
classt &parsed_class,
1594+
const u4 &attribute_length)
1595+
{
1596+
std::string name = parsed_class.name.c_str();
1597+
u2 number_of_classes = read_u2();
1598+
u4 number_of_bytes_to_be_read = number_of_classes * 8 + 2;
1599+
INVARIANT(
1600+
number_of_bytes_to_be_read == attribute_length,
1601+
"The number of bytes to be read for the InnerClasses attribute does not "
1602+
"match the attribute length.");
1603+
1604+
const auto pool_entry_lambda = [this](u2 index) -> pool_entryt & {
1605+
return pool_entry(index);
1606+
};
1607+
const auto remove_separator_char = [](std::string str, char ch) {
1608+
str.erase(std::remove(str.begin(), str.end(), ch), str.end());
1609+
return str;
1610+
};
1611+
1612+
for(int i = 0; i < number_of_classes; i++)
1613+
{
1614+
u2 inner_class_info_index = read_u2();
1615+
u2 outer_class_info_index = read_u2();
1616+
UNUSED u2 inner_name_index = read_u2();
1617+
u2 inner_class_access_flags = read_u2();
1618+
1619+
std::string inner_class_info_name =
1620+
class_infot(pool_entry(inner_class_info_index))
1621+
.get_name(pool_entry_lambda);
1622+
bool is_private = (inner_class_access_flags & ACC_PRIVATE) != 0;
1623+
bool is_public = (inner_class_access_flags & ACC_PUBLIC) != 0;
1624+
bool is_protected = (inner_class_access_flags & ACC_PROTECTED) != 0;
1625+
1626+
// If the original parsed class name matches the inner class name,
1627+
// the parsed class is an inner class, so overwrite the parsed class'
1628+
// access information and mark it as an inner class.
1629+
bool is_inner_class = remove_separator_char(id2string(parsed_class.name), '.') ==
1630+
remove_separator_char(inner_class_info_name, '/');
1631+
if(is_inner_class)
1632+
parsed_class.is_inner_class = is_inner_class;
1633+
if(!is_inner_class)
1634+
continue;
1635+
// Note that if outer_class_info_index == 0, the inner class is an anonymous
1636+
// or local class, and is treated as private.
1637+
if(outer_class_info_index == 0)
1638+
{
1639+
parsed_class.is_private = true;
1640+
parsed_class.is_protected = false;
1641+
parsed_class.is_public = false;
1642+
}
1643+
else
1644+
{
1645+
parsed_class.is_private = is_private;
1646+
parsed_class.is_protected = is_protected;
1647+
parsed_class.is_public = is_public;
1648+
}
1649+
}
1650+
}
1651+
15791652
void java_bytecode_parsert::rclass_attribute(classt &parsed_class)
15801653
{
15811654
u2 attribute_name_index=read_u2();
@@ -1640,6 +1713,11 @@ void java_bytecode_parsert::rclass_attribute(classt &parsed_class)
16401713
parsed_class.attribute_bootstrapmethods_read = true;
16411714
read_bootstrapmethods_entry(parsed_class);
16421715
}
1716+
else if(attribute_name == "InnerClasses")
1717+
{
1718+
java_bytecode_parsert::rinner_classes_attribute(
1719+
parsed_class, attribute_length);
1720+
}
16431721
else
16441722
skip_bytes(attribute_length);
16451723
}

cbmc/jbmc/src/java_bytecode/java_types.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ class java_class_typet:public class_typet
111111
return set(ID_access, access);
112112
}
113113

114+
const bool get_is_inner_class() const
115+
{
116+
return get_bool(ID_is_inner_class);
117+
}
118+
119+
void set_is_inner_class(const bool &is_inner_class)
120+
{
121+
return set(ID_is_inner_class, is_inner_class);
122+
}
123+
114124
bool get_final()
115125
{
116126
return get_bool(ID_final);

cbmc/jbmc/src/jbmc/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,3 @@ add_executable(jbmc jbmc_main.cpp)
3434
target_link_libraries(jbmc jbmc-lib)
3535

3636
install(TARGETS jbmc DESTINATION bin)
37-
38-
git_revision(jbmc-lib)

cbmc/jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ Author: Daniel Kroening, [email protected]
1616
#include <iostream>
1717
#include <memory>
1818

19-
#include <util/exit_codes.h>
2019
#include <util/config.h>
21-
#include <util/unicode.h>
20+
#include <util/exit_codes.h>
2221
#include <util/invariant.h>
22+
#include <util/unicode.h>
23+
#include <util/version.h>
2324

2425
#include <langapi/language.h>
2526

@@ -60,8 +61,6 @@ Author: Daniel Kroening, [email protected]
6061
#include <java_bytecode/replace_java_nondet.h>
6162
#include <java_bytecode/simple_method_stubbing.h>
6263

63-
#include "version.h"
64-
6564
jbmc_parse_optionst::jbmc_parse_optionst(int argc, const char **argv):
6665
parse_options_baset(JBMC_OPTIONS, argc, argv),
6766
messaget(ui_message_handler),

cbmc/jbmc/src/jdiff/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,3 @@ target_link_libraries(jdiff-lib
2626
# Executable
2727
add_executable(jdiff jdiff_main.cpp)
2828
target_link_libraries(jdiff jdiff-lib)
29-
30-
git_revision(jdiff-lib)

cbmc/jbmc/src/jdiff/jdiff_parse_options.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Peter Schrammel
2020
#include <util/exit_codes.h>
2121
#include <util/make_unique.h>
2222
#include <util/options.h>
23+
#include <util/version.h>
2324

2425
#include <langapi/language.h>
2526

@@ -60,8 +61,6 @@ Author: Peter Schrammel
6061
#include <goto-diff/goto_diff.h>
6162
#include <goto-diff/unified_diff.h>
6263

63-
#include "version.h"
64-
6564
jdiff_parse_optionst::jdiff_parse_optionst(int argc, const char **argv)
6665
: parse_options_baset(JDIFF_OPTIONS, argc, argv),
6766
jdiff_languagest(cmdline, ui_message_handler),

cbmc/jbmc/unit/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ SRC += java_bytecode/goto-programs/class_hierarchy_output.cpp \
1212
java_bytecode/java_bytecode_convert_class/convert_java_annotations.cpp \
1313
java_bytecode/java_bytecode_convert_method/convert_invoke_dynamic.cpp \
1414
java_bytecode/java_bytecode_parse_generics/parse_generic_class.cpp \
15+
java_bytecode/java_bytecode_parser/parse_java_attributes.cpp \
1516
java_bytecode/java_object_factory/gen_nondet_string_init.cpp \
1617
java_bytecode/java_bytecode_parse_lambdas/java_bytecode_parse_lambda_method_table.cpp \
1718
java_bytecode/java_bytecode_parse_lambdas/java_bytecode_convert_class_lambda_method_handles.cpp \
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)