Skip to content

Commit 5256e2a

Browse files
authored
Merge pull request #3873 from tautschnig/symbol_exprt-typeless
symbol_exprt::typeless [blocks: #3766]
2 parents dda09d1 + 89ebf7c commit 5256e2a

File tree

10 files changed

+28
-15
lines changed

10 files changed

+28
-15
lines changed

jbmc/src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ exprt java_bytecode_parsert::get_relement_value()
16001600
case 'c':
16011601
{
16021602
u2 class_info_index = read_u2();
1603-
return symbol_exprt(pool_entry(class_info_index).s);
1603+
return symbol_exprt::typeless(pool_entry(class_info_index).s);
16041604
}
16051605

16061606
case '@':

src/ansi-c/c_typecheck_base.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,9 @@ void c_typecheck_baset::typecheck_declaration(
697697
// also cater for renaming/placement in sections
698698
const auto &renaming_entry = asm_label_map.find(full_spec.alias);
699699
if(renaming_entry == asm_label_map.end())
700-
symbol.value = symbol_exprt(full_spec.alias);
700+
symbol.value = symbol_exprt::typeless(full_spec.alias);
701701
else
702-
symbol.value = symbol_exprt(renaming_entry->second);
702+
symbol.value = symbol_exprt::typeless(renaming_entry->second);
703703
symbol.is_macro=true;
704704
}
705705

src/cpp/cpp_typecheck_compound_type.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,7 @@ void cpp_typecheckt::typecheck_compound_declarator(
743743
}
744744
else
745745
{
746-
symbol_exprt symexpr;
747-
symexpr.set_identifier(new_symbol->name);
746+
symbol_exprt symexpr = symbol_exprt::typeless(new_symbol->name);
748747

749748
exprt::operandst ops;
750749
ops.push_back(value);

src/goto-symex/build_goto_trace.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,11 @@ void build_goto_trace(
224224

225225
if(it->is_shared_read() || it->is_shared_write())
226226
{
227-
// these are just used to get the time stamp
228-
exprt clock_value=prop_conv.get(
229-
symbol_exprt(partial_order_concurrencyt::rw_clock_id(it)));
227+
// these are just used to get the time stamp -- the clock type is
228+
// computed to be of the minimal necessary size, but we don't need to
229+
// know it to get the value so just use typeless
230+
exprt clock_value = prop_conv.get(
231+
symbol_exprt::typeless(partial_order_concurrencyt::rw_clock_id(it)));
230232

231233
const auto cv = numeric_cast<mp_integer>(clock_value);
232234
if(cv.has_value())

src/jsil/jsil_convert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ bool jsil_convertt::convert_code(const symbolt &symbol, codet &code)
9191

9292
code_try_catcht t_c(std::move(t));
9393
// Adding empty symbol to catch decl
94-
code_declt d(symbol_exprt("decl_symbol"));
94+
code_declt d(symbol_exprt::typeless("decl_symbol"));
9595
t_c.add_catch(d, g);
9696
t_c.add_source_location()=code.source_location();
9797

src/jsil/jsil_parse_tree.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ void jsil_declarationt::to_symbol(symbolt &symbol) const
6666
static_cast<const codet&>(find(ID_value))));
6767

6868
irept returns(find(ID_return));
69-
code_returnt r(symbol_exprt(returns.get(ID_value)));
69+
code_returnt r(symbol_exprt::typeless(returns.get(ID_value)));
7070

7171
irept throws(find(ID_throw));
7272
side_effect_expr_throwt t(
73-
symbol_exprt(throws.get(ID_value)), nil_typet(), s.source_location());
73+
symbol_exprt::typeless(throws.get(ID_value)),
74+
nil_typet(),
75+
s.source_location());
7476
code_expressiont ct(t);
7577

7678
if(insert_at_label(r, returns.get(ID_label), code))

src/jsil/parser.y

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ procedure_decl: TOK_PROCEDURE proc_ident '(' parameters_opt ')'
148148
proc_ident: TOK_IDENTIFIER
149149
| TOK_EVAL
150150
{
151-
symbol_exprt e("eval");
151+
symbol_exprt e = symbol_exprt::typeless("eval");
152152
newstack($$).swap(e);
153153
}
154154
| TOK_BUILTIN_IDENTIFIER
@@ -164,7 +164,8 @@ proc_ident: TOK_IDENTIFIER
164164
proc_ident_expr: proc_ident
165165
| TOK_STRING
166166
{
167-
symbol_exprt s(to_string_constant(stack($$)).get_value());
167+
symbol_exprt s = symbol_exprt::typeless(
168+
to_string_constant(stack($$)).get_value());
168169
stack($$).swap(s);
169170
}
170171
;

src/linking/linking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ void linkingt::detailed_conflict_report_rec(
227227
{
228228
std::string msg_bak;
229229
msg_bak.swap(msg);
230-
symbol_exprt c(ID_C_this);
230+
symbol_exprt c = symbol_exprt::typeless(ID_C_this);
231231
detailed_conflict_report_rec(
232232
old_symbol,
233233
new_symbol,

src/linking/linking_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class linkingt:public typecheckt
143143
const typet &type1,
144144
const typet &type2)
145145
{
146-
symbol_exprt conflict_path(ID_C_this);
146+
symbol_exprt conflict_path = symbol_exprt::typeless(ID_C_this);
147147
detailed_conflict_report_rec(
148148
old_symbol,
149149
new_symbol,

src/util/std_expr.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,15 @@ class symbol_exprt : public nullary_exprt
179179
set_identifier(identifier);
180180
}
181181

182+
/// Generate a symbol_exprt without a proper type. Use if, and only if, the
183+
/// type either cannot be determined just yet (such as during type checking)
184+
/// or when the type truly is immaterial. The latter case may better be dealt
185+
/// with by using just an irep_idt, and not a symbol_exprt.
186+
static symbol_exprt typeless(const irep_idt &id)
187+
{
188+
return symbol_exprt(id, typet());
189+
}
190+
182191
void set_identifier(const irep_idt &identifier)
183192
{
184193
set(ID_identifier, identifier);

0 commit comments

Comments
 (0)