Skip to content

Call get_language_options on --show-parse-tree #1113

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
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
2 changes: 2 additions & 0 deletions src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ int cbmc_parse_optionst::get_goto_program(
}

languaget *language=get_language_from_filename(filename);
language->get_language_options(cmdline);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is potentially also missing from clobber_parse_options.cpp and possibly other places (by looking for references to get_language_from_filename and get_language_from_mode). Is there a way we can make this less error prone, or at least add a clear error message if get_language_options hasn't been called for an instance of language

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okk, I added it to clobber...cpp too, I also changed the exception message to include that maybe get_language_options was not called


if(language==NULL)
{
Expand Down Expand Up @@ -751,6 +752,7 @@ void cbmc_parse_optionst::preprocessing()
}

languaget *ptr=get_language_from_filename(filename);
ptr->get_language_options(cmdline);

if(ptr==NULL)
{
Expand Down
1 change: 1 addition & 0 deletions src/clobber/clobber_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ bool clobber_parse_optionst::get_goto_program(
}

languaget *language=get_language_from_filename(filename);
language->get_language_options(cmdline);

if(language==NULL)
{
Expand Down
4 changes: 4 additions & 0 deletions src/java_bytecode/java_bytecode_language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
#include <util/config.h>
#include <util/cmdline.h>
#include <util/string2int.h>
#include <util/invariant.h>
#include <json/json_parser.h>

#include <goto-programs/class_hierarchy.h>
Expand Down Expand Up @@ -79,6 +80,8 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
}
else
java_cp_include_files=".*";

language_options_initialized=true;
}

std::set<std::string> java_bytecode_languaget::extensions() const
Expand All @@ -105,6 +108,7 @@ bool java_bytecode_languaget::parse(
std::istream &instream,
const std::string &path)
{
PRECONDITION(language_options_initialized);
java_class_loader.set_message_handler(get_message_handler());
java_class_loader.set_java_cp_include_files(java_cp_include_files);

Expand Down
2 changes: 1 addition & 1 deletion src/java_bytecode/java_class_loader_limit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void java_class_loader_limitt::setup_class_load_limit(
std::string &java_cp_include_files)
{
if(java_cp_include_files.empty())
throw "class regexp cannot be empty";
throw "class regexp cannot be empty, `get_language_options` not called?";

// '@' signals file reading with list of class files to load
regex_match=java_cp_include_files[0]!='@';
Expand Down
1 change: 1 addition & 0 deletions src/util/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class languaget:public messaget
static irep_idt get_stub_return_symbol_name(const irep_idt &function_id);

bool generate_opaque_stubs;
bool language_options_initialized=false;

private:
bool is_symbol_opaque_function(const symbolt &symbol);
Expand Down