@@ -16,6 +16,7 @@ Author: Daniel Poetzl
16
16
#include < goto-programs/remove_returns.h>
17
17
18
18
#include < util/base_type.h>
19
+ #include < util/exception_utils.h>
19
20
#include < util/invariant.h>
20
21
#include < util/irep.h>
21
22
#include < util/string_utils.h>
@@ -105,8 +106,9 @@ void replace_callst::operator()(
105
106
if (rhs.id () == ID_symbol)
106
107
{
107
108
const symbol_exprt &se = to_symbol_expr (rhs);
108
- if (has_suffix (id2string (se.get_identifier ()), RETURN_VALUE_SUFFIX))
109
- throw " Returns must not be removed before replacing calls" ;
109
+ INVARIANT (
110
+ !has_suffix (id2string (se.get_identifier ()), RETURN_VALUE_SUFFIX),
111
+ " returns must not be removed before replacing calls" );
110
112
}
111
113
}
112
114
@@ -132,7 +134,10 @@ replace_callst::replacement_mapt replace_callst::parse_replacement_list(
132
134
replacement_map.insert (std::make_pair (original, replacement));
133
135
134
136
if (!r.second )
135
- throw " Conflicting replacement for function " + original;
137
+ {
138
+ throw invalid_user_input_exceptiont (
139
+ " conflicting replacement for function " + original, " --replace-calls" );
140
+ }
136
141
}
137
142
138
143
return replacement_map;
@@ -146,22 +151,26 @@ void replace_callst::check_replacement_map(
146
151
for (const auto &p : replacement_map)
147
152
{
148
153
if (replacement_map.find (p.second ) != replacement_map.end ())
149
- throw " Function " + id2string (p.second ) +
150
- " cannot both be replaced and "
151
- " be a replacement" ;
154
+ throw invalid_user_input_exceptiont (
155
+ " function " + id2string (p.second ) +
156
+ " cannot both be replaced and be a replacement" ,
157
+ " --replace-calls" );
152
158
153
159
auto it2 = goto_functions.function_map .find (p.second );
154
160
155
161
if (it2 == goto_functions.function_map .end ())
156
- throw " Replacement function " + id2string (p.second ) +
157
- " needs to be present" ;
162
+ throw invalid_user_input_exceptiont (
163
+ " replacement function " + id2string (p.second ) + " needs to be present" ,
164
+ " --replace-calls" );
158
165
159
166
auto it1 = goto_functions.function_map .find (p.first );
160
167
if (it1 != goto_functions.function_map .end ())
161
168
{
162
169
if (!base_type_eq (it1->second .type , it2->second .type , ns))
163
- throw " Functions " + id2string (p.first ) + " and " +
164
- id2string (p.second ) + " are not type-compatible" ;
170
+ throw invalid_user_input_exceptiont (
171
+ " functions " + id2string (p.first ) + " and " + id2string (p.second ) +
172
+ " are not type-compatible" ,
173
+ " --replace-calls" );
165
174
}
166
175
}
167
176
}
0 commit comments