Skip to content

Commit aa8ffa1

Browse files
authored
Merge pull request #6387 from diffblue/code_frontend_declt
introduce code_frontend_declt
2 parents 49c9812 + 7649e74 commit aa8ffa1

21 files changed

+133
-74
lines changed

src/ansi-c/c_typecheck_code.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ void c_typecheck_baset::typecheck_decl(codet &code)
316316
}
317317
else
318318
{
319-
code_declt decl(symbol.symbol_expr());
319+
code_frontend_declt decl(symbol.symbol_expr());
320320
decl.add_source_location() = symbol.location;
321321
decl.symbol().add_source_location() = symbol.location;
322322

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr)
323323

324324
// replace declarations by symbol expressions
325325
for(auto &binding : bindings)
326-
binding = to_code_decl(to_code(binding)).symbol();
326+
binding = to_code_frontend_decl(to_code(binding)).symbol();
327327

328328
if(expr.id() == ID_lambda)
329329
{
@@ -788,7 +788,7 @@ void c_typecheck_baset::typecheck_expr_operands(exprt &expr)
788788
throw 0;
789789
}
790790

791-
code_declt decl(symbol.symbol_expr());
791+
code_frontend_declt decl(symbol.symbol_expr());
792792
decl.add_source_location() = declaration.source_location();
793793

794794
binding = decl;

src/ansi-c/c_typecheck_gcc_polymorphic_builtins.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ static void instantiate_atomic_fetch_op(
635635
const symbol_exprt result =
636636
result_symbol(identifier_with_type, type, source_location, symbol_table)
637637
.symbol_expr();
638-
block.add(codet{ID_decl_block, {code_declt{result}}});
638+
block.add(codet{ID_decl_block, {code_frontend_declt{result}}});
639639

640640
// place operations on *ptr in an atomic section
641641
block.add(code_expressiont{side_effect_expr_function_callt{
@@ -697,7 +697,7 @@ static void instantiate_atomic_op_fetch(
697697
const symbol_exprt result =
698698
result_symbol(identifier_with_type, type, source_location, symbol_table)
699699
.symbol_expr();
700-
block.add(codet{ID_decl_block, {code_declt{result}}});
700+
block.add(codet{ID_decl_block, {code_frontend_declt{result}}});
701701

702702
// place operations on *ptr in an atomic section
703703
block.add(code_expressiont{side_effect_expr_function_callt{
@@ -810,7 +810,7 @@ static void instantiate_sync_val_compare_and_swap(
810810
const symbol_exprt result =
811811
result_symbol(identifier_with_type, type, source_location, symbol_table)
812812
.symbol_expr();
813-
block.add(codet{ID_decl_block, {code_declt{result}}});
813+
block.add(codet{ID_decl_block, {code_frontend_declt{result}}});
814814

815815
// place operations on *ptr in an atomic section
816816
block.add(code_expressiont{side_effect_expr_function_callt{
@@ -868,7 +868,7 @@ static void instantiate_sync_lock_test_and_set(
868868
const symbol_exprt result =
869869
result_symbol(identifier_with_type, type, source_location, symbol_table)
870870
.symbol_expr();
871-
block.add(codet{ID_decl_block, {code_declt{result}}});
871+
block.add(codet{ID_decl_block, {code_frontend_declt{result}}});
872872

873873
// place operations on *ptr in an atomic section
874874
block.add(code_expressiont{side_effect_expr_function_callt{
@@ -990,7 +990,7 @@ static void instantiate_atomic_load_n(
990990
const symbol_exprt result =
991991
result_symbol(identifier_with_type, type, source_location, symbol_table)
992992
.symbol_expr();
993-
block.add(codet{ID_decl_block, {code_declt{result}}});
993+
block.add(codet{ID_decl_block, {code_frontend_declt{result}}});
994994

995995
block.add(code_expressiont{side_effect_expr_function_callt{
996996
symbol_exprt::typeless(ID___atomic_load),
@@ -1105,7 +1105,7 @@ static void instantiate_atomic_exchange_n(
11051105
const symbol_exprt result =
11061106
result_symbol(identifier_with_type, type, source_location, symbol_table)
11071107
.symbol_expr();
1108-
block.add(codet{ID_decl_block, {code_declt{result}}});
1108+
block.add(codet{ID_decl_block, {code_frontend_declt{result}}});
11091109

11101110
block.add(code_expressiont{side_effect_expr_function_callt{
11111111
symbol_exprt::typeless(ID___atomic_exchange),
@@ -1142,7 +1142,7 @@ static void instantiate_atomic_compare_exchange(
11421142
result_symbol(
11431143
identifier_with_type, c_bool_type(), source_location, symbol_table)
11441144
.symbol_expr();
1145-
block.add(codet{ID_decl_block, {code_declt{result}}});
1145+
block.add(codet{ID_decl_block, {code_frontend_declt{result}}});
11461146

11471147
// place operations on *ptr in an atomic section
11481148
block.add(code_expressiont{side_effect_expr_function_callt{

src/ansi-c/c_typecheck_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
634634
// produce the code that declares and initializes the symbol
635635
symbol_exprt symbol_expr = new_symbol.symbol_expr();
636636

637-
code_declt declaration(symbol_expr);
637+
code_frontend_declt declaration(symbol_expr);
638638
declaration.add_source_location() = size_source_location;
639639

640640
code_assignt assignment;

src/ansi-c/expr2c.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,9 +2761,8 @@ std::string expr2ct::convert_code_continue(unsigned indent)
27612761
return dest;
27622762
}
27632763

2764-
std::string expr2ct::convert_code_decl(
2765-
const codet &src,
2766-
unsigned indent)
2764+
std::string
2765+
expr2ct::convert_code_frontend_decl(const codet &src, unsigned indent)
27672766
{
27682767
// initializer to go away
27692768
if(src.operands().size()!=1 &&
@@ -3013,7 +3012,7 @@ std::string expr2ct::convert_code(
30133012
return convert_code_continue(indent);
30143013

30153014
if(statement==ID_decl)
3016-
return convert_code_decl(src, indent);
3015+
return convert_code_frontend_decl(src, indent);
30173016

30183017
if(statement==ID_decl_block)
30193018
return convert_code_decl_block(src, indent);

src/ansi-c/expr2c_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class expr2ct
214214
std::string convert_code_break(unsigned indent);
215215
std::string convert_code_switch(const codet &src, unsigned indent);
216216
std::string convert_code_continue(unsigned indent);
217-
std::string convert_code_decl(const codet &src, unsigned indent);
217+
std::string convert_code_frontend_decl(const codet &, unsigned indent);
218218
std::string convert_code_decl_block(const codet &src, unsigned indent);
219219
std::string convert_code_dead(const codet &src, unsigned indent);
220220
// NOLINTNEXTLINE(whitespace/line_length)

src/cpp/cpp_typecheck_code.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void cpp_typecheckt::typecheck_try_catch(codet &code)
120120
{
121121
// turn references into non-references
122122
{
123-
code_declt &decl = to_code_decl(statements.front());
123+
code_frontend_declt &decl = to_code_frontend_decl(statements.front());
124124
cpp_declarationt &cpp_declaration = to_cpp_declaration(decl.symbol());
125125

126126
assert(cpp_declaration.declarators().size()==1);
@@ -139,8 +139,8 @@ void cpp_typecheckt::typecheck_try_catch(codet &code)
139139
catch_block.statements().front().get_statement() == ID_decl_block);
140140

141141
// get the declaration
142-
const code_declt &code_decl =
143-
to_code_decl(to_code(catch_block.statements().front().op0()));
142+
const code_frontend_declt &code_decl = to_code_frontend_decl(
143+
to_code(catch_block.statements().front().op0()));
144144

145145
// get the type
146146
const typet &type = code_decl.symbol().type();
@@ -199,7 +199,7 @@ void cpp_typecheckt::typecheck_switch(codet &code)
199199
assert(decl.operands().size()==1);
200200

201201
// replace declaration by its symbol
202-
value = to_code_decl(to_code(to_unary_expr(decl).op())).symbol();
202+
value = to_code_frontend_decl(to_code(to_unary_expr(decl).op())).symbol();
203203

204204
c_typecheck_baset::typecheck_switch(code);
205205

@@ -456,7 +456,7 @@ void cpp_typecheckt::typecheck_decl(codet &code)
456456
throw 0;
457457
}
458458

459-
code_declt decl_statement(cpp_symbol_expr(symbol));
459+
code_frontend_declt decl_statement(cpp_symbol_expr(symbol));
460460
decl_statement.add_source_location()=symbol.location;
461461

462462
// Do we have an initializer that's not code?

src/cpp/cpp_typecheck_declaration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ codet cpp_typecheckt::convert_anonymous_union(cpp_declarationt &declaration)
5858
throw 0;
5959
}
6060

61-
new_code.add_to_operands(code_declt(cpp_symbol_expr(symbol)));
61+
new_code.add_to_operands(code_frontend_declt(cpp_symbol_expr(symbol)));
6262

6363
// do scoping
6464
symbolt union_symbol =

src/cpp/parse.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ optionalt<codet> Parser::rTypedefStatement()
679679
if(!rTypedef(declaration))
680680
return {};
681681

682-
return code_declt(
682+
return code_frontend_declt(
683683
static_cast<symbol_exprt &>(static_cast<exprt &>(declaration)));
684684
}
685685

@@ -7501,7 +7501,7 @@ optionalt<codet> Parser::rStatement()
75017501
cpp_declarationt declaration;
75027502
if(!rTypedefUsing(declaration))
75037503
return {};
7504-
code_declt statement(
7504+
code_frontend_declt statement(
75057505
static_cast<symbol_exprt &>(static_cast<exprt &>(declaration)));
75067506
statement.add_source_location() = declaration.source_location();
75077507
return std::move(statement);
@@ -7790,7 +7790,7 @@ optionalt<codet> Parser::rTryStatement()
77907790
if(declaration.declarators().front().name().is_nil())
77917791
declaration.declarators().front().name() = cpp_namet("#anon");
77927792

7793-
code_declt code_decl(
7793+
code_frontend_declt code_decl(
77947794
static_cast<symbol_exprt &>(static_cast<exprt &>(declaration)));
77957795
set_location(code_decl, catch_token);
77967796

@@ -8237,7 +8237,7 @@ optionalt<codet> Parser::rDeclarationStatement()
82378237
cpp_declarationt declaration;
82388238
if(!rConstDeclaration(declaration))
82398239
return {};
8240-
return code_declt(
8240+
return code_frontend_declt(
82418241
static_cast<symbol_exprt &>(static_cast<exprt &>(declaration)));
82428242
}
82438243
else
@@ -8268,7 +8268,7 @@ optionalt<codet> Parser::rIntegralDeclStatement(
82688268
if(lex.LookAhead(0)==';')
82698269
{
82708270
lex.get_token(tk);
8271-
code_declt statement(
8271+
code_frontend_declt statement(
82728272
static_cast<symbol_exprt &>(static_cast<exprt &>(declaration)));
82738273
set_location(statement, tk);
82748274
return std::move(statement);
@@ -8281,7 +8281,7 @@ optionalt<codet> Parser::rIntegralDeclStatement(
82818281
if(lex.get_token(tk)!=';')
82828282
return {};
82838283

8284-
code_declt statement(
8284+
code_frontend_declt statement(
82858285
static_cast<symbol_exprt &>(static_cast<exprt &>(declaration)));
82868286
set_location(statement, tk);
82878287
return std::move(statement);
@@ -8333,7 +8333,7 @@ Parser::rOtherDeclStatement(cpp_storage_spect &storage_spec, typet &cv_q)
83338333
if(lex.get_token(tk)!=';')
83348334
return {};
83358335

8336-
code_declt statement(
8336+
code_frontend_declt statement(
83378337
static_cast<symbol_exprt &>(static_cast<exprt &>(declaration)));
83388338
set_location(statement, tk);
83398339
return std::move(statement);

src/goto-instrument/dump_c.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ void dump_ct::convert_compound_enum(
649649
}
650650

651651
void dump_ct::cleanup_decl(
652-
code_declt &decl,
652+
code_frontend_declt &decl,
653653
std::list<irep_idt> &local_static,
654654
std::list<irep_idt> &local_type_decls)
655655
{
@@ -908,7 +908,7 @@ void dump_ct::convert_global_variable(
908908
!converted_global.insert(symbol.name).second)
909909
return;
910910

911-
code_declt d(symbol.symbol_expr());
911+
code_frontend_declt d(symbol.symbol_expr());
912912

913913
find_symbols_sett syms;
914914
if(symbol.value.is_not_nil())
@@ -1214,7 +1214,7 @@ void dump_ct::insert_local_static_decls(
12141214
local_static_decls.find(*it);
12151215
PRECONDITION(d_it!=local_static_decls.end());
12161216

1217-
code_declt d=d_it->second;
1217+
code_frontend_declt d = d_it->second;
12181218
std::list<irep_idt> redundant;
12191219
cleanup_decl(d, redundant, type_decls);
12201220

src/goto-instrument/dump_c_class.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class dump_ct
198198
const typet &type)
199199
{
200200
symbol_exprt sym(identifier, type);
201-
code_declt d(sym);
201+
code_frontend_declt d(sym);
202202

203203
std::string d_str=expr_to_string(d);
204204
assert(!d_str.empty());
@@ -232,7 +232,7 @@ class dump_ct
232232
const typet &type,
233233
std::ostream &os);
234234

235-
typedef std::unordered_map<irep_idt, code_declt> local_static_declst;
235+
typedef std::unordered_map<irep_idt, code_frontend_declt> local_static_declst;
236236

237237
void convert_global_variable(
238238
const symbolt &symbol,
@@ -259,7 +259,7 @@ class dump_ct
259259
void cleanup_expr(exprt &expr);
260260
void cleanup_type(typet &type);
261261
void cleanup_decl(
262-
code_declt &decl,
262+
code_frontend_declt &decl,
263263
std::list<irep_idt> &local_static,
264264
std::list<irep_idt> &local_type_decls);
265265
void cleanup_harness(code_blockt &b);

src/goto-instrument/goto_program2code.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ goto_programt::const_targett goto_program2codet::convert_decl(
449449
goto_programt::const_targett upper_bound,
450450
code_blockt &dest)
451451
{
452-
code_declt d = code_declt{target->decl_symbol()};
452+
code_frontend_declt d = code_frontend_declt{target->decl_symbol()};
453453
symbol_exprt &symbol = d.symbol();
454454

455455
goto_programt::const_targett next=target;

src/goto-programs/goto_convert.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ void goto_convertt::convert(
436436
if(statement==ID_block)
437437
convert_block(to_code_block(code), dest, mode);
438438
else if(statement==ID_decl)
439-
convert_decl(to_code_decl(code), dest, mode);
439+
convert_frontend_decl(to_code_frontend_decl(code), dest, mode);
440440
else if(statement==ID_decl_type)
441441
convert_decl_type(code, dest);
442442
else if(statement==ID_expression)
@@ -606,8 +606,8 @@ void goto_convertt::convert_expression(
606606
}
607607
}
608608

609-
void goto_convertt::convert_decl(
610-
const code_declt &code,
609+
void goto_convertt::convert_frontend_decl(
610+
const code_frontend_declt &code,
611611
goto_programt &dest,
612612
const irep_idt &mode)
613613
{
@@ -1845,9 +1845,9 @@ symbolt &goto_convertt::new_tmp_symbol(
18451845
mode,
18461846
symbol_table);
18471847

1848-
code_declt decl(new_symbol.symbol_expr());
1848+
code_frontend_declt decl(new_symbol.symbol_expr());
18491849
decl.add_source_location()=source_location;
1850-
convert_decl(decl, dest, mode);
1850+
convert_frontend_decl(decl, dest, mode);
18511851

18521852
return new_symbol;
18531853
}

src/goto-programs/goto_convert_class.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ class goto_convertt:public messaget
222222
const code_blockt &code,
223223
goto_programt &dest,
224224
const irep_idt &mode);
225-
void convert_decl(
226-
const code_declt &code,
227-
goto_programt &dest,
225+
void convert_frontend_decl(
226+
const code_frontend_declt &,
227+
goto_programt &,
228228
const irep_idt &mode);
229229
void convert_decl_type(const codet &code, goto_programt &dest);
230230
void convert_expression(

src/goto-programs/goto_convert_side_effect.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,9 @@ void goto_convertt::remove_function_call(
381381
symbol_table);
382382

383383
{
384-
code_declt decl(new_symbol.symbol_expr());
384+
code_frontend_declt decl(new_symbol.symbol_expr());
385385
decl.add_source_location()=new_symbol.location;
386-
convert_decl(decl, dest, mode);
386+
convert_frontend_decl(decl, dest, mode);
387387
}
388388

389389
{
@@ -421,9 +421,9 @@ void goto_convertt::remove_cpp_new(
421421
ID_cpp,
422422
symbol_table);
423423

424-
code_declt decl(new_symbol.symbol_expr());
424+
code_frontend_declt decl(new_symbol.symbol_expr());
425425
decl.add_source_location()=new_symbol.location;
426-
convert_decl(decl, dest, ID_cpp);
426+
convert_frontend_decl(decl, dest, ID_cpp);
427427

428428
const code_assignt call(new_symbol.symbol_expr(), expr);
429429

@@ -467,9 +467,9 @@ void goto_convertt::remove_malloc(
467467
mode,
468468
symbol_table);
469469

470-
code_declt decl(new_symbol.symbol_expr());
470+
code_frontend_declt decl(new_symbol.symbol_expr());
471471
decl.add_source_location()=new_symbol.location;
472-
convert_decl(decl, dest, mode);
472+
convert_frontend_decl(decl, dest, mode);
473473

474474
code_assignt call(new_symbol.symbol_expr(), expr);
475475
call.add_source_location()=expr.source_location();

0 commit comments

Comments
 (0)