-
Notifications
You must be signed in to change notification settings - Fork 274
Add bit vector extract operation support to incremental SMT2 solving #6654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bit vector extract operation support to incremental SMT2 solving #6654
Conversation
This resolves clang-tidy warnings in the definitions of the theories due to "initialization with static storage duration may throw an exception that cannot be caught".
src/util/type_traits.h
Outdated
// Author: Diffblue Ltd. | ||
|
||
/// \file | ||
/// Back ports of utilities available in the `<type_traits>` library for C++14 | ||
/// or C++17 to C++11. These can be replaced with the standard library versions | ||
/// as and when we upgrade the version CBMC is compiled with. | ||
|
||
#ifndef CPROVER_UTIL_TYPE_TRAITS_H | ||
#define CPROVER_UTIL_TYPE_TRAITS_H | ||
|
||
#include <type_traits> | ||
|
||
template <bool value> | ||
using bool_constant = std::integral_constant<bool, value>; | ||
|
||
namespace detail // NOLINT | ||
{ | ||
// Implementation detail of `void_t`. | ||
template <typename... typest> | ||
struct make_voidt | ||
{ | ||
using type = void; | ||
}; | ||
} // namespace detail | ||
|
||
// Back ported from C++17 STL. | ||
template <typename... typest> | ||
using void_t = typename detail::make_voidt<typest...>::type; | ||
|
||
#endif // CPROVER_UTIL_TYPE_TRAITS_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to move this to the only file actually using it and also #ifdef
it with compiler versions (__cplusplus
). Or, at bare minimum, make the comments sufficiently detailed to explain what exactly the code should look like once we move to C++14 (as is done in file_util.h
or optional.h
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am more than happy to add extra comments detailing how to transition to using the C++17 version in preparation for the move to that standard. However given that the back ported version will compile with either standards version, is it worth complicating things with different code for different standards, based on the version in __cplusplus
?
Codecov Report
@@ Coverage Diff @@
## develop #6654 +/- ##
===========================================
+ Coverage 76.73% 76.76% +0.03%
===========================================
Files 1579 1582 +3
Lines 181994 182357 +363
===========================================
+ Hits 139650 139984 +334
- Misses 42344 42373 +29
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have performed a partial review so far, but I have a couple questions.
TEST_CASE("Test smt_indext.pretty is accessible.", "[core][smt2_incremental]") | ||
{ | ||
const smt_indext index = smt_numeral_indext{42}; | ||
REQUIRE(index.pretty(0, 0) == "smt_numeral_index\n * value: 42"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is based on the assumption that .pretty()
is always going to return text of a specific format.
I'm not sure if this assumption is always supposed to hold.
If the aim of the test is to make sure that pretty()
is accessible, why not just make sure that it's not the empty string? And if you need to make sure that the value is there, make a substring search on that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this test would need to be updated if pretty
were to change the formatting returned. I'll just check for non-empty instead, to make this less brittle.
} | ||
SECTION("Symbol") | ||
{ | ||
REQUIRE(smt_symbol_indext{"foo"}.identifier() == "foo"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you create a smt_symbol_indext{""}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the constructed instant will contain the empty string. Are you suggesting an additional invariant?
de618c0
to
6edaf35
Compare
This is implemented using sfinae to detect if the supplied `functiont` has an `indices` member function or not, so that it is unneccessary to add an `indices` member function which returns the empty collections of indicies for the cases where `function` needs a simple (non indexed) identifier. `type_traits.h` is in `solvers/smt2_incremental/` because this is the only part of the codebase where it is currently used and keeping it here means the PR with this commit should need fewer code reviewer approvals.
Because adding an include in the following commit will cause clang-format to re-order the includes. Doing the reorder in advance makes it possible to review the re-ordering and the additional include separately.
30d747b
to
8edd58d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, just a couple of questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concerns have been adequately addressed.
This PR adds support for the bit vector extract operation to the incremental SMT2 solving code. It is separated out from other additions to the bit vector theory, due to the need to add more generalised support for indexed identifiers and the dependency in turn on the back porting of
std::void_t
.