Skip to content

Commit b144b2b

Browse files
committed
fixup! Do not use optionalt::value()
1 parent 5ef3788 commit b144b2b

33 files changed

+88
-88
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ extract_generic_superclass_reference(const optionalt<std::string> &signature)
191191
// skip the (potential) list of generic parameters at the beginning of the
192192
// signature
193193
const size_t start =
194-
signature.value().front() == '<'
195-
? find_closing_delimiter(signature.value(), 0, '<', '>') + 1
194+
signature->front() == '<'
195+
? find_closing_delimiter(*signature, 0, '<', '>') + 1
196196
: 0;
197197

198198
// extract the superclass reference
199199
const size_t end =
200-
find_closing_semi_colon_for_reference_type(signature.value(), start);
200+
find_closing_semi_colon_for_reference_type(*signature, start);
201201
const std::string superclass_ref =
202-
signature.value().substr(start, (end - start) + 1);
202+
signature->substr(start, (end - start) + 1);
203203

204204
// if the superclass is generic then the reference is of form
205205
// `Lsuperclass-name<generic-types;>;` if it is implicitly generic, then the
@@ -232,14 +232,14 @@ static optionalt<std::string> extract_generic_interface_reference(
232232
// skip the (potential) list of generic parameters at the beginning of the
233233
// signature
234234
size_t start =
235-
signature.value().front() == '<'
236-
? find_closing_delimiter(signature.value(), 0, '<', '>') + 1
235+
signature->front() == '<'
236+
? find_closing_delimiter(*signature, 0, '<', '>') + 1
237237
: 0;
238238

239239
// skip the superclass reference (if there is at least one interface
240240
// reference in the signature, then there is a superclass reference)
241241
start =
242-
find_closing_semi_colon_for_reference_type(signature.value(), start) + 1;
242+
find_closing_semi_colon_for_reference_type(*signature, start) + 1;
243243

244244
// if the interface name includes package name, convert dots to slashes
245245
std::string interface_name_slash_to_dot = interface_name;
@@ -250,12 +250,12 @@ static optionalt<std::string> extract_generic_interface_reference(
250250
'/');
251251

252252
start =
253-
signature.value().find("L" + interface_name_slash_to_dot + "<", start);
253+
signature->find("L" + interface_name_slash_to_dot + "<", start);
254254
if(start != std::string::npos)
255255
{
256256
const size_t &end =
257-
find_closing_semi_colon_for_reference_type(signature.value(), start);
258-
return signature.value().substr(start, (end - start) + 1);
257+
find_closing_semi_colon_for_reference_type(*signature, start);
258+
return signature->substr(start, (end - start) + 1);
259259
}
260260
}
261261
return {};
@@ -277,20 +277,20 @@ void java_bytecode_convert_classt::convert(
277277
}
278278

279279
java_class_typet class_type;
280-
if(c.signature.has_value() && c.signature.value()[0]=='<')
280+
if(c.signature.has_value() && (*c.signature)[0]=='<')
281281
{
282282
java_generic_class_typet generic_class_type;
283283
#ifdef DEBUG
284284
std::cout << "INFO: found generic class signature "
285-
<< c.signature.value()
285+
<< *c.signature
286286
<< " in parsed class "
287287
<< c.name << "\n";
288288
#endif
289289
try
290290
{
291291
const std::vector<typet> &generic_types=java_generic_type_from_string(
292292
id2string(c.name),
293-
c.signature.value());
293+
*c.signature);
294294
for(const typet &t : generic_types)
295295
{
296296
generic_class_type.generic_types()
@@ -301,7 +301,7 @@ void java_bytecode_convert_classt::convert(
301301
catch(const unsupported_java_class_signature_exceptiont &e)
302302
{
303303
log.debug() << "Class: " << c.name
304-
<< "\n could not parse signature: " << c.signature.value()
304+
<< "\n could not parse signature: " << *c.signature
305305
<< "\n " << e.what()
306306
<< "\n ignoring that the class is generic" << messaget::eom;
307307
}
@@ -359,15 +359,15 @@ void java_bytecode_convert_classt::convert(
359359
try
360360
{
361361
const java_generic_struct_tag_typet generic_base(
362-
base, superclass_ref.value(), qualified_classname);
362+
base, *superclass_ref, qualified_classname);
363363
class_type.add_base(generic_base);
364364
}
365365
catch(const unsupported_java_class_signature_exceptiont &e)
366366
{
367367
log.debug() << "Superclass: " << c.super_class
368368
<< " of class: " << c.name
369369
<< "\n could not parse signature: "
370-
<< superclass_ref.value() << "\n " << e.what()
370+
<< *superclass_ref << "\n " << e.what()
371371
<< "\n ignoring that the superclass is generic"
372372
<< messaget::eom;
373373
class_type.add_base(base);
@@ -401,13 +401,13 @@ void java_bytecode_convert_classt::convert(
401401
try
402402
{
403403
const java_generic_struct_tag_typet generic_base(
404-
base, interface_ref.value(), qualified_classname);
404+
base, *interface_ref, qualified_classname);
405405
class_type.add_base(generic_base);
406406
}
407407
catch(const unsupported_java_class_signature_exceptiont &e)
408408
{
409409
log.debug() << "Interface: " << interface << " of class: " << c.name
410-
<< "\n could not parse signature: " << interface_ref.value()
410+
<< "\n could not parse signature: " << *interface_ref
411411
<< "\n " << e.what()
412412
<< "\n ignoring that the interface is generic"
413413
<< messaget::eom;

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ java_method_typet member_type_lazy(
255255
try
256256
{
257257
auto member_type_from_signature =
258-
java_type_from_string(signature.value(), class_name);
258+
java_type_from_string(*signature, class_name);
259259
INVARIANT(
260260
member_type_from_signature.has_value() &&
261261
member_type_from_signature->id() == ID_code,
@@ -269,7 +269,7 @@ java_method_typet member_type_lazy(
269269
else
270270
{
271271
message.debug() << "Method: " << class_name << "." << method_name
272-
<< "\n signature: " << signature.value()
272+
<< "\n signature: " << *signature
273273
<< "\n descriptor: " << descriptor
274274
<< "\n different number of parameters, reverting to "
275275
"descriptor"
@@ -279,7 +279,7 @@ java_method_typet member_type_lazy(
279279
catch(const unsupported_java_class_signature_exceptiont &e)
280280
{
281281
message.debug() << "Method: " << class_name << "." << method_name
282-
<< "\n could not parse signature: " << signature.value()
282+
<< "\n could not parse signature: " << *signature
283283
<< "\n " << e.what() << "\n"
284284
<< " reverting to descriptor: " << descriptor
285285
<< message.eom;

jbmc/src/java_bytecode/java_bytecode_language.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -338,18 +338,18 @@ void java_bytecode_languaget::parse_from_main_class()
338338
throwMainClassLoadingError(id2string(main_class));
339339
return;
340340
}
341-
status() << "Trying to load Java main class: " << maybe_class_name.value()
341+
status() << "Trying to load Java main class: " << *maybe_class_name
342342
<< eom;
343343
if(!java_class_loader.can_load_class(
344-
maybe_class_name.value(), get_message_handler()))
344+
*maybe_class_name, get_message_handler()))
345345
{
346346
throwMainClassLoadingError(id2string(main_class));
347347
return;
348348
}
349349
// Everything went well. We have a loadable main class.
350350
// The entry point ('main') will be checked later.
351351
config.main = id2string(main_class);
352-
main_class = maybe_class_name.value();
352+
main_class = *maybe_class_name;
353353
}
354354
status() << "Found Java main class: " << main_class << eom;
355355
// Now really load it.
@@ -403,7 +403,7 @@ bool java_bytecode_languaget::parse(
403403
// If we have an entry method, we can derive a main class.
404404
if(config.main.has_value())
405405
{
406-
const std::string &entry_method = config.main.value();
406+
const std::string &entry_method = *config.main;
407407
const auto last_dot_position = entry_method.find_last_of('.');
408408
main_class = entry_method.substr(0, last_dot_position);
409409
}

jbmc/src/java_bytecode/java_entry_point.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ main_function_resultt get_main_symbol(
558558
{
559559
std::string error_message;
560560
irep_idt main_symbol_id = resolve_friendly_method_name(
561-
config.main.value(), symbol_table, error_message);
561+
*config.main, symbol_table, error_message);
562562

563563
if(main_symbol_id.empty())
564564
{

jbmc/src/java_bytecode/java_types.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ inline optionalt<typet> java_type_from_string_with_exception(
11451145
{
11461146
try
11471147
{
1148-
return java_type_from_string(signature.value(), class_name);
1148+
return java_type_from_string(*signature, class_name);
11491149
}
11501150
catch(unsupported_java_class_signature_exceptiont &)
11511151
{

jbmc/unit/java-testing-utils/require_goto_statements.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ require_goto_statements::find_struct_component_assignments(
102102
const member_exprt &superclass_expr =
103103
to_member_expr(member_expr.compound());
104104
const irep_idt supercomponent_name =
105-
"@" + id2string(superclass_name.value());
105+
"@" + id2string(*superclass_name);
106106

107107
object_descriptor_exprt ode;
108108
const namespacet ns(symbol_table);

jbmc/unit/java-testing-utils/require_type.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pointer_typet require_type::require_pointer(
2323
const pointer_typet &pointer = to_pointer_type(type);
2424

2525
if(subtype)
26-
REQUIRE(pointer.subtype() == subtype.value());
26+
REQUIRE(pointer.subtype() == *subtype);
2727

2828
return pointer;
2929
}
@@ -248,7 +248,7 @@ const typet &require_type::require_java_non_generic_type(
248248
REQUIRE(!is_java_generic_parameter(type));
249249
REQUIRE(!is_java_generic_type(type));
250250
if(expect_subtype)
251-
REQUIRE(type.subtype() == expect_subtype.value());
251+
REQUIRE(type.subtype() == *expect_subtype);
252252
return type;
253253
}
254254

jbmc/unit/java_bytecode/java_types/generic_type_index.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ SCENARIO("generic_type_index", "[core][java_types]")
3434
THEN("X has index 0, Y index 1 and Z is not found")
3535
{
3636
REQUIRE(indexX.has_value());
37-
REQUIRE(indexX.value() == 0);
37+
REQUIRE(*indexX == 0);
3838
REQUIRE(index_value.has_value());
39-
REQUIRE(index_value.value() == 1);
39+
REQUIRE(*index_value == 1);
4040
REQUIRE_FALSE(indexZ.has_value());
4141
}
4242
}
@@ -66,9 +66,9 @@ SCENARIO("generic_type_index", "[core][java_types]")
6666
THEN("K has index 0, V index 1 and T is not found")
6767
{
6868
REQUIRE(index_param0.has_value());
69-
REQUIRE(index_param0.value() == 0);
69+
REQUIRE(*index_param0 == 0);
7070
REQUIRE(index_param1.has_value());
71-
REQUIRE(index_param1.value() == 1);
71+
REQUIRE(*index_param1 == 1);
7272
REQUIRE_FALSE(index_param2.has_value());
7373
}
7474
}

src/analyses/variable-sensitivity/abstract_environment.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ abstract_object_pointert abstract_environmentt::resolve_symbol(
140140
const auto symbol_entry = map.find(symbol.get_identifier());
141141

142142
if(symbol_entry.has_value())
143-
return symbol_entry.value();
143+
return *symbol_entry;
144144
return abstract_object_factory(expr.type(), ns, true, false);
145145
}
146146

@@ -490,7 +490,7 @@ abstract_environmentt::modified_symbols(
490490
const auto &second_entry = second.map.find(entry.first);
491491
if(second_entry.has_value())
492492
{
493-
if(second_entry.value().get()->has_been_modified(entry.second))
493+
if(second_entry->get()->has_been_modified(entry.second))
494494
{
495495
CHECK_RETURN(!entry.first.empty());
496496
symbols_diff.push_back(entry.first);

src/analyses/variable-sensitivity/full_array_abstract_object.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ abstract_object_pointert full_array_abstract_objectt::write_leaf_element(
334334
{
335335
result->map.replace(
336336
index.value,
337-
abstract_objectt::merge(old_value.value(), value, widen_modet::no)
337+
abstract_objectt::merge(*old_value, value, widen_modet::no)
338338
.object);
339339
}
340340

@@ -371,7 +371,7 @@ void full_array_abstract_objectt::map_put(
371371
// if we're over the max_index, merge with existing value
372372
auto replacement_value =
373373
overrun
374-
? abstract_objectt::merge(old_value.value(), value, widen_modet::no)
374+
? abstract_objectt::merge(*old_value, value, widen_modet::no)
375375
.object
376376
: value;
377377

@@ -386,7 +386,7 @@ abstract_object_pointert full_array_abstract_objectt::map_find_or_top(
386386
{
387387
auto value = map.find(index_value);
388388
if(value.has_value())
389-
return value.value();
389+
return *value;
390390
return get_top_entry(env, ns);
391391
}
392392

src/analyses/variable-sensitivity/full_struct_abstract_object.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ abstract_object_pointert full_struct_abstract_objectt::read_component(
9797

9898
if(value.has_value())
9999
{
100-
return value.value();
100+
return *value;
101101
}
102102
else
103103
{
@@ -145,7 +145,7 @@ abstract_object_pointert full_struct_abstract_objectt::write_component(
145145
{
146146
result->map.replace(
147147
c,
148-
environment.write(old_value.value(), value, stack, ns, merging_write));
148+
environment.write(*old_value, value, stack, ns, merging_write));
149149
}
150150

151151
result->set_not_top();
@@ -179,7 +179,7 @@ abstract_object_pointert full_struct_abstract_objectt::write_component(
179179

180180
result->map.replace(
181181
c,
182-
abstract_objectt::merge(old_value.value(), value, widen_modet::no)
182+
abstract_objectt::merge(*old_value, value, widen_modet::no)
183183
.object);
184184
}
185185
else
@@ -225,7 +225,7 @@ void full_struct_abstract_objectt::output(
225225
out << ", ";
226226
}
227227
out << '.' << field.get_name() << '=';
228-
static_cast<const abstract_object_pointert &>(value.value())
228+
static_cast<const abstract_object_pointert &>(*value)
229229
->output(out, ai, ns);
230230
first = false;
231231
}

src/analyses/variable-sensitivity/interval_abstract_value.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static inline mp_integer force_value_from_expr(const exprt &value)
119119
PRECONDITION(constant_interval_exprt::is_int(value.type()));
120120
optionalt<mp_integer> maybe_integer_value = numeric_cast<mp_integer>(value);
121121
INVARIANT(maybe_integer_value.has_value(), "Input has to have a value");
122-
return maybe_integer_value.value();
122+
return *maybe_integer_value;
123123
}
124124

125125
static inline constant_interval_exprt

src/analyses/variable-sensitivity/liveness_context.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ bool liveness_contextt::has_location() const
1515

1616
abstract_objectt::locationt liveness_contextt::get_location() const
1717
{
18-
return assign_location.value();
18+
return *assign_location;
1919
}
2020

2121
/**

src/ansi-c/ansi_c_entry_point.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ bool ansi_c_entry_point(
121121
std::list<irep_idt> matches;
122122

123123
for(const auto &symbol_name_entry :
124-
equal_range(symbol_table.symbol_base_map, config.main.value()))
124+
equal_range(symbol_table.symbol_base_map, *config.main))
125125
{
126126
// look it up
127127
symbol_tablet::symbolst::const_iterator s_it =
@@ -137,15 +137,15 @@ bool ansi_c_entry_point(
137137
if(matches.empty())
138138
{
139139
messaget message(message_handler);
140-
message.error() << "main symbol '" << config.main.value() << "' not found"
140+
message.error() << "main symbol '" << *config.main << "' not found"
141141
<< messaget::eom;
142142
return true; // give up
143143
}
144144

145145
if(matches.size()>=2)
146146
{
147147
messaget message(message_handler);
148-
message.error() << "main symbol '" << config.main.value()
148+
message.error() << "main symbol '" << *config.main
149149
<< "' is ambiguous" << messaget::eom;
150150
return true;
151151
}

0 commit comments

Comments
 (0)