Skip to content

Commit f537e7c

Browse files
author
Daniel Kroening
committed
code_declt is now typed
1 parent 235cfa8 commit f537e7c

File tree

10 files changed

+28
-34
lines changed

10 files changed

+28
-34
lines changed

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ void add_pointer_to_array_association(
668668
loc,
669669
ID_java,
670670
symbol_table);
671-
exprt return_expr = return_sym.symbol_expr();
671+
auto return_expr = return_sym.symbol_expr();
672672
code.add(code_declt(return_expr), loc);
673673
code.add(
674674
code_assign_function_application(
@@ -700,7 +700,7 @@ void add_array_to_length_association(
700700
loc,
701701
ID_java,
702702
symbol_table);
703-
const exprt return_expr = return_sym.symbol_expr();
703+
const auto return_expr = return_sym.symbol_expr();
704704
code.add(code_declt(return_expr), loc);
705705
code.add(
706706
code_assign_function_application(
@@ -732,7 +732,7 @@ void add_character_set_constraint(
732732
PRECONDITION(pointer.type().id() == ID_pointer);
733733
symbolt &return_sym = get_fresh_aux_symbol(
734734
java_int_type(), "cnstr_added", "cnstr_added", loc, ID_java, symbol_table);
735-
const exprt return_expr = return_sym.symbol_expr();
735+
const auto return_expr = return_sym.symbol_expr();
736736
code.add(code_declt(return_expr), loc);
737737
const constant_exprt char_set_expr(char_set, string_typet());
738738
code.add(
@@ -775,7 +775,7 @@ refined_string_exprt java_string_library_preprocesst::string_expr_of_function(
775775
loc,
776776
ID_java,
777777
symbol_table);
778-
const exprt return_code = return_code_sym.symbol_expr();
778+
const auto return_code = return_code_sym.symbol_expr();
779779
code.add(code_declt(return_code), loc);
780780

781781
const refined_string_exprt string_expr =
@@ -1217,7 +1217,7 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
12171217
std::string aux_name="tmp_"+id2string(type_name);
12181218
symbolt symbol=get_fresh_aux_symbol(
12191219
value_type, aux_name, aux_name, loc, ID_java, symbol_table);
1220-
exprt value=symbol.symbol_expr();
1220+
auto value = symbol.symbol_expr();
12211221

12221222
// Check that the type of the object is in the symbol table,
12231223
// otherwise there is no safe way of finding its value.
@@ -1325,8 +1325,9 @@ exprt java_string_library_preprocesst::make_argument_for_format(
13251325
std::string tmp_name="tmp_"+id2string(name);
13261326
symbolt field_symbol = get_fresh_aux_symbol(
13271327
type, id2string(function_id), tmp_name, loc, ID_java, symbol_table);
1328-
field_expr=field_symbol.symbol_expr();
1329-
code.add(code_declt(field_expr), loc);
1328+
auto field_symbol_expr = field_symbol.symbol_expr();
1329+
field_expr = field_symbol_expr;
1330+
code.add(code_declt(field_symbol_expr), loc);
13301331
}
13311332
else
13321333
field_expr =

src/analyses/constant_propagator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void constant_propagator_domaint::transform(
9191
if(from->is_decl())
9292
{
9393
const code_declt &code_decl=to_code_decl(from->code);
94-
const symbol_exprt &symbol=to_symbol_expr(code_decl.symbol());
94+
const symbol_exprt &symbol = code_decl.symbol();
9595
values.set_to_top(symbol);
9696
}
9797
else if(from->is_assign())

src/analyses/locals.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ void localst::build(const goto_functiont &goto_function)
2121
if(it->is_decl())
2222
{
2323
const code_declt &code_decl=to_code_decl(it->code);
24-
locals_map[code_decl.get_identifier()]=
25-
to_symbol_expr(code_decl.symbol());
24+
locals_map[code_decl.get_identifier()] = code_decl.symbol();
2625
}
2726

2827
for(const auto &param : goto_function.type.parameters())

src/cpp/cpp_typecheck_code.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void cpp_typecheckt::typecheck_try_catch(codet &code)
100100
to_code_decl(to_code(code.op0().op0()));
101101

102102
// get the type
103-
const typet &type=code_decl.op0().type();
103+
const typet &type = code_decl.symbol().type();
104104

105105
// annotate exception ID
106106
op.set(ID_exception_id, cpp_exception_id(type, *this));

src/goto-diff/change_impact.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ void full_slicert::operator()(
8080
jumps.push_back(e_it->second);
8181
else if(e_it->first->is_decl())
8282
{
83-
const exprt &s=to_code_decl(e_it->first->code).symbol();
84-
decl_dead[to_symbol_expr(s).get_identifier()].push(e_it->second);
83+
const auto &s=to_code_decl(e_it->first->code).symbol();
84+
decl_dead[s.get_identifier()].push(e_it->second);
8585
}
8686
else if(e_it->first->is_dead())
8787
{

src/goto-instrument/dump_c.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,9 @@ void dump_ct::convert_global_variable(
894894
}
895895

896896
if(!func.empty() && !symbol.is_extern)
897-
local_static_decls[symbol.name]=d;
897+
{
898+
local_static_decls.insert(std::pair<irep_idt, code_declt>(symbol.name, d));
899+
}
898900
else if(!symbol.value.is_nil())
899901
{
900902
os << "// " << symbol.name << '\n';

src/goto-instrument/full_slicer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ void full_slicert::operator()(
310310
jumps.push_back(e_it->second);
311311
else if(e_it->first->is_decl())
312312
{
313-
const exprt &s=to_code_decl(e_it->first->code).symbol();
314-
decl_dead[to_symbol_expr(s).get_identifier()].push(e_it->second);
313+
const auto &s = to_code_decl(e_it->first->code).symbol();
314+
decl_dead[s.get_identifier()].push(e_it->second);
315315
}
316316
else if(e_it->first->is_dead())
317317
{

src/goto-instrument/goto_program2code.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ goto_programt::const_targett goto_program2codet::convert_decl(
458458
codet &dest)
459459
{
460460
code_declt d=to_code_decl(target->code);
461-
symbol_exprt &symbol=to_symbol_expr(d.symbol());
461+
symbol_exprt &symbol = d.symbol();
462462

463463
goto_programt::const_targett next=target;
464464
++next;

src/util/std_code.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include "std_expr.h"
1515

16-
const irep_idt &code_declt::get_identifier() const
17-
{
18-
return to_symbol_expr(symbol()).get_identifier();
19-
}
20-
2116
const irep_idt &code_deadt::get_identifier() const
2217
{
2318
return to_symbol_expr(symbol()).get_identifier();

src/util/std_code.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Author: Daniel Kroening, [email protected]
1212

1313
#include <list>
1414

15-
#include "expr.h"
1615
#include "expr_cast.h"
1716
#include "invariant.h"
17+
#include "std_expr.h"
1818

1919
/// Data structure for representing an arbitrary statement in a program. Every
2020
/// specific type of statement (e.g. block of statements, assignment,
@@ -276,28 +276,25 @@ inline code_assignt &to_code_assign(codet &code)
276276
class code_declt:public codet
277277
{
278278
public:
279-
DEPRECATED("use code_declt(symbol) instead")
280-
code_declt():codet(ID_decl)
279+
explicit code_declt(const symbol_exprt &symbol) : codet(ID_decl)
281280
{
282-
operands().resize(1);
281+
copy_to_operands(symbol);
283282
}
284283

285-
explicit code_declt(const exprt &symbol):codet(ID_decl)
284+
symbol_exprt &symbol()
286285
{
287-
copy_to_operands(symbol);
286+
return static_cast<symbol_exprt &>(op0());
288287
}
289288

290-
exprt &symbol()
289+
const symbol_exprt &symbol() const
291290
{
292-
return op0();
291+
return static_cast<const symbol_exprt &>(op0());
293292
}
294293

295-
const exprt &symbol() const
294+
const irep_idt &get_identifier() const
296295
{
297-
return op0();
296+
return symbol().get_identifier();
298297
}
299-
300-
const irep_idt &get_identifier() const;
301298
};
302299

303300
template<> inline bool can_cast_expr<code_declt>(const exprt &base)

0 commit comments

Comments
 (0)