Skip to content

Commit 9c12abb

Browse files
author
Daniel Kroening
committed
make linter happy
1 parent ba8bbe2 commit 9c12abb

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/goto-programs/goto_program.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ std::ostream &goto_programt::output_instruction(
163163
unsigned i=0;
164164
const irept::subt &exception_list=
165165
instruction.code.find(ID_exception_list).get_sub();
166-
assert(instruction.targets.size()==exception_list.size());
166+
DATA_INVARIANT(instruction.targets.size()==exception_list.size(),
167+
"size of target list");
167168
for(instructiont::targetst::const_iterator
168169
gt_it=instruction.targets.begin();
169170
gt_it!=instruction.targets.end();
@@ -220,8 +221,10 @@ void goto_programt::get_decl_identifiers(
220221
{
221222
if(it->is_decl())
222223
{
223-
assert(it->code.get_statement()==ID_decl);
224-
assert(it->code.operands().size()==1);
224+
DATA_INVARIANT(it->code.get_statement()==ID_decl,
225+
"declaration statements");
226+
DATA_INVARIANT(it->code.operands().size()==1,
227+
"operand of declaration statement");
225228
const symbol_exprt &symbol_expr=to_symbol_expr(it->code.op0());
226229
decl_identifiers.insert(symbol_expr.get_identifier());
227230
}
@@ -539,7 +542,7 @@ void goto_programt::compute_target_numbers()
539542
if(i.is_target())
540543
{
541544
i.target_number=++cnt;
542-
assert(i.target_number!=0);
545+
DATA_INVARIANT(i.target_number!=0, "target numbers");
543546
}
544547
}
545548

@@ -552,8 +555,10 @@ void goto_programt::compute_target_numbers()
552555
{
553556
if(t!=instructions.end())
554557
{
555-
assert(t->target_number!=0);
556-
assert(t->target_number!=instructiont::nil_target);
558+
DATA_INVARIANT(t->target_number!=0,
559+
"target numbers");
560+
DATA_INVARIANT(t->target_number!=instructiont::nil_target,
561+
"target numbers");
557562
}
558563
}
559564
}

src/goto-programs/goto_program.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class goto_programt
188188
/// target
189189
targett get_target() const
190190
{
191-
assert(targets.size()==1);
191+
PRECONDITION(targets.size()==1);
192192
return targets.front();
193193
}
194194

@@ -398,7 +398,7 @@ class goto_programt
398398
static const irep_idt get_function_id(
399399
const goto_programt &p)
400400
{
401-
assert(!p.empty());
401+
PRECONDITION(!p.empty());
402402

403403
return get_function_id(--p.instructions.end());
404404
}
@@ -411,7 +411,7 @@ class goto_programt
411411
/// Insertion that preserves jumps to "target".
412412
void insert_before_swap(targett target)
413413
{
414-
assert(target!=instructions.end());
414+
PRECONDITION(target!=instructions.end());
415415
const auto next=std::next(target);
416416
instructions.insert(next, instructiont())->swap(*target);
417417
}
@@ -430,7 +430,7 @@ class goto_programt
430430
targett target,
431431
goto_programt &p)
432432
{
433-
assert(target!=instructions.end());
433+
PRECONDITION(target!=instructions.end());
434434
if(p.instructions.empty())
435435
return;
436436
insert_before_swap(target, p.instructions.front());
@@ -586,9 +586,10 @@ class goto_programt
586586

587587
targett get_end_function()
588588
{
589-
assert(!instructions.empty());
589+
PRECONDITION(!instructions.empty());
590590
const auto end_function=std::prev(instructions.end());
591-
assert(end_function->is_end_function());
591+
DATA_INVARIANT(end_function->is_end_function(),
592+
"goto program ends on END_FUNCTION");
592593
return end_function;
593594
}
594595

@@ -671,6 +672,7 @@ inline bool order_const_target(
671672
return &_i1<&_i2;
672673
}
673674

675+
// NOLINTNEXTLINE(readability/identifiers)
674676
struct const_target_hash
675677
{
676678
std::size_t operator()(

0 commit comments

Comments
 (0)