Skip to content

Commit e6ec72c

Browse files
author
Owen
committed
Turn get_may, set_may, etc into irep_ids
These strings appear often enough that they should be irep ids
1 parent 0a28dd1 commit e6ec72c

File tree

6 files changed

+32
-29
lines changed

6 files changed

+32
-29
lines changed

src/analyses/custom_bitvector_analysis.cpp

+13-15
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,9 @@ void custom_bitvector_domaint::transform(
450450
const auto &code = instruction.get_other();
451451
const irep_idt &statement = code.get_statement();
452452

453-
if(statement=="set_may" ||
454-
statement=="set_must" ||
455-
statement=="clear_may" ||
456-
statement=="clear_must")
453+
if(
454+
statement == ID_set_may || statement == ID_set_must ||
455+
statement == ID_clear_may || statement == ID_clear_must)
457456
{
458457
DATA_INVARIANT(
459458
code.operands().size() == 2, "set/clear_may/must has two operands");
@@ -463,13 +462,13 @@ void custom_bitvector_domaint::transform(
463462
// initialize to make Visual Studio happy
464463
modet mode = modet::SET_MUST;
465464

466-
if(statement=="set_must")
465+
if(statement == ID_set_must)
467466
mode=modet::SET_MUST;
468-
else if(statement=="clear_must")
467+
else if(statement == ID_clear_must)
469468
mode=modet::CLEAR_MUST;
470-
else if(statement=="set_may")
469+
else if(statement == ID_set_may)
471470
mode=modet::SET_MAY;
472-
else if(statement=="clear_may")
471+
else if(statement == ID_clear_may)
473472
mode=modet::CLEAR_MAY;
474473
else
475474
UNREACHABLE;
@@ -687,8 +686,7 @@ void custom_bitvector_domaint::erase_blank_vectors(bitst &bits)
687686

688687
bool custom_bitvector_domaint::has_get_must_or_may(const exprt &src)
689688
{
690-
if(src.id()=="get_must" ||
691-
src.id()=="get_may")
689+
if(src.id() == ID_get_must || src.id() == ID_get_may)
692690
return true;
693691

694692
forall_operands(it, src)
@@ -702,7 +700,7 @@ exprt custom_bitvector_domaint::eval(
702700
const exprt &src,
703701
custom_bitvector_analysist &custom_bitvector_analysis) const
704702
{
705-
if(src.id()=="get_must" || src.id()=="get_may")
703+
if(src.id() == ID_get_must || src.id() == ID_get_may)
706704
{
707705
if(src.operands().size()==2)
708706
{
@@ -717,15 +715,15 @@ exprt custom_bitvector_domaint::eval(
717715
if(pointer.is_constant() &&
718716
to_constant_expr(pointer).get_value()==ID_NULL) // NULL means all
719717
{
720-
if(src.id()=="get_may")
718+
if(src.id() == ID_get_may)
721719
{
722720
for(const auto &bit : may_bits)
723721
if(get_bit(bit.second, bit_nr))
724722
return true_exprt();
725723

726724
return false_exprt();
727725
}
728-
else if(src.id()=="get_must")
726+
else if(src.id() == ID_get_must)
729727
{
730728
return false_exprt();
731729
}
@@ -739,9 +737,9 @@ exprt custom_bitvector_domaint::eval(
739737

740738
bool value=false;
741739

742-
if(src.id()=="get_must")
740+
if(src.id() == ID_get_must)
743741
value=get_bit(v.must_bits, bit_nr);
744-
else if(src.id()=="get_may")
742+
else if(src.id() == ID_get_may)
745743
value=get_bit(v.may_bits, bit_nr);
746744

747745
if(value)

src/ansi-c/c_typecheck_expr.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2074,7 +2074,7 @@ exprt c_typecheck_baset::do_special_functions(
20742074
typecheck_function_call_arguments(expr);
20752075

20762076
binary_predicate_exprt get_must_expr(
2077-
expr.arguments()[0], "get_must", expr.arguments()[1]);
2077+
expr.arguments()[0], ID_get_must, expr.arguments()[1]);
20782078
get_must_expr.add_source_location()=source_location;
20792079

20802080
return std::move(get_must_expr);
@@ -2091,7 +2091,7 @@ exprt c_typecheck_baset::do_special_functions(
20912091
typecheck_function_call_arguments(expr);
20922092

20932093
binary_predicate_exprt get_may_expr(
2094-
expr.arguments()[0], "get_may", expr.arguments()[1]);
2094+
expr.arguments()[0], ID_get_may, expr.arguments()[1]);
20952095
get_may_expr.add_source_location()=source_location;
20962096

20972097
return std::move(get_may_expr);

src/ansi-c/expr2c.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -2911,8 +2911,7 @@ std::string expr2ct::convert_code(
29112911
if(statement==ID_array_replace)
29122912
return convert_code_array_replace(src, indent);
29132913

2914-
if(statement=="set_may" ||
2915-
statement=="set_must")
2914+
if(statement == ID_set_may || statement == ID_set_must)
29162915
return indent_str(indent) + convert_function(src, id2string(statement)) +
29172916
";";
29182917

@@ -3451,10 +3450,10 @@ std::string expr2ct::convert_with_precedence(
34513450
else if(src.id()==ID_pointer_object)
34523451
return convert_function(src, "POINTER_OBJECT");
34533452

3454-
else if(src.id()=="get_must")
3453+
else if(src.id() == ID_get_must)
34553454
return convert_function(src, CPROVER_PREFIX "get_must");
34563455

3457-
else if(src.id()=="get_may")
3456+
else if(src.id() == ID_get_may)
34583457
return convert_function(src, CPROVER_PREFIX "get_may");
34593458

34603459
else if(src.id()=="object_value")

src/goto-analyzer/taint_analysis.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void taint_analysist::instrument(
162162
{
163163
case taint_parse_treet::rulet::SOURCE:
164164
{
165-
codet code_set_may("set_may");
165+
codet code_set_may{ID_set_may};
166166
code_set_may.operands().resize(2);
167167
code_set_may.op0() = where;
168168
code_set_may.op1() =
@@ -174,10 +174,10 @@ void taint_analysist::instrument(
174174

175175
case taint_parse_treet::rulet::SINK:
176176
{
177-
binary_predicate_exprt get_may(
177+
binary_predicate_exprt get_may{
178178
where,
179-
"get_may",
180-
address_of_exprt(string_constantt(rule.taint)));
179+
ID_get_may,
180+
address_of_exprt(string_constantt(rule.taint))};
181181
goto_programt::targett t =
182182
insert_before.add(goto_programt::make_assertion(
183183
not_exprt(get_may), instruction.source_location));
@@ -189,7 +189,7 @@ void taint_analysist::instrument(
189189

190190
case taint_parse_treet::rulet::SANITIZER:
191191
{
192-
codet code_clear_may("clear_may");
192+
codet code_clear_may{ID_clear_may};
193193
code_clear_may.operands().resize(2);
194194
code_clear_may.op0() = where;
195195
code_clear_may.op1() =

src/goto-instrument/thread_instrumentation.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ void thread_exit_instrumentation(goto_programt &goto_program)
4141
const string_constantt mutex_locked_string("mutex-locked");
4242

4343
// NULL is any
44-
binary_predicate_exprt get_may(
44+
binary_predicate_exprt get_may{
4545
null_pointer_exprt(pointer_type(empty_typet())),
46-
"get_may",
47-
address_of_exprt(mutex_locked_string));
46+
ID_get_may,
47+
address_of_exprt(mutex_locked_string)};
4848

4949
*end = goto_programt::make_assertion(not_exprt(get_may), source_location);
5050

src/util/irep_ids.def

+6
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,12 @@ IREP_ID_ONE(to_member)
722722
IREP_ID_ONE(pointer_to_member)
723723
IREP_ID_ONE(tuple)
724724
IREP_ID_ONE(function_body)
725+
IREP_ID_ONE(get_may)
726+
IREP_ID_ONE(set_may)
727+
IREP_ID_ONE(clear_may)
728+
IREP_ID_ONE(get_must)
729+
IREP_ID_ONE(set_must)
730+
IREP_ID_ONE(clear_must)
725731

726732
// Projects depending on this code base that wish to extend the list of
727733
// available ids should provide a file local_irep_ids.def in their source tree

0 commit comments

Comments
 (0)