Skip to content

Commit 5d291f6

Browse files
author
martin
committed
Add a message_handler parameter to ai_baset in preparation for logging
The legacy ait interface is preserved by creating a local null_message_handlert and then passing this as a reference to the parent constructor. This is not ideal but does preserve behaviour.
1 parent f0a4e75 commit 5d291f6

File tree

7 files changed

+41
-17
lines changed

7 files changed

+41
-17
lines changed

src/analyses/ai.h

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Author: Daniel Kroening, [email protected]
5151
#include <util/deprecate.h>
5252
#include <util/json.h>
5353
#include <util/make_unique.h>
54+
#include <util/message.h>
5455
#include <util/xml.h>
5556

5657
#include <goto-programs/goto_model.h>
@@ -127,10 +128,12 @@ class ai_baset
127128
ai_baset(
128129
std::unique_ptr<ai_history_factory_baset> &&hf,
129130
std::unique_ptr<ai_domain_factory_baset> &&df,
130-
std::unique_ptr<ai_storage_baset> &&st)
131+
std::unique_ptr<ai_storage_baset> &&st,
132+
message_handlert &mh)
131133
: history_factory(std::move(hf)),
132134
domain_factory(std::move(df)),
133-
storage(std::move(st))
135+
storage(std::move(st)),
136+
message_handler(mh)
134137
{
135138
}
136139

@@ -515,6 +518,9 @@ class ai_baset
515518
{
516519
return storage->get_state(p, *domain_factory);
517520
}
521+
522+
// Logging
523+
message_handlert &message_handler;
518524
};
519525

520526
// Perform interprocedural analysis by simply recursing in the interpreter
@@ -525,8 +531,9 @@ class ai_recursive_interproceduralt : public ai_baset
525531
ai_recursive_interproceduralt(
526532
std::unique_ptr<ai_history_factory_baset> &&hf,
527533
std::unique_ptr<ai_domain_factory_baset> &&df,
528-
std::unique_ptr<ai_storage_baset> &&st)
529-
: ai_baset(std::move(hf), std::move(df), std::move(st))
534+
std::unique_ptr<ai_storage_baset> &&st,
535+
message_handlert &mh)
536+
: ai_baset(std::move(hf), std::move(df), std::move(st), mh)
530537
{
531538
}
532539

@@ -562,7 +569,8 @@ class ait : public ai_recursive_interproceduralt
562569
util_make_unique<
563570
ai_history_factory_default_constructort<ahistoricalt>>(),
564571
util_make_unique<ai_domain_factory_default_constructort<domainT>>(),
565-
util_make_unique<location_sensitive_storaget>())
572+
util_make_unique<location_sensitive_storaget>(),
573+
no_logging)
566574
{
567575
}
568576

@@ -571,7 +579,8 @@ class ait : public ai_recursive_interproceduralt
571579
util_make_unique<
572580
ai_history_factory_default_constructort<ahistoricalt>>(),
573581
std::move(df),
574-
util_make_unique<location_sensitive_storaget>())
582+
util_make_unique<location_sensitive_storaget>(),
583+
no_logging)
575584
{
576585
}
577586

@@ -613,6 +622,9 @@ class ait : public ai_recursive_interproceduralt
613622
/// This function exists to enforce that `domainT` is derived from
614623
/// \ref ai_domain_baset
615624
void dummy(const domainT &s) { const statet &x=s; (void)x; }
625+
626+
// To keep the old constructor interface we disable logging
627+
null_message_handlert no_logging;
616628
};
617629

618630
/// Base class for concurrency-aware abstract interpretation. See

src/analyses/variable-sensitivity/three_way_merge_abstract_interpreter.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ class ai_three_way_merget : public ai_recursive_interproceduralt
3030
ai_three_way_merget(
3131
std::unique_ptr<ai_history_factory_baset> &&hf,
3232
std::unique_ptr<ai_domain_factory_baset> &&df,
33-
std::unique_ptr<ai_storage_baset> &&st)
34-
: ai_recursive_interproceduralt(std::move(hf), std::move(df), std::move(st))
33+
std::unique_ptr<ai_storage_baset> &&st,
34+
message_handlert &mh)
35+
: ai_recursive_interproceduralt(
36+
std::move(hf),
37+
std::move(df),
38+
std::move(st),
39+
mh)
3540
{
3641
}
3742

src/analyses/variable-sensitivity/variable_sensitivity_dependence_graph.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,14 +641,16 @@ variable_sensitivity_dependence_grapht::variable_sensitivity_dependence_grapht(
641641
const goto_functionst &goto_functions,
642642
const namespacet &_ns,
643643
variable_sensitivity_object_factory_ptrt object_factory,
644-
const vsd_configt &configuration)
644+
const vsd_configt &configuration,
645+
message_handlert &message_handler)
645646
: ai_three_way_merget(
646647
util_make_unique<ai_history_factory_default_constructort<ahistoricalt>>(),
647648
util_make_unique<variable_sensitivity_dependence_domain_factoryt>(
648649
*this,
649650
object_factory,
650651
configuration),
651-
util_make_unique<location_sensitive_storaget>()),
652+
util_make_unique<location_sensitive_storaget>(),
653+
message_handler),
652654
goto_functions(goto_functions),
653655
ns(_ns)
654656
{

src/analyses/variable-sensitivity/variable_sensitivity_dependence_graph.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ class variable_sensitivity_dependence_grapht : public ai_three_way_merget,
244244
const goto_functionst &goto_functions,
245245
const namespacet &_ns,
246246
variable_sensitivity_object_factory_ptrt object_factory,
247-
const vsd_configt &_configuration);
247+
const vsd_configt &_configuration,
248+
message_handlert &message_handler);
248249

249250
void
250251
initialize(const irep_idt &function_id, const goto_programt &goto_program)

src/goto-analyzer/build_analyzer.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ Author: Martin Brain, [email protected]
2222

2323
#include <goto-programs/goto_model.h>
2424

25+
#include <util/message.h>
2526
#include <util/options.h>
2627

2728
/// Ideally this should be a pure function of options.
2829
/// However at the moment some domains require the goto_model or parts of it
2930
std::unique_ptr<ai_baset> build_analyzer(
3031
const optionst &options,
3132
const goto_modelt &goto_model,
32-
const namespacet &ns)
33+
const namespacet &ns,
34+
message_handlert &mh)
3335
{
3436
auto vsd_config = vsd_configt::from_options(options);
3537
auto vs_object_factory =
@@ -99,15 +101,15 @@ std::unique_ptr<ai_baset> build_analyzer(
99101
if(options.get_bool_option("recursive-interprocedural"))
100102
{
101103
return util_make_unique<ai_recursive_interproceduralt>(
102-
std::move(hf), std::move(df), std::move(st));
104+
std::move(hf), std::move(df), std::move(st), mh);
103105
}
104106
else if(options.get_bool_option("three-way-merge"))
105107
{
106108
// Only works with VSD
107109
if(options.get_bool_option("vsd"))
108110
{
109111
return util_make_unique<ai_three_way_merget>(
110-
std::move(hf), std::move(df), std::move(st));
112+
std::move(hf), std::move(df), std::move(st), mh);
111113
}
112114
}
113115
}
@@ -127,7 +129,7 @@ std::unique_ptr<ai_baset> build_analyzer(
127129
else if(options.get_bool_option("dependence-graph-vs"))
128130
{
129131
return util_make_unique<variable_sensitivity_dependence_grapht>(
130-
goto_model.goto_functions, ns, vs_object_factory, vsd_config);
132+
goto_model.goto_functions, ns, vs_object_factory, vsd_config, mh);
131133
}
132134
else if(options.get_bool_option("vsd"))
133135
{

src/goto-analyzer/build_analyzer.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class ai_baset;
1515
class goto_modelt;
1616
class namespacet;
1717
class optionst;
18+
class message_handlert;
1819

1920
/// Build an abstract interpreter configured by the options.
2021
/// This may require options for:
@@ -29,6 +30,7 @@ class optionst;
2930
std::unique_ptr<ai_baset> build_analyzer(
3031
const optionst &options,
3132
const goto_modelt &goto_model,
32-
const namespacet &ns);
33+
const namespacet &ns,
34+
message_handlert &mh);
3335

3436
#endif // CPROVER_GOTO_ANALYZER_GOTO_ANALYZER_PARSE_OPTIONS_H

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
568568

569569
try
570570
{
571-
analyzer = build_analyzer(options, goto_model, ns);
571+
analyzer = build_analyzer(options, goto_model, ns, ui_message_handler);
572572
}
573573
catch(const invalid_command_line_argument_exceptiont &e)
574574
{

0 commit comments

Comments
 (0)