Skip to content

Commit d724288

Browse files
committed
Do not use optionalt::value()
std::optional::value() is unavailable in earlier versions of macOS. We generally use operator* already, which always works.
1 parent 7125ed1 commit d724288

File tree

87 files changed

+294
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+294
-324
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -190,16 +190,15 @@ extract_generic_superclass_reference(const optionalt<std::string> &signature)
190190
{
191191
// skip the (potential) list of generic parameters at the beginning of the
192192
// signature
193-
const size_t start =
194-
signature.value().front() == '<'
195-
? find_closing_delimiter(signature.value(), 0, '<', '>') + 1
196-
: 0;
193+
const size_t start = signature->front() == '<'
194+
? find_closing_delimiter(*signature, 0, '<', '>') + 1
195+
: 0;
197196

198197
// extract the superclass reference
199198
const size_t end =
200-
find_closing_semi_colon_for_reference_type(signature.value(), start);
199+
find_closing_semi_colon_for_reference_type(*signature, start);
201200
const std::string superclass_ref =
202-
signature.value().substr(start, (end - start) + 1);
201+
signature->substr(start, (end - start) + 1);
203202

204203
// if the superclass is generic then the reference is of form
205204
// `Lsuperclass-name<generic-types;>;` if it is implicitly generic, then the
@@ -231,15 +230,13 @@ static optionalt<std::string> extract_generic_interface_reference(
231230
{
232231
// skip the (potential) list of generic parameters at the beginning of the
233232
// signature
234-
size_t start =
235-
signature.value().front() == '<'
236-
? find_closing_delimiter(signature.value(), 0, '<', '>') + 1
237-
: 0;
233+
size_t start = signature->front() == '<'
234+
? find_closing_delimiter(*signature, 0, '<', '>') + 1
235+
: 0;
238236

239237
// skip the superclass reference (if there is at least one interface
240238
// reference in the signature, then there is a superclass reference)
241-
start =
242-
find_closing_semi_colon_for_reference_type(signature.value(), start) + 1;
239+
start = find_closing_semi_colon_for_reference_type(*signature, start) + 1;
243240

244241
// if the interface name includes package name, convert dots to slashes
245242
std::string interface_name_slash_to_dot = interface_name;
@@ -249,13 +246,12 @@ static optionalt<std::string> extract_generic_interface_reference(
249246
'.',
250247
'/');
251248

252-
start =
253-
signature.value().find("L" + interface_name_slash_to_dot + "<", start);
249+
start = signature->find("L" + interface_name_slash_to_dot + "<", start);
254250
if(start != std::string::npos)
255251
{
256252
const size_t &end =
257-
find_closing_semi_colon_for_reference_type(signature.value(), start);
258-
return signature.value().substr(start, (end - start) + 1);
253+
find_closing_semi_colon_for_reference_type(*signature, start);
254+
return signature->substr(start, (end - start) + 1);
259255
}
260256
}
261257
return {};
@@ -277,20 +273,17 @@ void java_bytecode_convert_classt::convert(
277273
}
278274

279275
java_class_typet class_type;
280-
if(c.signature.has_value() && c.signature.value()[0]=='<')
276+
if(c.signature.has_value() && (*c.signature)[0] == '<')
281277
{
282278
java_generic_class_typet generic_class_type;
283279
#ifdef DEBUG
284-
std::cout << "INFO: found generic class signature "
285-
<< c.signature.value()
286-
<< " in parsed class "
287-
<< c.name << "\n";
280+
std::cout << "INFO: found generic class signature " << *c.signature
281+
<< " in parsed class " << c.name << "\n";
288282
#endif
289283
try
290284
{
291-
const std::vector<typet> &generic_types=java_generic_type_from_string(
292-
id2string(c.name),
293-
c.signature.value());
285+
const std::vector<typet> &generic_types =
286+
java_generic_type_from_string(id2string(c.name), *c.signature);
294287
for(const typet &t : generic_types)
295288
{
296289
generic_class_type.generic_types()
@@ -301,9 +294,9 @@ void java_bytecode_convert_classt::convert(
301294
catch(const unsupported_java_class_signature_exceptiont &e)
302295
{
303296
log.debug() << "Class: " << c.name
304-
<< "\n could not parse signature: " << c.signature.value()
305-
<< "\n " << e.what()
306-
<< "\n ignoring that the class is generic" << messaget::eom;
297+
<< "\n could not parse signature: " << *c.signature << "\n "
298+
<< e.what() << "\n ignoring that the class is generic"
299+
<< messaget::eom;
307300
}
308301
}
309302

@@ -359,15 +352,15 @@ void java_bytecode_convert_classt::convert(
359352
try
360353
{
361354
const java_generic_struct_tag_typet generic_base(
362-
base, superclass_ref.value(), qualified_classname);
355+
base, *superclass_ref, qualified_classname);
363356
class_type.add_base(generic_base);
364357
}
365358
catch(const unsupported_java_class_signature_exceptiont &e)
366359
{
367360
log.debug() << "Superclass: " << c.super_class
368361
<< " of class: " << c.name
369-
<< "\n could not parse signature: "
370-
<< superclass_ref.value() << "\n " << e.what()
362+
<< "\n could not parse signature: " << *superclass_ref
363+
<< "\n " << e.what()
371364
<< "\n ignoring that the superclass is generic"
372365
<< messaget::eom;
373366
class_type.add_base(base);
@@ -401,13 +394,13 @@ void java_bytecode_convert_classt::convert(
401394
try
402395
{
403396
const java_generic_struct_tag_typet generic_base(
404-
base, interface_ref.value(), qualified_classname);
397+
base, *interface_ref, qualified_classname);
405398
class_type.add_base(generic_base);
406399
}
407400
catch(const unsupported_java_class_signature_exceptiont &e)
408401
{
409402
log.debug() << "Interface: " << interface << " of class: " << c.name
410-
<< "\n could not parse signature: " << interface_ref.value()
403+
<< "\n could not parse signature: " << *interface_ref
411404
<< "\n " << e.what()
412405
<< "\n ignoring that the interface is generic"
413406
<< messaget::eom;

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 4 additions & 4 deletions
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,8 +279,8 @@ 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()
283-
<< "\n " << e.what() << "\n"
282+
<< "\n could not parse signature: " << *signature << "\n "
283+
<< e.what() << "\n"
284284
<< " reverting to descriptor: " << descriptor
285285
<< message.eom;
286286
}

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ main_function_resultt get_main_symbol(
557557
if(config.main.has_value())
558558
{
559559
std::string error_message;
560-
irep_idt main_symbol_id = resolve_friendly_method_name(
561-
config.main.value(), symbol_table, error_message);
560+
irep_idt main_symbol_id =
561+
resolve_friendly_method_name(*config.main, symbol_table, error_message);
562562

563563
if(main_symbol_id.empty())
564564
{

jbmc/src/java_bytecode/java_types.h

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +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)
338-
.object);
337+
abstract_objectt::merge(*old_value, value, widen_modet::no).object);
339338
}
340339

341340
DATA_INVARIANT(result->verify(), "Structural invariants maintained");
@@ -371,8 +370,7 @@ void full_array_abstract_objectt::map_put(
371370
// if we're over the max_index, merge with existing value
372371
auto replacement_value =
373372
overrun
374-
? abstract_objectt::merge(old_value.value(), value, widen_modet::no)
375-
.object
373+
? abstract_objectt::merge(*old_value, value, widen_modet::no).object
376374
: value;
377375

378376
map.replace(index_value, replacement_value);
@@ -386,7 +384,7 @@ abstract_object_pointert full_array_abstract_objectt::map_find_or_top(
386384
{
387385
auto value = map.find(index_value);
388386
if(value.has_value())
389-
return value.value();
387+
return *value;
390388
return get_top_entry(env, ns);
391389
}
392390

0 commit comments

Comments
 (0)