Skip to content

Commit c11b5cd

Browse files
committed
Print info using DATA_INVARIANT_WITH_DIAGNOSTICS
1 parent c25e205 commit c11b5cd

File tree

1 file changed

+14
-26
lines changed

1 file changed

+14
-26
lines changed

src/goto-programs/goto_convert_functions.cpp

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -163,36 +163,24 @@ void goto_convert_functionst::convert_function(
163163
symbol.is_compiled()) /* goto_inline may have removed the body */
164164
return;
165165

166-
const size_t ERROR_MSG_LEN = 512;
167-
char parameter_error_message[ERROR_MSG_LEN];
168166
// we have a body, make sure all parameter names are valid
169167
for(const auto &p : f.parameter_identifiers)
170168
{
171-
if (p.empty())
172-
{
173-
snprintf(parameter_error_message,
174-
ERROR_MSG_LEN - 1,
175-
"parameter identifier should not be empty\n"
176-
"function: %s\n"
177-
"parameter: %s",
178-
identifier.c_str(),
179-
p.c_str());
180-
}
181-
DATA_INVARIANT(!p.empty(), parameter_error_message);
182-
183-
if (!symbol_table.has_symbol(p))
184-
{
185-
snprintf(parameter_error_message,
186-
ERROR_MSG_LEN - 1,
187-
"parameter identifier must be a known symbol\n"
188-
"function: %s\n"
189-
"parameter: %s",
190-
identifier.c_str(),
191-
p.c_str());
192-
}
193-
DATA_INVARIANT(
169+
DATA_INVARIANT_WITH_DIAGNOSTICS(
170+
!p.empty(),
171+
"parameter identifier should not be empty",
172+
"function:",
173+
identifier,
174+
"parameter:",
175+
p);
176+
177+
DATA_INVARIANT_WITH_DIAGNOSTICS(
194178
symbol_table.has_symbol(p),
195-
parameter_error_message);
179+
"parameter identifier must be a known symbol",
180+
"function:",
181+
identifier,
182+
"parameter:",
183+
p);
196184
}
197185

198186
lifetimet parent_lifetime = lifetime;

0 commit comments

Comments
 (0)