Skip to content

Wrap return value in std::move (Clang 7 build fix) #3301

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 1 commit into from
Nov 9, 2018
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
12 changes: 8 additions & 4 deletions jbmc/src/java_bytecode/java_string_library_preprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,8 @@ codet java_string_library_preprocesst::make_assign_function_from_call(
/// \return An expression contaning a symbol `tmp_type_name` where `type_name`
/// is the given argument (ie. boolean, char etc.). Which represents the
/// primitive value contained in the given object.
exprt java_string_library_preprocesst::get_primitive_value_of_object(
optionalt<symbol_exprt>
java_string_library_preprocesst::get_primitive_value_of_object(
const exprt &object,
irep_idt type_name,
const source_locationt &loc,
Expand Down Expand Up @@ -1222,7 +1223,7 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
object_type=symbol_typet("java::java.lang.Double");
}
else if(type_name==ID_void)
return nil_exprt();
return {};
else
UNREACHABLE;

Expand Down Expand Up @@ -1398,9 +1399,12 @@ exprt java_string_library_preprocesst::make_argument_for_format(
}
else if(name==ID_int || name==ID_float || name==ID_char || name==ID_boolean)
{
exprt value=get_primitive_value_of_object(
const auto value = get_primitive_value_of_object(
arg_i, name, loc, symbol_table, code_not_null);
code_not_null.add(code_assignt(field_expr, value), loc);
if(value.has_value())
code_not_null.add(code_assignt(field_expr, *value), loc);
else
code_not_null.add(code_assignt(field_expr, nil_exprt()), loc);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Puh, I'm pretty sure this is broken and has actually been all along? @romainbrenguier maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

The else case should never happen, it would be better to put an invariant here.
The nil_exprt case happen for name == ID_void, which is excluded by the if condition.

}
else
{
Expand Down
3 changes: 2 additions & 1 deletion jbmc/src/java_bytecode/java_string_library_preprocess.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Date: March 2017
#include <util/string_expr.h>

#include <util/ieee_float.h> // should get rid of this
#include <util/optional.h>

#include <array>
#include <unordered_set>
Expand Down Expand Up @@ -324,7 +325,7 @@ class java_string_library_preprocesst:public messaget
symbol_table_baset &symbol_table,
code_blockt &code);

exprt get_primitive_value_of_object(
optionalt<symbol_exprt> get_primitive_value_of_object(
const exprt &object,
irep_idt type_name,
const source_locationt &loc,
Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/literals/convert_float_literal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ exprt convert_float_literal(const std::string &src)
return complex_exprt(zero_real_component, result, complex_type);
}

return result;
return std::move(result);
}