Skip to content

Commit 71d2053

Browse files
author
martin
committed
Refactor the command line handling of specific analyses.
This patch should not alter behaviour at all. It is to help simplify and clarify the following changes to option structure.
1 parent c99c2e4 commit 71d2053

File tree

1 file changed

+77
-8
lines changed

1 file changed

+77
-8
lines changed

src/goto-analyzer/goto_analyzer_parse_options.cpp

+77-8
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,75 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
131131
if(cmdline.isset("error-label"))
132132
options.set_option("error-label", cmdline.get_values("error-label"));
133133
#endif
134+
135+
// Select a specific analysis
136+
if(cmdline.isset("taint"))
137+
{
138+
options.set_option("taint", true);
139+
options.set_option("specific-analysis", true);
140+
}
141+
if(cmdline.isset("unreachable-instructions"))
142+
{
143+
options.set_option("unreachable-instructions", true);
144+
options.set_option("specific-analysis", true);
145+
}
146+
if(cmdline.isset("unreachable-functions"))
147+
{
148+
options.set_option("unreachable-functions", true);
149+
options.set_option("specific-analysis", true);
150+
}
151+
if(cmdline.isset("reachable-functions"))
152+
{
153+
options.set_option("reachable-functions", true);
154+
options.set_option("specific-analysis", true);
155+
}
156+
if(cmdline.isset("intervals"))
157+
{
158+
options.set_option("intervals", true);
159+
options.set_option("specific-analysis", true);
160+
}
161+
if(cmdline.isset("show-intervals"))
162+
{
163+
options.set_option("show-intervals", true);
164+
options.set_option("specific-analysis", true);
165+
}
166+
if(cmdline.isset("non-null"))
167+
{
168+
options.set_option("non-null", true);
169+
options.set_option("specific-analysis", true);
170+
}
171+
if(cmdline.isset("show-local-may-alias"))
172+
{
173+
options.set_option("show-local-may-alias", true);
174+
options.set_option("specific-analysis", true);
175+
}
176+
177+
// Output format choice
178+
if(cmdline.isset("text"))
179+
{
180+
options.set_option("text", true);
181+
options.set_option("outfile", cmdline.get_value("text"));
182+
}
183+
else if(cmdline.isset("json"))
184+
{
185+
options.set_option("json", true);
186+
options.set_option("outfile", cmdline.get_value("json"));
187+
}
188+
else if(cmdline.isset("xml"))
189+
{
190+
options.set_option("xml", true);
191+
options.set_option("outfile", cmdline.get_value("xml"));
192+
}
193+
else if(cmdline.isset("dot"))
194+
{
195+
options.set_option("dot", true);
196+
options.set_option("outfile", cmdline.get_value("dot"));
197+
}
198+
else
199+
{
200+
options.set_option("text", true);
201+
options.set_option("outfile", "-");
202+
}
134203
}
135204

136205
/// invoke main modules
@@ -199,7 +268,7 @@ int goto_analyzer_parse_optionst::doit()
199268
return 6;
200269
}
201270

202-
if(cmdline.isset("taint"))
271+
if(options.get_bool_option("taint"))
203272
{
204273
std::string taint_file=cmdline.get_value("taint");
205274

@@ -218,7 +287,7 @@ int goto_analyzer_parse_optionst::doit()
218287
}
219288
}
220289

221-
if(cmdline.isset("unreachable-instructions"))
290+
if(options.get_bool_option("unreachable-instructions"))
222291
{
223292
const std::string json_file=cmdline.get_value("json");
224293

@@ -242,7 +311,7 @@ int goto_analyzer_parse_optionst::doit()
242311
return 0;
243312
}
244313

245-
if(cmdline.isset("unreachable-functions"))
314+
if(options.get_bool_option("unreachable-functions"))
246315
{
247316
const std::string json_file=cmdline.get_value("json");
248317

@@ -266,7 +335,7 @@ int goto_analyzer_parse_optionst::doit()
266335
return 0;
267336
}
268337

269-
if(cmdline.isset("reachable-functions"))
338+
if(options.get_bool_option("reachable-functions"))
270339
{
271340
const std::string json_file=cmdline.get_value("json");
272341

@@ -290,7 +359,7 @@ int goto_analyzer_parse_optionst::doit()
290359
return 0;
291360
}
292361

293-
if(cmdline.isset("show-local-may-alias"))
362+
if(options.get_bool_option("show-local-may-alias"))
294363
{
295364
namespacet ns(goto_model.symbol_table);
296365

@@ -318,14 +387,14 @@ int goto_analyzer_parse_optionst::doit()
318387
if(set_properties())
319388
return 7;
320389

321-
if(cmdline.isset("show-intervals"))
390+
if(options.get_bool_option("show-intervals"))
322391
{
323392
show_intervals(goto_model, std::cout);
324393
return 0;
325394
}
326395

327-
if(cmdline.isset("non-null") ||
328-
cmdline.isset("intervals"))
396+
if(options.get_bool_option("non-null") ||
397+
options.get_bool_option("intervals"))
329398
{
330399
optionst options;
331400
options.set_option("json", cmdline.get_value("json"));

0 commit comments

Comments
 (0)