Skip to content

Commit 90ec73d

Browse files
committed
Amend condition for when stub method body should be made
There are three types of method symbols that we expect here: 1) symbols for regular methods, i.e. the bytecode of the method is available and the method is in the supplied context 2) symbols for opaque methods, i.e. the bytecode of the method is not available 3) symbols for excluded methods, i.e. the bytecode of the method is available but the method is not in the supplied context The previous check was correct for 1) and 2): we do not want to create stub bodies ("return nondet") for regular methods but we do want to create them for opaque methods. The new check makes sure that stub bodies are also created for excluded methods (3). Previously the value of those symbols was just left as nil, meaning the (type of the) return value of the method was not constrained in any way.
1 parent ecb171e commit 90ec73d

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void parse_java_language_options(const cmdlinet &cmd, optionst &options)
104104
}
105105
}
106106

107-
static prefix_filtert get_context(const optionst &options)
107+
prefix_filtert get_context(const optionst &options)
108108
{
109109
std::vector<std::string> context_include;
110110
std::vector<std::string> context_exclude;

jbmc/src/java_bytecode/java_bytecode_language.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,6 @@ std::unique_ptr<languaget> new_java_bytecode_language();
304304

305305
void parse_java_language_options(const cmdlinet &cmd, optionst &options);
306306

307+
prefix_filtert get_context(const optionst &options);
308+
307309
#endif // CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_LANGUAGE_H

jbmc/src/jbmc/jbmc_parse_options.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,8 @@ int jbmc_parse_optionst::get_goto_program(
690690
std::unique_ptr<abstract_goto_modelt> &goto_model_ptr,
691691
const optionst &options)
692692
{
693+
if(options.is_set("context-include") || options.is_set("context-exclude"))
694+
method_context = get_context(options);
693695
lazy_goto_modelt lazy_goto_model =
694696
lazy_goto_modelt::from_handler_object(*this, options, ui_message_handler);
695697
lazy_goto_model.initialize(cmdline.args, options);
@@ -1009,7 +1011,9 @@ bool jbmc_parse_optionst::generate_function_body(
10091011
// Provide a simple stub implementation for any function we don't have a
10101012
// bytecode implementation for:
10111013

1012-
if(body_available)
1014+
if(
1015+
body_available &&
1016+
(!method_context || (*method_context)(id2string(function_name))))
10131017
return false;
10141018

10151019
if(!can_generate_function_body(function_name))

jbmc/src/jbmc/jbmc_parse_options.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ class jbmc_parse_optionst : public parse_options_baset
133133
const optionst &);
134134
bool show_loaded_functions(const abstract_goto_modelt &goto_model);
135135
bool show_loaded_symbols(const abstract_goto_modelt &goto_model);
136+
137+
/// See java_bytecode_languaget::method_context.
138+
/// The two fields are initialized in exactly the same way.
139+
/// TODO Refactor this so it only needs to be computed once, in one place.
140+
optionalt<prefix_filtert> method_context;
136141
};
137142

138143
#endif // CPROVER_JBMC_JBMC_PARSE_OPTIONS_H

0 commit comments

Comments
 (0)