Skip to content

Commit e889df7

Browse files
author
Daniel Kroening
committed
code_declt is now typed
1 parent 026419e commit e889df7

File tree

12 files changed

+30
-36
lines changed

12 files changed

+30
-36
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
@@ -683,7 +683,7 @@ void add_pointer_to_array_association(
683683
loc,
684684
ID_java,
685685
symbol_table);
686-
exprt return_expr = return_sym.symbol_expr();
686+
auto return_expr = return_sym.symbol_expr();
687687
code.add(code_declt(return_expr), loc);
688688
code.add(
689689
code_assign_function_application(
@@ -715,7 +715,7 @@ void add_array_to_length_association(
715715
loc,
716716
ID_java,
717717
symbol_table);
718-
const exprt return_expr = return_sym.symbol_expr();
718+
const auto return_expr = return_sym.symbol_expr();
719719
code.add(code_declt(return_expr), loc);
720720
code.add(
721721
code_assign_function_application(
@@ -747,7 +747,7 @@ void add_character_set_constraint(
747747
PRECONDITION(pointer.type().id() == ID_pointer);
748748
symbolt &return_sym = get_fresh_aux_symbol(
749749
java_int_type(), "cnstr_added", "cnstr_added", loc, ID_java, symbol_table);
750-
const exprt return_expr = return_sym.symbol_expr();
750+
const auto return_expr = return_sym.symbol_expr();
751751
code.add(code_declt(return_expr), loc);
752752
const constant_exprt char_set_expr(char_set, string_typet());
753753
code.add(
@@ -790,7 +790,7 @@ refined_string_exprt java_string_library_preprocesst::string_expr_of_function(
790790
loc,
791791
ID_java,
792792
symbol_table);
793-
const exprt return_code = return_code_sym.symbol_expr();
793+
const auto return_code = return_code_sym.symbol_expr();
794794
code.add(code_declt(return_code), loc);
795795

796796
const refined_string_exprt string_expr =
@@ -1232,7 +1232,7 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
12321232
std::string aux_name="tmp_"+id2string(type_name);
12331233
symbolt symbol=get_fresh_aux_symbol(
12341234
value_type, aux_name, aux_name, loc, ID_java, symbol_table);
1235-
exprt value=symbol.symbol_expr();
1235+
auto value = symbol.symbol_expr();
12361236

12371237
// Check that the type of the object is in the symbol table,
12381238
// otherwise there is no safe way of finding its value.
@@ -1340,8 +1340,9 @@ exprt java_string_library_preprocesst::make_argument_for_format(
13401340
std::string tmp_name="tmp_"+id2string(name);
13411341
symbolt field_symbol = get_fresh_aux_symbol(
13421342
type, id2string(function_id), tmp_name, loc, ID_java, symbol_table);
1343-
field_expr=field_symbol.symbol_expr();
1344-
code.add(code_declt(field_expr), loc);
1343+
auto field_symbol_expr = field_symbol.symbol_expr();
1344+
field_expr = field_symbol_expr;
1345+
code.add(code_declt(field_symbol_expr), loc);
13451346
}
13461347
else
13471348
field_expr =

src/analyses/constant_propagator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ void constant_propagator_domaint::transform(
9393
if(from->is_decl())
9494
{
9595
const code_declt &code_decl=to_code_decl(from->code);
96-
const symbol_exprt &symbol=to_symbol_expr(code_decl.symbol());
96+
const symbol_exprt &symbol = code_decl.symbol();
9797
values.set_to_top(symbol);
9898
}
9999
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.emplace(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/goto-programs/goto_convert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ void goto_convertt::convert_decl(
607607
goto_programt &dest,
608608
const irep_idt &mode)
609609
{
610-
const irep_idt &identifier = to_symbol_expr(code.symbol()).get_identifier();
610+
const irep_idt &identifier = code.get_identifier();
611611

612612
const symbolt &symbol = ns.lookup(identifier);
613613

src/goto-symex/symex_decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void goto_symext::symex_decl(statet &state)
2929
// we handle the decl with only one operand
3030
PRECONDITION(code.operands().size() == 1);
3131

32-
symex_decl(state, to_symbol_expr(to_code_decl(code).symbol()));
32+
symex_decl(state, to_code_decl(code).symbol());
3333
}
3434

3535
void goto_symext::symex_decl(statet &state, const symbol_exprt &expr)

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+
add_to_operands(symbol);
283282
}
284283

285-
explicit code_declt(const exprt &symbol):codet(ID_decl)
284+
symbol_exprt &symbol()
286285
{
287-
add_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)