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 @@ -125,14 +125,11 @@ typet ansi_c_declarationt::full_type(
125
125
return result;
126
126
}
127
127
128
- void ansi_c_declarationt::to_symbol (
129
- const ansi_c_declaratort &declarator,
130
- symbolt &symbol) const
128
+ symbolt
129
+ ansi_c_declarationt::to_symbol (const ansi_c_declaratort &declarator) const
131
130
{
132
- symbol. clear () ;
131
+ symbolt symbol{declarator. get_name (), full_type (declarator), ID_C} ;
133
132
symbol.value =declarator.value ();
134
- symbol.type =full_type (declarator);
135
- symbol.name =declarator.get_name ();
136
133
symbol.pretty_name =symbol.name ;
137
134
symbol.base_name =declarator.get_base_name ();
138
135
symbol.is_type =get_is_typedef ();
@@ -190,4 +187,6 @@ void ansi_c_declarationt::to_symbol(
190
187
symbol.is_macro || (!get_is_global () && !get_is_extern ()) ||
191
188
(get_is_global () && get_is_static ()) || symbol.is_parameter ;
192
189
}
190
+
191
+ return symbol;
193
192
}
Original file line number Diff line number Diff line change @@ -195,9 +195,7 @@ class ansi_c_declarationt:public exprt
195
195
set (ID_is_weak, is_weak);
196
196
}
197
197
198
- void to_symbol (
199
- const ansi_c_declaratort &,
200
- symbolt &symbol) const ;
198
+ symbolt to_symbol (const ansi_c_declaratort &) const ;
201
199
202
200
typet full_type (const ansi_c_declaratort &) const ;
203
201
Original file line number Diff line number Diff line change @@ -781,8 +781,7 @@ void c_typecheck_baset::typecheck_declaration(
781
781
declaration.set_is_typedef (full_spec.is_typedef );
782
782
declaration.set_is_weak (full_spec.is_weak );
783
783
784
- symbolt symbol;
785
- declaration.to_symbol (declarator, symbol);
784
+ symbolt symbol = declaration.to_symbol (declarator);
786
785
current_symbol=symbol;
787
786
788
787
// now check other half of type
Original file line number Diff line number Diff line change @@ -43,8 +43,7 @@ bool jsil_convertt::operator()(
43
43
it!=parse_tree.items .end ();
44
44
++it)
45
45
{
46
- symbolt new_symbol;
47
- it->to_symbol (new_symbol);
46
+ symbolt new_symbol = it->to_symbol ();
48
47
49
48
if (convert_code (new_symbol, to_code (new_symbol.value )))
50
49
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 @@ -93,22 +93,6 @@ class symbolt
93
93
{
94
94
}
95
95
96
- // / Zero initialise a symbol object.
97
- void clear ()
98
- {
99
- type.make_nil ();
100
- value.make_nil ();
101
- location.make_nil ();
102
-
103
- name=module=base_name=mode=pretty_name=irep_idt ();
104
-
105
- is_type=is_macro=is_exported=
106
- is_input=is_output=is_state_var=is_property=
107
- is_static_lifetime=is_thread_local=
108
- is_lvalue=is_file_local=is_extern=is_volatile=
109
- is_parameter=is_auxiliary=is_weak=false ;
110
- }
111
-
112
96
void swap (symbolt &b);
113
97
void show (std::ostream &out) const ;
114
98
You can’t perform that action at this time.
0 commit comments