Skip to content

Commit 60cc2ca

Browse files
stahlbauertautschnig
authored andcommitted
Do not dump certain types if they are defined in system headers
1 parent 61de294 commit 60cc2ca

File tree

2 files changed

+42
-6
lines changed

2 files changed

+42
-6
lines changed

src/goto-instrument/dump_c.cpp

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,16 @@ void dump_ct::operator()(std::ostream &os)
172172
type_id==ID_incomplete_union ||
173173
type_id==ID_c_enum))
174174
{
175-
os << "// " << symbol.name << '\n';
176-
os << "// " << symbol.location << '\n';
175+
if(!ignore(symbol))
176+
{
177+
os << "// " << symbol.name << '\n';
178+
os << "// " << symbol.location << '\n';
177179

178-
if(type_id==ID_c_enum)
179-
convert_compound_enum(symbol.type, os);
180-
else
181-
os << type_to_string(symbol_typet(symbol.name)) << ";\n\n";
180+
if(type_id==ID_c_enum)
181+
convert_compound_enum(symbol.type, os);
182+
else
183+
os << type_to_string(symbol_typet(symbol.name)) << ";\n\n";
184+
}
182185
}
183186
else if(symbol.is_static_lifetime && symbol.type.id()!=ID_code)
184187
convert_global_variable(
@@ -749,6 +752,38 @@ void dump_ct::init_system_library_map()
749752
ADD_TO_SYSTEM_LIBRARY(sys_wait_syms, "sys/wait.h");
750753
}
751754

755+
/*******************************************************************\
756+
757+
Function: dump_ct::ignore
758+
759+
Inputs: type input to check whether it should not be dumped
760+
761+
Outputs: true, iff the type should not be printed
762+
763+
Purpose: Ignore selected types as they are covered via system headers
764+
765+
\*******************************************************************/
766+
767+
bool dump_ct::ignore(const typet &type)
768+
{
769+
symbolt symbol;
770+
symbol.type=type;
771+
772+
return ignore(symbol);
773+
}
774+
775+
/*******************************************************************\
776+
777+
Function: dump_ct::ignore
778+
779+
Inputs: type input to check whether it should not be dumped
780+
781+
Outputs: true, iff the symbol should not be printed
782+
783+
Purpose: Ignore selected symbols as they are covered via system headers
784+
785+
\*******************************************************************/
786+
752787
bool dump_ct::ignore(const symbolt &symbol)
753788
{
754789
const std::string &name_str=id2string(symbol.name);

src/goto-instrument/dump_c_class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class dump_ct
9090
std::string expr_to_string(const exprt &expr);
9191

9292
bool ignore(const symbolt &symbol);
93+
bool ignore(const typet &type);
9394

9495
static std::string indent(const unsigned n)
9596
{

0 commit comments

Comments
 (0)