Skip to content

Commit f1b6ac4

Browse files
authored
Merge branch 'diffblue:develop' into develop
2 parents cae2e42 + f6f7057 commit f1b6ac4

File tree

4 files changed

+184
-20
lines changed

4 files changed

+184
-20
lines changed

COMPILING.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -577,27 +577,12 @@ make test
577577

578578
## Rust API
579579

580-
CBMC is now offering a [Rust API](src/libcprover-rust/). To build that along with
581-
CBMC, you need two things:
580+
CBMC is now offering a [Rust API](src/libcprover-rust/).
582581

583-
- Rust/Cargo, instructions the installation of which can be found [here](https://www.rust-lang.org/tools/install), and
584-
- CMake (the Rust API doesn't support being built with `Make` yet)
585-
- Version `3.19.0`+ is required for the build, because of a dependency on CMake modules
586-
that need the higher version themselves.
587-
588-
Provided these two are available, you can perform a CBMC build *including*
589-
the Rust API by passing in the option `WITH_RUST_API` to `CMake` like this:
590-
591-
```sh
592-
$ cmake -S. -Bbuild -DWITH_RUST_API=ON <other_options>
593-
[...]
594-
-- Rust Target: aarch64-apple-darwin
595-
-- Found Rust: /opt/homebrew/bin/rustc (found version "1.66.1")
596-
-- Using Corrosion as a subdirectory
597-
-- Configuring done
598-
-- Generating done
599-
-- Build files have been written to: cbmc/build
600-
```
582+
The Rust API used to be built along with CBMC, but we have since decoupled that
583+
to be built on its own. Instructions for doing so are in the project's
584+
[`readme.md`](src/libcprover-rust/readme.md), which are also mirrored
585+
on the crate's webpage at [crates.io](https://crates.io/crates/libcprover_rust).
601586

602587
If you come across any issues during the configuration or the build of the Rust API,
603588
please let us know by filing a [bug report](https://github.com/diffblue/cbmc/issues/new)

src/goto-instrument/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ SRC = accelerate/accelerate.cpp \
2121
contracts/dynamic-frames/dfcc_loop_nesting_graph.cpp \
2222
contracts/dynamic-frames/dfcc_contract_mode.cpp \
2323
contracts/dynamic-frames/dfcc_loop_contract_mode.cpp \
24+
contracts/dynamic-frames/dfcc_loop_tags.cpp \
2425
contracts/dynamic-frames/dfcc_library.cpp \
2526
contracts/dynamic-frames/dfcc_is_cprover_symbol.cpp \
2627
contracts/dynamic-frames/dfcc_is_fresh.cpp \
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
/*******************************************************************\
2+
3+
Module: Dynamic frame condition checking
4+
5+
Author: Qinheping Hu, [email protected]
6+
Author: Remi Delmas, [email protected]
7+
8+
\*******************************************************************/
9+
10+
#include "dfcc_loop_tags.h"
11+
12+
const irep_idt ID_loop_id = "loop-id";
13+
const irep_idt ID_loop_head = "loop-head";
14+
const irep_idt ID_loop_body = "loop-body";
15+
const irep_idt ID_loop_latch = "loop-latch";
16+
const irep_idt ID_loop_exiting = "loop-exiting";
17+
const irep_idt ID_loop_top_level = "loop-top-level";
18+
19+
void dfcc_set_loop_id(
20+
goto_programt::instructiont::targett &target,
21+
const std::size_t loop_id)
22+
{
23+
target->source_location_nonconst().set(ID_loop_id, loop_id);
24+
}
25+
26+
optionalt<std::size_t>
27+
dfcc_get_loop_id(const goto_programt::instructiont::targett &target)
28+
{
29+
if(target->source_location_nonconst().get(ID_loop_id).empty())
30+
return {};
31+
32+
return target->source_location_nonconst().get_size_t(ID_loop_id);
33+
}
34+
35+
bool dfcc_has_loop_id(
36+
const goto_programt::instructiont::targett &target,
37+
std::size_t loop_id)
38+
{
39+
auto loop_id_opt = dfcc_get_loop_id(target);
40+
return loop_id_opt.has_value() && loop_id_opt.value() == loop_id;
41+
}
42+
43+
static void dfcc_set_loop_tag(
44+
goto_programt::instructiont::targett &target,
45+
const irep_idt &tag)
46+
{
47+
target->source_location_nonconst().set(tag, true);
48+
}
49+
50+
static bool has_loop_tag(
51+
const goto_programt::instructiont::targett &target,
52+
const irep_idt &tag)
53+
{
54+
return target->source_location().get_bool(tag);
55+
}
56+
57+
void dfcc_set_loop_head(goto_programt::instructiont::targett &target)
58+
{
59+
dfcc_set_loop_tag(target, ID_loop_head);
60+
}
61+
62+
bool dfcc_is_loop_head(const goto_programt::instructiont::targett &target)
63+
{
64+
return has_loop_tag(target, ID_loop_head);
65+
}
66+
67+
void dfcc_set_loop_body(goto_programt::instructiont::targett &target)
68+
{
69+
dfcc_set_loop_tag(target, ID_loop_body);
70+
}
71+
72+
bool dfcc_is_loop_body(const goto_programt::instructiont::targett &target)
73+
{
74+
return has_loop_tag(target, ID_loop_body);
75+
}
76+
77+
void dfcc_set_loop_exiting(goto_programt::instructiont::targett &target)
78+
{
79+
dfcc_set_loop_tag(target, ID_loop_exiting);
80+
}
81+
82+
bool dfcc_is_loop_exiting(const goto_programt::instructiont::targett &target)
83+
{
84+
return has_loop_tag(target, ID_loop_exiting);
85+
}
86+
87+
void dfcc_set_loop_latch(goto_programt::instructiont::targett &target)
88+
{
89+
dfcc_set_loop_tag(target, ID_loop_latch);
90+
}
91+
92+
bool dfcc_is_loop_latch(const goto_programt::instructiont::targett &target)
93+
{
94+
return has_loop_tag(target, ID_loop_latch);
95+
}
96+
97+
void dfcc_set_loop_top_level(goto_programt::instructiont::targett &target)
98+
{
99+
dfcc_set_loop_tag(target, ID_loop_top_level);
100+
}
101+
102+
bool dfcc_is_loop_top_level(const goto_programt::instructiont::targett &target)
103+
{
104+
return has_loop_tag(target, ID_loop_top_level);
105+
}
106+
107+
void dfcc_remove_loop_tags(source_locationt &source_location)
108+
{
109+
source_location.remove(ID_loop_id);
110+
source_location.remove(ID_loop_head);
111+
source_location.remove(ID_loop_body);
112+
source_location.remove(ID_loop_exiting);
113+
source_location.remove(ID_loop_latch);
114+
source_location.remove(ID_loop_top_level);
115+
}
116+
117+
void dfcc_remove_loop_tags(goto_programt::targett &target)
118+
{
119+
dfcc_remove_loop_tags(target->source_location_nonconst());
120+
}
121+
122+
void dfcc_remove_loop_tags(goto_programt &goto_program)
123+
{
124+
for(auto target = goto_program.instructions.begin();
125+
target != goto_program.instructions.end();
126+
target++)
127+
{
128+
dfcc_remove_loop_tags(target);
129+
}
130+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*******************************************************************\
2+
3+
Module: Dynamic frame condition checking for loop contracts
4+
5+
Author: Qinheping Hu, [email protected]
6+
Author: Remi Delmas, [email protected]
7+
8+
\*******************************************************************/
9+
10+
/// \file
11+
/// Functions that allow to tag GOTO instructions with loop identifiers and
12+
/// loop instruction type: head, body, exiting, latch.
13+
14+
#ifndef CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_LOOP_TAGS_H
15+
#define CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_LOOP_TAGS_H
16+
17+
#include <goto-programs/goto_program.h>
18+
19+
void dfcc_set_loop_id(
20+
goto_programt::instructiont::targett &target,
21+
std::size_t loop_id);
22+
23+
bool dfcc_has_loop_id(
24+
const goto_programt::instructiont::targett &target,
25+
std::size_t loop_id);
26+
27+
optionalt<std::size_t>
28+
dfcc_get_loop_id(const goto_programt::instructiont::targett &target);
29+
30+
void dfcc_set_loop_head(goto_programt::instructiont::targett &target);
31+
bool dfcc_is_loop_head(const goto_programt::instructiont::targett &target);
32+
33+
void dfcc_set_loop_body(goto_programt::instructiont::targett &target);
34+
bool dfcc_is_loop_body(const goto_programt::instructiont::targett &target);
35+
36+
void dfcc_set_loop_exiting(goto_programt::instructiont::targett &target);
37+
bool dfcc_is_loop_exiting(const goto_programt::instructiont::targett &target);
38+
39+
void dfcc_set_loop_latch(goto_programt::instructiont::targett &target);
40+
bool dfcc_is_loop_latch(const goto_programt::instructiont::targett &target);
41+
42+
void dfcc_set_loop_top_level(goto_programt::instructiont::targett &target);
43+
bool dfcc_is_loop_top_level(const goto_programt::instructiont::targett &target);
44+
45+
void dfcc_remove_loop_tags(source_locationt &source_location);
46+
void dfcc_remove_loop_tags(goto_programt &goto_program);
47+
void dfcc_remove_loop_tags(goto_programt::targett &target);
48+
#endif

0 commit comments

Comments
 (0)