@@ -28,72 +28,64 @@ Function: verilog_typecheck_exprt::convert_type
28
28
29
29
typet verilog_typecheck_exprt::convert_type (const typet &src)
30
30
{
31
- auto source_location = src.source_location ();
31
+ const auto & source_location = src.source_location ();
32
32
33
33
if (src.is_nil () || src.id ()==ID_reg)
34
34
{
35
35
// it's just a bit
36
- return bool_typet ();
36
+ return bool_typet (). with_source_location (source_location) ;
37
37
}
38
38
else if (src.id () == ID_integer)
39
39
{
40
- typet result = integer_typet ();
41
- result.add_source_location () = std::move (source_location);
42
- return result;
40
+ return integer_typet ().with_source_location (source_location);
43
41
}
44
42
else if (src.id () == ID_verilog_byte)
45
43
{
46
- return signedbv_typet{8 };
44
+ return signedbv_typet{8 }. with_source_location (source_location) ;
47
45
}
48
46
else if (src.id () == ID_verilog_shortint)
49
47
{
50
- return signedbv_typet{16 };
48
+ return signedbv_typet{16 }. with_source_location (source_location) ;
51
49
}
52
50
else if (src.id () == ID_verilog_int)
53
51
{
54
- return signedbv_typet{32 };
52
+ return signedbv_typet{32 }. with_source_location (source_location) ;
55
53
}
56
54
else if (src.id () == ID_verilog_longint)
57
55
{
58
- return signedbv_typet{64 };
56
+ return signedbv_typet{64 }. with_source_location (source_location) ;
59
57
}
60
58
else if (src.id () == ID_verilog_integer)
61
59
{
62
- return signedbv_typet{32 };
60
+ return signedbv_typet{32 }. with_source_location (source_location) ;
63
61
}
64
62
else if (src.id () == ID_verilog_time)
65
63
{
66
- return unsignedbv_typet{64 };
64
+ return unsignedbv_typet{64 }. with_source_location (source_location) ;
67
65
}
68
66
else if (src.id () == ID_verilog_bit)
69
67
{
70
- return unsignedbv_typet{1 };
68
+ return unsignedbv_typet{1 }. with_source_location (source_location) ;
71
69
}
72
70
else if (src.id () == ID_verilog_logic)
73
71
{
74
- return unsignedbv_typet{1 };
72
+ return unsignedbv_typet{1 }. with_source_location (source_location) ;
75
73
}
76
74
else if (src.id () == ID_verilog_reg)
77
75
{
78
- return unsignedbv_typet{1 };
76
+ return unsignedbv_typet{1 }. with_source_location (source_location) ;
79
77
}
80
78
else if (src.id () == ID_verilog_shortreal)
81
79
{
82
- typet result = verilog_shortreal_typet ();
83
- result.add_source_location () = std::move (source_location);
84
- return result;
80
+ return verilog_shortreal_typet ().with_source_location (source_location);
85
81
}
86
82
else if (src.id () == ID_verilog_real)
87
83
{
88
- typet result = verilog_real_typet ();
89
- result.add_source_location () = std::move (source_location);
90
- return result;
84
+ return verilog_real_typet ().with_source_location (source_location);
91
85
}
92
86
else if (src.id () == ID_verilog_realtime)
93
87
{
94
- typet result = verilog_realtime_typet ();
95
- result.add_source_location () = std::move (source_location);
96
- return result;
88
+ return verilog_realtime_typet ().with_source_location (source_location);
97
89
}
98
90
else if (src.id () == ID_typedef_type)
99
91
{
@@ -108,15 +100,17 @@ typet verilog_typecheck_exprt::convert_type(const typet &src)
108
100
109
101
DATA_INVARIANT (symbol_ptr->is_type , " typedef symbols must be types" );
110
102
111
- return symbol_ptr->type ;
103
+ auto result = symbol_ptr->type ; // copy
104
+ return result.with_source_location (source_location);
112
105
}
113
106
else if (src.id () == ID_verilog_enum)
114
107
{
115
108
// Replace by base type.
116
109
// The default base type is 'int'.
117
110
auto &enum_type = to_verilog_enum_type (src);
118
- return enum_type.has_base_type () ? enum_type.base_type ()
119
- : signedbv_typet (32 );
111
+ auto result =
112
+ enum_type.has_base_type () ? enum_type.base_type () : signedbv_typet (32 );
113
+ return result.with_source_location (source_location);
120
114
}
121
115
else if (src.id () == ID_array)
122
116
{
@@ -149,7 +143,7 @@ typet verilog_typecheck_exprt::convert_type(const typet &src)
149
143
dest.set (ID_C_little_endian, little_endian);
150
144
dest.set (ID_C_offset, integer2string (offset));
151
145
152
- return std::move (dest);
146
+ return std::move (dest). with_source_location (source_location) ;
153
147
}
154
148
else
155
149
{
@@ -161,7 +155,7 @@ typet verilog_typecheck_exprt::convert_type(const typet &src)
161
155
result.add_source_location () = source_location;
162
156
result.set (ID_offset, from_integer (offset, integer_typet ()));
163
157
164
- return std::move (result);
158
+ return std::move (result). with_source_location (source_location) ;
165
159
}
166
160
}
167
161
else if (src.id () == ID_verilog_type_reference)
@@ -172,7 +166,7 @@ typet verilog_typecheck_exprt::convert_type(const typet &src)
172
166
// the expression is not evaluated
173
167
auto expr = type_reference.expression_op ();
174
168
convert_expr (expr);
175
- return expr.type ();
169
+ return expr.type (). with_source_location (source_location) ;
176
170
}
177
171
else
178
172
return convert_type (type_reference.type_op ());
0 commit comments