File tree Expand file tree Collapse file tree 7 files changed +13
-36
lines changed Expand file tree Collapse file tree 7 files changed +13
-36
lines changed Original file line number Diff line number Diff line change @@ -123,14 +123,11 @@ typet ansi_c_declarationt::full_type(
123
123
return result;
124
124
}
125
125
126
- void ansi_c_declarationt::to_symbol (
127
- const ansi_c_declaratort &declarator,
128
- symbolt &symbol) const
126
+ symbolt
127
+ ansi_c_declarationt::to_symbol (const ansi_c_declaratort &declarator) const
129
128
{
130
- symbol. clear () ;
129
+ symbolt symbol{declarator. get_name (), full_type (declarator), ID_C} ;
131
130
symbol.value =declarator.value ();
132
- symbol.type =full_type (declarator);
133
- symbol.name =declarator.get_name ();
134
131
symbol.pretty_name =symbol.name ;
135
132
symbol.base_name =declarator.get_base_name ();
136
133
symbol.is_type =get_is_typedef ();
@@ -194,4 +191,6 @@ void ansi_c_declarationt::to_symbol(
194
191
(get_is_global () && get_is_static () && !get_is_used ()) ||
195
192
symbol.is_parameter ;
196
193
}
194
+
195
+ return symbol;
197
196
}
Original file line number Diff line number Diff line change @@ -205,9 +205,7 @@ class ansi_c_declarationt:public exprt
205
205
set (ID_is_used, is_used);
206
206
}
207
207
208
- void to_symbol (
209
- const ansi_c_declaratort &,
210
- symbolt &symbol) const ;
208
+ symbolt to_symbol (const ansi_c_declaratort &) const ;
211
209
212
210
typet full_type (const ansi_c_declaratort &) const ;
213
211
Original file line number Diff line number Diff line change @@ -658,8 +658,7 @@ void c_typecheck_baset::typecheck_declaration(
658
658
declaration.set_is_weak (full_spec.is_weak );
659
659
declaration.set_is_used (full_spec.is_used );
660
660
661
- symbolt symbol;
662
- declaration.to_symbol (declarator, symbol);
661
+ symbolt symbol = declaration.to_symbol (declarator);
663
662
current_symbol=symbol;
664
663
665
664
// now check other half of type
Original file line number Diff line number Diff line change @@ -42,8 +42,7 @@ bool jsil_convertt::operator()(
42
42
it!=parse_tree.items .end ();
43
43
++it)
44
44
{
45
- symbolt new_symbol;
46
- it->to_symbol (new_symbol);
45
+ symbolt new_symbol = it->to_symbol ();
47
46
48
47
if (convert_code (new_symbol, to_code (new_symbol.value )))
49
48
return true ;
Original file line number Diff line number Diff line change @@ -40,10 +40,8 @@ static bool insert_at_label(
40
40
return true ;
41
41
}
42
42
43
- void jsil_declarationt::to_symbol (symbolt &symbol ) const
43
+ symbolt jsil_declarationt::to_symbol () const
44
44
{
45
- symbol.clear ();
46
-
47
45
symbol_exprt s (to_symbol_expr (
48
46
static_cast <const exprt&>(find (ID_declarator))));
49
47
@@ -56,10 +54,8 @@ void jsil_declarationt::to_symbol(symbolt &symbol) const
56
54
else if (proc_type==" spec" )
57
55
symbol_type=jsil_spec_code_typet (symbol_type);
58
56
59
- symbol. name = s.get_identifier ();
57
+ symbolt symbol{ s.get_identifier (), symbol_type, " jsil " } ;
60
58
symbol.base_name =s.get_identifier ();
61
- symbol.mode =" jsil" ;
62
- symbol.type =symbol_type;
63
59
symbol.location =s.source_location ();
64
60
65
61
code_blockt code (to_code_block (
@@ -79,6 +75,8 @@ void jsil_declarationt::to_symbol(symbolt &symbol) const
79
75
throw " throw label " +throws.get_string (ID_label)+" not found" ;
80
76
81
77
symbol.value .swap (code);
78
+
79
+ return symbol;
82
80
}
83
81
84
82
void jsil_declarationt::output (std::ostream &out) const
Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ class jsil_declarationt:public exprt
92
92
return static_cast <code_blockt &>(add (ID_value));
93
93
}
94
94
95
- void to_symbol (symbolt &symbol ) const ;
95
+ symbolt to_symbol () const ;
96
96
97
97
void output (std::ostream &) const ;
98
98
};
Original file line number Diff line number Diff line change @@ -91,22 +91,6 @@ class symbolt
91
91
location.make_nil ();
92
92
}
93
93
94
- // / Zero initialise a symbol object.
95
- void clear ()
96
- {
97
- type.make_nil ();
98
- value.make_nil ();
99
- location.make_nil ();
100
-
101
- name=module =base_name=mode=pretty_name=irep_idt ();
102
-
103
- is_type=is_macro=is_exported=
104
- is_input=is_output=is_state_var=is_property=
105
- is_static_lifetime=is_thread_local=
106
- is_lvalue=is_file_local=is_extern=is_volatile=
107
- is_parameter=is_auxiliary=is_weak=false ;
108
- }
109
-
110
94
void swap (symbolt &b);
111
95
void show (std::ostream &out) const ;
112
96
You can’t perform that action at this time.
0 commit comments