Skip to content

Commit 189d7a9

Browse files
author
Daniel Kroening
committed
codet now inherits from irept
1 parent a21d400 commit 189d7a9

18 files changed

+246
-124
lines changed

src/ansi-c/c_typecheck_code.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ void c_typecheck_baset::typecheck_code(codet &code)
3232
throw 0;
3333
}
3434

35-
code.type() = empty_typet();
36-
3735
const irep_idt &statement=code.get_statement();
3836

3937
if(statement==ID_expression)

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ void c_typecheck_baset::typecheck_expr_operands(exprt &expr)
773773
code_declt decl(symbol.symbol_expr());
774774
decl.add_source_location()=declaration.source_location();
775775

776-
expr.op0()=decl;
776+
expr.get_sub()[0] = decl;
777777

778778
typecheck_expr(expr.op1());
779779
}
@@ -991,7 +991,7 @@ void c_typecheck_baset::typecheck_expr_sizeof(exprt &expr)
991991
ID_statement_expression, void_type(), expr.source_location());
992992
auto decl_block=code_blockt::from_list(clean_code);
993993
decl_block.set_statement(ID_decl_block);
994-
side_effect_expr.copy_to_operands(decl_block);
994+
side_effect_expr.get_sub().push_back(decl_block);
995995
clean_code.clear();
996996

997997
// We merge the side-effect into the operand of the typecast,
@@ -1048,7 +1048,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr)
10481048
ID_statement_expression, void_type(), expr.source_location());
10491049
auto decl_block=code_blockt::from_list(clean_code);
10501050
decl_block.set_statement(ID_decl_block);
1051-
side_effect_expr.copy_to_operands(decl_block);
1051+
side_effect_expr.get_sub().push_back(decl_block);
10521052
clean_code.clear();
10531053

10541054
// We merge the side-effect into the operand of the typecast,

src/cpp/cpp_destructor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ optionalt<codet> cpp_typecheckt::cpp_destructor(
6464

6565
auto i_code = cpp_destructor(source_location, index);
6666
if(i_code.has_value())
67-
new_code.add_to_operands(std::move(i_code.value()));
67+
new_code.add(std::move(i_code.value()));
6868
}
6969

7070
return std::move(new_code);

src/cpp/cpp_typecheck_code.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ void cpp_typecheckt::typecheck_code(codet &code)
2525

2626
if(statement==ID_try_catch)
2727
{
28-
code.type() = empty_typet();
2928
typecheck_try_catch(code);
3029
}
3130
else if(statement==ID_member_initializer)
3231
{
33-
code.type() = empty_typet();
3432
typecheck_member_initializer(code);
3533
}
3634
else if(statement==ID_msc_if_exists ||

src/cpp/cpp_typecheck_compound_type.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,14 +671,16 @@ void cpp_typecheckt::typecheck_compound_declarator(
671671
exprt already_typechecked(ID_already_typechecked);
672672
already_typechecked.add_to_operands(std::move(expr_call));
673673

674-
func_symb.value = code_returnt(already_typechecked).make_block();
674+
func_symb.value =
675+
code_returnt(already_typechecked).make_block().as_expr();
675676
}
676677
else
677678
{
678679
exprt already_typechecked(ID_already_typechecked);
679680
already_typechecked.add_to_operands(std::move(expr_call));
680681

681-
func_symb.value = code_expressiont(already_typechecked).make_block();
682+
func_symb.value =
683+
code_expressiont(already_typechecked).make_block().as_expr();
682684
}
683685

684686
// add this new function to the list of components

src/cpp/cpp_typecheck_constructor.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static void copy_parent(
4747
code_assignt code(dereference_exprt(op0), op1);
4848
code.add_source_location() = source_location;
4949

50-
block.operands().push_back(code);
50+
block.operands().push_back(code.as_expr());
5151
}
5252

5353
/// Generate code to copy the member.
@@ -76,7 +76,7 @@ static void copy_member(
7676
code_expressiont code(assign);
7777
code.add_source_location() = source_location;
7878

79-
block.operands().push_back(code);
79+
block.operands().push_back(code.as_expr());
8080
}
8181

8282
/// Generate code to copy the member.
@@ -113,7 +113,7 @@ static void copy_array(
113113
code_expressiont code(assign);
114114
code.add_source_location() = source_location;
115115

116-
block.operands().push_back(code);
116+
block.operands().push_back(code.as_expr());
117117
}
118118

119119
/// Generate code for implicit default constructors
@@ -579,6 +579,7 @@ void cpp_typecheckt::full_member_initialization(
579579

580580
code_ifthenelset cond(
581581
cpp_namet("@most_derived").as_expr(), std::move(block));
582+
582583
final_initializers.move_to_sub(cond);
583584
}
584585

src/cpp/cpp_typecheck_declaration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void cpp_typecheckt::convert_non_template_declaration(
173173
declarator.init_args().operands());
174174

175175
if(constructor.has_value())
176-
symbol.value = constructor.value();
176+
symbol.value = constructor.value().as_expr();
177177
else
178178
symbol.value = nil_exprt();
179179
}

src/cpp/cpp_typecheck_function.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void cpp_typecheckt::convert_function(symbolt &symbol)
104104
!symbol.value.has_operands() || !symbol.value.op0().has_operands() ||
105105
symbol.value.op0().op0().id() != ID_already_typechecked)
106106
{
107-
symbol.value.copy_to_operands(dtor(msymb));
107+
symbol.value.copy_to_operands(dtor(msymb).as_expr());
108108
}
109109
}
110110

src/cpp/cpp_typecheck_initializer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void cpp_typecheckt::convert_initializer(symbolt &symbol)
180180
cpp_constructor(symbol.value.source_location(), expr_symbol, ops);
181181

182182
if(constructor.has_value())
183-
symbol.value = constructor.value();
183+
symbol.value = constructor.value().as_expr();
184184
else
185185
symbol.value = nil_exprt();
186186
}
@@ -308,7 +308,7 @@ void cpp_typecheckt::zero_initializer(
308308
already_typechecked(assign.lhs());
309309

310310
typecheck_code(assign);
311-
ops.push_back(assign);
311+
ops.push_back(assign.as_expr());
312312
}
313313
else
314314
{
@@ -329,6 +329,6 @@ void cpp_typecheckt::zero_initializer(
329329
already_typechecked(assign.lhs());
330330

331331
typecheck_code(assign);
332-
ops.push_back(assign);
332+
ops.push_back(assign.as_expr());
333333
}
334334
}

src/cpp/expr2cpp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,15 +398,15 @@ std::string expr2cppt::convert_code(
398398
const codet &src,
399399
unsigned indent)
400400
{
401-
const irep_idt &statement=src.get(ID_statement);
401+
const irep_idt &statement = src.get_statement();
402402

403403
if(statement==ID_cpp_delete ||
404404
statement==ID_cpp_delete_array)
405-
return convert_code_cpp_delete(src, indent);
405+
return convert_code_cpp_delete(src.as_expr(), indent);
406406

407407
if(statement==ID_cpp_new ||
408408
statement==ID_cpp_new_array)
409-
return convert_cpp_new(src, indent);
409+
return convert_cpp_new(src.as_expr(), indent);
410410

411411
return expr2ct::convert_code(src, indent);
412412
}

src/cpp/parse.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2714,7 +2714,7 @@ bool Parser::rConstructorDecl(
27142714
{
27152715
case TOK_INTEGER:
27162716
{
2717-
constructor.value()=codet("cpp-pure-virtual");
2717+
constructor.value() = exprt("cpp-pure-virtual");
27182718
set_location(constructor.value(), value);
27192719
}
27202720
break;
@@ -2727,7 +2727,7 @@ bool Parser::rConstructorDecl(
27272727
return false;
27282728
}
27292729

2730-
constructor.value()=codet(ID_default);
2730+
constructor.value() = exprt(ID_default);
27312731
set_location(constructor.value(), value);
27322732
}
27332733
break;
@@ -2740,7 +2740,7 @@ bool Parser::rConstructorDecl(
27402740
return false;
27412741
}
27422742

2743-
constructor.value()=codet(ID_cpp_delete);
2743+
constructor.value() = exprt(ID_cpp_delete);
27442744
set_location(constructor.value(), value);
27452745
}
27462746
break;
@@ -2905,7 +2905,7 @@ bool Parser::rDeclaratorWithInit(
29052905
}
29062906

29072907
lex.get_token(tk);
2908-
declarator.value()=codet(ID_default);
2908+
declarator.value() = exprt(ID_default);
29092909
set_location(declarator.value(), tk);
29102910
}
29112911
else if(lex.LookAhead(0)==TOK_DELETE) // C++0x
@@ -2917,7 +2917,7 @@ bool Parser::rDeclaratorWithInit(
29172917
}
29182918

29192919
lex.get_token(tk);
2920-
declarator.value()=codet(ID_cpp_delete);
2920+
declarator.value() = exprt(ID_cpp_delete);
29212921
set_location(declarator.value(), tk);
29222922
}
29232923
else
@@ -3415,7 +3415,7 @@ bool Parser::rMemberInit(exprt &init)
34153415
std::cout << std::string(__indent, ' ') << "Parser::rMemberInit 2\n";
34163416
#endif
34173417

3418-
init=codet(ID_member_initializer);
3418+
init = exprt(ID_member_initializer);
34193419
init.add(ID_member).swap(name);
34203420

34213421
cpp_tokent tk1, tk2;
@@ -7187,7 +7187,7 @@ bool Parser::rFunctionBody(cpp_declaratort &declarator)
71877187
if(lex.get_token(cb)!='}')
71887188
return false;
71897189

7190-
declarator.value()=body;
7190+
declarator.value() = body.as_expr();
71917191
return true;
71927192
}
71937193
else

src/goto-symex/goto_symex.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class goto_symext
203203
// c) clean up byte_extract on the lhs of an assignment
204204
void clean_expr(
205205
exprt &, statet &, bool write);
206+
void clean_expr(codet &, statet &, bool write);
206207

207208
void trigger_auto_object(const exprt &, statet &);
208209
void initialize_auto_object(const exprt &, statet &);
@@ -383,7 +384,7 @@ class goto_symext
383384
statet &, const exprt &lhs, const side_effect_exprt &);
384385
virtual void symex_fkt(statet &, const code_function_callt &);
385386
virtual void symex_trace(statet &, const code_function_callt &);
386-
virtual void symex_printf(statet &, const exprt &rhs);
387+
virtual void symex_printf(statet &, const irept &);
387388
virtual void symex_input(statet &, const codet &);
388389
virtual void symex_output(statet &, const codet &);
389390

src/goto-symex/symex_builtin_functions.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -303,12 +303,11 @@ irep_idt get_string_argument(const exprt &src, const namespacet &ns)
303303
return get_string_argument_rec(tmp);
304304
}
305305

306-
void goto_symext::symex_printf(
307-
statet &state,
308-
const exprt &rhs)
306+
void goto_symext::symex_printf(statet &state, const irept &rhs)
309307
{
310-
PRECONDITION(!rhs.operands().empty());
308+
//PRECONDITION(!rhs.operands().empty());
311309

310+
#if 0
312311
exprt tmp_rhs=rhs;
313312
state.rename(tmp_rhs, ns);
314313
do_simplify(tmp_rhs);
@@ -326,6 +325,7 @@ void goto_symext::symex_printf(
326325
target.output_fmt(
327326
state.guard.as_expr(),
328327
state.source, "printf", format_string, args);
328+
#endif
329329
}
330330

331331
void goto_symext::symex_input(

src/jsil/jsil_entry_point.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void create_initialize(symbol_tablet &symbol_table)
3838
code_assignt a(rounding_mode, from_integer(0, rounding_mode.type()));
3939
init_code.add(a);
4040

41-
initialize.value=init_code;
41+
initialize.value = init_code.as_expr();
4242

4343
if(symbol_table.add(initialize))
4444
throw "failed to add " INITIALIZE_FUNCTION;

src/jsil/parser.y

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ statements: statement
210210

211211
statement: TOK_NEWLINE
212212
{
213-
newstack($$)=code_skipt();
213+
newstack($$)=code_skipt().as_expr();
214214
}
215215
| instruction TOK_NEWLINE
216216
{
@@ -241,7 +241,7 @@ instruction: TOK_LABEL TOK_IDENTIFIER
241241
}
242242
| TOK_SKIP
243243
{
244-
newstack($$)=code_skipt();
244+
newstack($$)=code_skipt().as_expr();
245245
}
246246
| TOK_IDENTIFIER TOK_DEFEQ rhs
247247
{

src/linking/static_lifetime_init.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,8 @@ void static_lifetime_init(
109109

110110
symbolt &init_symbol = symbol_table.get_writeable_ref(INITIALIZE_FUNCTION);
111111

112-
init_symbol.value=code_blockt();
113-
init_symbol.value.add_source_location()=source_location;
114-
115-
code_blockt &dest=to_code_block(to_code(init_symbol.value));
112+
code_blockt dest;
113+
dest.add_source_location() = source_location;
116114

117115
// add the magic label to hide
118116
dest.add(code_labelt(CPROVER_PREFIX "HIDE", code_skipt()));
@@ -164,4 +162,6 @@ void static_lifetime_init(
164162
dest.add(function_call);
165163
}
166164
}
165+
166+
init_symbol.value = dest.as_expr();
167167
}

0 commit comments

Comments
 (0)