Skip to content

Commit f83185e

Browse files
committed
Revert "Do not use optionalt::value()"
This reverts commit d724288.
1 parent 7ad368d commit f83185e

File tree

87 files changed

+324
-294
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

+324
-294
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,16 @@ 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 = signature->front() == '<'
194-
? find_closing_delimiter(*signature, 0, '<', '>') + 1
195-
: 0;
193+
const size_t start =
194+
signature.value().front() == '<'
195+
? find_closing_delimiter(signature.value(), 0, '<', '>') + 1
196+
: 0;
196197

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

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

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

241244
// if the interface name includes package name, convert dots to slashes
242245
std::string interface_name_slash_to_dot = interface_name;
@@ -246,12 +249,13 @@ static optionalt<std::string> extract_generic_interface_reference(
246249
'.',
247250
'/');
248251

249-
start = signature->find("L" + interface_name_slash_to_dot + "<", start);
252+
start =
253+
signature.value().find("L" + interface_name_slash_to_dot + "<", start);
250254
if(start != std::string::npos)
251255
{
252256
const size_t &end =
253-
find_closing_semi_colon_for_reference_type(*signature, start);
254-
return signature->substr(start, (end - start) + 1);
257+
find_closing_semi_colon_for_reference_type(signature.value(), start);
258+
return signature.value().substr(start, (end - start) + 1);
255259
}
256260
}
257261
return {};
@@ -273,17 +277,20 @@ void java_bytecode_convert_classt::convert(
273277
}
274278

275279
java_class_typet class_type;
276-
if(c.signature.has_value() && (*c.signature)[0] == '<')
280+
if(c.signature.has_value() && c.signature.value()[0]=='<')
277281
{
278282
java_generic_class_typet generic_class_type;
279283
#ifdef DEBUG
280-
std::cout << "INFO: found generic class signature " << *c.signature
281-
<< " in parsed class " << c.name << "\n";
284+
std::cout << "INFO: found generic class signature "
285+
<< c.signature.value()
286+
<< " in parsed class "
287+
<< c.name << "\n";
282288
#endif
283289
try
284290
{
285-
const std::vector<typet> &generic_types =
286-
java_generic_type_from_string(id2string(c.name), *c.signature);
291+
const std::vector<typet> &generic_types=java_generic_type_from_string(
292+
id2string(c.name),
293+
c.signature.value());
287294
for(const typet &t : generic_types)
288295
{
289296
generic_class_type.generic_types()
@@ -294,9 +301,9 @@ void java_bytecode_convert_classt::convert(
294301
catch(const unsupported_java_class_signature_exceptiont &e)
295302
{
296303
log.debug() << "Class: " << c.name
297-
<< "\n could not parse signature: " << *c.signature << "\n "
298-
<< e.what() << "\n ignoring that the class is generic"
299-
<< messaget::eom;
304+
<< "\n could not parse signature: " << c.signature.value()
305+
<< "\n " << e.what()
306+
<< "\n ignoring that the class is generic" << messaget::eom;
300307
}
301308
}
302309

@@ -352,15 +359,15 @@ void java_bytecode_convert_classt::convert(
352359
try
353360
{
354361
const java_generic_struct_tag_typet generic_base(
355-
base, *superclass_ref, qualified_classname);
362+
base, superclass_ref.value(), qualified_classname);
356363
class_type.add_base(generic_base);
357364
}
358365
catch(const unsupported_java_class_signature_exceptiont &e)
359366
{
360367
log.debug() << "Superclass: " << c.super_class
361368
<< " of class: " << c.name
362-
<< "\n could not parse signature: " << *superclass_ref
363-
<< "\n " << e.what()
369+
<< "\n could not parse signature: "
370+
<< superclass_ref.value() << "\n " << e.what()
364371
<< "\n ignoring that the superclass is generic"
365372
<< messaget::eom;
366373
class_type.add_base(base);
@@ -394,13 +401,13 @@ void java_bytecode_convert_classt::convert(
394401
try
395402
{
396403
const java_generic_struct_tag_typet generic_base(
397-
base, *interface_ref, qualified_classname);
404+
base, interface_ref.value(), qualified_classname);
398405
class_type.add_base(generic_base);
399406
}
400407
catch(const unsupported_java_class_signature_exceptiont &e)
401408
{
402409
log.debug() << "Interface: " << interface << " of class: " << c.name
403-
<< "\n could not parse signature: " << *interface_ref
410+
<< "\n could not parse signature: " << interface_ref.value()
404411
<< "\n " << e.what()
405412
<< "\n ignoring that the interface is generic"
406413
<< 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, class_name);
258+
java_type_from_string(signature.value(), 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
272+
<< "\n signature: " << signature.value()
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 << "\n "
283-
<< e.what() << "\n"
282+
<< "\n could not parse signature: " << signature.value()
283+
<< "\n " << 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
341+
status() << "Trying to load Java main class: " << maybe_class_name.value()
342342
<< eom;
343343
if(!java_class_loader.can_load_class(
344-
*maybe_class_name, get_message_handler()))
344+
maybe_class_name.value(), 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;
352+
main_class = maybe_class_name.value();
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;
406+
const std::string &entry_method = config.main.value();
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 =
561-
resolve_friendly_method_name(*config.main, symbol_table, error_message);
560+
irep_idt main_symbol_id = resolve_friendly_method_name(
561+
config.main.value(), 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, class_name);
1148+
return java_type_from_string(signature.value(), 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);
105+
"@" + id2string(superclass_name.value());
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);
26+
REQUIRE(pointer.subtype() == subtype.value());
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);
251+
REQUIRE(type.subtype() == expect_subtype.value());
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 == 0);
37+
REQUIRE(indexX.value() == 0);
3838
REQUIRE(index_value.has_value());
39-
REQUIRE(*index_value == 1);
39+
REQUIRE(index_value.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 == 0);
69+
REQUIRE(index_param0.value() == 0);
7070
REQUIRE(index_param1.has_value());
71-
REQUIRE(*index_param1 == 1);
71+
REQUIRE(index_param1.value() == 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;
143+
return symbol_entry.value();
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->get()->has_been_modified(entry.second))
493+
if(second_entry.value().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: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ 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, widen_modet::no).object);
337+
abstract_objectt::merge(old_value.value(), value, widen_modet::no)
338+
.object);
338339
}
339340

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

376378
map.replace(index_value, replacement_value);
@@ -384,7 +386,7 @@ abstract_object_pointert full_array_abstract_objectt::map_find_or_top(
384386
{
385387
auto value = map.find(index_value);
386388
if(value.has_value())
387-
return *value;
389+
return value.value();
388390
return get_top_entry(env, ns);
389391
}
390392

src/analyses/variable-sensitivity/full_struct_abstract_object.cpp

Lines changed: 8 additions & 5 deletions
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;
100+
return value.value();
101101
}
102102
else
103103
{
@@ -144,7 +144,8 @@ abstract_object_pointert full_struct_abstract_objectt::write_component(
144144
else
145145
{
146146
result->map.replace(
147-
c, environment.write(*old_value, value, stack, ns, merging_write));
147+
c,
148+
environment.write(old_value.value(), value, stack, ns, merging_write));
148149
}
149150

150151
result->set_not_top();
@@ -177,7 +178,9 @@ abstract_object_pointert full_struct_abstract_objectt::write_component(
177178
}
178179

179180
result->map.replace(
180-
c, abstract_objectt::merge(*old_value, value, widen_modet::no).object);
181+
c,
182+
abstract_objectt::merge(old_value.value(), value, widen_modet::no)
183+
.object);
181184
}
182185
else
183186
{
@@ -222,8 +225,8 @@ void full_struct_abstract_objectt::output(
222225
out << ", ";
223226
}
224227
out << '.' << field.get_name() << '=';
225-
static_cast<const abstract_object_pointert &>(*value)->output(
226-
out, ai, ns);
228+
static_cast<const abstract_object_pointert &>(value.value())
229+
->output(out, ai, ns);
227230
first = false;
228231
}
229232
}

src/analyses/variable-sensitivity/interval_abstract_value.cpp

Lines changed: 1 addition & 1 deletion
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;
122+
return maybe_integer_value.value();
123123
}
124124

125125
static inline constant_interval_exprt

src/analyses/variable-sensitivity/liveness_context.cpp

Lines changed: 1 addition & 1 deletion
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;
18+
return assign_location.value();
1919
}
2020

2121
/**

src/ansi-c/ansi_c_entry_point.cpp

Lines changed: 4 additions & 4 deletions
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))
124+
equal_range(symbol_table.symbol_base_map, config.main.value()))
125125
{
126126
// look it up
127127
symbol_tablet::symbolst::const_iterator s_it =
@@ -137,16 +137,16 @@ bool ansi_c_entry_point(
137137
if(matches.empty())
138138
{
139139
messaget message(message_handler);
140-
message.error() << "main symbol '" << *config.main << "' not found"
140+
message.error() << "main symbol '" << config.main.value() << "' 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 << "' is ambiguous"
149-
<< messaget::eom;
148+
message.error() << "main symbol '" << config.main.value()
149+
<< "' is ambiguous" << messaget::eom;
150150
return true;
151151
}
152152

0 commit comments

Comments
 (0)