Skip to content

Commit 74159df

Browse files
committed
Turn tracking-not-support exception into an invariant
The C front-end already performs the very same check.
1 parent d875666 commit 74159df

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/goto-instrument/contracts/utils.cpp

+7-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Date: September 2021
1111
#include "utils.h"
1212

1313
#include <util/c_types.h>
14-
#include <util/exception_utils.h>
1514
#include <util/fresh_symbol.h>
1615
#include <util/graph.h>
1716
#include <util/mathematical_expr.h>
@@ -470,16 +469,13 @@ static void replace_history_parameter_rec(
470469

471470
const auto &parameter = to_history_expr(expr, history_id).expression();
472471
const auto &id = parameter.id();
473-
if(
474-
id != ID_dereference && id != ID_member && id != ID_symbol &&
475-
id != ID_ptrmember && id != ID_constant && id != ID_typecast &&
476-
id != ID_index)
477-
{
478-
throw invalid_source_file_exceptiont(
479-
"Tracking history of " + id2string(parameter.id()) +
480-
" expressions is not supported yet.",
481-
expr.source_location());
482-
}
472+
DATA_INVARIANT_WITH_DIAGNOSTICS(
473+
id == ID_dereference || id == ID_member || id == ID_symbol ||
474+
id == ID_ptrmember || id == ID_constant || id == ID_typecast ||
475+
id == ID_index,
476+
"Tracking history of " + id2string(id) +
477+
" expressions is not supported yet.",
478+
parameter.pretty());
483479

484480
// speculatively insert a dummy, which will be replaced below if the insert
485481
// actually happened

0 commit comments

Comments
 (0)