Skip to content

Commit 3400b88

Browse files
WIP Add message warning about overriding __CPROVER things
1 parent c2289b3 commit 3400b88

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/goto-programs/replace_function_bodies.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,12 +407,23 @@ std::unique_ptr<generate_function_bodiest> generate_function_bodies_factory(
407407
std::vector<irep_idt> globals_to_havoc;
408408
namespacet ns(symbol_table);
409409
messaget messages(message_handler);
410+
const std::regex cprover_prefix = std::regex("__CPROVER.*");
410411
for(auto const &symbol : symbol_table.symbols)
411412
{
412413
if(
413414
symbol.second.is_lvalue && symbol.second.is_static_lifetime &&
414415
std::regex_match(id2string(symbol.first), globals_regex))
415416
{
417+
if(std::regex_match(id2string(symbol.first), cprover_prefix))
418+
{
419+
messages.warning() << "generate function bodies: "
420+
<< "matched global '"
421+
<< id2string(symbol.first)
422+
<< "' begins with __CPROVER, "
423+
<< "havoc-ing this global may interfere"
424+
<< " with analysis"
425+
<< messaget::eom;
426+
}
416427
globals_to_havoc.push_back(symbol.first);
417428
}
418429
}
@@ -465,21 +476,32 @@ void replace_function_bodies(
465476
goto_modelt &model,
466477
message_handlert &message_handler)
467478
{
479+
messaget messages(message_handler);
480+
const std::regex cprover_prefix = std::regex("__CPROVER.*");
468481
bool did_generate_body = false;
469482
for(auto &function : model.goto_functions.function_map)
470483
{
471484
if(
472485
!function.second.body_available() &&
473486
std::regex_match(id2string(function.first), functions_regex))
474487
{
488+
if(std::regex_match(id2string(function.first), cprover_prefix))
489+
{
490+
messages.warning()
491+
<< "generate function bodies: matched function '"
492+
<< id2string(function.first)
493+
<< "' begins with __CPROVER "
494+
<< "the generated body for this function "
495+
<< "may interfere with analysis"
496+
<< messaget::eom;
497+
}
475498
did_generate_body = true;
476499
generate_function_body.generate_function_body(
477500
function.second, model.symbol_table, function.first);
478501
}
479502
}
480503
if(!did_generate_body)
481504
{
482-
messaget messages(message_handler);
483505
messages.warning()
484506
<< "generate function bodies: No function name matched regex"
485507
<< messaget::eom;

0 commit comments

Comments
 (0)