Skip to content

Commit a01eeb7

Browse files
committed
Use invariant annotations instead of asserts
1 parent e8e1677 commit a01eeb7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/goto-instrument/model_argc_argv.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Date: April 2016
1616
#include <sstream>
1717

1818
#include <util/cprover_prefix.h>
19+
#include <util/invariant.h>
1920
#include <util/message.h>
2021
#include <util/namespace.h>
2122
#include <util/config.h>
@@ -132,8 +133,8 @@ bool model_argc_argv(
132133
symbol_table.add(it->second))
133134
UNREACHABLE;
134135
}
136+
POSTCONDITION(value.is_not_nil());
135137

136-
assert(value.is_not_nil());
137138
goto_convert(
138139
to_code(value),
139140
symbol_table,
@@ -147,15 +148,17 @@ bool model_argc_argv(
147148

148149
goto_functionst::function_mapt::iterator start_entry=
149150
goto_functions.function_map.find(goto_functions.entry_point());
150-
assert(
151+
DATA_INVARIANT(
151152
start_entry!=goto_functions.function_map.end() &&
152-
start_entry->second.body_available());
153+
start_entry->second.body_available(),
154+
"entry point expected to have a body");
153155

154156
goto_programt &start=start_entry->second.body;
155157
goto_programt::targett main_call=start.instructions.begin();
156158
for(goto_programt::targett end=start.instructions.end();
157159
main_call!=end;
158160
++main_call)
161+
{
159162
if(main_call->is_function_call())
160163
{
161164
const exprt &func=
@@ -164,8 +167,9 @@ bool model_argc_argv(
164167
to_symbol_expr(func).get_identifier()==main_symbol.name)
165168
break;
166169
}
170+
}
171+
POSTCONDITION(main_call!=start.instructions.end());
167172

168-
assert(main_call!=start.instructions.end());
169173
start.insert_before_swap(main_call, init_instructions);
170174

171175
// update counters etc.

0 commit comments

Comments
 (0)