Skip to content

Commit 87cccf3

Browse files
authored
Merge branch 'diffblue:develop' into develop
2 parents 020120a + 159af34 commit 87cccf3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+879
-507
lines changed

.github/workflows/pull-request-check-clang-format.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set -e
77
echo "Pull request's base branch is: ${BASE_BRANCH}"
88
echo "Pull request's merge branch is: ${MERGE_BRANCH}"
99
echo "Pull request's source branch is: ${GITHUB_HEAD_REF}"
10-
clang-format-11 --version
10+
clang-format-15 --version
1111

1212
# The checkout action leaves us in detatched head state. The following line
1313
# names the checked out commit, for simpler reference later.
@@ -26,7 +26,7 @@ echo "Checking for formatting errors introduced since $MERGE_BASE"
2626

2727
# Do the checking. "eval" is used so that quotes (as inserted into $EXCLUDES
2828
# above) are not interpreted as parts of file names.
29-
eval git-clang-format-11 --binary clang-format-11 $MERGE_BASE -- $EXCLUDES
29+
eval git-clang-format-15 --binary clang-format-15 $MERGE_BASE -- $EXCLUDES
3030
git diff > formatted.diff
3131
if [[ -s formatted.diff ]] ; then
3232
echo 'Formatting error! The following diff shows the required changes'

.github/workflows/syntax-checks.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
# This job takes approximately 1 minute
88
check-clang-format:
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-24.04
1010
steps:
1111
- uses: actions/checkout@v4
1212
with:
@@ -19,8 +19,8 @@ jobs:
1919
DEBIAN_FRONTEND: noninteractive
2020
run: |
2121
sudo apt-get update
22-
sudo apt-get install --no-install-recommends -yq clang-format-11
23-
- name: Check updated lines of code match clang-format-11 style
22+
sudo apt-get install --no-install-recommends -yq clang-format-15
23+
- name: Check updated lines of code match clang-format-15 style
2424
env:
2525
BASE_BRANCH: ${{ github.base_ref }}
2626
MERGE_BRANCH: ${{ github.ref }}

CODING_STANDARD.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,13 @@ Now, you can commit and push the formatting fixes.
340340
To avoid waiting until you've made a PR to find formatting issues, you can
341341
install clang-format locally and run it against your code as you are working.
342342

343-
Different versions of clang-format have slightly different behaviors. CBMC uses
344-
clang-format-11 as it is available the repositories for Ubuntu 20.04 and
345-
Homebrew.
346-
To install on a Unix-like system, try installing using the system package
347-
manager:
343+
Different versions of clang-format have slightly different behaviors. CBMC
344+
uses clang-format-15, or later, available in the standard Ubuntu 24.04 and
345+
Homebrew repositories. To install on a Unix-like system, try installing
346+
using the system package manager:
348347
```
349-
apt-get install clang-format-11 # Run this on Ubuntu, Debian etc.
350-
brew install clang-format@11 # Run this on a Mac with Homebrew installed
348+
apt-get install clang-format # Run this on Ubuntu, Debian etc.
349+
brew install clang-format # Run this on a Mac with Homebrew installed
351350
```
352351

353352
If your platform doesn't have a package for clang-format, you can download a
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
file_with_no_newline.i
3+
4+
^file_with_no_newline\.i((:[01]:1)|(\(1\))): error: .*$
5+
^EXIT=(1|64)$
6+
^SIGNAL=0$
7+
--
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
syntax error, no newline here ->

regression/cbmc-library/__sort_of_CPROVER_round_to_integral-01/main.c

Lines changed: 0 additions & 9 deletions
This file was deleted.

regression/cbmc-library/__sort_of_CPROVER_round_to_integralf-01/main.c

Lines changed: 0 additions & 9 deletions
This file was deleted.

regression/cbmc-library/__sort_of_CPROVER_round_to_integralf-01/test.desc

Lines changed: 0 additions & 8 deletions
This file was deleted.

regression/cbmc-library/__sort_of_CPROVER_round_to_integrall-01/main.c

Lines changed: 0 additions & 9 deletions
This file was deleted.

regression/cbmc-library/__sort_of_CPROVER_round_to_integrall-01/test.desc

Lines changed: 0 additions & 8 deletions
This file was deleted.

regression/cbmc/Pointer_array8/main.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#pragma pack(push)
2+
#pragma pack(1)
3+
typedef struct
4+
{
5+
int data[2];
6+
} arr;
7+
8+
typedef struct
9+
{
10+
arr vec[2];
11+
} arrvec;
12+
#pragma pack(pop)
13+
14+
int main()
15+
{
16+
arrvec A;
17+
arrvec *x = &A;
18+
__CPROVER_assume(x->vec[1].data[0] < 42);
19+
unsigned k;
20+
__CPROVER_assert(k != 2 || ((int *)x)[k] < 42, "");
21+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
KNOWNBUG
1+
CORE no-new-smt
22
main.c
3-
--pointer-check --bounds-check
3+
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$

regression/cbmc/array-cell-sensitivity15/test.desc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ access.c
33
--program-only
44
^EXIT=0$
55
^SIGNAL=0$
6-
s!0@1#2\.\.n == \{ s!0@1#1\.\.n\[\[0\]\], s!0@1#1\.\.n\[\[1\]\], s!0@1#1\.\.n\[\[2\]\], s!0@1#1\.\.n\[\[3\]\] } WITH \[\(.*\)i!0@1#2:=k!0@1#1\]
6+
s!0@1#2\.\.n ==.*\{ s!0@1#1\.\.n\[\[0\]\], s!0@1#1\.\.n\[\[1\]\], s!0@1#1\.\.n\[\[2\]\], s!0@1#1\.\.n\[\[3\]\] \}
77
--
8-
byte_update
98
--
109
This tests applying field-sensitivity to a pointer to an array that is part of a struct. See cbmc issue #5397 and PR #5418 for more detail.
1110
Disabled for paths-lifo mode, which does not support --program-only.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
(set-logic FP)
2+
3+
(define-fun zero () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 0))
4+
(define-fun minus-zero () (_ FloatingPoint 11 53) (fp.neg zero))
5+
(define-fun one () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 1))
6+
(define-fun minus-one () (_ FloatingPoint 11 53) (fp.neg one))
7+
(define-fun zero-point-one () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 0.1))
8+
(define-fun minus-zero-point-one () (_ FloatingPoint 11 53) (fp.neg zero-point-one))
9+
(define-fun ten-point-one () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 10.1))
10+
(define-fun minus-ten-point-one () (_ FloatingPoint 11 53) (fp.neg ten-point-one))
11+
(define-fun ten () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 10))
12+
(define-fun minus-ten () (_ FloatingPoint 11 53) (fp.neg ten))
13+
(define-fun eleven () (_ FloatingPoint 11 53) ((_ to_fp 11 53) RNE 11))
14+
(define-fun minus-eleven () (_ FloatingPoint 11 53) (fp.neg eleven))
15+
(define-fun magic () (_ FloatingPoint 11 53) (fp #b0 #b10000110011 #x0000000000000))
16+
(define-fun dmax () (_ FloatingPoint 11 53) (fp #b0 #b11111111110 #xFFFFFFFFFFFFF))
17+
18+
(assert (not (and
19+
20+
; round up
21+
(= (fp.roundToIntegral RTP (_ NaN 11 53)) (_ NaN 11 53))
22+
(= (fp.roundToIntegral RTP (_ +oo 11 53)) (_ +oo 11 53))
23+
(= (fp.roundToIntegral RTP (_ -oo 11 53)) (_ -oo 11 53))
24+
(= (fp.roundToIntegral RTP zero) zero)
25+
(= (fp.roundToIntegral RTP minus-zero) minus-zero)
26+
(= (fp.roundToIntegral RTP one) one)
27+
(= (fp.roundToIntegral RTP zero-point-one) one)
28+
(= (fp.roundToIntegral RTP minus-zero-point-one) minus-zero)
29+
(= (fp.roundToIntegral RTP ten-point-one) eleven)
30+
(= (fp.roundToIntegral RTP minus-ten-point-one) minus-ten)
31+
(= (fp.roundToIntegral RTP magic) magic)
32+
(= (fp.roundToIntegral RTP dmax) dmax)
33+
34+
; round down
35+
(= (fp.roundToIntegral RTN (_ NaN 11 53)) (_ NaN 11 53))
36+
(= (fp.roundToIntegral RTN (_ +oo 11 53)) (_ +oo 11 53))
37+
(= (fp.roundToIntegral RTN (_ -oo 11 53)) (_ -oo 11 53))
38+
(= (fp.roundToIntegral RTN zero) zero)
39+
(= (fp.roundToIntegral RTN minus-zero) minus-zero)
40+
(= (fp.roundToIntegral RTN one) one)
41+
(= (fp.roundToIntegral RTN zero-point-one) zero)
42+
(= (fp.roundToIntegral RTN minus-zero-point-one) minus-one)
43+
(= (fp.roundToIntegral RTN ten-point-one) ten)
44+
(= (fp.roundToIntegral RTN minus-ten-point-one) minus-eleven)
45+
(= (fp.roundToIntegral RTN magic) magic)
46+
(= (fp.roundToIntegral RTN dmax) dmax)
47+
48+
; round to nearest ties to even
49+
(= (fp.roundToIntegral RNE (_ NaN 11 53)) (_ NaN 11 53))
50+
(= (fp.roundToIntegral RNE (_ +oo 11 53)) (_ +oo 11 53))
51+
(= (fp.roundToIntegral RNE (_ -oo 11 53)) (_ -oo 11 53))
52+
(= (fp.roundToIntegral RNE zero) zero)
53+
(= (fp.roundToIntegral RNE minus-zero) minus-zero)
54+
(= (fp.roundToIntegral RNE one) one)
55+
(= (fp.roundToIntegral RNE zero-point-one) zero)
56+
(= (fp.roundToIntegral RNE minus-zero-point-one) minus-zero)
57+
(= (fp.roundToIntegral RNE ten-point-one) ten)
58+
(= (fp.roundToIntegral RNE minus-ten-point-one) minus-ten)
59+
(= (fp.roundToIntegral RNE magic) magic)
60+
(= (fp.roundToIntegral RNE dmax) dmax)
61+
62+
; round to zero
63+
(= (fp.roundToIntegral RTZ (_ NaN 11 53)) (_ NaN 11 53))
64+
(= (fp.roundToIntegral RTZ (_ +oo 11 53)) (_ +oo 11 53))
65+
(= (fp.roundToIntegral RTZ (_ -oo 11 53)) (_ -oo 11 53))
66+
(= (fp.roundToIntegral RTZ zero) zero)
67+
(= (fp.roundToIntegral RTZ minus-zero) minus-zero)
68+
(= (fp.roundToIntegral RTZ one) one)
69+
(= (fp.roundToIntegral RTZ zero-point-one) zero)
70+
(= (fp.roundToIntegral RTZ minus-zero-point-one) minus-zero)
71+
(= (fp.roundToIntegral RTZ ten-point-one) ten)
72+
(= (fp.roundToIntegral RTZ minus-ten-point-one) minus-ten)
73+
(= (fp.roundToIntegral RTZ magic) magic)
74+
(= (fp.roundToIntegral RTZ dmax) dmax)
75+
76+
; round to nearest ties to away
77+
(= (fp.roundToIntegral RNA (_ NaN 11 53)) (_ NaN 11 53))
78+
(= (fp.roundToIntegral RNA (_ +oo 11 53)) (_ +oo 11 53))
79+
(= (fp.roundToIntegral RNA (_ -oo 11 53)) (_ -oo 11 53))
80+
(= (fp.roundToIntegral RNA zero) zero)
81+
(= (fp.roundToIntegral RNA minus-zero) minus-zero)
82+
(= (fp.roundToIntegral RNA one) one)
83+
(= (fp.roundToIntegral RNA zero-point-one) zero)
84+
(= (fp.roundToIntegral RNA minus-zero-point-one) minus-zero)
85+
(= (fp.roundToIntegral RNA ten-point-one) ten)
86+
(= (fp.roundToIntegral RNA minus-ten-point-one) minus-ten)
87+
(= (fp.roundToIntegral RNA magic) magic)
88+
(= (fp.roundToIntegral RNA dmax) dmax)
89+
)))
90+
91+
; should be unsat
92+
(check-sat)

src/ansi-c/ansi_c_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,13 @@ void ansi_c_parsert::set_pragma_cprover()
208208
for(const auto &pragma : pragma_set)
209209
flattened[pragma.first] = pragma.second;
210210

211-
source_location.remove(ID_pragma);
211+
_source_location.remove(ID_pragma);
212212

213213
for(const auto &pragma : flattened)
214214
{
215215
std::string check_name = id2string(pragma.first);
216216
std::string full_name =
217217
(pragma.second ? "enable:" : "disable:") + check_name;
218-
source_location.add_pragma(full_name);
218+
_source_location.add_pragma(full_name);
219219
}
220220
}

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3249,6 +3249,24 @@ exprt c_typecheck_baset::do_special_functions(
32493249

32503250
return std::move(infl_expr);
32513251
}
3252+
else if(
3253+
identifier == CPROVER_PREFIX "round_to_integralf" ||
3254+
identifier == CPROVER_PREFIX "round_to_integrald" ||
3255+
identifier == CPROVER_PREFIX "round_to_integralld")
3256+
{
3257+
if(expr.arguments().size() != 2)
3258+
{
3259+
error().source_location = f_op.source_location();
3260+
error() << identifier << " expects two arguments" << eom;
3261+
throw 0;
3262+
}
3263+
3264+
auto round_to_integral_expr =
3265+
floatbv_round_to_integral_exprt{expr.arguments()[0], expr.arguments()[1]};
3266+
round_to_integral_expr.add_source_location() = source_location;
3267+
3268+
return std::move(round_to_integral_expr);
3269+
}
32523270
else if(
32533271
identifier == CPROVER_PREFIX "abs" || identifier == CPROVER_PREFIX "labs" ||
32543272
identifier == CPROVER_PREFIX "llabs" ||

src/ansi-c/cprover_builtin_headers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ int __CPROVER_islessgreaterf(float f, float g);
9494
int __CPROVER_islessgreaterd(double f, double g);
9595
int __CPROVER_isunorderedf(float f, float g);
9696
int __CPROVER_isunorderedd(double f, double g);
97+
float __CPROVER_round_to_integralf(float, int);
98+
double __CPROVER_round_to_integrald(double, int);
99+
long double __CPROVER_round_to_integralld(long double, int);
97100

98101
// absolute value
99102
int __CPROVER_abs(int x);

0 commit comments

Comments
 (0)