Skip to content

Commit 2e90035

Browse files
author
Daniel Kroening
authored
Merge pull request #2590 from peterschrammel/use-proper-irep-ids
Use irep id defs for all #comments
2 parents a354235 + 12e970b commit 2e90035

18 files changed

+75
-67
lines changed

src/ansi-c/c_typecheck_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ void c_typecheck_baset::typecheck_expr_symbol(exprt &expr)
836836
if(expr.type().id()==ID_code) // function designator
837837
{ // special case: this is sugar for &f
838838
address_of_exprt tmp(expr, pointer_type(expr.type()));
839-
tmp.set("#implicit", true);
839+
tmp.set(ID_C_implicit, true);
840840
tmp.add_source_location()=expr.source_location();
841841
expr=tmp;
842842
}

src/cpp/cpp_constructor.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ codet cpp_typecheckt::cpp_constructor(
4646
// The purpose of the tag #array_ini is to rule out ill-formed
4747
// programs.
4848

49-
if(!operands.empty() && !operands.front().get_bool("#array_ini"))
49+
if(!operands.empty() && !operands.front().get_bool(ID_C_array_ini))
5050
{
5151
error().source_location=source_location;
5252
error() << "bad array initializer" << eom;
@@ -65,7 +65,7 @@ codet cpp_typecheckt::cpp_constructor(
6565
const exprt &size_expr=
6666
to_array_type(tmp_type).size();
6767

68-
if(size_expr.id()=="infinity")
68+
if(size_expr.id() == ID_infinity)
6969
{
7070
// don't initialize
7171
codet nil;
@@ -91,8 +91,8 @@ codet cpp_typecheckt::cpp_constructor(
9191
exprt op_tc=operands.front();
9292
typecheck_expr(op_tc);
9393
// Override constantness
94-
object_tc.type().set("#constant", false);
95-
object_tc.set("#lvalue", true);
94+
object_tc.type().set("ID_C_constant", false);
95+
object_tc.set("ID_C_lvalue", true);
9696
side_effect_exprt assign("assign");
9797
assign.add_source_location()=source_location;
9898
assign.copy_to_operands(object_tc, op_tc);

src/cpp/cpp_declarator_converter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ symbolt &cpp_declarator_convertert::convert(
200200
if(!storage_spec.is_extern())
201201
symbol.is_extern = false;
202202

203-
if(declarator.get_bool("#template_case"))
203+
if(declarator.get_bool(ID_C_template_case))
204204
return symbol;
205205

206206
combine_types(declarator.name().source_location(), final_type, symbol);
@@ -258,7 +258,7 @@ void cpp_declarator_convertert::combine_types(
258258
if(decl_parameter.type()!=symbol_parameter.type())
259259
{
260260
// The 'this' parameter of virtual functions mismatches
261-
if(i!=0 || !symbol_code_type.get_bool("#is_virtual"))
261+
if(i != 0 || !symbol_code_type.get_bool(ID_C_is_virtual))
262262
{
263263
cpp_typecheck.error().source_location=source_location;
264264
cpp_typecheck.error() << "symbol `" << symbol.display_name()

src/cpp/cpp_typecheck_code.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
178178
// Let's first typecheck the operands.
179179
Forall_operands(it, code)
180180
{
181-
const bool has_array_ini = it->get_bool("#array_ini");
181+
const bool has_array_ini = it->get_bool(ID_C_array_ini);
182182
typecheck_expr(*it);
183183
if(has_array_ini)
184-
it->set("#array_ini", true);
184+
it->set(ID_C_array_ini, true);
185185
}
186186

187187
// The initializer may be a data member (non-type)
@@ -228,7 +228,7 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
228228
// done building the expression, check the argument types
229229
typecheck_function_call_arguments(function_call);
230230

231-
if(symbol_expr.get_bool("#not_accessible"))
231+
if(symbol_expr.get_bool(ID_C_not_accessible))
232232
{
233233
irep_idt access = symbol_expr.get(ID_C_access);
234234

@@ -312,9 +312,9 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
312312
reference_initializer(code.op0(), symbol_expr.type());
313313

314314
// assign the pointers
315-
symbol_expr.type().remove("#reference");
316-
symbol_expr.set("#lvalue", true);
317-
code.op0().type().remove("#reference");
315+
symbol_expr.type().remove(ID_C_reference);
316+
symbol_expr.set(ID_C_lvalue, true);
317+
code.op0().type().remove(ID_C_reference);
318318

319319
side_effect_exprt assign(ID_assign);
320320
assign.add_source_location() = code.source_location();

src/cpp/cpp_typecheck_compound_type.cpp

+12-14
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
426426
if(cpp_name.is_operator())
427427
{
428428
component.set("is_operator", true);
429-
component.type().set("#is_operator", true);
429+
component.type().set(ID_C_is_operator, true);
430430
}
431431

432432
if(is_cast_operator)
@@ -442,7 +442,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
442442
if(is_static)
443443
{
444444
component.set(ID_is_static, true);
445-
component.type().set("#is_static", true);
445+
component.type().set(ID_C_is_static, true);
446446
}
447447

448448
if(is_typedef)
@@ -517,7 +517,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
517517
else // virtual
518518
{
519519
component.type().set(ID_C_is_virtual, true);
520-
component.type().set("#virtual_name", virtual_name);
520+
component.type().set(ID_C_virtual_name, virtual_name);
521521

522522
// Check if it is a pure virtual method
523523
if(value.is_not_nil() && value.id() == ID_constant)
@@ -888,9 +888,9 @@ void cpp_typecheckt::typecheck_friend_declaration(
888888
// typecheck ftype
889889

890890
// TODO
891-
// typecheck_type(ftype);
892-
// assert(ftype.id()==ID_symbol);
893-
// symbol.type.add("#friends").move_to_sub(ftype);
891+
// typecheck_type(ftype);
892+
// assert(ftype.id()==ID_symbol);
893+
// symbol.type.add("ID_C_friends").move_to_sub(ftype);
894894

895895
return;
896896
}
@@ -914,7 +914,7 @@ void cpp_typecheckt::typecheck_friend_declaration(
914914
declaration.type(), declaration.storage_spec(),
915915
declaration.member_spec(), sub_it);
916916
exprt symb_expr=cpp_symbol_expr(conv_symb);
917-
symbol.type.add("#friends").move_to_sub(symb_expr);
917+
symbol.type.add(ID_C_friends).move_to_sub(symb_expr);
918918
}
919919
else
920920
{
@@ -929,7 +929,7 @@ void cpp_typecheckt::typecheck_friend_declaration(
929929

930930
exprt symb_expr=cpp_symbol_expr(conv_symb);
931931

932-
symbol.type.add("#friends").move_to_sub(symb_expr);
932+
symbol.type.add(ID_C_friends).move_to_sub(symb_expr);
933933
}
934934
}
935935
}
@@ -1462,7 +1462,7 @@ void cpp_typecheckt::convert_anon_struct_union_member(
14621462

14631463
put_compound_into_scope(component);
14641464

1465-
struct_union_symbol.type.set("#unnamed_object", base_name);
1465+
struct_union_symbol.type.set(ID_C_unnamed_object, base_name);
14661466
}
14671467

14681468
bool cpp_typecheckt::get_component(
@@ -1496,7 +1496,7 @@ bool cpp_typecheckt::get_component(
14961496
{
14971497
if(disable_access_control)
14981498
{
1499-
member.set("#not_accessible", true);
1499+
member.set(ID_C_not_accessible, true);
15001500
member.set(ID_C_access, component.get(ID_access));
15011501
}
15021502
else
@@ -1520,8 +1520,7 @@ bool cpp_typecheckt::get_component(
15201520

15211521
return true; // component found
15221522
}
1523-
else if(
1524-
follow(component.type()).find("#unnamed_object").is_not_nil())
1523+
else if(follow(component.type()).find(ID_C_unnamed_object).is_not_nil())
15251524
{
15261525
// could be anonymous union or struct
15271526

@@ -1597,8 +1596,7 @@ bool cpp_typecheckt::check_component_access(
15971596
}
15981597

15991598
// check friendship
1600-
const irept::subt &friends=
1601-
struct_union_type.find("#friends").get_sub();
1599+
const irept::subt &friends = struct_union_type.find(ID_C_friends).get_sub();
16021600

16031601
forall_irep(f_it, friends)
16041602
{

src/cpp/cpp_typecheck_constructor.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ void cpp_typecheckt::default_cpctor(
344344
memberexpr.add_source_location()=source_location;
345345

346346
if(mem_it->type().id()==ID_array)
347-
memberexpr.set("#array_ini", true);
347+
memberexpr.set(ID_C_array_ini, true);
348348

349349
mem_init.move_to_operands(memberexpr);
350350
initializers.move_to_sub(mem_init);
@@ -386,7 +386,7 @@ void cpp_typecheckt::default_assignop(
386386

387387
declarator_type.id(ID_function_type);
388388
declarator_type.subtype()=reference_type(nil_typet());
389-
declarator_type.subtype().add("#qualifier").make_nil();
389+
declarator_type.subtype().add(ID_C_qualifier).make_nil();
390390

391391
exprt &args=static_cast<exprt&>(declarator.type().add(ID_parameters));
392392
args.add_source_location()=source_location;

src/cpp/cpp_typecheck_conversions.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1258,9 +1258,9 @@ bool cpp_typecheckt::reference_binding(
12581258
expr.set(ID_C_lvalue, true);
12591259
else if(expr.get(ID_statement)==ID_function_call)
12601260
expr.set(ID_C_lvalue, true);
1261-
else if(expr.get_bool("#temporary_avoided"))
1261+
else if(expr.get_bool(ID_C_temporary_avoided))
12621262
{
1263-
expr.remove("#temporary_avoided");
1263+
expr.remove(ID_C_temporary_avoided);
12641264
exprt temporary;
12651265
new_temporary(expr.source_location(), expr.type(), expr, temporary);
12661266
expr.swap(temporary);
@@ -1965,7 +1965,7 @@ bool cpp_typecheckt::static_typecast(
19651965
else
19661966
{
19671967
// try to avoid temporary
1968-
new_expr.set("#temporary_avoided", true);
1968+
new_expr.set(ID_C_temporary_avoided, true);
19691969
if(new_expr.get_bool(ID_C_lvalue))
19701970
new_expr.remove(ID_C_lvalue);
19711971
}

src/cpp/cpp_typecheck_declaration.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ void cpp_typecheckt::convert_anonymous_union(
9898
id.is_member=true;
9999
}
100100

101-
symbol_table.get_writeable_ref(union_symbol.name).type.set(
102-
"#unnamed_object", symbol.base_name);
101+
symbol_table.get_writeable_ref(union_symbol.name)
102+
.type.set(ID_C_unnamed_object, symbol.base_name);
103103

104104
code.swap(new_code);
105105
}

src/cpp/cpp_typecheck_expr.cpp

+15-17
Original file line numberDiff line numberDiff line change
@@ -2017,8 +2017,8 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
20172017
{
20182018
if(expr.function().type().find("to-member").is_not_nil())
20192019
{
2020-
const exprt &bound=
2021-
static_cast<const exprt &>(expr.function().type().find("#bound"));
2020+
const exprt &bound =
2021+
static_cast<const exprt &>(expr.function().type().find(ID_C_bound));
20222022

20232023
if(bound.is_nil())
20242024
{
@@ -2032,7 +2032,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
20322032
expr.arguments().insert(expr.arguments().begin(), bound);
20332033

20342034
// we don't need the object any more
2035-
expr.function().type().remove("#bound");
2035+
expr.function().type().remove(ID_C_bound);
20362036
}
20372037

20382038
// do implicit dereference
@@ -2060,8 +2060,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
20602060
}
20612061
else if(expr.function().type().id()==ID_code)
20622062
{
2063-
if(expr.function().type().get_bool("#is_virtual") &&
2064-
!is_qualified)
2063+
if(expr.function().type().get_bool(ID_C_is_virtual) && !is_qualified)
20652064
{
20662065
exprt vtptr_member;
20672066
if(op0.id()==ID_member || op0.id()==ID_ptrmember)
@@ -2093,9 +2092,9 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
20932092
vtptr_member.set(ID_component_name, vtable_name);
20942093

20952094
// look for the right entry
2096-
irep_idt vtentry_component_name=
2097-
vt_compo.type().subtype().get_string(ID_identifier)+"::"+
2098-
expr.function().type().get_string("#virtual_name");
2095+
irep_idt vtentry_component_name =
2096+
vt_compo.type().subtype().get_string(ID_identifier) +
2097+
"::" + expr.function().type().get_string(ID_C_virtual_name);
20992098

21002099
exprt vtentry_member(ID_ptrmember);
21012100
vtentry_member.copy_to_operands(vtptr_member);
@@ -2190,10 +2189,10 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
21902189
member);
21912190

21922191
// special case for the initialization of parents
2193-
if(member.get_bool("#not_accessible"))
2192+
if(member.get_bool(ID_C_not_accessible))
21942193
{
21952194
assert(member.get(ID_C_access)!="");
2196-
tmp_object_expr.set("#not_accessible", true);
2195+
tmp_object_expr.set(ID_C_not_accessible, true);
21972196
tmp_object_expr.set(ID_C_access, member.get(ID_C_access));
21982197
}
21992198

@@ -2307,7 +2306,7 @@ void cpp_typecheckt::typecheck_function_call_arguments(
23072306
exprt::operandst::iterator arg_it=expr.arguments().begin();
23082307
for(const auto &parameter : parameters)
23092308
{
2310-
if(parameter.get_bool("#call_by_value"))
2309+
if(parameter.get_bool(ID_C_call_by_value))
23112310
{
23122311
assert(is_reference(parameter.type()));
23132312

@@ -2383,7 +2382,7 @@ void cpp_typecheckt::typecheck_method_application(
23832382

23842383
const symbolt &symbol=lookup(member_expr.get(ID_component_name));
23852384
symbolt &method_symbol=symbol_table.get_writeable_ref(symbol.name);
2386-
const symbolt &tag_symbol=lookup(symbol.type.get("#member_name"));
2385+
const symbolt &tag_symbol = lookup(symbol.type.get(ID_C_member_name));
23872386

23882387
// build the right template map
23892388
// if this is an instantiated template class method
@@ -2409,15 +2408,15 @@ void cpp_typecheckt::typecheck_method_application(
24092408
new_function.add_source_location()=member_expr.source_location();
24102409
expr.function().swap(new_function);
24112410

2412-
if(!expr.function().type().get_bool("#is_static"))
2411+
if(!expr.function().type().get_bool(ID_C_is_static))
24132412
{
24142413
const code_typet &func_type=to_code_type(symbol.type);
24152414
typet this_type=func_type.parameters().front().type();
24162415

24172416
// Special case. Make it a reference.
24182417
assert(this_type.id()==ID_pointer);
24192418
this_type.set(ID_C_reference, true);
2420-
this_type.set("#this", true);
2419+
this_type.set(ID_C_this, true);
24212420

24222421
if(expr.arguments().size()==func_type.parameters().size())
24232422
{
@@ -2690,7 +2689,7 @@ void cpp_typecheckt::convert_pmop(exprt &expr)
26902689
}
26912690

26922691
exprt tmp(expr.op1());
2693-
tmp.type().set("#bound", expr.op0());
2692+
tmp.type().set(ID_C_bound, expr.op0());
26942693
expr.swap(tmp);
26952694
return;
26962695
}
@@ -2714,8 +2713,7 @@ void cpp_typecheckt::typecheck_expr_function_identifier(exprt &expr)
27142713

27152714
void cpp_typecheckt::typecheck_expr(exprt &expr)
27162715
{
2717-
bool override_constantness=
2718-
expr.get_bool("#override_constantness");
2716+
bool override_constantness = expr.get_bool(ID_C_override_constantness);
27192717

27202718
// We take care of an ambiguity in the C++ grammar.
27212719
// Needs to be done before the operands!

src/cpp/cpp_typecheck_fargs.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ bool cpp_typecheck_fargst::match(
107107
if(it==ops.begin() && parameter.get(ID_C_base_name)==ID_this)
108108
{
109109
type.set(ID_C_reference, true);
110-
type.set("#this", true);
110+
type.set(ID_C_this, true);
111111
}
112112

113113
unsigned rank=0;

src/cpp/cpp_typecheck_resolve.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1697,7 +1697,7 @@ exprt cpp_typecheck_resolvet::resolve(
16971697
}
16981698

16991699
// we do some checks before we return
1700-
if(result.get_bool("#not_accessible"))
1700+
if(result.get_bool(ID_C_not_accessible))
17011701
{
17021702
#if 0
17031703
if(!fail_with_exception)
@@ -2223,8 +2223,9 @@ bool cpp_typecheck_resolvet::disambiguate_functions(
22232223
}
22242224
else
22252225
{
2226-
if(expr.type().get_bool("#is_operator") &&
2227-
fargs.operands.size() == parameters.size())
2226+
if(
2227+
expr.type().get_bool(ID_C_is_operator) &&
2228+
fargs.operands.size() == parameters.size())
22282229
{
22292230
return fargs.match(type, args_distance, cpp_typecheck);
22302231
}

src/goto-programs/builtin_functions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ void goto_convertt::do_function_call_symbol(
654654
const exprt::operandst &arguments,
655655
goto_programt &dest)
656656
{
657-
if(function.get_bool("#invalid_object"))
657+
if(function.get_bool(ID_C_invalid_object))
658658
return; // ignore
659659

660660
// lookup symbol

src/goto-symex/build_goto_trace.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void set_internal_dynamic_object(
114114
const symbolt *symbol;
115115
if(!ns.lookup(id, symbol))
116116
{
117-
bool result=symbol->type.get_bool("#dynamic");
117+
bool result = symbol->type.get_bool(ID_C_dynamic);
118118
if(result)
119119
goto_trace_step.internal=true;
120120
}

0 commit comments

Comments
 (0)