Skip to content

Commit a9bc909

Browse files
author
Daniel Kroening
committed
Merge branch 'master' of github.com:diffblue/cbmc
2 parents fa47d99 + e3ad659 commit a9bc909

File tree

123 files changed

+598
-161
lines changed

Some content is hidden

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

123 files changed

+598
-161
lines changed

appveyor.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ test_script:
7575
cat goto-instrument-typedef/chain.sh || true
7676
7777
rem HACK disable failing tests
78+
rmdir /s /q ansi-c\arch_flags_mcpu_bad
79+
rmdir /s /q ansi-c\arch_flags_mcpu_good
80+
rmdir /s /q ansi-c\arch_flags_mthumb_bad
81+
rmdir /s /q ansi-c\arch_flags_mthumb_good
7882
rmdir /s /q ansi-c\Forward_Declaration2
7983
rmdir /s /q ansi-c\Incomplete_Type1
8084
rmdir /s /q ansi-c\Union_Padding1

regression/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,10 @@ DIRS = ansi-c \
1212

1313
test:
1414
$(foreach var,$(DIRS), $(MAKE) -C $(var) test || exit 1;)
15+
16+
clean:
17+
@for dir in *; do \
18+
if [ -d "$$dir" ]; then \
19+
$(MAKE) -C "$$dir" clean; \
20+
fi; \
21+
done;
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int foo() { return 3; }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int bar(){ return 9; }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CORE
2+
preproc.i
3+
-mcpu=cortex-a15 -o linked-object.gb object.intel
4+
^EXIT=(64|1)$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
9+
--
10+
This tests the -mcpu=cortex=a15 flag that should activate ARM-32 mode.
11+
The object file 'object.intel' was compiled from 'source.c' with goto-cc
12+
on a 64-bit platform:
13+
14+
goto-cc -c source.c
15+
16+
preproc.i is already pre-processed so that it can be linked in without
17+
needing to invoke a pre-processor from a cross-compile toolchain on your
18+
local machine. Linking it together with the Intel object file, while
19+
passing -mcpu=cortex-a15 on the command line, should fail because
20+
-mcpu=cortex-a15 implies that we're trying to make an ARM executable.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int foo() { return 3; }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int bar(){ return 9; }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CORE
2+
preproc.i
3+
-mcpu=cortex-a15 -o linked-object.gb object.arm
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
9+
--
10+
This tests the -mcpu=cortex-a15 flag that should activate ARM-32 mode.
11+
The object file 'object.arm' was compiled from 'source.c' with goto-cc
12+
along with an ARM cross-compiler on a 64-bit platform with the following
13+
command line:
14+
15+
goto-cc --native-compiler=arm-none-eabi-gcc -mcpu=cortex-a15 -c source.c
16+
17+
preproc.i is already pre-processed so that it can be linked in without
18+
needing to invoke a pre-processor from a cross-compile toolchain on your
19+
local machine. Linking it together with the ARM object file, while
20+
passing -mcpu=cortex-a15 on the command line, should succeed.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int foo() { return 3; }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int bar(){ return 9; }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CORE
2+
preproc.i
3+
-mthumb -o linked-object.gb object.intel
4+
^EXIT=(64|1)$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
9+
--
10+
This tests the -mthumb flag that should activate ARM-32 mode. The object
11+
file 'object.intel' was compiled from 'source.c' with goto-cc on a
12+
64-bit platform:
13+
14+
goto-cc -c source.c
15+
16+
preproc.i is already pre-processed so that it can be linked in without
17+
needing to invoke a pre-processor from a cross-compile toolchain on your
18+
local machine. Linking it together with the Intel object file, while
19+
passing -mthumb on the command line, should fail because -mthumb implies
20+
that we're trying to make an ARM executable.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int foo() { return 3; }
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int bar(){ return 9; }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CORE
2+
preproc.i
3+
-mthumb -o linked-object.gb object.arm
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$
9+
--
10+
This tests the -mthumb flag that should activate ARM-32 mode. The object
11+
file 'object.arm' was compiled from 'source.c' with goto-cc along with
12+
an ARM cross-compiler on a 64-bit platform with the following command
13+
line:
14+
15+
goto-cc --native-compiler=arm-none-eabi-gcc -mthumb -c source.c
16+
17+
preproc.i is already pre-processed so that it can be linked in without
18+
needing to invoke a pre-processor from a cross-compile toolchain on your
19+
local machine. Linking it together with the ARM object file, while
20+
passing -mthumb on the command line, should succeed.

regression/cbmc/void_pointer1/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
char buffer[2];
2+
int length = 2;
3+
4+
void func(void* buf, int len)
5+
{
6+
while( len-- )
7+
*(char *)buf++;
8+
}
9+
10+
void main(){
11+
func(buffer,length);
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--pointer-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/cbmc/void_pointer2/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
char buffer[2];
2+
int length = 2;
3+
4+
void func(void* buf, int len)
5+
{
6+
while( len-- )
7+
*(char *)buf++;
8+
}
9+
10+
void main(){
11+
func(buffer,length);
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--pointer-check --no-simplify --unwind 3
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring

regression/goto-analyzer/constant_propagation_10/constant_propagation_10.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ int main()
44
signed int i;
55
signed int j;
66
i = 0;
7-
if(!(i >= 2))
7+
if(!(i >= 2))
88
{
99
j = j + 1;
1010
i = i + 1;

src/analyses/dependence_graph.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ Date: August 2013
1111

1212
#include <cassert>
1313

14+
#include <util/json.h>
15+
#include <util/json_expr.h>
16+
1417
#include "goto_rw.h"
1518

1619
#include "dependence_graph.h"
@@ -347,6 +350,46 @@ void dep_graph_domaint::output(
347350

348351
/*******************************************************************\
349352
353+
Function: dep_graph_domaint::output_json
354+
355+
Inputs: The abstract interpreter and the namespace.
356+
357+
Outputs: The domain, formatted as a JSON object.
358+
359+
Purpose: Outputs the current value of the domain.
360+
361+
\*******************************************************************/
362+
363+
jsont dep_graph_domaint::output_json(
364+
const ai_baset &ai,
365+
const namespacet &ns) const
366+
{
367+
json_arrayt graph;
368+
369+
for(const auto &cd : control_deps)
370+
{
371+
json_objectt &link=graph.push_back().make_object();
372+
link["locationNumber"]=
373+
json_numbert(std::to_string(cd->location_number));
374+
link["sourceLocation"]=json(cd->source_location);
375+
link["type"]=json_stringt("control");
376+
}
377+
378+
for(const auto &dd : data_deps)
379+
{
380+
json_objectt &link=graph.push_back().make_object();
381+
link["locationNumber"]=
382+
json_numbert(std::to_string(dd->location_number));
383+
link["sourceLocation"]=json(dd->source_location);
384+
json_stringt(dd->source_location.as_string());
385+
link["type"]=json_stringt("data");
386+
}
387+
388+
return graph;
389+
}
390+
391+
/*******************************************************************\
392+
350393
Function: dependence_grapht::add_dep
351394
352395
Inputs:

src/analyses/dependence_graph.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ class dep_graph_domaint:public ai_domain_baset
8787
const ai_baset &ai,
8888
const namespacet &ns) const final;
8989

90-
void make_top() final
90+
jsont output_json(
91+
const ai_baset &ai,
92+
const namespacet &ns) const override;
93+
94+
void make_top() final override
9195
{
9296
assert(node_id!=std::numeric_limits<node_indext>::max());
9397

src/analyses/goto_check.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,8 @@ void goto_checkt::bounds_check(
12381238
plus_exprt effective_offset(ode.offset(), pointer_offset(pointer));
12391239

12401240
assert(effective_offset.op0().type()==effective_offset.op1().type());
1241-
assert(effective_offset.type()==size.type());
1241+
if(effective_offset.type()!=size.type())
1242+
size.make_typecast(effective_offset.type());
12421243

12431244
binary_relation_exprt inequality(effective_offset, ID_lt, size);
12441245

src/analyses/goto_rw.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ void rw_range_sett::get_objects_complex(
149149

150150
range_spect sub_size=
151151
to_range_spect(pointer_offset_bits(op.type().subtype(), ns));
152+
assert(sub_size>0);
152153
range_spect offset=
153154
(range_start==-1 || expr.id()==ID_complex_real) ? 0 : sub_size;
154155

src/analyses/interval_domain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ bool interval_domaint::merge(
157157
for(int_mapt::iterator it=int_map.begin();
158158
it!=int_map.end(); ) // no it++
159159
{
160-
//search for the variable that needs to be merged
161-
//containers have different size and variable order
160+
// search for the variable that needs to be merged
161+
// containers have different size and variable order
162162
const int_mapt::const_iterator b_it=b.int_map.find(it->first);
163163
if(b_it==b.int_map.end())
164164
{

src/analyses/invariant_set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Author: Daniel Kroening, [email protected]
1616
#include <util/base_type.h>
1717
#include <util/std_types.h>
1818

19-
#include <ansi-c/c_types.h>
19+
#include <util/c_types.h>
2020
#include <langapi/language_util.h>
2121

2222
#include "invariant_set.h"

src/analyses/local_bitvector_analysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/std_code.h>
1414
#include <util/expr_util.h>
1515

16-
#include <ansi-c/c_types.h>
16+
#include <util/c_types.h>
1717
#include <langapi/language_util.h>
1818

1919
#include "local_bitvector_analysis.h"

src/analyses/local_cfg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Author: Daniel Kroening, [email protected]
1414
#include <util/std_code.h>
1515
#include <util/expr_util.h>
1616

17-
#include <ansi-c/c_types.h>
17+
#include <util/c_types.h>
1818
#include <langapi/language_util.h>
1919

2020
#endif

src/analyses/local_may_alias.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/std_expr.h>
1414
#include <util/std_code.h>
1515

16-
#include <ansi-c/c_types.h>
16+
#include <util/c_types.h>
1717
#include <langapi/language_util.h>
1818

1919
#include "local_may_alias.h"

src/ansi-c/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ SRC = anonymous_member.cpp \
2424
c_typecheck_initializer.cpp \
2525
c_typecheck_type.cpp \
2626
c_typecheck_typecast.cpp \
27-
c_types.cpp \
2827
cprover_library.cpp \
2928
designator.cpp \
3029
expr2c.cpp \

src/ansi-c/ansi_c_convert_type.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Author: Daniel Kroening, [email protected]
88

99
#include <cassert>
1010

11+
#include <util/c_types.h>
1112
#include <util/namespace.h>
1213
#include <util/simplify_expr.h>
1314
#include <util/config.h>

src/ansi-c/ansi_c_convert_type.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include <util/message.h>
1313

14-
#include "c_types.h"
1514
#include "c_qualifiers.h"
1615
#include "c_storage_spec.h"
1716

src/ansi-c/ansi_c_entry_point.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Author: Daniel Kroening, [email protected]
1717
#include <util/cprover_prefix.h>
1818
#include <util/prefix.h>
1919

20-
#include <ansi-c/c_types.h>
20+
#include <util/c_types.h>
2121
#include <ansi-c/string_constant.h>
2222

2323
#include <goto-programs/goto_functions.h>

src/ansi-c/c_nondet_symbol_factory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Author: DiffBlue Limited. All rights reserved.
1010
#include <sstream>
1111

1212
#include <util/arith_tools.h>
13+
#include <util/c_types.h>
1314
#include <util/fresh_symbol.h>
1415
#include <util/std_types.h>
1516
#include <util/std_code.h>
@@ -20,7 +21,6 @@ Author: DiffBlue Limited. All rights reserved.
2021

2122
#include <linking/zero_initializer.h>
2223

23-
#include <ansi-c/c_types.h>
2424
#include <ansi-c/string_constant.h>
2525

2626
#include <goto-programs/goto_functions.h>

src/ansi-c/c_preprocess.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Author: Daniel Kroening, [email protected]
2121

2222
#include <fstream>
2323

24+
#include <util/c_types.h>
2425
#include <util/config.h>
2526
#include <util/message.h>
2627
#include <util/tempfile.h>
@@ -29,7 +30,6 @@ Author: Daniel Kroening, [email protected]
2930
#include <util/std_types.h>
3031
#include <util/prefix.h>
3132

32-
#include "c_types.h"
3333
#include "c_preprocess.h"
3434

3535
#define GCC_DEFINES_16 \

src/ansi-c/c_sizeof.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ Author: Daniel Kroening, [email protected]
66
77
\*******************************************************************/
88

9+
#include <util/c_types.h>
910
#include <util/config.h>
1011
#include <util/arith_tools.h>
1112
#include <util/simplify_expr.h>
1213
#include <util/std_expr.h>
1314

1415
#include "c_sizeof.h"
1516
#include "c_typecast.h"
16-
#include "c_types.h"
1717

1818
/*******************************************************************\
1919

0 commit comments

Comments
 (0)