Skip to content

Commit 620fef2

Browse files
author
Daniel Kroening
committed
use pointer_type() instead of pointer_typet()
1 parent 0d1baf8 commit 620fef2

23 files changed

+85
-74
lines changed

src/cpp/cpp_typecheck_compound_type.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
1111
#include <util/arith_tools.h>
1212
#include <util/simplify_expr.h>
1313
#include <util/std_types.h>
14+
#include <util/c_types.h>
1415

1516
#include <ansi-c/c_qualifiers.h>
1617

@@ -601,7 +602,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
601602

602603
// add a virtual-table pointer
603604
struct_typet::componentt compo;
604-
compo.type()=pointer_typet(symbol_typet(vt_name));
605+
compo.type()=pointer_type(symbol_typet(vt_name));
605606
compo.set_name(id2string(symbol.name) +"::@vtable_pointer");
606607
compo.set(ID_base_name, "@vtable_pointer");
607608
compo.set(
@@ -623,7 +624,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
623624

624625
// add an entry to the virtual table
625626
struct_typet::componentt vt_entry;
626-
vt_entry.type()=pointer_typet(component.type());
627+
vt_entry.type()=pointer_type(component.type());
627628
vt_entry.set_name(id2string(vtit->first)+"::"+virtual_name);
628629
vt_entry.set(ID_base_name, virtual_name);
629630
vt_entry.set(ID_pretty_name, virtual_name);
@@ -1492,7 +1493,7 @@ void cpp_typecheckt::add_this_to_method_type(
14921493
if(has_volatile(method_qualifier))
14931494
subtype.set(ID_C_volatile, true);
14941495

1495-
parameter.type()=pointer_typet(subtype);
1496+
parameter.type()=pointer_type(subtype);
14961497
}
14971498

14981499
/*******************************************************************\

src/cpp/cpp_typecheck_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ void cpp_typecheckt::typecheck_expr_address_of(exprt &expr)
872872
const bool is_ref=is_reference(expr.type());
873873
c_typecheck_baset::typecheck_expr_address_of(expr);
874874
if(is_ref)
875-
expr.type()=reference_typet(expr.type().subtype());
875+
expr.type()=reference_type(expr.type().subtype());
876876
}
877877

878878
/*******************************************************************\

src/cpp/cpp_typecheck_virtual_table.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Author: Daniel Kroening, [email protected]
66
77
\*******************************************************************/
88

9-
#include <util/std_types.h>
9+
#include <util/c_types.h>
1010
#include <util/std_expr.h>
1111

1212
#include "cpp_typecheck.h"
@@ -37,21 +37,20 @@ void cpp_typecheckt::do_virtual_table(const symbolt &symbol)
3737
const code_typet &code_type=to_code_type(compo.type());
3838
assert(code_type.parameters().size() > 0);
3939

40-
const pointer_typet &pointer_type =
41-
static_cast<const pointer_typet&>(code_type.parameters()[0].type());
40+
const pointer_typet &parameter_pointer_type=
41+
to_pointer_type(code_type.parameters()[0].type());
4242

43-
irep_idt class_id=pointer_type.subtype().get("identifier");
43+
irep_idt class_id=parameter_pointer_type.subtype().get("identifier");
4444

4545
std::map<irep_idt, exprt> &value_map =
4646
vt_value_maps[class_id];
4747

48-
4948
exprt e=symbol_exprt(compo.get_name(), code_type);
5049

5150
if(compo.get_bool("is_pure_virtual"))
5251
{
53-
pointer_typet pointer_type(code_type);
54-
e=null_pointer_exprt(pointer_type);
52+
pointer_typet code_pointer_type=pointer_type(code_type);
53+
e=null_pointer_exprt(code_pointer_type);
5554
value_map[compo.get("virtual_name")]=e;
5655
}
5756
else

src/cpp/parse.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7660,7 +7660,7 @@ bool Parser::rPrimaryExpr(exprt &exp)
76607660

76617661
case TOK_NULLPTR:
76627662
lex.get_token(tk);
7663-
exp=constant_exprt(ID_NULL, pointer_typet(typet(ID_nullptr)));
7663+
exp=constant_exprt(ID_NULL, typet(ID_pointer, typet(ID_nullptr)));
76647664
set_location(exp, tk);
76657665
#ifdef DEBUG
76667666
std::cout << std::string(__indent, ' ') << "Parser::rPrimaryExpr 6\n";

src/goto-instrument/function.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ code_function_callt function_to_call(
4141
if(s_it==symbol_table.symbols.end())
4242
{
4343
// not there
44-
pointer_typet p(char_type());
44+
typet p=pointer_type(char_type());
4545
p.subtype().set(ID_C_constant, true);
4646

4747
code_typet function_type;

src/goto-instrument/goto_program2code.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ goto_programt::const_targett goto_program2codet::convert_assign_varargs(
480480
static_cast<typet const&>(r.find(ID_C_va_arg_type));
481481

482482
dereference_exprt deref(
483-
null_pointer_exprt(pointer_typet(va_arg_type)),
483+
null_pointer_exprt(pointer_type(va_arg_type)),
484484
va_arg_type);
485485

486486
type_of.arguments().push_back(deref);
@@ -1634,7 +1634,7 @@ goto_programt::const_targett goto_program2codet::convert_start_thread(
16341634
// we don't bother setting the type
16351635
f.lhs()=cf.lhs();
16361636
f.function()=symbol_exprt("pthread_create", code_typet());
1637-
exprt n=null_pointer_exprt(pointer_typet(empty_typet()));
1637+
exprt n=null_pointer_exprt(pointer_type(empty_typet()));
16381638
f.arguments().push_back(n);
16391639
f.arguments().push_back(n);
16401640
f.arguments().push_back(cf.function());

src/goto-instrument/thread_instrumentation.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void thread_exit_instrumentation(goto_programt &goto_program)
6767
binary_exprt get_may("get_may");
6868

6969
// NULL is any
70-
get_may.op0()=null_pointer_exprt(to_pointer_type(pointer_type(empty_typet())));
70+
get_may.op0()=null_pointer_exprt(pointer_type(empty_typet()));
7171
get_may.op1()=address_of_exprt(mutex_locked_string);
7272

7373
end->make_assertion(not_exprt(get_may));

src/goto-instrument/wmm/shared_buffers.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Author: Daniel Kroening, [email protected]
66
77
\*******************************************************************/
88

9+
#include <util/c_types.h>
10+
911
#include "shared_buffers.h"
1012
#include "fence.h"
1113

@@ -74,7 +76,7 @@ const shared_bufferst::varst &shared_bufferst::operator()(
7476
object,
7577
symbol.base_name,
7678
"$read_delayed_var",
77-
pointer_typet(symbol.type));
79+
pointer_type(symbol.type));
7880

7981
for(unsigned cnt=0; cnt<nb_threads; cnt++)
8082
{
@@ -162,7 +164,7 @@ void shared_bufferst::add_initialization(goto_programt &goto_program)
162164
assignment(goto_program, t, source_location, vars.second.read_delayed,
163165
false_exprt());
164166
assignment(goto_program, t, source_location, vars.second.read_delayed_var,
165-
null_pointer_exprt(pointer_typet(vars.second.type)));
167+
null_pointer_exprt(pointer_type(vars.second.type)));
166168

167169
for(const auto &id : vars.second.r_buff0_thds)
168170
assignment(goto_program, t, source_location, id, false_exprt());
@@ -1328,7 +1330,7 @@ void shared_bufferst::cfg_visitort::weak_memory(
13281330
r_it->second.object, vars.type);
13291331
symbol_exprt new_read_expr=symbol_exprt(
13301332
vars.read_delayed_var,
1331-
pointer_typet(vars.type));
1333+
pointer_type(vars.type));
13321334
symbol_exprt read_delayed_expr=symbol_exprt(
13331335
vars.read_delayed, bool_typet());
13341336

src/goto-programs/builtin_functions.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ void goto_convertt::do_java_new(
728728
// we produce a malloc side-effect, which stays
729729
side_effect_exprt malloc_expr(ID_malloc);
730730
malloc_expr.copy_to_operands(object_size);
731-
malloc_expr.type()=pointer_typet(object_type);
731+
malloc_expr.type()=rhs.type();
732732

733733
goto_programt::targett t_n=dest.add_instruction(ASSIGN);
734734
t_n->code=code_assignt(lhs, malloc_expr);
@@ -796,7 +796,7 @@ void goto_convertt::do_java_new_array(
796796
// we produce a malloc side-effect, which stays
797797
side_effect_exprt malloc_expr(ID_malloc);
798798
malloc_expr.copy_to_operands(object_size);
799-
malloc_expr.type()=pointer_typet(object_type);
799+
malloc_expr.type()=rhs.type();
800800

801801
goto_programt::targett t_n=dest.add_instruction(ASSIGN);
802802
t_n->code=code_assignt(lhs, malloc_expr);

src/goto-programs/class_identifier.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Chris Smowton, [email protected]
99
#include "class_identifier.h"
1010

1111
#include <util/std_expr.h>
12+
#include <util/c_types.h>
1213
#include <util/namespace.h>
1314

1415
/*******************************************************************\
@@ -83,7 +84,7 @@ exprt get_class_identifier_field(
8384
"Non-pointer this-arg in remove-virtuals?");
8485
const auto &points_to=this_expr.type().subtype();
8586
if(points_to==empty_typet())
86-
this_expr=typecast_exprt(this_expr, pointer_typet(suggested_type));
87+
this_expr=typecast_exprt(this_expr, pointer_type(suggested_type));
8788
exprt deref=dereference_exprt(this_expr, this_expr.type().subtype());
8889
return build_class_identifier(deref, ns);
8990
}

src/goto-programs/remove_asm.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Date: December 2014
1212
#include <sstream>
1313

1414
#include <util/std_expr.h>
15+
#include <util/c_types.h>
1516

1617
#include <ansi-c/string_constant.h>
1718
#include <assembler/assembler_parser.h>
@@ -70,7 +71,8 @@ void remove_asmt::gcc_asm_function_call(
7071
code_function_callt function_call;
7172
function_call.lhs().make_nil();
7273

73-
const pointer_typet void_pointer=pointer_typet(void_typet());
74+
const typet void_pointer=
75+
pointer_type(void_typet());
7476

7577
// outputs
7678
forall_operands(it, code.op1())

src/goto-programs/remove_exceptions.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Date: December 2016
1616
#include <algorithm>
1717

1818
#include <util/std_expr.h>
19+
#include <util/c_types.h>
1920
#include <util/symbol_table.h>
2021

2122
#include "remove_exceptions.h"
@@ -116,12 +117,12 @@ void remove_exceptionst::add_exceptional_returns(
116117
new_symbol.base_name=id2string(function_symbol.base_name)+EXC_SUFFIX;
117118
new_symbol.name=id2string(function_symbol.name)+EXC_SUFFIX;
118119
new_symbol.mode=function_symbol.mode;
119-
new_symbol.type=pointer_typet(empty_typet());
120+
new_symbol.type=pointer_type(empty_typet());
120121
symbol_table.add(new_symbol);
121122

122123
// initialize the exceptional return with NULL
123124
symbol_exprt lhs_expr_null=new_symbol.symbol_expr();
124-
null_pointer_exprt rhs_expr_null((pointer_typet(empty_typet())));
125+
null_pointer_exprt rhs_expr_null(pointer_type(empty_typet()));
125126
goto_programt::targett t_null=
126127
goto_program.insert_before(goto_program.instructions.begin());
127128
t_null->make_assignment();
@@ -165,7 +166,7 @@ void remove_exceptionst::instrument_exception_handler(
165166
symbol_table.lookup(id2string(function_id)+EXC_SUFFIX);
166167
// next we reset the exceptional return to NULL
167168
symbol_exprt lhs_expr_null=function_symbol.symbol_expr();
168-
null_pointer_exprt rhs_expr_null((pointer_typet(empty_typet())));
169+
null_pointer_exprt rhs_expr_null(pointer_type(empty_typet()));
169170

170171
// add the assignment
171172
goto_programt::targett t_null=goto_program.insert_after(instr_it);
@@ -367,7 +368,7 @@ void remove_exceptionst::instrument_function_call(
367368
// add a null check (so that instanceof can be applied)
368369
equal_exprt eq_null(
369370
callee_exc,
370-
null_pointer_exprt(pointer_typet(empty_typet())));
371+
null_pointer_exprt(pointer_type(empty_typet())));
371372
goto_programt::targett t_null=goto_program.insert_after(instr_it);
372373
t_null->make_goto(next_it);
373374
t_null->source_location=instr_it->source_location;

src/goto-programs/remove_virtual_functions.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Author: Daniel Kroening, [email protected]
88

99
#include <util/prefix.h>
1010
#include <util/type_eq.h>
11+
#include <util/c_types.h>
1112

1213
#include "class_hierarchy.h"
1314
#include "class_identifier.h"
@@ -175,7 +176,8 @@ void remove_virtual_functionst::remove_virtual_function(
175176
t1->make_function_call(code);
176177
auto &newcall=to_code_function_call(t1->code);
177178
newcall.function()=fun.symbol_expr;
178-
pointer_typet need_type(symbol_typet(fun.symbol_expr.get(ID_C_class)));
179+
typet need_type=
180+
pointer_type(symbol_typet(fun.symbol_expr.get(ID_C_class)));
179181
if(!type_eq(newcall.arguments()[0].type(), need_type, ns))
180182
newcall.arguments()[0].make_typecast(need_type);
181183
}

src/goto-programs/string_abstraction.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ void string_abstractiont::add_argument(
322322
const irep_idt &identifier)
323323
{
324324
typet final_type=is_ptr_argument(type)?
325-
type:pointer_typet(type);
325+
type:pointer_type(type);
326326

327327
str_args.push_back(code_typet::parametert(final_type));
328328
str_args.back().add_source_location()=fct_symbol.location;
@@ -963,7 +963,7 @@ const typet &string_abstractiont::build_abstraction_type_rec(const typet &type,
963963
// char* or void* or char[]
964964
if(is_char_type(eff_type.subtype()) ||
965965
eff_type.subtype().id()==ID_empty)
966-
map_entry.first->second=pointer_typet(string_struct);
966+
map_entry.first->second=pointer_type(string_struct);
967967
else
968968
{
969969
const typet &subt=build_abstraction_type_rec(eff_type.subtype(), known);
@@ -973,8 +973,7 @@ const typet &string_abstractiont::build_abstraction_type_rec(const typet &type,
973973
map_entry.first->second=
974974
array_typet(subt, to_array_type(eff_type).size());
975975
else
976-
map_entry.first->second=
977-
pointer_typet(subt);
976+
map_entry.first->second=pointer_type(subt);
978977
}
979978
}
980979
}

src/goto-symex/symex_builtin_functions.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void goto_symext::symex_malloc(
177177

178178
if(object_type.id()==ID_array)
179179
{
180-
rhs.type()=pointer_typet(value_symbol.type.subtype());
180+
rhs.type()=pointer_type(value_symbol.type.subtype());
181181
index_exprt index_expr(value_symbol.type.subtype());
182182
index_expr.array()=value_symbol.symbol_expr();
183183
index_expr.index()=from_integer(0, index_type());
@@ -186,7 +186,7 @@ void goto_symext::symex_malloc(
186186
else
187187
{
188188
rhs.op0()=value_symbol.symbol_expr();
189-
rhs.type()=pointer_typet(value_symbol.type);
189+
rhs.type()=pointer_type(value_symbol.type);
190190
}
191191

192192
if(rhs.type()!=lhs.type())
@@ -496,7 +496,7 @@ void goto_symext::symex_cpp_new(
496496

497497
// make symbol expression
498498

499-
exprt rhs(ID_address_of, pointer_typet());
499+
exprt rhs(ID_address_of, code.type());
500500
rhs.type().subtype()=code.type().subtype();
501501

502502
if(do_array)

src/goto-symex/symex_dereference.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ exprt goto_symext::address_arithmetic(
153153
}
154154

155155
// do (expr.type() *)(((char *)op)+offset)
156-
result=typecast_exprt(result, pointer_typet(char_type()));
156+
result=typecast_exprt(result, pointer_type(char_type()));
157157

158158
// there could be further dereferencing in the offset
159159
exprt offset=be.offset();
@@ -163,14 +163,14 @@ exprt goto_symext::address_arithmetic(
163163

164164
// treat &array as &array[0]
165165
const typet &expr_type=ns.follow(expr.type());
166-
pointer_typet dest_type;
166+
typet dest_type_subtype;
167167

168168
if(expr_type.id()==ID_array && !keep_array)
169-
dest_type.subtype()=expr_type.subtype();
169+
dest_type_subtype=expr_type.subtype();
170170
else
171-
dest_type.subtype()=expr_type;
171+
dest_type_subtype=expr_type;
172172

173-
result=typecast_exprt(result, dest_type);
173+
result=typecast_exprt(result, pointer_type(dest_type_subtype));
174174
}
175175
else if(expr.id()==ID_index ||
176176
expr.id()==ID_member)
@@ -253,7 +253,7 @@ exprt goto_symext::address_arithmetic(
253253

254254
const typet &expr_type=ns.follow(expr.type());
255255
assert((expr_type.id()==ID_array && !keep_array) ||
256-
base_type_eq(pointer_typet(expr_type), result.type(), ns));
256+
base_type_eq(pointer_type(expr_type), result.type(), ns));
257257

258258
return result;
259259
}
@@ -324,7 +324,7 @@ void goto_symext::dereference_rec(
324324
index_exprt index_expr=to_index_expr(expr);
325325

326326
address_of_exprt address_of_expr(index_expr.array());
327-
address_of_expr.type()=pointer_typet(expr.type());
327+
address_of_expr.type()=pointer_type(expr.type());
328328

329329
dereference_exprt tmp;
330330
tmp.pointer()=plus_exprt(address_of_expr, index_expr.index());
@@ -361,7 +361,7 @@ void goto_symext::dereference_rec(
361361
to_address_of_expr(tc_op).object().type().id()==ID_array &&
362362
base_type_eq(
363363
expr.type(),
364-
pointer_typet(to_address_of_expr(tc_op).object().type().subtype()),
364+
pointer_type(to_address_of_expr(tc_op).object().type().subtype()),
365365
ns))
366366
{
367367
expr=

0 commit comments

Comments
 (0)