Skip to content

Commit d77dea3

Browse files
author
Daniel Kroening
committed
strongly type the lookup() methods in namespacet
1 parent 2382f27 commit d77dea3

15 files changed

+80
-79
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ void c_typecheck_baset::typecheck_expr_member(exprt &expr)
14691469
exprt &op0=expr.op0();
14701470
typet type=op0.type();
14711471

1472-
follow_symbol(type);
1472+
type = follow(type);
14731473

14741474
if(type.id()==ID_incomplete_struct)
14751475
{

src/cpp/cpp_constructor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ codet cpp_typecheckt::cpp_constructor(
3333

3434
elaborate_class_template(object_tc.type());
3535

36-
typet tmp_type(object_tc.type());
37-
follow_symbol(tmp_type);
36+
typet tmp_type(follow(object_tc.type()));
3837

3938
assert(!is_reference(tmp_type));
4039

src/cpp/cpp_destructor.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ codet cpp_typecheckt::cpp_destructor(
2626

2727
elaborate_class_template(object.type());
2828

29-
typet tmp_type(object.type());
30-
follow_symbol(tmp_type);
29+
typet tmp_type(follow(object.type()));
3130

3231
assert(!is_reference(tmp_type));
3332

src/cpp/cpp_instantiate_template.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ void cpp_typecheckt::elaborate_class_template(
189189
if(type.id()!=ID_symbol)
190190
return;
191191

192-
const symbolt &symbol=lookup(type);
192+
const symbolt &symbol = lookup(to_symbol_type(type));
193193

194194
// Make a copy, as instantiate will destroy the symbol type!
195195
const typet t_type=symbol.type;

src/cpp/cpp_typecheck_bases.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ void cpp_typecheckt::typecheck_compound_bases(struct_typet &type)
5151
throw 0;
5252
}
5353

54-
const symbolt &base_symbol=
55-
lookup(base_symbol_expr.type());
54+
const symbolt &base_symbol =
55+
lookup(to_symbol_type(base_symbol_expr.type()));
5656

5757
if(base_symbol.type.id()==ID_incomplete_struct)
5858
{

src/cpp/cpp_typecheck_expr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ void cpp_typecheckt::typecheck_expr_main(exprt &expr)
100100
typecheck_type(base);
101101
typecheck_type(deriv);
102102

103-
follow_symbol(base);
104-
follow_symbol(deriv);
103+
base = follow(base);
104+
deriv = follow(deriv);
105105

106106
if(base.id()!=ID_struct || deriv.id()!=ID_struct)
107107
expr=false_exprt();
@@ -1991,7 +1991,7 @@ void cpp_typecheckt::typecheck_side_effect_function_call(
19911991

19921992
// look at type of function
19931993

1994-
follow_symbol(expr.function().type());
1994+
expr.function().type() = follow(expr.function().type());
19951995

19961996
if(expr.function().type().id()==ID_pointer)
19971997
{

src/cpp/cpp_typecheck_resolve.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ exprt cpp_typecheck_resolvet::convert_identifier(
352352

353353
while(followed_type.id()==ID_symbol)
354354
{
355-
typet tmp=cpp_typecheck.lookup(followed_type).type;
356-
followed_type=tmp;
355+
followed_type =
356+
cpp_typecheck.follow(to_symbol_type(followed_type));
357357
constant |= followed_type.get_bool(ID_C_constant);
358358
}
359359

@@ -1899,8 +1899,7 @@ exprt cpp_typecheck_resolvet::guess_function_template_args(
18991899
const exprt &expr,
19001900
const cpp_typecheck_fargst &fargs)
19011901
{
1902-
typet tmp=expr.type();
1903-
cpp_typecheck.follow_symbol(tmp);
1902+
typet tmp = cpp_typecheck.follow(expr.type());
19041903

19051904
if(!tmp.get_bool(ID_is_template))
19061905
return nil_exprt(); // not a template

src/goto-instrument/wmm/fence.cpp

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,33 @@ bool is_fence(
1919
const goto_programt::instructiont &instruction,
2020
const namespacet &ns)
2121
{
22-
return (instruction.is_function_call() && ns.lookup(
23-
to_code_function_call(instruction.code).function()).base_name == "fence")
24-
/* if assembly-sensitive algorithms are not available */
25-
|| (instruction.is_other() && instruction.code.get_statement()==ID_fence
26-
&& instruction.code.get_bool(ID_WWfence)
27-
&& instruction.code.get_bool(ID_WRfence)
28-
&& instruction.code.get_bool(ID_RWfence)
29-
&& instruction.code.get_bool(ID_RRfence));
22+
return (instruction.is_function_call() &&
23+
ns.lookup(
24+
to_symbol_expr(
25+
to_code_function_call(instruction.code).function()))
26+
.base_name == "fence")
27+
/* if assembly-sensitive algorithms are not available */
28+
|| (instruction.is_other() &&
29+
instruction.code.get_statement() == ID_fence &&
30+
instruction.code.get_bool(ID_WWfence) &&
31+
instruction.code.get_bool(ID_WRfence) &&
32+
instruction.code.get_bool(ID_RWfence) &&
33+
instruction.code.get_bool(ID_RRfence));
3034
}
3135

3236
bool is_lwfence(
3337
const goto_programt::instructiont &instruction,
3438
const namespacet &ns)
3539
{
36-
return (instruction.is_function_call() && ns.lookup(
37-
to_code_function_call(instruction.code).function()).base_name == "lwfence")
38-
/* if assembly-sensitive algorithms are not available */
39-
|| (instruction.is_other() && instruction.code.get_statement()==ID_fence
40-
&& instruction.code.get_bool(ID_WWfence)
41-
&& instruction.code.get_bool(ID_RWfence)
42-
&& instruction.code.get_bool(ID_RRfence));
40+
return (instruction.is_function_call() &&
41+
ns.lookup(
42+
to_symbol_expr(
43+
to_code_function_call(instruction.code).function()))
44+
.base_name == "lwfence")
45+
/* if assembly-sensitive algorithms are not available */
46+
|| (instruction.is_other() &&
47+
instruction.code.get_statement() == ID_fence &&
48+
instruction.code.get_bool(ID_WWfence) &&
49+
instruction.code.get_bool(ID_RWfence) &&
50+
instruction.code.get_bool(ID_RRfence));
4351
}

src/goto-symex/symex_assign.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ void goto_symext::symex_assign_symbol(
245245
tmp_guard.append(guard);
246246

247247
// do the assignment
248-
const symbolt &symbol=ns.lookup(ssa_lhs.get_original_expr());
248+
const symbolt &symbol =
249+
ns.lookup(to_symbol_expr(ssa_lhs.get_original_expr()));
250+
249251
if(symbol.is_auxiliary)
250252
assignment_type=symex_targett::assignment_typet::HIDDEN;
251253

src/pointer-analysis/goto_program_dereference.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bool goto_program_dereferencet::has_failed_symbol(
2828
if(expr.get_bool("#invalid_object"))
2929
return false;
3030

31-
const symbolt &ptr_symbol=ns.lookup(expr);
31+
const symbolt &ptr_symbol = ns.lookup(to_symbol_expr(expr));
3232

3333
const irep_idt &failed_symbol=
3434
ptr_symbol.type.get("#failed_symbol");

0 commit comments

Comments
 (0)