Skip to content

Commit 47e426f

Browse files
author
Thomas Kiley
authored
Merge pull request #1442 from andreast271/compilation-NDEBUG-enable
Enable compilation with NDEBUG defined
2 parents 869043a + 764c651 commit 47e426f

33 files changed

+126
-101
lines changed

src/ansi-c/c_nondet_symbol_factory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ exprt c_nondet_symbol_factory(
236236

237237
symbolt *main_symbol_ptr;
238238
bool moving_symbol_failed=symbol_table.move(main_symbol, main_symbol_ptr);
239-
assert(!moving_symbol_failed);
239+
CHECK_RETURN(!moving_symbol_failed);
240240

241241
std::vector<symbolt const *> symbols_created;
242242
symbol_exprt main_symbol_expr=(*main_symbol_ptr).symbol_expr();

src/ansi-c/c_typecheck_initializer.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ void c_typecheck_baset::do_initializer(
3333

3434
if(type.id()==ID_array)
3535
{
36-
// any arrays must have a size
3736
const typet &result_type=follow(result.type());
38-
assert(result_type.id()==ID_array &&
39-
to_array_type(result_type).size().is_not_nil());
37+
DATA_INVARIANT(result_type.id()==ID_array &&
38+
to_array_type(result_type).size().is_not_nil(),
39+
"any array must have a size");
4040

4141
// we don't allow initialisation with symbols of array type
4242
if(result.id()!=ID_array)
@@ -436,9 +436,11 @@ exprt::operandst::const_iterator c_typecheck_baset::do_designated_initializer(
436436
throw 0;
437437
}
438438

439-
assert(index<components.size());
440-
assert(components[index].type().id()!=ID_code &&
441-
!components[index].get_is_padding());
439+
DATA_INVARIANT(index<components.size(),
440+
"member designator is bounded by components size");
441+
DATA_INVARIANT(components[index].type().id()!=ID_code &&
442+
!components[index].get_is_padding(),
443+
"member designator points at data member");
442444

443445
dest=&(dest->operands()[index]);
444446
}
@@ -449,7 +451,8 @@ exprt::operandst::const_iterator c_typecheck_baset::do_designated_initializer(
449451
const union_typet::componentst &components=
450452
union_type.components();
451453

452-
assert(index<components.size());
454+
DATA_INVARIANT(index<components.size(),
455+
"member designator is bounded by components size");
453456

454457
const union_typet::componentt &component=union_type.components()[index];
455458

src/cpp/cpp_typecheck_compound_type.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
535535
vt_symb_type.is_type=true;
536536

537537
const bool failed=!symbol_table.insert(std::move(vt_symb_type)).second;
538-
assert(!failed);
538+
CHECK_RETURN(!failed);
539539

540540
// add a virtual-table pointer
541541
struct_typet::componentt compo;
@@ -611,7 +611,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
611611

612612
// add the parameter to the symbol table
613613
const bool failed=!symbol_table.insert(std::move(arg_symb)).second;
614-
assert(!failed);
614+
CHECK_RETURN(!failed);
615615
}
616616

617617
// do the body of the function
@@ -669,7 +669,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
669669
// add the function to the symbol table
670670
{
671671
const bool failed=!symbol_table.insert(std::move(func_symb)).second;
672-
assert(!failed);
672+
CHECK_RETURN(!failed);
673673
}
674674

675675
// next base

src/cpp/cpp_typecheck_constructor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ void cpp_typecheckt::default_assignop_value(
486486

487487
mp_integer size;
488488
bool to_int=to_integer(size_expr, size);
489-
assert(!to_int);
490-
assert(size>=0);
489+
CHECK_RETURN(!to_int);
490+
CHECK_RETURN(size>=0);
491491

492492
exprt::operandst empty_operands;
493493
for(mp_integer i=0; i < size; ++i)

src/cpp/cpp_typecheck_initializer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ void cpp_typecheckt::zero_initializer(
215215
mp_integer size;
216216

217217
bool to_int=to_integer(size_expr, size);
218-
assert(!to_int);
219-
assert(size>=0);
218+
CHECK_RETURN(!to_int);
219+
CHECK_RETURN(size>=0);
220220

221221
exprt::operandst empty_operands;
222222
for(mp_integer i=0; i<size; ++i)

src/cpp/cpp_typecheck_resolve.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2125,7 +2125,8 @@ void cpp_typecheck_resolvet::apply_template_args(
21252125
const struct_typet &struct_type=
21262126
to_struct_type(type_symb.type);
21272127

2128-
assert(struct_type.has_component(new_symbol.name));
2128+
DATA_INVARIANT(struct_type.has_component(new_symbol.name),
2129+
"method should exist in struct");
21292130
member_exprt member(code_type);
21302131
member.set_component_name(new_symbol.name);
21312132
member.struct_op()=*fargs.operands.begin();

src/cpp/cpp_typecheck_virtual_table.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@ void cpp_typecheckt::do_virtual_table(const symbolt &symbol)
9696
vt_symb_var.value=values;
9797

9898
bool failed=!symbol_table.insert(std::move(vt_symb_var)).second;
99-
assert(!failed);
99+
CHECK_RETURN(!failed);
100100
}
101101
}

src/goto-instrument/accelerate/polynomial.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ int monomialt::compare(monomialt &other)
409409
return -1;
410410
}
411411

412-
assert(!"NOTREACHEDBITCHES");
412+
UNREACHABLE;
413413
}
414414

415415
int polynomialt::max_degree(const exprt &var)

src/goto-instrument/accelerate/util.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,6 @@ typet join_types(const typet &t1, const typet &t2)
117117
std::cerr << "Tried to join types: "
118118
<< t1.pretty() << " and " << t2.pretty()
119119
<< '\n';
120-
assert(!"Couldn't join types");
120+
121+
INVARIANT(false, "failed to join types");
121122
}

src/goto-instrument/full_slicer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ void full_slicert::add_jumps(
185185
if(cfg[entry->second].node_required)
186186
{
187187
const irep_idt id2=goto_programt::get_function_id(*d_it);
188-
assert(id==id2);
188+
INVARIANT(id==id2,
189+
"goto/jump expected to be within a single function");
189190

190191
cfg_post_dominatorst::cfgt::entry_mapt::const_iterator e2=
191192
pd.cfg.entry_map.find(*d_it);

0 commit comments

Comments
 (0)