Skip to content

Commit 5243777

Browse files
committed
Remove shadowing "options" from jdiff/goto_diff methods
As these inherit from language_uit, there is already an options member available. Also do not make functions virtual unnecessarily, there is not inheritance anywhere.
1 parent 75216f4 commit 5243777

File tree

7 files changed

+74
-84
lines changed

7 files changed

+74
-84
lines changed

jbmc/src/janalyzer/janalyzer_parse_options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ class janalyzer_parse_optionst : public parse_options_baset, public messaget
164164

165165
virtual void register_languages();
166166

167-
virtual void get_command_line_options(optionst &options);
167+
void get_command_line_options(optionst &options);
168168

169-
virtual bool process_goto_program(const optionst &options);
169+
bool process_goto_program(const optionst &options);
170170
bool set_properties();
171171

172172
virtual int perform_analysis(const optionst &options);

jbmc/src/jdiff/jdiff_parse_options.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ ::jdiff_parse_optionst::jdiff_parse_optionst(
8181
{
8282
}
8383

84-
void jdiff_parse_optionst::get_command_line_options(optionst &options)
84+
void jdiff_parse_optionst::get_command_line_options()
8585
{
8686
if(config.set(cmdline))
8787
{
@@ -200,8 +200,7 @@ int jdiff_parse_optionst::doit()
200200
// command line options
201201
//
202202

203-
optionst options;
204-
get_command_line_options(options);
203+
get_command_line_options();
205204
eval_verbosity(
206205
cmdline.get_value("verbosity"), messaget::M_STATISTICS, ui_message_handler);
207206

@@ -220,10 +219,10 @@ int jdiff_parse_optionst::doit()
220219

221220
goto_modelt goto_model1, goto_model2;
222221

223-
int get_goto_program_ret = get_goto_program(options, *this, goto_model1);
222+
int get_goto_program_ret = get_goto_program(*this, goto_model1);
224223
if(get_goto_program_ret != -1)
225224
return get_goto_program_ret;
226-
get_goto_program_ret = get_goto_program(options, languages2, goto_model2);
225+
get_goto_program_ret = get_goto_program(languages2, goto_model2);
227226
if(get_goto_program_ret != -1)
228227
return get_goto_program_ret;
229228

@@ -284,7 +283,6 @@ int jdiff_parse_optionst::doit()
284283
}
285284

286285
int jdiff_parse_optionst::get_goto_program(
287-
const optionst &options,
288286
jdiff_languagest &languages,
289287
goto_modelt &goto_model)
290288
{
@@ -327,7 +325,7 @@ int jdiff_parse_optionst::get_goto_program(
327325
goto_convert(
328326
goto_model.symbol_table, goto_model.goto_functions, ui_message_handler);
329327

330-
if(process_goto_program(options, goto_model))
328+
if(process_goto_program(goto_model))
331329
return CPROVER_EXIT_INTERNAL_ERROR;
332330

333331
// if we had a second argument then we will handle it next
@@ -338,9 +336,7 @@ int jdiff_parse_optionst::get_goto_program(
338336
return -1; // no error, continue
339337
}
340338

341-
bool jdiff_parse_optionst::process_goto_program(
342-
const optionst &options,
343-
goto_modelt &goto_model)
339+
bool jdiff_parse_optionst::process_goto_program(goto_modelt &goto_model)
344340
{
345341
try
346342
{

jbmc/src/jdiff/jdiff_parse_options.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,11 @@ class jdiff_parse_optionst : public parse_options_baset, public jdiff_languagest
5959
ui_message_handlert ui_message_handler;
6060
jdiff_languagest languages2;
6161

62-
virtual void get_command_line_options(optionst &options);
62+
void get_command_line_options();
6363

64-
virtual int get_goto_program(
65-
const optionst &options,
66-
jdiff_languagest &languages,
67-
goto_modelt &goto_model);
64+
int get_goto_program(jdiff_languagest &languages, goto_modelt &goto_model);
6865

69-
virtual bool
70-
process_goto_program(const optionst &options, goto_modelt &goto_model);
66+
bool process_goto_program(goto_modelt &goto_model);
7167

7268
void preprocessing();
7369
};

src/goto-analyzer/goto_analyzer_parse_options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ class goto_analyzer_parse_optionst:
169169

170170
virtual void register_languages();
171171

172-
virtual void get_command_line_options(optionst &options);
172+
void get_command_line_options(optionst &options);
173173

174-
virtual bool process_goto_program(const optionst &options);
174+
bool process_goto_program(const optionst &options);
175175
bool set_properties();
176176

177177
virtual int perform_analysis(const optionst &options);

src/goto-diff/goto_diff_languages.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,25 @@ Author: Peter Schrammel
1515
#include <langapi/language_ui.h>
1616
#include <goto-programs/goto_model.h>
1717

18+
#include <util/options.h>
19+
1820
class goto_diff_languagest:public language_uit
1921
{
2022
public:
2123
explicit goto_diff_languagest(
2224
const cmdlinet &cmdline,
23-
ui_message_handlert &ui_message_handler) :
24-
language_uit(cmdline, ui_message_handler)
25+
ui_message_handlert &ui_message_handler)
26+
: language_uit(cmdline, ui_message_handler, new optionst)
2527
{
2628
register_languages();
2729
}
2830

31+
~goto_diff_languagest()
32+
{
33+
delete options;
34+
options = nullptr;
35+
}
36+
2937
protected:
3038
virtual void register_languages();
3139
};

src/goto-diff/goto_diff_parse_options.cpp

Lines changed: 48 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Author: Peter Schrammel
1919
#include <util/config.h>
2020
#include <util/exit_codes.h>
2121
#include <util/make_unique.h>
22-
#include <util/options.h>
2322
#include <util/version.h>
2423

2524
#include <langapi/language.h>
@@ -79,7 +78,7 @@ ::goto_diff_parse_optionst::goto_diff_parse_optionst(
7978
{
8079
}
8180

82-
void goto_diff_parse_optionst::get_command_line_options(optionst &options)
81+
void goto_diff_parse_optionst::get_command_line_options()
8382
{
8483
if(config.set(cmdline))
8584
{
@@ -88,16 +87,16 @@ void goto_diff_parse_optionst::get_command_line_options(optionst &options)
8887
}
8988

9089
if(cmdline.isset("program-only"))
91-
options.set_option("program-only", true);
90+
options->set_option("program-only", true);
9291

9392
if(cmdline.isset("show-vcc"))
94-
options.set_option("show-vcc", true);
93+
options->set_option("show-vcc", true);
9594

9695
if(cmdline.isset("cover"))
97-
parse_cover_options(cmdline, options);
96+
parse_cover_options(cmdline, *options);
9897

9998
if(cmdline.isset("mm"))
100-
options.set_option("mm", cmdline.get_value("mm"));
99+
options->set_option("mm", cmdline.get_value("mm"));
101100

102101
if(cmdline.isset("c89"))
103102
config.ansi_c.set_c89();
@@ -118,107 +117,107 @@ void goto_diff_parse_optionst::get_command_line_options(optionst &options)
118117
config.cpp.set_cpp11();
119118

120119
// all checks supported by goto_check
121-
PARSE_OPTIONS_GOTO_CHECK(cmdline, options);
120+
PARSE_OPTIONS_GOTO_CHECK(cmdline, (*options));
122121

123122
if(cmdline.isset("debug-level"))
124-
options.set_option("debug-level", cmdline.get_value("debug-level"));
123+
options->set_option("debug-level", cmdline.get_value("debug-level"));
125124

126125
if(cmdline.isset("slice-by-trace"))
127-
options.set_option("slice-by-trace", cmdline.get_value("slice-by-trace"));
126+
options->set_option("slice-by-trace", cmdline.get_value("slice-by-trace"));
128127

129128
if(cmdline.isset("unwindset"))
130-
options.set_option("unwindset", cmdline.get_value("unwindset"));
129+
options->set_option("unwindset", cmdline.get_value("unwindset"));
131130

132131
// constant propagation
133132
if(cmdline.isset("no-propagation"))
134-
options.set_option("propagation", false);
133+
options->set_option("propagation", false);
135134
else
136-
options.set_option("propagation", true);
135+
options->set_option("propagation", true);
137136

138137
// check array bounds
139138
if(cmdline.isset("bounds-check"))
140-
options.set_option("bounds-check", true);
139+
options->set_option("bounds-check", true);
141140
else
142-
options.set_option("bounds-check", false);
141+
options->set_option("bounds-check", false);
143142

144143
// check division by zero
145144
if(cmdline.isset("div-by-zero-check"))
146-
options.set_option("div-by-zero-check", true);
145+
options->set_option("div-by-zero-check", true);
147146
else
148-
options.set_option("div-by-zero-check", false);
147+
options->set_option("div-by-zero-check", false);
149148

150149
// check overflow/underflow
151150
if(cmdline.isset("signed-overflow-check"))
152-
options.set_option("signed-overflow-check", true);
151+
options->set_option("signed-overflow-check", true);
153152
else
154-
options.set_option("signed-overflow-check", false);
153+
options->set_option("signed-overflow-check", false);
155154

156155
// check overflow/underflow
157156
if(cmdline.isset("unsigned-overflow-check"))
158-
options.set_option("unsigned-overflow-check", true);
157+
options->set_option("unsigned-overflow-check", true);
159158
else
160-
options.set_option("unsigned-overflow-check", false);
159+
options->set_option("unsigned-overflow-check", false);
161160

162161
// check overflow/underflow
163162
if(cmdline.isset("float-overflow-check"))
164-
options.set_option("float-overflow-check", true);
163+
options->set_option("float-overflow-check", true);
165164
else
166-
options.set_option("float-overflow-check", false);
165+
options->set_option("float-overflow-check", false);
167166

168167
// check for NaN (not a number)
169168
if(cmdline.isset("nan-check"))
170-
options.set_option("nan-check", true);
169+
options->set_option("nan-check", true);
171170
else
172-
options.set_option("nan-check", false);
171+
options->set_option("nan-check", false);
173172

174173
// check pointers
175174
if(cmdline.isset("pointer-check"))
176-
options.set_option("pointer-check", true);
175+
options->set_option("pointer-check", true);
177176
else
178-
options.set_option("pointer-check", false);
177+
options->set_option("pointer-check", false);
179178

180179
// check for memory leaks
181180
if(cmdline.isset("memory-leak-check"))
182-
options.set_option("memory-leak-check", true);
181+
options->set_option("memory-leak-check", true);
183182
else
184-
options.set_option("memory-leak-check", false);
183+
options->set_option("memory-leak-check", false);
185184

186185
// check assertions
187186
if(cmdline.isset("no-assertions"))
188-
options.set_option("assertions", false);
187+
options->set_option("assertions", false);
189188
else
190-
options.set_option("assertions", true);
189+
options->set_option("assertions", true);
191190

192191
// use assumptions
193192
if(cmdline.isset("no-assumptions"))
194-
options.set_option("assumptions", false);
193+
options->set_option("assumptions", false);
195194
else
196-
options.set_option("assumptions", true);
195+
options->set_option("assumptions", true);
197196

198197
// magic error label
199198
if(cmdline.isset("error-label"))
200-
options.set_option("error-label", cmdline.get_values("error-label"));
199+
options->set_option("error-label", cmdline.get_values("error-label"));
201200

202201
// generate unwinding assertions
203202
if(cmdline.isset("cover"))
204-
options.set_option("unwinding-assertions", false);
203+
options->set_option("unwinding-assertions", false);
205204
else
206-
options.set_option(
207-
"unwinding-assertions",
208-
cmdline.isset("unwinding-assertions"));
205+
options->set_option(
206+
"unwinding-assertions", cmdline.isset("unwinding-assertions"));
209207

210208
// generate unwinding assumptions otherwise
211-
options.set_option("partial-loops", cmdline.isset("partial-loops"));
209+
options->set_option("partial-loops", cmdline.isset("partial-loops"));
212210

213-
if(options.get_bool_option("partial-loops") &&
214-
options.get_bool_option("unwinding-assertions"))
211+
if(
212+
options->get_bool_option("partial-loops") &&
213+
options->get_bool_option("unwinding-assertions"))
215214
{
216215
error() << "--partial-loops and --unwinding-assertions"
217216
<< " must not be given together" << eom;
218217
exit(1);
219218
}
220219

221-
options.set_option("show-properties", cmdline.isset("show-properties"));
220+
options->set_option("show-properties", cmdline.isset("show-properties"));
222221
}
223222

224223
/// invoke main modules
@@ -234,8 +233,7 @@ int goto_diff_parse_optionst::doit()
234233
// command line options
235234
//
236235

237-
optionst options;
238-
get_command_line_options(options);
236+
get_command_line_options();
239237
eval_verbosity(
240238
cmdline.get_value("verbosity"), messaget::M_STATISTICS, ui_message_handler);
241239

@@ -254,12 +252,10 @@ int goto_diff_parse_optionst::doit()
254252

255253
goto_modelt goto_model1, goto_model2;
256254

257-
int get_goto_program_ret=
258-
get_goto_program(options, *this, goto_model1);
255+
int get_goto_program_ret = get_goto_program(*this, goto_model1);
259256
if(get_goto_program_ret!=-1)
260257
return get_goto_program_ret;
261-
get_goto_program_ret=
262-
get_goto_program(options, languages2, goto_model2);
258+
get_goto_program_ret = get_goto_program(languages2, goto_model2);
263259
if(get_goto_program_ret!=-1)
264260
return get_goto_program_ret;
265261

@@ -316,15 +312,14 @@ int goto_diff_parse_optionst::doit()
316312
return CPROVER_EXIT_SUCCESS;
317313
}
318314

319-
syntactic_difft sd(goto_model1, goto_model2, options, ui_message_handler);
315+
syntactic_difft sd(goto_model1, goto_model2, *options, ui_message_handler);
320316
sd();
321317
sd.output_functions();
322318

323319
return CPROVER_EXIT_SUCCESS;
324320
}
325321

326322
int goto_diff_parse_optionst::get_goto_program(
327-
const optionst &options,
328323
goto_diff_languagest &languages,
329324
goto_modelt &goto_model)
330325
{
@@ -371,7 +366,7 @@ int goto_diff_parse_optionst::get_goto_program(
371366
goto_model.goto_functions,
372367
ui_message_handler);
373368

374-
if(process_goto_program(options, goto_model))
369+
if(process_goto_program(goto_model))
375370
return CPROVER_EXIT_INTERNAL_ERROR;
376371

377372
// if we had a second argument then we will handle it next
@@ -382,9 +377,7 @@ int goto_diff_parse_optionst::get_goto_program(
382377
return -1; // no error, continue
383378
}
384379

385-
bool goto_diff_parse_optionst::process_goto_program(
386-
const optionst &options,
387-
goto_modelt &goto_model)
380+
bool goto_diff_parse_optionst::process_goto_program(goto_modelt &goto_model)
388381
{
389382
try
390383
{
@@ -417,7 +410,7 @@ bool goto_diff_parse_optionst::process_goto_program(
417410

418411
// add generic checks
419412
status() << "Generic Property Instrumentation" << eom;
420-
goto_check(options, goto_model);
413+
goto_check(*options, goto_model);
421414

422415
// checks don't know about adjusted float expressions
423416
adjust_float_expressions(goto_model);
@@ -435,7 +428,7 @@ bool goto_diff_parse_optionst::process_goto_program(
435428
// for coverage annotation:
436429
remove_skip(goto_model);
437430

438-
if(instrument_cover_goals(options, goto_model, get_message_handler()))
431+
if(instrument_cover_goals(*options, goto_model, get_message_handler()))
439432
return true;
440433
}
441434

0 commit comments

Comments
 (0)