Skip to content

Remove shadowing "options" from jdiff/goto_diff methods [blocks: #2310] #3683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions jbmc/src/janalyzer/janalyzer_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ class janalyzer_parse_optionst : public parse_options_baset, public messaget
ui_message_handlert ui_message_handler;
goto_modelt goto_model;

virtual void register_languages();
void register_languages();

virtual void get_command_line_options(optionst &options);
void get_command_line_options(optionst &options);

virtual bool process_goto_program(const optionst &options);
bool process_goto_program(const optionst &options);

virtual int perform_analysis(const optionst &options);

Expand Down
4 changes: 2 additions & 2 deletions jbmc/src/jdiff/jdiff_languages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ Author: Peter Schrammel
/// \file
/// Language Registration

#include "jdiff_languages.h"
#include "jdiff_parse_options.h"

#include <langapi/mode.h>

#include <java_bytecode/java_bytecode_language.h>

void jdiff_languagest::register_languages()
void jdiff_parse_optionst::register_languages()
{
register_language(new_java_bytecode_language);
}
34 changes: 0 additions & 34 deletions jbmc/src/jdiff/jdiff_languages.h

This file was deleted.

98 changes: 14 additions & 84 deletions jbmc/src/jdiff/jdiff_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Author: Peter Schrammel
#include <goto-programs/adjust_float_expressions.h>
#include <goto-programs/goto_convert_functions.h>
#include <goto-programs/goto_inline.h>
#include <goto-programs/initialize_goto_model.h>
#include <goto-programs/instrument_preconditions.h>
#include <goto-programs/link_to_library.h>
#include <goto-programs/loop_ids.h>
Expand Down Expand Up @@ -60,28 +61,10 @@ Author: Peter Schrammel
#include <goto-diff/goto_diff.h>
#include <goto-diff/unified_diff.h>

// TODO: do not use language_uit for this; requires a refactoring of
// initialize_goto_model to support parsing specific command line files
jdiff_parse_optionst::jdiff_parse_optionst(int argc, const char **argv)
: parse_options_baset(JDIFF_OPTIONS, argc, argv, ui_message_handler),
jdiff_languagest(cmdline, ui_message_handler, &options),
ui_message_handler(cmdline, std::string("JDIFF ") + CBMC_VERSION),
languages2(cmdline, ui_message_handler, &options)
{
}

::jdiff_parse_optionst::jdiff_parse_optionst(
int argc,
const char **argv,
const std::string &extra_options)
: parse_options_baset(
JDIFF_OPTIONS + extra_options,
argc,
argv,
ui_message_handler),
jdiff_languagest(cmdline, ui_message_handler, &options),
ui_message_handler(cmdline, std::string("JDIFF ") + CBMC_VERSION),
languages2(cmdline, ui_message_handler, &options)
messaget(ui_message_handler),
ui_message_handler(cmdline, std::string("JDIFF ") + CBMC_VERSION)
{
}

Expand Down Expand Up @@ -219,19 +202,21 @@ int jdiff_parse_optionst::doit()
return CPROVER_EXIT_INCORRECT_TASK;
}

goto_modelt goto_model1, goto_model2;
register_languages();

int get_goto_program_ret = get_goto_program(options, *this, goto_model1);
if(get_goto_program_ret != -1)
return get_goto_program_ret;
get_goto_program_ret = get_goto_program(options, languages2, goto_model2);
if(get_goto_program_ret != -1)
return get_goto_program_ret;
goto_modelt goto_model1 =
initialize_goto_model({cmdline.args[0]}, ui_message_handler, options);
if(process_goto_program(options, goto_model1))
return CPROVER_EXIT_INTERNAL_ERROR;
goto_modelt goto_model2 =
initialize_goto_model({cmdline.args[1]}, ui_message_handler, options);
if(process_goto_program(options, goto_model2))
return CPROVER_EXIT_INTERNAL_ERROR;

if(cmdline.isset("show-loops"))
{
show_loop_ids(get_ui(), goto_model1);
show_loop_ids(get_ui(), goto_model2);
show_loop_ids(ui_message_handler.get_ui(), goto_model1);
show_loop_ids(ui_message_handler.get_ui(), goto_model2);
return CPROVER_EXIT_SUCCESS;
}

Expand Down Expand Up @@ -284,61 +269,6 @@ int jdiff_parse_optionst::doit()
return CPROVER_EXIT_SUCCESS;
}

int jdiff_parse_optionst::get_goto_program(
const optionst &options,
jdiff_languagest &languages,
goto_modelt &goto_model)
{
status() << "Reading program from `" << cmdline.args[0] << "'" << eom;

if(is_goto_binary(cmdline.args[0]))
{
auto tmp_goto_model =
read_goto_binary(cmdline.args[0], languages.get_message_handler());
if(!tmp_goto_model.has_value())
return CPROVER_EXIT_INCORRECT_TASK;

goto_model = std::move(*tmp_goto_model);

config.set(cmdline);

// This one is done.
cmdline.args.erase(cmdline.args.begin());
}
else
{
// This is a a workaround to make parse() think that there is only
// one source file.
std::string arg2("");
if(cmdline.args.size() == 2)
{
arg2 = cmdline.args[1];
cmdline.args.erase(--cmdline.args.end());
}

if(languages.parse() || languages.typecheck() || languages.final())
return CPROVER_EXIT_INCORRECT_TASK;

// we no longer need any parse trees or language files
languages.clear_parse();

status() << "Generating GOTO Program" << eom;

goto_model.symbol_table = languages.symbol_table;
goto_convert(
goto_model.symbol_table, goto_model.goto_functions, ui_message_handler);

if(process_goto_program(options, goto_model))
return CPROVER_EXIT_INTERNAL_ERROR;

// if we had a second argument then we will handle it next
if(arg2 != "")
cmdline.args[0] = arg2;
}

return -1; // no error, continue
}

bool jdiff_parse_optionst::process_goto_program(
const optionst &options,
goto_modelt &goto_model)
Expand Down
23 changes: 4 additions & 19 deletions jbmc/src/jdiff/jdiff_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ Author: Peter Schrammel
#include <goto-programs/show_goto_functions.h>
#include <goto-programs/show_properties.h>

#include "jdiff_languages.h"

class goto_modelt;

// clang-format off
Expand All @@ -42,34 +40,21 @@ class goto_modelt;
"(compact-output)"
// clang-format on

class jdiff_parse_optionst : public parse_options_baset, public jdiff_languagest
class jdiff_parse_optionst : public parse_options_baset, public messaget
{
public:
virtual int doit();
virtual void help();

jdiff_parse_optionst(int argc, const char **argv);
jdiff_parse_optionst(
int argc,
const char **argv,
const std::string &extra_options);

protected:
optionst options;
ui_message_handlert ui_message_handler;
jdiff_languagest languages2;

virtual void get_command_line_options(optionst &options);

virtual int get_goto_program(
const optionst &options,
jdiff_languagest &languages,
goto_modelt &goto_model);
void register_languages();

virtual bool
process_goto_program(const optionst &options, goto_modelt &goto_model);
void get_command_line_options(optionst &options);

void preprocessing();
bool process_goto_program(const optionst &options, goto_modelt &goto_model);
};

#endif // CPROVER_JDIFF_JDIFF_PARSE_OPTIONS_H
4 changes: 2 additions & 2 deletions src/goto-diff/goto_diff_languages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Author: Daniel Kroening, [email protected]
/// \file
/// Language Registration

#include "goto_diff_languages.h"
#include "goto_diff_parse_options.h"

#include <langapi/mode.h>

#include <ansi-c/ansi_c_language.h>
#include <cpp/cpp_language.h>

void goto_diff_languagest::register_languages()
void goto_diff_parse_optionst::register_languages()
{
register_language(new_ansi_c_language);
register_language(new_cpp_language);
Expand Down
33 changes: 0 additions & 33 deletions src/goto-diff/goto_diff_languages.h

This file was deleted.

Loading