Skip to content

Commit 00ead5b

Browse files
author
Daniel Kroening
committed
Merge branch 'master' of github.com:diffblue/cbmc
2 parents 2db41da + f97c169 commit 00ead5b

File tree

12 files changed

+258
-91
lines changed

12 files changed

+258
-91
lines changed

CODING_STANDARD.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ Here a few minimalistic coding rules for the CPROVER source tree.
107107
include in the source file. For example, given `foo.h` and `foo.cpp`, the
108108
line `#include "foo.h"` should precede all other include statements in
109109
`foo.cpp`.
110+
- Use the C++ versions of C headers (e.g. `cmath` instead of `math.h`).
111+
Some of the C headers use macros instead of functions which can have
112+
unexpected consequences.
110113
111114
# Makefiles
112115
- Each source file should appear on a separate line

regression/cbmc/union9/main.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include <stdlib.h>
2+
#include <stdint.h>
3+
4+
typedef union {
5+
struct {
6+
uint8_t x;
7+
uint8_t z;
8+
} b;
9+
} union_t;
10+
11+
typedef struct {
12+
uint32_t magic;
13+
union_t unions[];
14+
} flex;
15+
16+
int flex_init(flex * flex, size_t num)
17+
{
18+
if (num == 0 || num >= 200) {
19+
return -1;
20+
}
21+
flex->unions[num - 1].b.z = 255;
22+
return 0;
23+
}
24+
25+
int main() {
26+
uint8_t num = nondet_size();
27+
flex * pool = (flex *) malloc(sizeof(flex) + num * sizeof(union_t));
28+
int ret = flex_init(pool, num);
29+
if (num > 0 && num < 200) {
30+
__CPROVER_assert(ret == 0, "Accept inside range");
31+
} else {
32+
__CPROVER_assert(ret != 0, "Reject outside range");
33+
}
34+
}
35+

regression/cbmc/union9/test.desc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/test.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ ()
184184
my @list;
185185

186186
opendir CWD, ".";
187-
@list = grep { !/^\./ && -d "$_" && !/CVS/ && -s "$_/test.desc" } readdir CWD;
187+
@list = grep { !/^\./ && -d "$_" && !/CVS/ } readdir CWD;
188188
closedir CWD;
189189

190190
@list = sort @list;

src/goto-programs/cfg.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,31 @@ struct cfg_base_nodet:public graph_nodet<empty_edget>, public T
3131
I PC;
3232
};
3333

34+
/// A multi-procedural control flow graph (CFG) whose nodes store references to
35+
/// instructions in a GOTO program.
36+
///
37+
/// An instance of cfg_baset<T> is a directed graph whose nodes inherit from a
38+
/// user-provided type T and store a pointer to an instruction of some
39+
/// goto program in the field `PC`. The field `PC` of every node points to the
40+
/// original GOTO instruction that gave rise to the node, and the field
41+
/// cfg_baset::entry_map maps every GOTO instruction to some CFG node.
42+
///
43+
/// The CFG is constructed on the operator() from either one goto_programt or
44+
/// multiple goto_programt objects (stored in a goto_functionst). The edges of
45+
/// the CFG are created on the method compute_edges(), and notably include:
46+
///
47+
/// - Edges from location A to B if both A and B belong to the same
48+
/// goto_programt and A can flow into B.
49+
/// - An edge from each FUNCTION_CALL instruction and the first instruction of
50+
/// the called function, when that function body is available and its body is
51+
/// non-empty.
52+
/// - For each FUNCTION_CALL instruction found, an edge between the exit point
53+
/// of the called function and the instruction immediately after the
54+
/// FUNCTION_CALL, when the function body is available and its body is
55+
/// non-empty.
56+
///
57+
/// Note that cfg_baset is the base class of many other subclasses and the
58+
/// specific edges constructed by operator() can be different in those.
3459
template<class T,
3560
typename P=const goto_programt,
3661
typename I=goto_programt::const_targett>

src/goto-programs/goto_program.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ std::ostream &goto_programt::output_instruction(
3333
return output_instruction(ns, identifier, out, *it);
3434
}
3535

36-
/// Writes to out a two line string representation of the specific instruction.
37-
/// It is of the format: // {location} file {source file} line {line in source
38-
/// file} {representation of the instruction}
36+
/// Writes to \p out a two/three line string representation of a given
37+
/// \p instruction. The output is of the format:
38+
/// ```
39+
/// // {location} file {source file} line {line in source file}
40+
/// // Labels: {list-of-labels}
41+
/// {representation of the instruction}
42+
/// ```
3943
/// \param ns: the namespace to resolve the expressions in
4044
/// \param identifier: the identifier used to find a symbol to identify the
4145
/// source language

0 commit comments

Comments
 (0)