File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,25 @@ The primary focus of this project is to validate a reasonable subset of C++ cont
18
18
with assertions, and to support [ C++26] ( https://en.cppreference.com/w/cpp/language/contracts.html )
19
19
as these first class contracts are supported by compilers.
20
20
21
+ ``` cpp
22
+ void f (int x) {
23
+ /* @ requires @* /
24
+ assert(x > 0);
25
+ }
26
+
27
+ void g() {
28
+ f(0); // contract violation
29
+ }
30
+ ```
31
+
32
+ Contract violations are discovered through a combination of CodeQL range analysis and SMT constraint generation that is then solved by Z3.
33
+
34
+ We currently support the following types of assertions:
35
+ - `assert` macros that have been annotated `/*@ requires @*/`.
36
+ - `BSLS_ASSERT` from [BDE](https://bloomberg.github.io/bde/).
37
+
38
+ In the future, we hope to support C++26 contract specifiers `pre(...)` and `post(...)`.
39
+
21
40
This project also serves as a useful example that may benefit other languages, and the availability
22
41
of Z3 inside CodeQL queries may have other useful applications that may deserve to be integrated
23
42
into this project in the future.
You can’t perform that action at this time.
0 commit comments