Skip to content

Commit 318c9a5

Browse files
committed
Remove infinity_exprt
This removes `infinity_exprt` together with all its uses, where were all about array size. Any such arrays were replaced by arrays of the maximum viable size.
1 parent d2b4455 commit 318c9a5

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

+97
-204
lines changed

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ refined_string_exprt java_string_library_preprocesst::replace_char_array(
450450
get_length(array, symbol_table), char_array, refined_string_type);
451451

452452
const dereference_exprt inf_array(
453-
char_array, array_typet(java_char_type(), infinity_exprt(java_int_type())));
453+
char_array, array_typet(java_char_type(), java_int_type().largest_expr()));
454454

455455
add_pointer_to_array_association(
456456
string_expr.content(), inf_array, symbol_table, loc, function_id, code);
@@ -619,7 +619,7 @@ exprt make_nondet_infinite_char_array(
619619
code_blockt &code)
620620
{
621621
const array_typet array_type(
622-
java_char_type(), infinity_exprt(java_int_type()));
622+
java_char_type(), java_int_type().largest_expr());
623623
const symbolt data_sym = fresh_java_symbol(
624624
pointer_type(array_type),
625625
"nondet_infinite_array_pointer",

jbmc/unit/solvers/strings/string_constraint_instantiation/instantiate_not_contains.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ class tt
4040
{
4141
return java_char_type();
4242
}
43-
typet length_type() const
43+
signedbv_typet length_type() const
4444
{
4545
return java_int_type();
4646
}
4747
array_typet array_type() const
4848
{
49-
return array_typet(char_type(), infinity_exprt(length_type()));
49+
return array_typet(char_type(), length_type().largest_expr());
5050
}
5151
refined_string_typet string_type() const
5252
{
5353
return refined_string_typet(length_type(), pointer_type(char_type()));
5454
}
5555
array_typet witness_type() const
5656
{
57-
return array_typet(length_type(), infinity_exprt(length_type()));
57+
return array_typet(length_type(), length_type().largest_expr());
5858
}
5959
};
6060

jbmc/unit/solvers/strings/string_refinement/dependency_graph.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ Author: Diffblue Ltd.
2121
#include <java_bytecode/java_bytecode_language.h>
2222
#endif
2323

24-
typet length_type()
24+
signedbv_typet length_type()
2525
{
2626
return signedbv_typet(32);
2727
}
2828

2929
/// Make a struct with a pointer content and an integer length
3030
struct_exprt make_string_argument(std::string name)
3131
{
32-
const array_typet char_array(char_type(), infinity_exprt(length_type()));
32+
const array_typet char_array(char_type(), length_type().largest_expr());
3333
struct_typet type(
3434
{{"length", length_type()}, {"content", pointer_type(char_array)}});
3535

regression/cbmc-concurrency/thread_chain_cbmc1/main.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
typedef unsigned long thread_id_t;
1919

2020
// Internal unbounded array indexed by local thread identifiers
21-
__CPROVER_bool __CPROVER_threads_exited[__CPROVER_constant_infinity_uint];
21+
__CPROVER_bool __CPROVER_threads_exited
22+
[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
2223

2324
// A thread_chain is like a chain of threads `f, g, ...` where `f`
2425
// must terminate before `g` can start to run, and so forth.

regression/cbmc-concurrency/thread_chain_cbmc2/main.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
typedef unsigned long thread_id_t;
1919

2020
// Internal unbounded array indexed by local thread identifiers
21-
__CPROVER_bool __CPROVER_threads_exited[__CPROVER_constant_infinity_uint];
21+
__CPROVER_bool __CPROVER_threads_exited
22+
[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
2223

2324
// A thread_chain is like a chain of threads `f, g, ...` where `f`
2425
// must terminate before `g` can start to run, and so forth.

regression/cbmc-cpp/Vector1/lib/list

+2-2
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,10 @@ namespace std {
372372
#ifdef VERS1
373373
unsigned _version;
374374
#elif defined VERS2
375-
unsigned _version[__CPROVER::constant_infinity_uint];
375+
unsigned _version[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
376376
#endif
377377

378-
T _data[__CPROVER::constant_infinity_uint];
378+
T _data[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
379379
};
380380

381381
}

regression/cbmc-cpp/Vector1/lib/vector

+2-2
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,10 @@ namespace std {
416416
#ifdef VERS1
417417
unsigned _version;
418418
#elif defined VERS2
419-
unsigned _version[__CPROVER::constant_infinity_uint];
419+
unsigned _version[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
420420
#endif
421421

422-
T _data[__CPROVER::constant_infinity_uint];
422+
T _data[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
423423
};
424424

425425
}

regression/cbmc-cpp/initialization5/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <cassert>
2-
int a[__CPROVER::constant_infinity_uint];
2+
int a[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
33

44
struct A
55
{
6-
int i[__CPROVER::constant_infinity_uint];
6+
int i[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
77
};
88

99
A o;

regression/cbmc/Unbounded_Array5/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
int mem[__CPROVER_constant_infinity_uint];
1+
int mem[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
22

33
int main()
44
{

regression/cbmc/array_of_bool_as_bitvec/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <stdlib.h>
44

55
__CPROVER_bool w[8];
6-
__CPROVER_bool v[__CPROVER_constant_infinity_uint];
6+
__CPROVER_bool v[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
77

88
void main()
99
{

regression/contracts/is_unique_01_replace/main.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bool ptr_ok(int *x)
1818
/*
1919
Here are the meanings of the predicates:
2020
21-
static _Bool __foo_memory_map[__CPROVER_constant_infinity_uint];
21+
static _Bool __foo_memory_map[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
2222
2323
bool __foo_requires_is_fresh(void **elem, size_t size) {
2424
*elem = malloc(size);

src/ansi-c/ansi_c_internal_additions.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,10 @@ void ansi_c_internal_additions(std::string &code, bool support_float16_type)
142142
"typedef __typeof__(sizeof(int)) " CPROVER_PREFIX "size_t;\n"
143143
"typedef "+c_type_as_string(signed_size_type().get(ID_C_c_type))+
144144
" " CPROVER_PREFIX "ssize_t;\n"
145-
"const unsigned " CPROVER_PREFIX "constant_infinity_uint;\n"
146145
"typedef void " CPROVER_PREFIX "integer;\n"
147146
"typedef void " CPROVER_PREFIX "rational;\n"
148147
"extern unsigned char " CPROVER_PREFIX "memory["
149-
CPROVER_PREFIX "constant_infinity_uint];\n"
148+
"(" CPROVER_PREFIX "size_t)1 << (sizeof(" CPROVER_PREFIX "_size_t) * 8 - 2)];\n"
150149

151150
// malloc
152151
"const void *" CPROVER_PREFIX "deallocated=0;\n"
@@ -169,13 +168,13 @@ void ansi_c_internal_additions(std::string &code, bool support_float16_type)
169168
code+=
170169
// this is ANSI-C
171170
"extern " CPROVER_PREFIX "thread_local const char __func__["
172-
CPROVER_PREFIX "constant_infinity_uint];\n"
171+
"(" CPROVER_PREFIX "size_t)1 << (sizeof(" CPROVER_PREFIX "size_t) * 8 - 2)];\n"
173172

174173
// this is GCC
175174
"extern " CPROVER_PREFIX "thread_local const char __FUNCTION__["
176-
CPROVER_PREFIX "constant_infinity_uint];\n"
175+
"(" CPROVER_PREFIX "size_t)1 << (sizeof(" CPROVER_PREFIX "size_t) * 8 - 2)];\n"
177176
"extern " CPROVER_PREFIX "thread_local const char __PRETTY_FUNCTION__["
178-
CPROVER_PREFIX "constant_infinity_uint];\n"
177+
"(" CPROVER_PREFIX "size_t)1 << (sizeof(" CPROVER_PREFIX "size_t) * 8 - 2)];\n"
179178

180179
// float stuff
181180
"int " CPROVER_PREFIX "thread_local " +

src/ansi-c/c_typecheck_expr.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,6 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr)
178178
typecheck_expr_side_effect(to_side_effect_expr(expr));
179179
else if(expr.is_constant())
180180
typecheck_expr_constant(expr);
181-
else if(expr.id()==ID_infinity)
182-
{
183-
// ignore
184-
}
185181
else if(expr.id()==ID_symbol)
186182
typecheck_expr_symbol(expr);
187183
else if(expr.id()==ID_unary_plus ||
@@ -885,13 +881,6 @@ void c_typecheck_baset::typecheck_expr_symbol(exprt &expr)
885881
// preserve location
886882
expr.add_source_location()=source_location;
887883
}
888-
else if(identifier.starts_with(CPROVER_PREFIX "constant_infinity"))
889-
{
890-
expr=infinity_exprt(symbol.type);
891-
892-
// put it back
893-
expr.add_source_location()=source_location;
894-
}
895884
else if(identifier=="__func__" ||
896885
identifier=="__FUNCTION__" ||
897886
identifier=="__PRETTY_FUNCTION__")
@@ -4637,9 +4626,6 @@ class is_compile_time_constantt
46374626
/// "constants"
46384627
bool is_constant(const exprt &e) const
46394628
{
4640-
if(e.id() == ID_infinity)
4641-
return true;
4642-
46434629
if(e.is_constant())
46444630
return true;
46454631

src/ansi-c/c_typecheck_initializer.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@ exprt c_typecheck_baset::do_initializer_rec(
223223

224224
void c_typecheck_baset::do_initializer(symbolt &symbol)
225225
{
226-
// this one doesn't need initialization
227-
if(symbol.name.starts_with(CPROVER_PREFIX "constant_infinity"))
228-
return;
229-
230226
if(symbol.is_type)
231227
return;
232228

src/ansi-c/c_typecheck_type.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,6 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
581581

582582
size=tmp_size;
583583
}
584-
else if(tmp_size.id()==ID_infinity)
585-
{
586-
size=tmp_size;
587-
}
588584
else if(tmp_size.id()==ID_symbol &&
589585
tmp_size.type().get_bool(ID_C_constant))
590586
{

src/ansi-c/expr2c.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -4110,7 +4110,6 @@ std::optional<std::string> expr2ct::convert_function(const exprt &src)
41104110
{ID_get_must, CPROVER_PREFIX "get_must"},
41114111
{ID_ieee_float_equal, "IEEE_FLOAT_EQUAL"},
41124112
{ID_ieee_float_notequal, "IEEE_FLOAT_NOTEQUAL"},
4113-
{ID_infinity, "INFINITY"},
41144113
{ID_is_dynamic_object, "IS_DYNAMIC_OBJECT"},
41154114
{ID_is_invalid_pointer, "IS_INVALID_POINTER"},
41164115
{ID_is_invalid_pointer, CPROVER_PREFIX "is_invalid_pointer"},

src/ansi-c/goto-conversion/goto_check_c.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -1680,9 +1680,6 @@ void goto_check_ct::bounds_check_index(
16801680
// Linking didn't complete, we don't have a size.
16811681
// Not clear what to do.
16821682
}
1683-
else if(size.id() == ID_infinity)
1684-
{
1685-
}
16861683
else if(
16871684
expr.array().id() == ID_member &&
16881685
(size.is_zero() || array_type.get_bool(ID_C_flexible_array_member)))

src/ansi-c/library/cprover.h

-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ typedef __typeof__(sizeof(int)) __CPROVER_size_t;
1818
// NOLINTNEXTLINE(readability/identifiers)
1919
typedef signed long long __CPROVER_ssize_t;
2020

21-
#define __CPROVER_constant_infinity_uint 1
22-
2321
void *__CPROVER_allocate(__CPROVER_size_t size, __CPROVER_bool zero);
2422
void __CPROVER_deallocate(void *);
2523
extern const void *__CPROVER_deallocated;

src/ansi-c/library/pthread_lib.c

+28-18
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,18 @@ int pthread_mutex_destroy(pthread_mutex_t *mutex)
291291
#define __CPROVER_PTHREAD_H_INCLUDED
292292
#endif
293293

294-
__CPROVER_bool __CPROVER_threads_exited[__CPROVER_constant_infinity_uint];
294+
// Clang refuses anything larger than SIZE_MAX/8, thus using - 4 in the shift
295+
// expression below
296+
__CPROVER_bool __CPROVER_threads_exited
297+
[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 4)];
295298
__CPROVER_thread_local unsigned long __CPROVER_thread_id = 0;
296299
#if 0
297300
// Destructor support is disabled as it is too expensive due to its extensive
298301
// use of shared variables.
299302
__CPROVER_thread_local const void
300-
*__CPROVER_thread_keys[__CPROVER_constant_infinity_uint];
303+
*__CPROVER_thread_keys[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 4)];
301304
__CPROVER_thread_local void (
302-
*__CPROVER_thread_key_dtors[__CPROVER_constant_infinity_uint])(void *);
305+
*__CPROVER_thread_key_dtors[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 4)])(void *);
303306
__CPROVER_thread_local unsigned long __CPROVER_next_thread_key = 0;
304307
#endif
305308

@@ -337,7 +340,10 @@ void pthread_exit(void *value_ptr)
337340
#define __CPROVER_ERRNO_H_INCLUDED
338341
#endif
339342

340-
__CPROVER_bool __CPROVER_threads_exited[__CPROVER_constant_infinity_uint];
343+
// Clang refuses anything larger than SIZE_MAX/8, thus using - 4 in the shift
344+
// expression below
345+
__CPROVER_bool __CPROVER_threads_exited
346+
[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 4)];
341347
#ifndef LIBRARY_CHECK
342348
__CPROVER_thread_local unsigned long __CPROVER_thread_id = 0;
343349
#endif
@@ -376,7 +382,8 @@ __CPROVER_HIDE:;
376382
#endif
377383

378384
#ifdef __APPLE__
379-
__CPROVER_bool __CPROVER_threads_exited[__CPROVER_constant_infinity_uint];
385+
__CPROVER_bool __CPROVER_threads_exited
386+
[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
380387
# ifndef LIBRARY_CHECK
381388
__CPROVER_thread_local unsigned long __CPROVER_thread_id = 0;
382389
unsigned long __CPROVER_next_thread_id = 0;
@@ -544,17 +551,20 @@ int pthread_rwlock_wrlock(pthread_rwlock_t *lock)
544551

545552
/* FUNCTION: __spawned_thread */
546553

547-
__CPROVER_bool __CPROVER_threads_exited[__CPROVER_constant_infinity_uint];
554+
// Clang refuses anything larger than SIZE_MAX/8, thus using - 4 in the shift
555+
// expression below
556+
__CPROVER_bool __CPROVER_threads_exited
557+
[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 4)];
548558
#ifndef LIBRARY_CHECK
549559
__CPROVER_thread_local unsigned long __CPROVER_thread_id = 0;
550560
#endif
551561
#if 0
552562
// Destructor support is disabled as it is too expensive due to its extensive
553563
// use of shared variables.
554564
__CPROVER_thread_local const void
555-
*__CPROVER_thread_keys[__CPROVER_constant_infinity_uint];
565+
*__CPROVER_thread_keys[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)];
556566
__CPROVER_thread_local void (
557-
*__CPROVER_thread_key_dtors[__CPROVER_constant_infinity_uint])(void *);
567+
*__CPROVER_thread_key_dtors[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)])(void *);
558568
#endif
559569
__CPROVER_thread_local unsigned long __CPROVER_next_thread_key = 0;
560570

@@ -618,7 +628,7 @@ __CPROVER_HIDE:;
618628
unsigned long __CPROVER_next_thread_id = 0;
619629
# if 0
620630
__CPROVER_thread_local void (
621-
*__CPROVER_thread_key_dtors[__CPROVER_constant_infinity_uint])(void *);
631+
*__CPROVER_thread_key_dtors[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)])(void *);
622632
# endif
623633
__CPROVER_thread_local unsigned long __CPROVER_next_thread_key = 0;
624634
#endif
@@ -952,12 +962,12 @@ int pthread_barrier_wait(pthread_barrier_t *barrier)
952962
#define __CPROVER_PTHREAD_H_INCLUDED
953963
#endif
954964

955-
__CPROVER_thread_local const void
956-
*__CPROVER_thread_keys[__CPROVER_constant_infinity_uint];
965+
__CPROVER_thread_local const void *__CPROVER_thread_keys
966+
[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 1 - sizeof(void *))];
957967
#ifndef LIBRARY_CHECK
958968
# if 0
959969
__CPROVER_thread_local void (
960-
*__CPROVER_thread_key_dtors[__CPROVER_constant_infinity_uint])(void *);
970+
*__CPROVER_thread_key_dtors[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 2)])(void *);
961971
# endif
962972
__CPROVER_thread_local unsigned long __CPROVER_next_thread_key = 0;
963973
#endif
@@ -984,8 +994,8 @@ __CPROVER_HIDE:;
984994
#define __CPROVER_PTHREAD_H_INCLUDED
985995
#endif
986996

987-
__CPROVER_thread_local const void
988-
*__CPROVER_thread_keys[__CPROVER_constant_infinity_uint];
997+
__CPROVER_thread_local const void *__CPROVER_thread_keys
998+
[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 1 - sizeof(void *))];
989999

9901000
int pthread_key_delete(pthread_key_t key)
9911001
{
@@ -1001,8 +1011,8 @@ __CPROVER_HIDE:;
10011011
#define __CPROVER_PTHREAD_H_INCLUDED
10021012
#endif
10031013

1004-
__CPROVER_thread_local const void
1005-
*__CPROVER_thread_keys[__CPROVER_constant_infinity_uint];
1014+
__CPROVER_thread_local const void *__CPROVER_thread_keys
1015+
[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 1 - sizeof(void *))];
10061016

10071017
void *pthread_getspecific(pthread_key_t key)
10081018
{
@@ -1017,8 +1027,8 @@ __CPROVER_HIDE:;
10171027
#define __CPROVER_PTHREAD_H_INCLUDED
10181028
#endif
10191029

1020-
__CPROVER_thread_local const void
1021-
*__CPROVER_thread_keys[__CPROVER_constant_infinity_uint];
1030+
__CPROVER_thread_local const void *__CPROVER_thread_keys
1031+
[(__CPROVER_size_t)1 << (sizeof(__CPROVER_size_t) * 8 - 1 - sizeof(void *))];
10221032

10231033
int pthread_setspecific(pthread_key_t key, const void *value)
10241034
{

0 commit comments

Comments
 (0)