@@ -19,21 +19,18 @@ ansi_c_id_classt ansi_c_parsert::lookup(
19
19
bool label)
20
20
{
21
21
// labels and tags have a separate name space
22
- const irep_idt scope_name=
23
- tag?" tag-" +id2string (base_name):
24
- label?" label-" +id2string (base_name):
25
- base_name;
22
+ const irep_idt scope_name =
23
+ tag ? " tag-" + id2string (base_name)
24
+ : label ? " label-" + id2string (base_name) : base_name;
26
25
27
- for (scopest::const_reverse_iterator it=scopes.rbegin ();
28
- it!=scopes.rend ();
26
+ for (scopest::const_reverse_iterator it = scopes.rbegin (); it != scopes.rend ();
29
27
it++)
30
28
{
31
- scopet::name_mapt::const_iterator n_it=
32
- it->name_map .find (scope_name);
29
+ scopet::name_mapt::const_iterator n_it = it->name_map .find (scope_name);
33
30
34
- if (n_it!= it->name_map .end ())
31
+ if (n_it != it->name_map .end ())
35
32
{
36
- identifier= n_it->second .prefixed_name ;
33
+ identifier = n_it->second .prefixed_name ;
37
34
return n_it->second .id_class ;
38
35
}
39
36
}
@@ -42,33 +39,30 @@ ansi_c_id_classt ansi_c_parsert::lookup(
42
39
// If it's a tag, we will add to current scope.
43
40
if (tag)
44
41
{
45
- ansi_c_identifiert &i=
46
- current_scope ().name_map [scope_name];
47
- i.id_class =ansi_c_id_classt::ANSI_C_TAG;
48
- i.prefixed_name =current_scope ().prefix +id2string (scope_name);
49
- i.base_name =base_name;
50
- identifier=i.prefixed_name ;
42
+ ansi_c_identifiert &i = current_scope ().name_map [scope_name];
43
+ i.id_class = ansi_c_id_classt::ANSI_C_TAG;
44
+ i.prefixed_name = current_scope ().prefix + id2string (scope_name);
45
+ i.base_name = base_name;
46
+ identifier = i.prefixed_name ;
51
47
return ansi_c_id_classt::ANSI_C_TAG;
52
48
}
53
49
54
- identifier= base_name;
50
+ identifier = base_name;
55
51
return ansi_c_id_classt::ANSI_C_UNKNOWN;
56
52
}
57
53
58
54
void ansi_c_parsert::add_tag_with_body (irept &tag)
59
55
{
60
- const std::string scope_name=
61
- " tag-" +tag.get_string (ID_C_base_name);
56
+ const std::string scope_name = " tag-" + tag.get_string (ID_C_base_name);
62
57
63
- irep_idt prefixed_name= current_scope ().prefix + scope_name;
58
+ irep_idt prefixed_name = current_scope ().prefix + scope_name;
64
59
65
- if (prefixed_name!= tag.get (ID_identifier))
60
+ if (prefixed_name != tag.get (ID_identifier))
66
61
{
67
62
// re-defined in a deeper scope
68
- ansi_c_identifiert &identifier=
69
- current_scope ().name_map [scope_name];
70
- identifier.id_class =ansi_c_id_classt::ANSI_C_TAG;
71
- identifier.prefixed_name =prefixed_name;
63
+ ansi_c_identifiert &identifier = current_scope ().name_map [scope_name];
64
+ identifier.id_class = ansi_c_id_classt::ANSI_C_TAG;
65
+ identifier.prefixed_name = prefixed_name;
72
66
tag.set (ID_identifier, prefixed_name);
73
67
}
74
68
}
@@ -81,21 +75,18 @@ int yyansi_cerror(const std::string &error)
81
75
return 0 ;
82
76
}
83
77
84
- void ansi_c_parsert::add_declarator (
85
- exprt &declaration,
86
- irept &declarator)
78
+ void ansi_c_parsert::add_declarator (exprt &declaration, irept &declarator)
87
79
{
88
80
assert (declarator.is_not_nil ());
89
- ansi_c_declarationt &ansi_c_declaration=
90
- to_ansi_c_declaration (declaration);
81
+ ansi_c_declarationt &ansi_c_declaration = to_ansi_c_declaration (declaration);
91
82
92
83
ansi_c_declaratort new_declarator;
93
84
new_declarator.build (declarator);
94
85
95
- irep_idt base_name= new_declarator.get_base_name ();
86
+ irep_idt base_name = new_declarator.get_base_name ();
96
87
97
- bool is_member= ansi_c_declaration.get_is_member ();
98
- bool is_parameter= ansi_c_declaration.get_is_parameter ();
88
+ bool is_member = ansi_c_declaration.get_is_member ();
89
+ bool is_parameter = ansi_c_declaration.get_is_parameter ();
99
90
100
91
if (is_member)
101
92
{
@@ -113,39 +104,35 @@ void ansi_c_parsert::add_declarator(
113
104
if (!base_name.empty ())
114
105
{
115
106
c_storage_spect c_storage_spec (ansi_c_declaration.type ());
116
- bool is_typedef= c_storage_spec.is_typedef ;
117
- bool is_extern= c_storage_spec.is_extern ;
107
+ bool is_typedef = c_storage_spec.is_typedef ;
108
+ bool is_extern = c_storage_spec.is_extern ;
118
109
119
- bool force_root_scope= false ;
110
+ bool force_root_scope = false ;
120
111
121
112
// Functions always go into global scope, unless
122
113
// declared as a parameter or are typedefs.
123
- if (new_declarator.type ().id ()==ID_code &&
124
- !is_parameter &&
125
- !is_typedef)
126
- force_root_scope=true ;
114
+ if (new_declarator.type ().id () == ID_code && !is_parameter && !is_typedef)
115
+ force_root_scope = true ;
127
116
128
117
// variables marked as 'extern' always go into global scope
129
118
if (is_extern)
130
- force_root_scope= true ;
119
+ force_root_scope = true ;
131
120
132
- ansi_c_id_classt id_class=is_typedef?
133
- ansi_c_id_classt::ANSI_C_TYPEDEF:
134
- ansi_c_id_classt::ANSI_C_SYMBOL;
121
+ ansi_c_id_classt id_class = is_typedef ? ansi_c_id_classt::ANSI_C_TYPEDEF
122
+ : ansi_c_id_classt::ANSI_C_SYMBOL;
135
123
136
- scopet &scope=
137
- force_root_scope?root_scope ():current_scope ();
124
+ scopet &scope = force_root_scope ? root_scope () : current_scope ();
138
125
139
126
// set the final name
140
- irep_idt prefixed_name= force_root_scope?
141
- base_name:
142
- current_scope ().prefix + id2string (base_name);
127
+ irep_idt prefixed_name = force_root_scope
128
+ ? base_name
129
+ : current_scope ().prefix + id2string (base_name);
143
130
new_declarator.set_name (prefixed_name);
144
131
145
132
// add to scope
146
- ansi_c_identifiert &identifier= scope.name_map [base_name];
147
- identifier.id_class = id_class;
148
- identifier.prefixed_name = prefixed_name;
133
+ ansi_c_identifiert &identifier = scope.name_map [base_name];
134
+ identifier.id_class = id_class;
135
+ identifier.prefixed_name = prefixed_name;
149
136
150
137
if (force_root_scope)
151
138
current_scope ().name_map [base_name] = identifier;
@@ -156,13 +143,12 @@ void ansi_c_parsert::add_declarator(
156
143
157
144
ansi_c_id_classt ansi_c_parsert::get_class (const typet &type)
158
145
{
159
- if (type.id ()== ID_typedef)
146
+ if (type.id () == ID_typedef)
160
147
return ansi_c_id_classt::ANSI_C_TYPEDEF;
161
- else if (type.id ()==ID_struct ||
162
- type.id ()==ID_union ||
163
- type.id ()==ID_c_enum)
148
+ else if (
149
+ type.id () == ID_struct || type.id () == ID_union || type.id () == ID_c_enum)
164
150
return ansi_c_id_classt::ANSI_C_TAG;
165
- else if (type.id ()== ID_merged_type)
151
+ else if (type.id () == ID_merged_type)
166
152
{
167
153
for (const typet &subtype : to_type_with_subtypes (type).subtypes ())
168
154
{
0 commit comments