Commit Graph

759 Commits

Author SHA1 Message Date
Michael Tautschnig 6a0d998124 Rewrite byte_update lowering to respect endianness, support composite types
byte_update lowering now proceeds as follows:
1) Determine the size of the update, with the size of the object to be
updated as an upper bound. We fail if neither can be determined.
2) Turn the update value into a byte array of the size determined above.
3) If the offset is not constant, turn the object into a byte array, and
use a "with" expression to encode the update; else update the values in
place.
4) Construct a new object.
2019-02-26 19:09:24 +00:00
Daniel Kroening 85ba2253fe prefer .add over .emplace
This is easier to read.
2019-02-26 13:56:53 +00:00
Romain Brenguier e1fb6b7fec Add unit test for BDD
This adds a test case to check there are no mistakes in the BDD to expr
conversions.
This test can fail without the previous fix.
2019-02-25 17:28:16 +00:00
Michael Tautschnig 24bf054b07 Do not use has_prefix in source_location.h
source_location.h is transitivly included in almost every translation unit.
Avoid the prefix.h include by moving the a method definition to the cpp file.
2019-02-21 09:57:17 +00:00
Michael Tautschnig ec3ee8e039 byte_extract lowering for complex_typet
It may have worked before via the fallback to flattening of the entire
expression to a bitvector, but let's be on the safe side and construct
appropriate expressions.
2019-02-19 20:41:08 +00:00
Peter Schrammel 7cb1056b45 Add protected do_prop_solve for overriding
This will allow us to count solver invocations
without repeating the code in each propt implementation.
2019-02-18 22:41:39 +00:00
Daniel Kroening a5944a75a9 numeric_cast_v(expr) now requires constant_expr
This is follow-up from a discussion on PR #3998, and a comment by
@tautschnig.

This function always fails, with an exception, when given anything but a
constant_exprt.

This change means that the caller must do the type conversion.  The benefit
is to make the caller more aware of the requirement that this must be a
constant, and to make the caller handle the error appropriately (with an
user-friendly error message) in case this is not possible.

The disadvantage is additional code at the call site.
2019-02-17 16:27:44 +00:00
Daniel Kroening 93d5278b21 simplify_exprt::bits2expr now returns optionalt<exprt>
This prevents accidental modifications of a nil_exprt.
2019-02-16 19:34:52 +00:00
hannes-steffenhagen-diffblue a62b5daf44
Merge pull request #4192 from hannes-steffenhagen-diffblue/string_to_optional
Add string2optional conversion functions
2019-02-15 14:25:36 +00:00
Hannes Steffenhagen e9ccc27f97 Add string2optional conversion functions
These are intended as helpers for when you want to convert a string to
and integer, but don't want to assert the result (e.g. when dealing with
user input there's usually something better you can do than outright
crashing if the conversion fails), but also don't want to deal with
exceptions (which involve more code to write and read and it's easy to
handle the wrong set of exceptions, whether it is too many or too few).
2019-02-15 12:24:04 +00:00
Michael Tautschnig 9a67ec4d55 Lowering of byte_extract over string constants
These need to be handled like arrays of characters.
2019-02-15 09:48:37 +00:00
Michael Tautschnig 004bd27a49 byte_extract lowering of pointers
Bit operations cannot be performed on pointers, thus type cast them to unsigned
bitvectors first and then convert back the result.
2019-02-14 20:52:31 +00:00
Michael Tautschnig 761ad8a2cb byte_extract lowering of unions
We previously handled unions like PODs.
2019-02-14 16:47:04 +00:00
Michael Tautschnig 5c3860636e byte_extract lowering of vectors and array cleanup
Refactor the code used for arrays to make it re-usable for vectors and arrays.
2019-02-14 15:24:53 +00:00
Michael Tautschnig d24e63f018 byte_extract lowering over arrays: fix bits vs bytes error
The offset is computed in bits.
2019-02-14 08:37:52 +00:00
Michael Tautschnig a3d77e6ac0 byte_extract lowering: ensure type consistency
Make sure we construct concatenations that are type consistent.
2019-02-14 07:09:44 +00:00
Daniel Kroening f77bca3dce use goto_progamt::make_X API
This prevents partial construction of instructiont.
2019-02-13 15:45:49 +00:00
Daniel Kroening 9e0c5a3d51 remove the trivial constructor from symex_targett::sourcet
sourcet contains an interator, and the current interface explicitly allows
it to be uninitialised.  However, most parts of the code base access
source.pc without checking.  This commit removes the option to leave the
source uninitialized.
2019-02-12 17:37:29 +00:00
Daniel Kroening e0afefd72c use instructiont::make_goto variant that takes a guard
This prevents partial construction.
2019-02-08 22:04:37 +00:00
Tuttle 01f4ee2672 Added basic block source lines to source_locationt
Block coverage obtained with "cbmc --cover locations" now reports the file name
and line number of every line of source code contributing to a basic block in
the "description" field of the xml output. (The lines contributing to a block
can come from multiple files via function inlining and definitions in include
files, so reporting line numbers alone is not sufficient.)
2019-02-07 20:44:56 +00:00
Michael Tautschnig 864fa155e6 byte_extract lowering: Fail when we _don't_ have a constant
Fixes: #4116
2019-02-07 17:32:35 +00:00
Michael Tautschnig 2dc086356a
Merge pull request #4102 from tautschnig/remove-void_typet
Remove void_typet
2019-02-07 13:11:29 +00:00
Michael Tautschnig 1f94bceb73 byte_extract lowering: lower newly introduced byte_extract expressions
byte_extract lowering must not return any further byte_extract expressions.
2019-02-07 11:24:47 +00:00
Michael Tautschnig e15756d32e Always use empty_typet instead of void_typet
void_typet was only sometimes used.
2019-02-07 11:24:24 +00:00
Michael Tautschnig 5a2df0d8b5 Fixes to the byte_operator lowering unit test
Let's only test byte extracts within bounds for now (there is ample work to be
done to get those right), but make sure there is possible combination for each
pair of types. Endianness needs to be taken into account when constructing the
expected value. Disable any non-POD tests as they all need more work.
2019-02-06 19:02:46 +00:00
Michael Tautschnig 2df457856f Avoid deprecated symbol_exprt default construction in unit test
We don't care about either the type or the name in this test, so just use
symbol_exprt::typeless(irep_idt()).
2019-02-05 19:37:34 +00:00
Thomas Spriggs 52e95a6920 Add try_dynamic_cast from rvalue to optional
This commit adds templates for `expr_try_dynamic_cast` and
`type_try_dynamic_cast` where the parameter is an rvalue and the return
type is an `optionalt`. This is implemented by moving the parameter into
the `optionalt`.

Included are unit tests of the new templates, which show that they
return the types and values expected. As well as tests and a static
assert for the existing overloads which show that they still return a
pointer.

These new templates are useful in the case where we are using the
result of a function, which returns by value but only in the case where
the value can be cast to a given type. For example with the new
overloads the following code can be written -
```
exprt enig();
void handle_struct_case(const struct_exprt &struct_expr);

void myFunction()
{
  if(const auto my_struct = expr_try_dynamic_cast<struct_exprt>(enig()))
    handle_struct_case(*my_struct);
}
```
However without the new templates and because the old ones do not bind
to rvalues, an additional temporary variable otherwise would have to be
declared -
```
void myFunction2()
{
  const exprt enigma = enig();
  if(const auto my_struct = expr_try_dynamic_cast<struct_exprt>(enigma))
    handle_struct_case(*my_struct);
}
```
2019-02-05 12:29:03 +00:00
Michael Tautschnig 69a3cc44a6
Merge pull request #3824 from tautschnig/remove-language_uit
Remove language_uit as it is no longer used
2019-02-04 19:17:29 +00:00
Michael Tautschnig 4adcfd8074
Merge pull request #3126 from diffblue/goto-instruction-function
remove goto_programt::instructiont::function member [blocks: #3113]
2019-02-04 17:16:52 +00:00
Michael Tautschnig 884266786d
Merge pull request #4044 from tautschnig/propt-message-handler
Require a message handler when constructing a propt [blocks: #3800]
2019-02-04 16:48:18 +00:00
Michael Tautschnig 04c337b8a9 Remove unnecessary language_ui.h includes
This isn't used, we use cbmc_parse_optionst here.
2019-02-04 16:38:21 +00:00
Daniel Kroening c9c872e267 remove goto_programt::instructiont::function member 2019-02-04 14:35:09 +00:00
Michael Tautschnig 4cb4bc9653 Cleanup use of messaget in unit tests
Constructing a messaget without a message handler is deprecated. Don't
unnecessarily include iostream, use a (null) message handler instead.
2019-02-03 20:47:19 +00:00
Michael Tautschnig 89641a2b47 Require a message handler when constructing a propt
Constructing a messaget without a message handler is deprecated.
2019-02-03 02:20:18 +00:00
Michael Tautschnig 82e08a7d27 A decision_proceduret does not need a namespace
This is a generic interface towards decisions procedures, there is no reason all
decision procedures should need a namespace.
2019-02-03 01:07:38 +00:00
Daniel Kroening c78f239a09 Fix binary represenation in XML generated from constant_exprt
We no longer use binary as bitvector representation, and thus, conversion
must happen.
2019-02-02 10:15:53 +00:00
Daniel Kroening 4dc7725e34 vector_typet::size() is now a constant_exprt
The codebase assumes basically globally that vector_typet::size() is a
constant_exprt.  This is now enforced by the signature.
2019-02-01 21:03:00 +00:00
Peter Schrammel c74d257a1d
Merge pull request #3968 from peterschrammel/cover-verifier
Add cover goals verifier [blocks: 3969]
2019-02-01 16:01:28 +00:00
Peter Schrammel 27e3efd70b Fix unit test dependencies 2019-02-01 14:13:00 +00:00
Fotis Koutoulakis f98cbed9e7 Add new join_strings function that applies a function to the elements of the container it flattens
and add tests for it.
2019-02-01 11:28:50 +00:00
Michael Tautschnig 1bba22fcb9 Unit test of byte operator lowering
The test attempts to systematically explore combinations of types, and shows a
number of current bugs or limitations.
2019-02-01 07:44:13 +00:00
Romain Brenguier f02417343f
Merge pull request #3977 from romainbrenguier/refactor/bdd-module
Add Cudd as an alternative for miniBDD
2019-02-01 07:33:56 +00:00
Romain Brenguier f1a1bb75d2 Add CUDD to CMake
CMake instructions to download Cudd when the CMAKE_USE_CUDD parameter is
set to true.
2019-02-01 06:48:55 +00:00
Romain Brenguier 488652f96a Unit test for bdd_expr
Add a couple of basic tests for bdd_expr, in order to check that there
is no obvious mistake in the use of BDDs from bdd_expr.
2019-02-01 06:48:51 +00:00
Romain Brenguier 68bfb0b79b Move miniBDD to a new bdd module
This will allow us to have several implementations of BDD among which we
choose at compile time.
2019-02-01 06:48:46 +00:00
Romain Brenguier 8e8d11fb7e Reformatting miniBDD unit test 2019-02-01 06:48:44 +00:00
Peter Schrammel 0ab57df179 Fix whitespace 2019-01-31 15:29:14 +00:00
Peter Schrammel 2fcc886e4c Move counterexample beautification to goto_checker
This is language-independent and can be used by
incremental goto checkers that provide traces.
2019-01-31 15:29:14 +00:00
Fotis Koutoulakis 14cfc086bd Copy constructor parameter instead of storing reference
Previously we stored a reference to the name_prefix parameter in
allocate objects that led to segfaults if it was constructed with
a temporary. Now we store a copy instead, which prevents that from
happening.
2019-01-31 11:02:49 +00:00
Michael Tautschnig 267094c7eb Replace all uses of deprecated symbol_exprt constructors
This helps type safety has it avoids constructing symbol_exprts that never get a
proper type (or identifier).
2019-01-29 18:23:23 +00:00
Michael Tautschnig 0ebe5f4b6f Use .clang-format-ignore
Remove previously added clang-format {off,on} markers from imported code, and
add optional.hpp to the list as well.
2019-01-29 09:43:59 +00:00
Michael Tautschnig d1875dba52
Merge pull request #3965 from tautschnig/vs2013-cleanup
Remove Visual Studio 2013-specific code
2019-01-29 07:06:11 +00:00
Thomas Spriggs 773603cf35 Add support for range to construct json_arrayt and json_objectt
The end result of this commit is that code like the following example
can be used to construct `json_arrayt` / `json_objectt` -
```
const std::vector<std::string> input{"foo", "bar"};
const auto json_array =
make_range(input)
.map(constructor_of<json_stringt>())
.collect<json_arrayt>();
```
This commit includes -
* Constructors from iterators for json_arrayt and json_objectt, so
that the iterators from a range can be used to construct these classes.
* A `collect` member function for `ranget`, so that a chain of range
operations can finish with the construction of a resulting container
containing a collection of the results.
* A `constructor_of` template function, which provides syntactic sugar
when using `map` to call a constructor, compared to writing a new lambda
function each time such an operation is carried out.
* Unit tests covering all of the above functionality.
2019-01-28 17:39:02 +00:00
Thomas Spriggs 5be69b7fd9 Add initializer_list constructor to `json_arrayt`
This new constructor facilitates the construction of instances of
`json_arrayt` which are const, because it gives a tidy way to construct
an entire `json_arrayt`.
2019-01-28 17:39:02 +00:00
Thomas Spriggs a8de5e5c00 Add initializer_list constructor to `json_objectt`
This new constructor facilitates the construction of instances of
`json_objectt` which are const, because it gives a tidy way to construct
an entire `json_objectt`.
2019-01-28 16:44:49 +00:00
Michael Tautschnig 27dd26838b Construct side_effect_expr_nondett with a source location
Construction without a source location is deprecated.
2019-01-27 22:48:32 +00:00
Michael Tautschnig d785393034
Merge pull request #3933 from tautschnig/deprecation-function_callt
Avoid default constructing code_function_callt [blocks: #3800, #3938]
2019-01-27 22:47:16 +00:00
Michael Tautschnig b01d313d55 Remove Visual Studio 2013-specific code
We strictly require Visual Studio 2015 or later in other areas of the code base,
and thus do not need to maintain bits of code that is necessarily dead.
2019-01-27 17:53:57 +00:00
Michael Tautschnig 9976eca8ef Avoid default constructing code_function_callt
Construct them bottom-up, which is more efficient and type safe.
2019-01-26 18:22:19 +00:00
Michael Tautschnig 52d379f8aa Construct code_(do)whilet bottom-up
This is more efficient and type safe as it avoids (deprecated) default
constructing.
2019-01-26 13:12:01 +00:00
Fotis Koutoulakis f6f7ecdbcc
Merge pull request #3920 from hannes-steffenhagen-diffblue/feature-banner_helper
Feature banner helper
2019-01-25 16:56:01 +00:00
Hannes Steffenhagen 73118f0f53 Add helper function for aligning banners 2019-01-25 10:29:44 +00:00
Michael Tautschnig dc4ffae644
Merge pull request #3898 from tautschnig/use-object_descriptor
Extend object_descriptor_exprt::build and use it
2019-01-24 21:18:37 +00:00
Michael Tautschnig 1a0b770aa9
Merge pull request #3912 from tautschnig/irept-opt-constructors
irept constructors to avoid immediate detach() calls
2019-01-24 16:05:41 +00:00
Michael Tautschnig 1e5f423202
Merge pull request #3896 from tautschnig/update-catch
Update CATCH to version 2.5.0
2019-01-24 14:44:20 +00:00
Michael Tautschnig 83af955fc2 Extend object_descriptor_exprt::build and use it
Move the implementation from the unit test to object_descriptor_exprt to have
all users of object_descriptor_exprt benefit from it.
2019-01-24 13:15:55 +00:00
Michael Tautschnig befaff7001 irept constructors to avoid immediate detach() calls
irept construction should not require multiple API calls.
2019-01-24 13:12:20 +00:00
Hannes Steffenhagen 3e0e19b297 Add cmdlinet::option_names
This function can be used to iterate over the command line arguments in
a for-each loop.
2019-01-23 13:55:52 +00:00
Michael Tautschnig 02fe307b7e Update CATCH to version 2.5.0
Downloaded via
https://github.com/catchorg/Catch2/releases/download/v2.5.0/catch.hpp

Version 2 also addresses the only local change we ever had, which was adding
"const &" to the exception type.
2019-01-23 13:38:27 +00:00
Daniel Kroening 2b87abdeed added util/mathematical_expr.h
Following the pattern in util/mathematical_types.h, expression classes that
don't exist immediately in usual programming languages are now in
util/mathematical_expr.h.
2019-01-23 08:22:19 +00:00
Daniel Kroening 6ae7e0e722 remove #include "mathematical_types.h" from std_expr.h
std_expr.h is a frequently used header file; removing the (unused) include
from this file has the potential to improve compile times.
2019-01-22 22:19:10 +00:00
Michael Tautschnig 606ffdfd29 Disable clang-format for catch.hpp
Do not impose formatting rules on imported code.
2019-01-21 20:49:28 +00:00
Michael Tautschnig e8b011e3cf Move catch.hpp to separate folder
This is to avoid direct inclusion of catch.hpp when use_catch.h should be used
instead. The first guard here is module_dependencies.txt, where only
testing-utils must have "catch" listed. The second line of defense is a macro
that must be set.
2019-01-21 20:49:28 +00:00
Michael Tautschnig 7c445677be CATCH: silence Visual Studio warnings
Wrap catch.hpp in a custom header use_catch.h that silences warnings, and make
all files use that header file instead.
2019-01-21 20:49:28 +00:00
Daniel Kroening 93a0994ac5 clang-format the moved files 2019-01-21 15:36:27 +00:00
Daniel Kroening 39a03aad7e move string solver into directory of its own
The string solver is now large enough to justify a separate directory.
2019-01-21 15:21:51 +00:00
Michael Tautschnig 1c12543621
Merge pull request #3623 from tautschnig/struct-union-constructor
Add initializer list constructor to struct/union typet and cleanup API use [blocks: #3597]
2019-01-21 14:59:31 +00:00
Michael Tautschnig 475a7b959b Construct array_exprt in a non-deprecated way
The existing array_exprt constructor relies on other deprecated constructors;
instead introduce a non-deprecated one and use it across the codebase.
2019-01-21 09:26:26 +00:00
Michael Tautschnig 15aef45331 Replace all uses of move_to_operands
move_to_operands is deprecated, use add_to_operands(std::move(...)) or proper
constructors instead.
2019-01-20 20:22:59 +00:00
thomasspriggs 57306338cc
Merge pull request #3833 from thomasspriggs/tas/range_constness
Fix a selection of `const` related issues with `ranget`.
2019-01-19 18:05:32 +00:00
Thomas Spriggs a89ca18e34 Provide `const` dereference of filter / concat iterators only
Deferencing a `const` iterator which refers to a non-const value should
enable mutation of that value. This is consistent with how iterators in
the STL work. It means that we only need to provide a single const
overload of these operators, not both the const and non-const
variations. So the benefit of this commit is better consistency with the
STL and fewer operator overloads to maintain.
2019-01-19 16:12:21 +00:00
Thomas Spriggs 3da70826e8 Add unit test on range.map over a const container
Given that `filter` and `concat` didn't work with const input
collections, it seems prudent to test that `map` works with const input
collections as well. There is no corresponding fix to make this test
pass in this PR.
2019-01-19 16:12:21 +00:00
Thomas Spriggs 256fd817d5 Rename `ranget::value_typet` to `ranget::value_type`
Algorithms which are written expecting a STL container may reference a
`value_type` member, as this is the name of the member in STL
containers. Therefore this needs to be named the same way in `ranget` in
order to be compatible with such algorithms.

This commit includes a unit test of `ranget` having correct the
`value_type` defined.
2019-01-19 16:11:25 +00:00
Thomas Spriggs 6060a878b2 Add `const` to `begin()` accessor of `ranget`
It was previously impossible to iterate over a `const` range, because
you couldn't call `.begin()` on it. This fixes that issue. Changing this
to `const` does not allow the internals of the range to be mutated, as
it returns a copy of the begin iterator, not a reference to it.

This commit adds `const` to ranges in range unit test to show that
ranges can be made const correct, using this fix.
2019-01-19 16:10:11 +00:00
Thomas Spriggs f8738c9943 Fix constness on dereferencing a `concat_iteratort`
Dereferencing a `concat_iteratort` from concating const collections
with `ranget` would previously introduce a compile error, due to a
`const` to non-const conversion. This commit fixes this, by using the
same return type as the iterator which it wraps around.

This commit includes a test for using range to concat `const`
collections.
2019-01-19 16:09:23 +00:00
Thomas Spriggs 4bd2317eb5 Fix constness on dereferencing a `filter_iteratort`
Dereferencing a `filter_iteratort` from filtering a const collection
with `ranget` would previously introduce a compile error, due to a
`const` to non-const conversion. This commit fixes this, by using the
same return type as the iterator which it wraps around.

This commit includes a test for using range to filter a `const`
collection.
2019-01-19 16:08:32 +00:00
Daniel Kroening 2b39c88777 extend constructor of SSA_stept
This enforces initialisation of two members used in all instances of
SSA_stept.
2019-01-19 13:53:05 +00:00
Peter Schrammel 8984eb90ff
Merge pull request #3797 from peterschrammel/refactor-path-strategy-chooser
Remove path strategy chooser from driver
2019-01-16 18:55:34 +00:00
Peter Schrammel 50a9ef1570 Refactor path strategy chooser into free functions
Since keeping an instance is not an option,
we should avoid having to create an instance on every
stateless function call.
2019-01-16 14:47:11 +00:00
Peter Schrammel af893778b2
Merge pull request #3819 from peterschrammel/solver-factory-namespace
Solver factory shouldn't have its own namespacet instance
2019-01-16 14:22:19 +00:00
Peter Schrammel cb18483111 Solver factory shouldn't have its own namespacet instance
The namespace is passed on into the solver allocated.
If the solver factory goes out of scope then the solver
will crash.
2019-01-16 00:22:09 +00:00
thomasspriggs 22f61c2b96
Merge pull request #3811 from thomasspriggs/tas/json_object_algo_support
Improve the support for `json_objectt` usage with STL algorithms.
2019-01-15 18:47:20 +00:00
Thomas Spriggs 07bbc9c609 Add unit test on json_object as output for std::transform
This unit test, tests that the functionality added to `json_objectt` in
the previous commit enables `json_object` to be used as the output
container of `std::transform`. It also tests that `std::inserter` can be
used to construct an `std::insert_iterator<json_objectt>` from a
`json_objectt`. This test is included, because it is good to test new
functionality.
2019-01-15 18:09:05 +00:00
martin 805a80fee9 Fix a typo in the dependencies between the unit tests and src/
This should only affect the case when the main part of CPROVER
hasn't been built but we try to run the test cases first.
2019-01-15 13:27:18 +00:00
Michael Tautschnig ac4ae98a8c Add initializer list constructor to struct/union typet and cleanup API use
Use the rvalue constructor and also review any other use of constructors
to avoid unnecessary copies.
2019-01-14 22:59:01 +00:00
Michael Tautschnig 4022dfbc3a
Merge pull request #3775 from tautschnig/deprecation-struct_exprt
Construct struct_exprt in a non-deprecated way
2019-01-14 08:35:11 +00:00
Michael Tautschnig 3e82e5b0cf Construct struct_exprt in a non-deprecated way
The existing struct_exprt constructor relies on other deprecated constructors;
instead introduce a non-deprecated one and use it across the codebase.
2019-01-13 09:56:38 +00:00
Michael Tautschnig 1ae4c0ba62 Construct array_list_exprt in a non-deprecated way
The existing array_list_exprt constructor relies on other deprecated
constructors; instead introduce a non-deprecated one and use it across the
codebase.
2019-01-13 09:46:30 +00:00
Michael Tautschnig ae003a46d1 Do not use symbol_typet, use struct_tag_typet
We are moving away from symbol types, and code may cease to support symbol ->
struct lookups.
2019-01-11 13:41:02 +00:00
Peter Schrammel c509d28145
Merge pull request #3711 from tautschnig/move-json-xml-expr
Move {json,xml}_expr.{h,cpp} to goto-programs [blocks: #3734, #3736]
2019-01-10 17:56:01 +00:00
Peter Schrammel a08b6cfebb Move symex_bmc and symex_coverage to goto-checker
These classes are language-independent.
2019-01-09 13:39:59 +00:00
Michael Tautschnig b3edca62e2 Move {json,xml}_expr.{h,cpp} to goto-programs
There should not be a dependency from util to langapi, and goto-programs is also
the only place where {json,xml}_expr are used.
2019-01-09 13:39:05 +00:00
Daniel Poetzl a3f38e711a Add unit test to check symbol table JSON input and output format consistency
The unit test first outputs a symbol table to JSON via show_symbol_table() and
then reads it back in again via symbol_table_from_json(). Then, it checks that
the initial symbol table and the symbol table read back in again are equal.
2019-01-09 12:20:32 +00:00
Michael Tautschnig b697346a8e
Merge pull request #3694 from tautschnig/memory_info
Enable memory_info on Windows
2019-01-07 12:30:46 +00:00
Michael Tautschnig cfb691928c Fix simplification of logical right shift of signed bitvectors
C/C++ front-ends generate arithmetic shifts for signed bitvectors, and Java
type-casts signed bitvectors to unsigned for the ">>>" operator. Yet
goto-programs still support logical right shift for both signed and unsigned
bitvectors. Thus the simplifier also needs to handle them correctly.
2019-01-07 11:13:07 +00:00
Michael Tautschnig 16428505ff set_current_path to wrap chdir
chdir is POSIX and will eventually be implemented via
std::filesystem::current_path. Moving this functionality to util helps removing
OS-specific parts from other areas of the code base.

Furthermore make get_temporary_directory return an absolute, resolved path.
2019-01-06 21:58:28 +00:00
Michael Tautschnig 4d6fd7fd53 Enable memory_info on Windows
Updated the output based on Microsoft's documentation and added a unit test (we
don't otherwise use this code within CBMC at the moment).
2019-01-06 11:23:16 +00:00
Michael Tautschnig 162220db6b Avoid shadowing "range"
Just move it to an inner block which is the first (and only) use of this
declaration.
2019-01-04 12:48:54 +00:00
Michael Tautschnig 07ef7501d3 Do not shadow "solvers"
This was fixed in d6da5dd3, but got replaced by the work on solver factories.
2019-01-04 12:48:54 +00:00
owen-jones-diffblue 2ce99a7f71
Merge pull request #3620 from owen-jones-diffblue/fix_doxygen_param_formatting
Fix doxygen param formatting
2019-01-04 10:08:22 +00:00
Joel Allred d32ab69a33
Merge pull request #3601 from tautschnig/json-api
Equip json_arrayt and json_objectt with a full API to enable hiding [blocks: #3602]
2019-01-03 17:55:43 +00:00
Chris Smowton 4b05dcbb7a
Merge pull request #2522 from smowton/smowton/feature/constant-propagator-improvement
Constant propagator: improve GOTO condition propagation
2019-01-03 17:46:36 +00:00
Chris Smowton 897ffdaf17 Constant propagator: improve boolean propagation
This supports propagation of booleans in more situations, including propagating "x != false"
and "IF x" like "IF x == TRUE".
2019-01-03 13:13:28 +00:00
Owen 22370b5a47 Indent continuation lines after \param and \return in doxygen 2019-01-03 11:46:21 +00:00
Michael Tautschnig 5167bcb818 Equip json_arrayt and json_objectt with a full API to enable hiding
As the comment said, various members of jsont should not need to be public.
2019-01-02 22:39:44 +00:00
Michael Tautschnig 3e83ef8c83 Fix type mismatch between value at call site and declaration
All values passed in are of type unsigned long. Also remove an unnecessary const
with a POD parameter type.
2018-12-28 19:57:26 +00:00
Peter Schrammel 0cafa14429
Merge pull request #3610 from tautschnig/whitespace
Fix whitespace in copyright headers
2018-12-21 15:14:59 +00:00
Michael Tautschnig 208197d7df
Merge pull request #3612 from tautschnig/use-throw-as
Use CATCH's REQUIRE_THROWS_AS [blocks: #2310]
2018-12-21 13:52:26 +00:00
Michael Tautschnig 061a1932d0
Merge pull request #3611 from tautschnig/standard-file-headers
Add standard file headers
2018-12-21 13:52:08 +00:00
Michael Tautschnig f3d8b29b77 Use CATCH's REQUIRE_THROWS_AS
This avoids warnings about unused local variables and also is more concise. Also
change one use of REQUIRE_THROWS to the more precise REQUIRE_THROWS_AS to make
sure we are seeing the expected kind of exception.
2018-12-21 11:10:05 +00:00
Michael Tautschnig 37638ceebd Add standard file headers
The author was specified as required by cpplint, but otherwise the header did
not look like the one we usually use.
2018-12-21 10:48:34 +00:00
Michael Tautschnig bc74f24e07 Avoid warning about unused variable
std::distance will do the iteration for us, no need to use a for loop.
2018-12-21 10:07:01 +00:00
Michael Tautschnig 3456903fca Fix whitespace in copyright headers
Uniformly format all Author and Module lines, and remove stray whitespace before
the end-of-header line. Also add in a missing "in" in some files to make the
grammar work out.
2018-12-21 10:04:49 +00:00
Michael Tautschnig a4828df793 Rename SUB_IS_LIST define to NAMED_SUB_IS_FORWARD_LIST
As suggested in code review.
2018-12-20 17:15:16 +00:00
Michael Tautschnig aef1ae90a2 irept: Use singly-linked lists with SUB_IS_LIST
This reduces the memory footprint by up to 5 (GCC's STL) pointers for both
named_sub. The cost is that computing the size of lists and add/remove require
additional iterator increments.
2018-12-20 17:15:16 +00:00
Daniel Kroening 48c40db564 irept: use single map for all named sub-nodes 2018-12-19 22:39:39 +00:00
Michael Tautschnig 28935e6eca
Merge pull request #3409 from tautschnig/big-int-unit-test
Move big-int unit test to unit/ folder and make it a CATCH-style test [blocks: #2452]
2018-12-19 11:45:17 +00:00
Michael Tautschnig e298520729 Fix simplify_extractbit and simplify_extractbits
With hexadecimal coding of constants we need to use expr2bits/bits2expr to
evaluate extractbits, and just the underlying get_bvrep_bit for extractbit. Also
document these expressions to clarify their semantics with regard to endianness.
2018-12-18 18:55:39 +00:00
Michael Tautschnig 0fe5168774 Fix binary value string in XML representation of expressions
The hexadecimal encoding of values implies that the value stored in a constant
cannot directly be used as a binary representation.
2018-12-18 17:37:05 +00:00
Michael Tautschnig aed7857f7a
Merge pull request #3591 from tautschnig/unit-test-bits
Unit test of expr2bits/bits2expr [blocks: #3592]
2018-12-18 17:34:58 +00:00
Michael Tautschnig c384b09636 Unit test of expr2bits/bits2expr
This is just to confirm that these work correctly for either endianness and with
the added work required by hexadecimal value coding.
2018-12-18 16:36:28 +00:00
Fotis Koutoulakis df616e4e1a Add well-formedness checks for symbols.
Add a method that checks a symbol for structural validity
according to some predetermined rule, and add it as an
extra rule for symbol-table validity that each symbol is
well-formed.
2018-12-18 15:45:05 +00:00
Michael Tautschnig 5f55c339ff
Merge pull request #3504 from tautschnig/constructors-ifthenelse
Multi-operand constructor for code_ifthenelset
2018-12-18 13:09:05 +00:00
Thomas Spriggs 0b73746794 Add unit test on ranges of move only values 2018-12-18 10:25:02 +00:00
Peter Schrammel bac549b50b Move cbmc_solvers as solver_factory to goto-checker module
This is the first step of introducing the goto-checker module
which will hold the language-agnostic BMC classes.
2018-12-17 17:58:29 +00:00
Michael Tautschnig 8427934a7e Use code_ifthenelset constructor 2018-12-17 15:40:25 +00:00
Thomas Spriggs 7ba5f29533 Make map work without specifying the type
This commit updates `ranget.map` so that the type is inferred from the
return type of the function passed. This makes the usage of `map` less
verbose and makes it more inline with other `ranget` operations like
`filter`.
2018-12-10 14:08:22 +00:00
Petr Bauch 60a833e927 Program table symbol type consistency
Look up the symbol id in symbol table and call base_type_eq on every symbol
expression in guard and code whenever relevant. Includes a unit test.

Also fixes unit tests that these new checks brake.
2018-12-05 10:50:55 +00:00
Petr Bauch a0289a7dbc Function type consistency between goto programs and symbol table
A simple iteration over goto-functions to check that it's base type is the same
as the one stored in the symbol table. Includes a unit test.
2018-12-05 10:44:37 +00:00
Petr Bauch bc281cc199 Symbol consistency between goto programs and symbol table
Iterate over all symbols in a goto program and for each one check that it is
present in the symbol table as well. Includes a unit test for the check.
2018-12-05 10:43:25 +00:00
Petr Bauch 2c9a5c3679 Well-formedness check for goto instructions
Check that targets are well-formed and consistent.
2018-12-04 08:28:02 +00:00
Petr Bauch c742e853c6 Well-formedness check for function calls and returns
Check that returned types are matching.
2018-12-04 08:26:55 +00:00
Petr Bauch 909f897449 Well-formedness check for assume and assert instructions
Check that the guard evaluates to a Boolean value.
2018-12-04 08:25:28 +00:00
Petr Bauch 5aa708a987 Well-formedness check for decl and dead instructions
Check that declared/removed symbol is known and the statement is valid.
2018-12-04 08:24:08 +00:00
Michael Tautschnig c1e635ce74 Add missing module_dependencies.txt files
The directories had been created before such files were mandated by cpp-lint.
2018-12-02 10:32:27 +00:00
Michael Tautschnig a6e0660f7b
Merge pull request #3287 from xbauch/feature/ssa_validate
Well-formedness checking of SSA equation [depends on #3480]
2018-12-01 18:46:27 +00:00
Petr Bauch eb0b86bef5 Well-formedness checking for SSA
Follows the #3123 skeleton with additional checks in SSA_stept. Adds a condition
such that renaming checks are only run with the validate option.
2018-11-30 10:53:58 +00:00
Hannes Steffenhagen fa39d19e9d Add optional_lookup utility function
This provides a more ergonomic interface over map::find
2018-11-29 17:09:45 +00:00
Romain Brenguier cfb1203bca Unit tests for range
This gives examples of how to use the class.
2018-11-26 10:30:40 +00:00
Michael Tautschnig de0b481f28
Merge pull request #3426 from tautschnig/vs-remove-names
Remove names of unused parameters [blocks: #2310]
2018-11-24 14:22:47 +00:00