Skip to content

Commit ac270c5

Browse files
stahlbauertautschnig
authored andcommitted
Dump the global declarations after the included system headers
1 parent b0e0c0a commit ac270c5

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/goto-instrument/dump_c.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ void dump_ct::operator()(std::ostream &os)
3838
std::stringstream func_decl_stream;
3939
std::stringstream compound_body_stream;
4040
std::stringstream global_var_stream;
41+
std::stringstream global_decl_stream;
4142
std::stringstream func_body_stream;
4243
local_static_declst local_static_decls;
4344

@@ -175,13 +176,14 @@ void dump_ct::operator()(std::ostream &os)
175176
{
176177
if(!ignore(symbol))
177178
{
178-
os << "// " << symbol.name << '\n';
179-
os << "// " << symbol.location << '\n';
179+
global_decl_stream << "// " << symbol.name << '\n';
180+
global_decl_stream << "// " << symbol.location << '\n';
180181

181182
if(type_id==ID_c_enum)
182-
convert_compound_enum(symbol.type, os);
183+
convert_compound_enum(symbol.type, global_decl_stream);
183184
else
184-
os << type_to_string(symbol_typet(symbol.name)) << ";\n\n";
185+
global_decl_stream << type_to_string(symbol_typet(symbol.name))
186+
<< ";\n\n";
185187
}
186188
}
187189
else if(symbol.is_static_lifetime && symbol.type.id()!=ID_code)
@@ -240,6 +242,8 @@ void dump_ct::operator()(std::ostream &os)
240242
compound_body_stream);
241243
}
242244

245+
// Dump the code to the target stream;
246+
// the statements before to this point collect the code to dump!
243247
for(std::set<std::string>::const_iterator
244248
it=system_headers.begin();
245249
it!=system_headers.end();
@@ -271,6 +275,9 @@ void dump_ct::operator()(std::ostream &os)
271275
<< "#endif\n\n";
272276
}
273277

278+
if(!global_decl_stream.str().empty())
279+
os << global_decl_stream.str() << '\n';
280+
274281
dump_typedefs(os);
275282

276283
if(!func_decl_stream.str().empty())

0 commit comments

Comments
 (0)