CBMC
build_analyzer.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Goto-Analyzer Command Line Option Processing
4 
5 Author: Martin Brain, martin.brain@cs.ox.ac.uk
6 
7 \*******************************************************************/
8 
9 #include "build_analyzer.h"
10 
11 #include <analyses/ai.h>
22 
24 
25 #include <util/message.h>
26 #include <util/options.h>
27 
30 std::unique_ptr<ai_baset> build_analyzer(
31  const optionst &options,
32  const goto_modelt &goto_model,
33  const namespacet &ns,
34  message_handlert &mh)
35 {
36  auto vsd_config = vsd_configt::from_options(options);
37  auto vs_object_factory =
39 
40  // These support all of the option categories
41  if(
42  options.get_bool_option("recursive-interprocedural") ||
43  options.get_bool_option("three-way-merge"))
44  {
45  // Build the history factory
46  std::unique_ptr<ai_history_factory_baset> hf = nullptr;
47  if(options.get_bool_option("ahistorical"))
48  {
49  hf = util_make_unique<
51  }
52  else if(options.get_bool_option("call-stack"))
53  {
54  hf = util_make_unique<call_stack_history_factoryt>(
55  options.get_unsigned_int_option("call-stack-recursion-limit"));
56  }
57  else if(options.get_bool_option("local-control-flow-history"))
58  {
59  hf = util_make_unique<local_control_flow_history_factoryt>(
60  options.get_bool_option("local-control-flow-history-forward"),
61  options.get_bool_option("local-control-flow-history-backward"),
62  options.get_unsigned_int_option("local-control-flow-history-limit"));
63  }
64 
65  // Build the domain factory
66  std::unique_ptr<ai_domain_factory_baset> df = nullptr;
67  if(options.get_bool_option("constants"))
68  {
69  df = util_make_unique<
71  }
72  else if(options.get_bool_option("intervals"))
73  {
74  df = util_make_unique<
76  }
77  else if(options.get_bool_option("vsd"))
78  {
79  df = util_make_unique<variable_sensitivity_domain_factoryt>(
80  vs_object_factory, vsd_config);
81  }
82  // non-null is not fully supported, despite the historical options
83  // dependency-graph is quite heavily tied to the legacy-ait infrastructure
84  // dependency-graph-vs is very similar to dependency-graph
85 
86  // Build the storage object
87  std::unique_ptr<ai_storage_baset> st = nullptr;
88  if(options.get_bool_option("one-domain-per-history"))
89  {
90  st = util_make_unique<history_sensitive_storaget>();
91  }
92  else if(options.get_bool_option("one-domain-per-location"))
93  {
94  st = util_make_unique<location_sensitive_storaget>();
95  }
96 
97  // Only try to build the abstract interpreter if all the parts have been
98  // correctly specified and configured
99  if(hf != nullptr && df != nullptr && st != nullptr)
100  {
101  if(options.get_bool_option("recursive-interprocedural"))
102  {
103  return util_make_unique<ai_recursive_interproceduralt>(
104  std::move(hf), std::move(df), std::move(st), mh);
105  }
106  else if(options.get_bool_option("three-way-merge"))
107  {
108  // Only works with VSD
109  if(options.get_bool_option("vsd"))
110  {
111  return util_make_unique<ai_three_way_merget>(
112  std::move(hf), std::move(df), std::move(st), mh);
113  }
114  }
115  }
116  }
117  else if(options.get_bool_option("legacy-ait"))
118  {
119  if(options.get_bool_option("constants"))
120  {
121  // constant_propagator_ait derives from ait<constant_propagator_domaint>
122  return util_make_unique<constant_propagator_ait>(
123  goto_model.goto_functions);
124  }
125  else if(options.get_bool_option("dependence-graph"))
126  {
127  return util_make_unique<dependence_grapht>(ns);
128  }
129  else if(options.get_bool_option("dependence-graph-vs"))
130  {
131  return util_make_unique<variable_sensitivity_dependence_grapht>(
132  goto_model.goto_functions, ns, vs_object_factory, vsd_config, mh);
133  }
134  else if(options.get_bool_option("vsd"))
135  {
136  auto df = util_make_unique<variable_sensitivity_domain_factoryt>(
137  vs_object_factory, vsd_config);
138  return util_make_unique<ait<variable_sensitivity_domaint>>(std::move(df));
139  }
140  else if(options.get_bool_option("intervals"))
141  {
142  return util_make_unique<ait<interval_domaint>>();
143  }
144 #if 0
145  // Not actually implemented, despite the option...
146  else if(options.get_bool_option("non-null"))
147  {
148  return util_make_unique<ait<non_null_domaint> >();
149  }
150 #endif
151  }
152  else if(options.get_bool_option("legacy-concurrent"))
153  {
154 #if 0
155  // Very few domains can work with this interpreter
156  // as it requires that changes to the domain are
157  // 'non-revertable' and it has merge shared
158  if(options.get_bool_option("dependence-graph"))
159  {
160  return util_make_unique<dependence_grapht>(ns);
161  }
162 #endif
163  }
164 
165  // Construction failed due to configuration errors
166  return nullptr;
167 }
build_analyzer.h
ai_domain_factory_default_constructort
Definition: ai_domain.h:218
variable_sensitivity_object_factory.h
optionst
Definition: options.h:22
local_control_flow_history.h
constant_propagator.h
goto_model.h
goto_modelt
Definition: goto_model.h:25
options.h
build_analyzer
std::unique_ptr< ai_baset > build_analyzer(const optionst &options, const goto_modelt &goto_model, const namespacet &ns, message_handlert &mh)
Ideally this should be a pure function of options.
Definition: build_analyzer.cpp:30
three_way_merge_abstract_interpreter.h
variable_sensitivity_dependence_graph.h
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
vsd_configt::from_options
static vsd_configt from_options(const optionst &options)
Definition: variable_sensitivity_configuration.cpp:20
util_make_unique
std::unique_ptr< T > util_make_unique(Ts &&... ts)
Definition: make_unique.h:19
ai_history_factory_default_constructort
An easy factory implementation for histories that don't need parameters.
Definition: ai_history.h:254
message_handlert
Definition: message.h:27
ai.h
optionst::get_unsigned_int_option
unsigned int get_unsigned_int_option(const std::string &option) const
Definition: options.cpp:56
interval_domain.h
goto_modelt::goto_functions
goto_functionst goto_functions
GOTO functions.
Definition: goto_model.h:33
variable_sensitivity_domain.h
optionst::get_bool_option
bool get_bool_option(const std::string &option) const
Definition: options.cpp:44
call_stack_history.h
message.h
variable_sensitivity_configuration.h
dependence_graph.h
variable_sensitivity_object_factoryt::configured_with
static variable_sensitivity_object_factory_ptrt configured_with(const vsd_configt &options)
Definition: variable_sensitivity_object_factory.h:41